Browse Source
Merge pull request #12019 from liamwhite/more-shutdown-deadlocks
audio_core: ignore renderer wait when stream is paused
pull/15/merge
liamwhite
2 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with
18 additions and
4 deletions
-
src/audio_core/sink/cubeb_sink.cpp
-
src/audio_core/sink/sdl2_sink.cpp
-
src/audio_core/sink/sink_stream.cpp
-
src/audio_core/sink/sink_stream.h
|
|
|
@ -146,7 +146,7 @@ public: |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
paused = true; |
|
|
|
SignalPause(); |
|
|
|
if (cubeb_stream_stop(stream_backend) != CUBEB_OK) { |
|
|
|
LOG_CRITICAL(Audio_Sink, "Error stopping cubeb stream"); |
|
|
|
} |
|
|
|
|
|
|
|
@ -111,7 +111,7 @@ public: |
|
|
|
if (device == 0 || paused) { |
|
|
|
return; |
|
|
|
} |
|
|
|
paused = true; |
|
|
|
SignalPause(); |
|
|
|
SDL_PauseAudioDevice(device, 1); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -282,11 +282,19 @@ u64 SinkStream::GetExpectedPlayedSampleCount() { |
|
|
|
void SinkStream::WaitFreeSpace(std::stop_token stop_token) { |
|
|
|
std::unique_lock lk{release_mutex}; |
|
|
|
release_cv.wait_for(lk, std::chrono::milliseconds(5), |
|
|
|
[this]() { return queued_buffers < max_queue_size; }); |
|
|
|
[this]() { return paused || queued_buffers < max_queue_size; }); |
|
|
|
if (queued_buffers > max_queue_size + 3) { |
|
|
|
Common::CondvarWait(release_cv, lk, stop_token, |
|
|
|
[this] { return queued_buffers < max_queue_size; }); |
|
|
|
[this] { return paused || queued_buffers < max_queue_size; }); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void SinkStream::SignalPause() { |
|
|
|
{ |
|
|
|
std::scoped_lock lk{release_mutex}; |
|
|
|
paused = true; |
|
|
|
} |
|
|
|
release_cv.notify_one(); |
|
|
|
} |
|
|
|
|
|
|
|
} // namespace AudioCore::Sink
|
|
|
|
@ -213,6 +213,12 @@ public: |
|
|
|
*/ |
|
|
|
void WaitFreeSpace(std::stop_token stop_token); |
|
|
|
|
|
|
|
protected: |
|
|
|
/** |
|
|
|
* Unblocks the ADSP if the stream is paused. |
|
|
|
*/ |
|
|
|
void SignalPause(); |
|
|
|
|
|
|
|
protected: |
|
|
|
/// Core system |
|
|
|
Core::System& system; |
|
|
|
|