audio_core: ignore renderer wait when stream is paused

This commit is contained in:
Liam 2023-11-12 23:10:53 -05:00
parent 767c4b5a99
commit ecaa038b4d
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;