diff options
author | yuzubot <yuzu@yuzu-emu.org> | 2022-07-06 05:57:05 +0000 |
---|---|---|
committer | yuzubot <yuzu@yuzu-emu.org> | 2022-07-06 05:57:05 +0000 |
commit | 38c8b54f56f28e23f58ef15d32241d58da4b21d4 (patch) | |
tree | 997d5ad58c91bc6a092c11f647c317d135582286 /src | |
parent | b82faa13720724babf941c8552b1af40926b9e8a (diff) |
"Merge Tagged PR 7346"
Diffstat (limited to 'src')
-rw-r--r-- | src/audio_core/stream.cpp | 13 | ||||
-rw-r--r-- | src/audio_core/stream.h | 3 |
2 files changed, 16 insertions, 0 deletions
diff --git a/src/audio_core/stream.cpp b/src/audio_core/stream.cpp index f8034b04bf..8d7a82dc9e 100644 --- a/src/audio_core/stream.cpp +++ b/src/audio_core/stream.cpp @@ -86,6 +86,16 @@ static void VolumeAdjustSamples(std::vector<s16>& samples, float game_volume) { } void Stream::PlayNextBuffer(std::chrono::nanoseconds ns_late) { +#ifndef _WIN32 + auto now = std::chrono::steady_clock::now(); + auto duration = now.time_since_epoch(); + auto nanoseconds = std::chrono::duration_cast<std::chrono::nanoseconds>(duration); + + if (nanoseconds > expected_cb_time) { + ns_late = nanoseconds - expected_cb_time; + } +#endif + if (!IsPlaying()) { // Ensure we are in playing state before playing the next buffer sink_stream.Flush(); @@ -120,6 +130,9 @@ void Stream::PlayNextBuffer(std::chrono::nanoseconds ns_late) { ns_late = {}; } +#ifndef _WIN32 + expected_cb_time = nanoseconds + (buffer_release_ns - ns_late); +#endif core_timing.ScheduleEvent(buffer_release_ns - ns_late, release_event, {}); } diff --git a/src/audio_core/stream.h b/src/audio_core/stream.h index f5de703962..fdf7ad6ca7 100644 --- a/src/audio_core/stream.h +++ b/src/audio_core/stream.h @@ -123,6 +123,9 @@ private: SinkStream& sink_stream; ///< Output sink for the stream Core::Timing::CoreTiming& core_timing; ///< Core timing instance. std::string name; ///< Name of the stream, must be unique +#ifndef _WIN32 + std::chrono::nanoseconds expected_cb_time = {}; ///< Estimated time of next callback +#endif }; using StreamPtr = std::shared_ptr<Stream>; |