Merge pull request #12019 from liamwhite/more-shutdown-deadlocks

audio_core: ignore renderer wait when stream is paused
This commit is contained in:
liamwhite 2023-11-14 12:22:56 -05:00 committed by GitHub
commit 51fc608f68
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 4 deletions

View file

@ -146,7 +146,7 @@ public:
return; return;
} }
paused = true; SignalPause();
if (cubeb_stream_stop(stream_backend) != CUBEB_OK) { if (cubeb_stream_stop(stream_backend) != CUBEB_OK) {
LOG_CRITICAL(Audio_Sink, "Error stopping cubeb stream"); LOG_CRITICAL(Audio_Sink, "Error stopping cubeb stream");
} }

View file

@ -111,7 +111,7 @@ public:
if (device == 0 || paused) { if (device == 0 || paused) {
return; return;
} }
paused = true; SignalPause();
SDL_PauseAudioDevice(device, 1); SDL_PauseAudioDevice(device, 1);
} }

View file

@ -282,11 +282,19 @@ u64 SinkStream::GetExpectedPlayedSampleCount() {
void SinkStream::WaitFreeSpace(std::stop_token stop_token) { void SinkStream::WaitFreeSpace(std::stop_token stop_token) {
std::unique_lock lk{release_mutex}; std::unique_lock lk{release_mutex};
release_cv.wait_for(lk, std::chrono::milliseconds(5), 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) { if (queued_buffers > max_queue_size + 3) {
Common::CondvarWait(release_cv, lk, stop_token, 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 } // namespace AudioCore::Sink

View file

@ -213,6 +213,12 @@ public:
*/ */
void WaitFreeSpace(std::stop_token stop_token); void WaitFreeSpace(std::stop_token stop_token);
protected:
/**
* Unblocks the ADSP if the stream is paused.
*/
void SignalPause();
protected: protected:
/// Core system /// Core system
Core::System& system; Core::System& system;