From dd0ca32f47fd72e8788e132191a8346d0ae44c40 Mon Sep 17 00:00:00 2001 From: pineappleEA Date: Mon, 21 Jun 2021 21:53:07 +0200 Subject: [PATCH] early-access version 1800 --- README.md | 2 +- src/audio_core/stream.cpp | 7 +++++-- src/audio_core/stream.h | 6 ++++++ src/core/hle/service/audio/audout_u.cpp | 10 +++++++++- 4 files changed, 21 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 285b24059..eed1233a3 100755 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ yuzu emulator early access ============= -This is the source code for early-access 1799. +This is the source code for early-access 1800. ## Legal Notice diff --git a/src/audio_core/stream.cpp b/src/audio_core/stream.cpp index ad6c587c2..5a30f55a7 100755 --- a/src/audio_core/stream.cpp +++ b/src/audio_core/stream.cpp @@ -107,9 +107,12 @@ void Stream::PlayNextBuffer(std::chrono::nanoseconds ns_late) { active_buffer = queued_buffers.front(); queued_buffers.pop(); - VolumeAdjustSamples(active_buffer->GetSamples(), game_volume); + auto& samples = active_buffer->GetSamples(); - sink_stream.EnqueueSamples(GetNumChannels(), active_buffer->GetSamples()); + VolumeAdjustSamples(samples, game_volume); + + sink_stream.EnqueueSamples(GetNumChannels(), samples); + played_samples += samples.size(); const auto buffer_release_ns = GetBufferReleaseNS(*active_buffer); diff --git a/src/audio_core/stream.h b/src/audio_core/stream.h index 559844b9b..41d8d0b46 100755 --- a/src/audio_core/stream.h +++ b/src/audio_core/stream.h @@ -89,6 +89,11 @@ public: return sample_rate; } + /// Gets the number of samples played so far + [[nodiscard]] u64 GetPlayedSampleCount() const { + return played_samples; + } + /// Gets the number of channels [[nodiscard]] u32 GetNumChannels() const; @@ -106,6 +111,7 @@ private: [[nodiscard]] std::chrono::nanoseconds GetBufferReleaseNS(const Buffer& buffer) const; u32 sample_rate; ///< Sample rate of the stream + u64 played_samples; ///< The current played sample count Format format; ///< Format of the stream float game_volume = 1.0f; ///< The volume the game currently has set ReleaseCallback release_callback; ///< Buffer release callback for the stream diff --git a/src/core/hle/service/audio/audout_u.cpp b/src/core/hle/service/audio/audout_u.cpp index 804c6b10c..92d4510b1 100755 --- a/src/core/hle/service/audio/audout_u.cpp +++ b/src/core/hle/service/audio/audout_u.cpp @@ -58,7 +58,7 @@ public: {7, &IAudioOut::AppendAudioOutBufferImpl, "AppendAudioOutBufferAuto"}, {8, &IAudioOut::GetReleasedAudioOutBufferImpl, "GetReleasedAudioOutBufferAuto"}, {9, &IAudioOut::GetAudioOutBufferCount, "GetAudioOutBufferCount"}, - {10, nullptr, "GetAudioOutPlayedSampleCount"}, + {10, &IAudioOut::GetAudioOutPlayedSampleCount, "GetAudioOutPlayedSampleCount"}, {11, &IAudioOut::FlushAudioOutBuffers, "FlushAudioOutBuffers"}, {12, &IAudioOut::SetAudioOutVolume, "SetAudioOutVolume"}, {13, &IAudioOut::GetAudioOutVolume, "GetAudioOutVolume"}, @@ -186,6 +186,14 @@ private: rb.Push(static_cast(stream->GetQueueSize())); } + void GetAudioOutPlayedSampleCount(Kernel::HLERequestContext& ctx) { + LOG_DEBUG(Service_Audio, "called"); + + IPC::ResponseBuilder rb{ctx, 4}; + rb.Push(ResultSuccess); + rb.Push(stream->GetPlayedSampleCount()); + } + void FlushAudioOutBuffers(Kernel::HLERequestContext& ctx) { LOG_DEBUG(Service_Audio, "called");