diff options
| author | Billy Laws <blaws05@gmail.com> | 2023-03-18 20:57:00 +0000 |
|---|---|---|
| committer | Billy Laws <blaws05@gmail.com> | 2023-03-27 21:34:28 +0100 |
| commit | ea5dd02db9bdb9759a400907672ec6606bebb96b (patch) | |
| tree | 9f6f4f4662eb48ad57fe713e29f6b98778f263bf /src/audio_core/sink/sink_stream.h | |
| parent | d8fc3f403b62e2b3d67ec08791fdc66847ddb4ac (diff) | |
audio: Wait for samples on the emulated DSP side to avoid desyncs
Waiting on the host side is inaccurate and leads to desyncs in the event of the sink missing a deadline that require stalls to fix. By waiting for the sink to have space before even starting rendering such desyncs can be avoided.
Diffstat (limited to 'src/audio_core/sink/sink_stream.h')
| -rw-r--r-- | src/audio_core/sink/sink_stream.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/audio_core/sink/sink_stream.h b/src/audio_core/sink/sink_stream.h index 2340c936c..709f3b0ec 100644 --- a/src/audio_core/sink/sink_stream.h +++ b/src/audio_core/sink/sink_stream.h @@ -16,6 +16,7 @@ #include "common/reader_writer_queue.h" #include "common/ring_buffer.h" #include "common/thread.h" +#include "common/polyfill_thread.h" namespace Core { class System; @@ -219,6 +220,11 @@ public: */ u64 GetExpectedPlayedSampleCount(); + /** + * Waits for free space in the sample ring buffer + */ + void WaitFreeSpace(); + protected: /// Core system Core::System& system; @@ -258,6 +264,9 @@ private: f32 system_volume{1.0f}; /// Set via IAudioDevice service calls f32 device_volume{1.0f}; + /// Signalled when ring buffer entries are consumed + std::condition_variable release_cv; + std::mutex release_mutex; std::mutex stall_guard; std::unique_lock<std::mutex> stalled_lock; }; |
