summaryrefslogtreecommitdiffstats
path: root/src/audio_core
diff options
context:
space:
mode:
authorLioncash <mathew1800@gmail.com>2020-07-16 01:14:21 +0200
committerLioncash <mathew1800@gmail.com>2020-07-16 01:41:22 +0200
commitbef1844a51a37c1c8dc531e67069ef00821ffa9c (patch)
tree2e46f404c3f0baf1b854e1bea916c19469fe424a /src/audio_core
parentcore_timing: Make use of std::chrono with ScheduleEvent (diff)
downloadyuzu-bef1844a51a37c1c8dc531e67069ef00821ffa9c.tar
yuzu-bef1844a51a37c1c8dc531e67069ef00821ffa9c.tar.gz
yuzu-bef1844a51a37c1c8dc531e67069ef00821ffa9c.tar.bz2
yuzu-bef1844a51a37c1c8dc531e67069ef00821ffa9c.tar.lz
yuzu-bef1844a51a37c1c8dc531e67069ef00821ffa9c.tar.xz
yuzu-bef1844a51a37c1c8dc531e67069ef00821ffa9c.tar.zst
yuzu-bef1844a51a37c1c8dc531e67069ef00821ffa9c.zip
Diffstat (limited to 'src/audio_core')
-rw-r--r--src/audio_core/stream.cpp13
-rw-r--r--src/audio_core/stream.h4
2 files changed, 9 insertions, 8 deletions
diff --git a/src/audio_core/stream.cpp b/src/audio_core/stream.cpp
index abd8576e2..f80ab92e4 100644
--- a/src/audio_core/stream.cpp
+++ b/src/audio_core/stream.cpp
@@ -38,7 +38,7 @@ Stream::Stream(Core::Timing::CoreTiming& core_timing, u32 sample_rate, Format fo
sink_stream{sink_stream}, core_timing{core_timing}, name{std::move(name_)} {
release_event = Core::Timing::CreateEvent(
- name, [this](u64 userdata, s64 cycles_late) { ReleaseActiveBuffer(cycles_late); });
+ name, [this](u64, std::chrono::nanoseconds ns_late) { ReleaseActiveBuffer(ns_late); });
}
void Stream::Play() {
@@ -78,7 +78,7 @@ static void VolumeAdjustSamples(std::vector<s16>& samples, float game_volume) {
}
}
-void Stream::PlayNextBuffer(s64 cycles_late) {
+void Stream::PlayNextBuffer(std::chrono::nanoseconds ns_late) {
if (!IsPlaying()) {
// Ensure we are in playing state before playing the next buffer
sink_stream.Flush();
@@ -103,17 +103,18 @@ void Stream::PlayNextBuffer(s64 cycles_late) {
sink_stream.EnqueueSamples(GetNumChannels(), active_buffer->GetSamples());
- const auto time_stretch_delta = std::chrono::nanoseconds{
- Settings::values.enable_audio_stretching.GetValue() ? 0 : cycles_late};
+ const auto time_stretch_delta = Settings::values.enable_audio_stretching.GetValue()
+ ? std::chrono::nanoseconds::zero()
+ : ns_late;
const auto future_time = GetBufferReleaseNS(*active_buffer) - time_stretch_delta;
core_timing.ScheduleEvent(future_time, release_event, {});
}
-void Stream::ReleaseActiveBuffer(s64 cycles_late) {
+void Stream::ReleaseActiveBuffer(std::chrono::nanoseconds ns_late) {
ASSERT(active_buffer);
released_buffers.push(std::move(active_buffer));
release_callback();
- PlayNextBuffer(cycles_late);
+ PlayNextBuffer(ns_late);
}
bool Stream::QueueBuffer(BufferPtr&& buffer) {
diff --git a/src/audio_core/stream.h b/src/audio_core/stream.h
index 2febd647c..6437b8591 100644
--- a/src/audio_core/stream.h
+++ b/src/audio_core/stream.h
@@ -91,10 +91,10 @@ public:
private:
/// Plays the next queued buffer in the audio stream, starting playback if necessary
- void PlayNextBuffer(s64 cycles_late = 0);
+ void PlayNextBuffer(std::chrono::nanoseconds ns_late = {});
/// Releases the actively playing buffer, signalling that it has been completed
- void ReleaseActiveBuffer(s64 cycles_late = 0);
+ void ReleaseActiveBuffer(std::chrono::nanoseconds ns_late = {});
/// Gets the number of core cycles when the specified buffer will be released
std::chrono::nanoseconds GetBufferReleaseNS(const Buffer& buffer) const;