summaryrefslogtreecommitdiffstats
path: root/src/audio_core/stream.cpp
diff options
context:
space:
mode:
authorFernando Sahmkow <fsahmkow27@gmail.com>2020-05-29 23:37:57 +0200
committerFernando Sahmkow <fsahmkow27@gmail.com>2020-06-27 17:36:23 +0200
commite3d561fb842fa9ea986064a9a73001a5889f15d8 (patch)
treeeac6c57ab550d37d5b78a93431d34baa51950fb7 /src/audio_core/stream.cpp
parentCommon/Kernel: Corrections and small bug fixing. (diff)
downloadyuzu-e3d561fb842fa9ea986064a9a73001a5889f15d8.tar
yuzu-e3d561fb842fa9ea986064a9a73001a5889f15d8.tar.gz
yuzu-e3d561fb842fa9ea986064a9a73001a5889f15d8.tar.bz2
yuzu-e3d561fb842fa9ea986064a9a73001a5889f15d8.tar.lz
yuzu-e3d561fb842fa9ea986064a9a73001a5889f15d8.tar.xz
yuzu-e3d561fb842fa9ea986064a9a73001a5889f15d8.tar.zst
yuzu-e3d561fb842fa9ea986064a9a73001a5889f15d8.zip
Diffstat (limited to 'src/audio_core/stream.cpp')
-rw-r--r--src/audio_core/stream.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/audio_core/stream.cpp b/src/audio_core/stream.cpp
index 6d5539b6b..dfc4805d9 100644
--- a/src/audio_core/stream.cpp
+++ b/src/audio_core/stream.cpp
@@ -66,6 +66,15 @@ s64 Stream::GetBufferReleaseNS(const Buffer& buffer) const {
return ns.count();
}
+s64 Stream::GetBufferReleaseNSHostTiming(const Buffer& buffer) const {
+ const std::size_t num_samples{buffer.GetSamples().size() / GetNumChannels()};
+ /// DSP signals before playing the last sample, in HLE we emulate this in this way
+ s64 base_samples = std::max<s64>(static_cast<s64>(num_samples) - 1, 0);
+ const auto ns =
+ std::chrono::nanoseconds((static_cast<u64>(base_samples) * 1000000000ULL) / sample_rate);
+ return ns.count();
+}
+
static void VolumeAdjustSamples(std::vector<s16>& samples, float game_volume) {
const float volume{std::clamp(Settings::Volume() - (1.0f - game_volume), 0.0f, 1.0f)};
@@ -105,7 +114,11 @@ void Stream::PlayNextBuffer() {
sink_stream.EnqueueSamples(GetNumChannels(), active_buffer->GetSamples());
- core_timing.ScheduleEvent(GetBufferReleaseNS(*active_buffer), release_event, {});
+ if (core_timing.IsHostTiming()) {
+ core_timing.ScheduleEvent(GetBufferReleaseNSHostTiming(*active_buffer), release_event, {});
+ } else {
+ core_timing.ScheduleEvent(GetBufferReleaseNS(*active_buffer), release_event, {});
+ }
}
void Stream::ReleaseActiveBuffer() {