summaryrefslogtreecommitdiffstats
path: root/src/audio_core
diff options
context:
space:
mode:
authorLioncash <mathew1800@gmail.com>2020-07-16 00:30:06 +0200
committerLioncash <mathew1800@gmail.com>2020-07-16 00:54:15 +0200
commit8b50c660dfce50a07c2b2aa3c1b6b8642259a944 (patch)
tree798b0427a660bf249311f3a13d96c6df69a6bcb5 /src/audio_core
parentMerge pull request #4342 from lioncash/endian (diff)
downloadyuzu-8b50c660dfce50a07c2b2aa3c1b6b8642259a944.tar
yuzu-8b50c660dfce50a07c2b2aa3c1b6b8642259a944.tar.gz
yuzu-8b50c660dfce50a07c2b2aa3c1b6b8642259a944.tar.bz2
yuzu-8b50c660dfce50a07c2b2aa3c1b6b8642259a944.tar.lz
yuzu-8b50c660dfce50a07c2b2aa3c1b6b8642259a944.tar.xz
yuzu-8b50c660dfce50a07c2b2aa3c1b6b8642259a944.tar.zst
yuzu-8b50c660dfce50a07c2b2aa3c1b6b8642259a944.zip
Diffstat (limited to 'src/audio_core')
-rw-r--r--src/audio_core/stream.cpp14
-rw-r--r--src/audio_core/stream.h6
2 files changed, 8 insertions, 12 deletions
diff --git a/src/audio_core/stream.cpp b/src/audio_core/stream.cpp
index aab3e979a..abd8576e2 100644
--- a/src/audio_core/stream.cpp
+++ b/src/audio_core/stream.cpp
@@ -59,11 +59,9 @@ Stream::State Stream::GetState() const {
return state;
}
-s64 Stream::GetBufferReleaseNS(const Buffer& buffer) const {
+std::chrono::nanoseconds Stream::GetBufferReleaseNS(const Buffer& buffer) const {
const std::size_t num_samples{buffer.GetSamples().size() / GetNumChannels()};
- const auto ns =
- std::chrono::nanoseconds((static_cast<u64>(num_samples) * 1000000000ULL) / sample_rate);
- return ns.count();
+ return std::chrono::nanoseconds((static_cast<u64>(num_samples) * 1000000000ULL) / sample_rate);
}
static void VolumeAdjustSamples(std::vector<s16>& samples, float game_volume) {
@@ -105,10 +103,10 @@ void Stream::PlayNextBuffer(s64 cycles_late) {
sink_stream.EnqueueSamples(GetNumChannels(), active_buffer->GetSamples());
- core_timing.ScheduleEvent(
- GetBufferReleaseNS(*active_buffer) -
- (Settings::values.enable_audio_stretching.GetValue() ? 0 : cycles_late),
- release_event, {});
+ const auto time_stretch_delta = std::chrono::nanoseconds{
+ Settings::values.enable_audio_stretching.GetValue() ? 0 : cycles_late};
+ const auto future_time = GetBufferReleaseNS(*active_buffer) - time_stretch_delta;
+ core_timing.ScheduleEvent(future_time, release_event, {});
}
void Stream::ReleaseActiveBuffer(s64 cycles_late) {
diff --git a/src/audio_core/stream.h b/src/audio_core/stream.h
index 524376257..2febd647c 100644
--- a/src/audio_core/stream.h
+++ b/src/audio_core/stream.h
@@ -4,6 +4,7 @@
#pragma once
+#include <chrono>
#include <functional>
#include <memory>
#include <string>
@@ -96,10 +97,7 @@ private:
void ReleaseActiveBuffer(s64 cycles_late = 0);
/// Gets the number of core cycles when the specified buffer will be released
- s64 GetBufferReleaseNS(const Buffer& buffer) const;
-
- /// Gets the number of core cycles when the specified buffer will be released
- s64 GetBufferReleaseNSHostTiming(const Buffer& buffer) const;
+ std::chrono::nanoseconds GetBufferReleaseNS(const Buffer& buffer) const;
u32 sample_rate; ///< Sample rate of the stream
Format format; ///< Format of the stream