diff options
| author | 2023-04-08 21:54:19 +0100 | |
|---|---|---|
| committer | 2023-04-08 21:54:19 +0100 | |
| commit | 8908663f1279c690bc19710da7e33d44314641b4 (patch) | |
| tree | 522dda751b910c89bfdc93d774d9585b36cc857e | |
| parent | Add some explicit latency to sample count reporting (diff) | |
| download | yuzu-8908663f1279c690bc19710da7e33d44314641b4.tar.gz yuzu-8908663f1279c690bc19710da7e33d44314641b4.tar.xz yuzu-8908663f1279c690bc19710da7e33d44314641b4.zip | |
Use GetGlobalTimeNs as opposed to clock ticks
| -rw-r--r-- | src/audio_core/sink/sink_stream.cpp | 5 | ||||
| -rw-r--r-- | src/audio_core/sink/sink_stream.h | 2 |
2 files changed, 3 insertions, 4 deletions
diff --git a/src/audio_core/sink/sink_stream.cpp b/src/audio_core/sink/sink_stream.cpp index 13c73b5d7..13ba26e74 100644 --- a/src/audio_core/sink/sink_stream.cpp +++ b/src/audio_core/sink/sink_stream.cpp | |||
| @@ -252,8 +252,7 @@ void SinkStream::ProcessAudioOutAndRender(std::span<s16> output_buffer, std::siz | |||
| 252 | 252 | ||
| 253 | { | 253 | { |
| 254 | std::scoped_lock lk{sample_count_lock}; | 254 | std::scoped_lock lk{sample_count_lock}; |
| 255 | last_sample_count_update_time = | 255 | last_sample_count_update_time = system.CoreTiming().GetGlobalTimeNs(); |
| 256 | Core::Timing::CyclesToUs(system.CoreTiming().GetClockTicks()); | ||
| 257 | min_played_sample_count = max_played_sample_count; | 256 | min_played_sample_count = max_played_sample_count; |
| 258 | max_played_sample_count += actual_frames_written; | 257 | max_played_sample_count += actual_frames_written; |
| 259 | } | 258 | } |
| @@ -261,7 +260,7 @@ void SinkStream::ProcessAudioOutAndRender(std::span<s16> output_buffer, std::siz | |||
| 261 | 260 | ||
| 262 | u64 SinkStream::GetExpectedPlayedSampleCount() { | 261 | u64 SinkStream::GetExpectedPlayedSampleCount() { |
| 263 | std::scoped_lock lk{sample_count_lock}; | 262 | std::scoped_lock lk{sample_count_lock}; |
| 264 | auto cur_time{Core::Timing::CyclesToUs(system.CoreTiming().GetClockTicks())}; | 263 | auto cur_time{system.CoreTiming().GetGlobalTimeNs()}; |
| 265 | auto time_delta{cur_time - last_sample_count_update_time}; | 264 | auto time_delta{cur_time - last_sample_count_update_time}; |
| 266 | auto exp_played_sample_count{min_played_sample_count + | 265 | auto exp_played_sample_count{min_played_sample_count + |
| 267 | (TargetSampleRate * time_delta) / std::chrono::seconds{1}}; | 266 | (TargetSampleRate * time_delta) / std::chrono::seconds{1}}; |
diff --git a/src/audio_core/sink/sink_stream.h b/src/audio_core/sink/sink_stream.h index 23e289c7b..21b5b40a1 100644 --- a/src/audio_core/sink/sink_stream.h +++ b/src/audio_core/sink/sink_stream.h | |||
| @@ -246,7 +246,7 @@ private: | |||
| 246 | /// Maximum number of total samples that can be played since the last callback | 246 | /// Maximum number of total samples that can be played since the last callback |
| 247 | u64 max_played_sample_count{}; | 247 | u64 max_played_sample_count{}; |
| 248 | /// The time the two above tracking variables were last written to | 248 | /// The time the two above tracking variables were last written to |
| 249 | std::chrono::microseconds last_sample_count_update_time{}; | 249 | std::chrono::nanoseconds last_sample_count_update_time{}; |
| 250 | /// Set by the audio render/in/out system which uses this stream | 250 | /// Set by the audio render/in/out system which uses this stream |
| 251 | f32 system_volume{1.0f}; | 251 | f32 system_volume{1.0f}; |
| 252 | /// Set via IAudioDevice service calls | 252 | /// Set via IAudioDevice service calls |