diff options
| author | 2021-06-23 11:31:12 -0700 | |
|---|---|---|
| committer | 2021-06-23 11:31:12 -0700 | |
| commit | 809e5fd52317f0a925ca463eca85a0b67d744f9e (patch) | |
| tree | 2be4647d9d8ca7b43643e2996a831b2c914c519b /src | |
| parent | Merge pull request #6518 from lioncash/func (diff) | |
| parent | Implement audout GetAudioOutPlayedSampleCount (diff) | |
| download | yuzu-809e5fd52317f0a925ca463eca85a0b67d744f9e.tar.gz yuzu-809e5fd52317f0a925ca463eca85a0b67d744f9e.tar.xz yuzu-809e5fd52317f0a925ca463eca85a0b67d744f9e.zip | |
Merge pull request #6504 from Kelebek1/samples-played
[audout] Implement GetAudioOutPlayedSampleCount
Diffstat (limited to 'src')
| -rw-r--r-- | src/audio_core/stream.cpp | 7 | ||||
| -rw-r--r-- | src/audio_core/stream.h | 6 | ||||
| -rw-r--r-- | src/core/hle/service/audio/audout_u.cpp | 10 |
3 files changed, 20 insertions, 3 deletions
diff --git a/src/audio_core/stream.cpp b/src/audio_core/stream.cpp index ad6c587c2..5a30f55a7 100644 --- a/src/audio_core/stream.cpp +++ b/src/audio_core/stream.cpp | |||
| @@ -107,9 +107,12 @@ void Stream::PlayNextBuffer(std::chrono::nanoseconds ns_late) { | |||
| 107 | active_buffer = queued_buffers.front(); | 107 | active_buffer = queued_buffers.front(); |
| 108 | queued_buffers.pop(); | 108 | queued_buffers.pop(); |
| 109 | 109 | ||
| 110 | VolumeAdjustSamples(active_buffer->GetSamples(), game_volume); | 110 | auto& samples = active_buffer->GetSamples(); |
| 111 | 111 | ||
| 112 | sink_stream.EnqueueSamples(GetNumChannels(), active_buffer->GetSamples()); | 112 | VolumeAdjustSamples(samples, game_volume); |
| 113 | |||
| 114 | sink_stream.EnqueueSamples(GetNumChannels(), samples); | ||
| 115 | played_samples += samples.size(); | ||
| 113 | 116 | ||
| 114 | const auto buffer_release_ns = GetBufferReleaseNS(*active_buffer); | 117 | const auto buffer_release_ns = GetBufferReleaseNS(*active_buffer); |
| 115 | 118 | ||
diff --git a/src/audio_core/stream.h b/src/audio_core/stream.h index 559844b9b..dbd97ec9c 100644 --- a/src/audio_core/stream.h +++ b/src/audio_core/stream.h | |||
| @@ -89,6 +89,11 @@ public: | |||
| 89 | return sample_rate; | 89 | return sample_rate; |
| 90 | } | 90 | } |
| 91 | 91 | ||
| 92 | /// Gets the number of samples played so far | ||
| 93 | [[nodiscard]] u64 GetPlayedSampleCount() const { | ||
| 94 | return played_samples; | ||
| 95 | } | ||
| 96 | |||
| 92 | /// Gets the number of channels | 97 | /// Gets the number of channels |
| 93 | [[nodiscard]] u32 GetNumChannels() const; | 98 | [[nodiscard]] u32 GetNumChannels() const; |
| 94 | 99 | ||
| @@ -106,6 +111,7 @@ private: | |||
| 106 | [[nodiscard]] std::chrono::nanoseconds GetBufferReleaseNS(const Buffer& buffer) const; | 111 | [[nodiscard]] std::chrono::nanoseconds GetBufferReleaseNS(const Buffer& buffer) const; |
| 107 | 112 | ||
| 108 | u32 sample_rate; ///< Sample rate of the stream | 113 | u32 sample_rate; ///< Sample rate of the stream |
| 114 | u64 played_samples{}; ///< The current played sample count | ||
| 109 | Format format; ///< Format of the stream | 115 | Format format; ///< Format of the stream |
| 110 | float game_volume = 1.0f; ///< The volume the game currently has set | 116 | float game_volume = 1.0f; ///< The volume the game currently has set |
| 111 | ReleaseCallback release_callback; ///< Buffer release callback for the stream | 117 | 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 100644 --- a/src/core/hle/service/audio/audout_u.cpp +++ b/src/core/hle/service/audio/audout_u.cpp | |||
| @@ -58,7 +58,7 @@ public: | |||
| 58 | {7, &IAudioOut::AppendAudioOutBufferImpl, "AppendAudioOutBufferAuto"}, | 58 | {7, &IAudioOut::AppendAudioOutBufferImpl, "AppendAudioOutBufferAuto"}, |
| 59 | {8, &IAudioOut::GetReleasedAudioOutBufferImpl, "GetReleasedAudioOutBufferAuto"}, | 59 | {8, &IAudioOut::GetReleasedAudioOutBufferImpl, "GetReleasedAudioOutBufferAuto"}, |
| 60 | {9, &IAudioOut::GetAudioOutBufferCount, "GetAudioOutBufferCount"}, | 60 | {9, &IAudioOut::GetAudioOutBufferCount, "GetAudioOutBufferCount"}, |
| 61 | {10, nullptr, "GetAudioOutPlayedSampleCount"}, | 61 | {10, &IAudioOut::GetAudioOutPlayedSampleCount, "GetAudioOutPlayedSampleCount"}, |
| 62 | {11, &IAudioOut::FlushAudioOutBuffers, "FlushAudioOutBuffers"}, | 62 | {11, &IAudioOut::FlushAudioOutBuffers, "FlushAudioOutBuffers"}, |
| 63 | {12, &IAudioOut::SetAudioOutVolume, "SetAudioOutVolume"}, | 63 | {12, &IAudioOut::SetAudioOutVolume, "SetAudioOutVolume"}, |
| 64 | {13, &IAudioOut::GetAudioOutVolume, "GetAudioOutVolume"}, | 64 | {13, &IAudioOut::GetAudioOutVolume, "GetAudioOutVolume"}, |
| @@ -186,6 +186,14 @@ private: | |||
| 186 | rb.Push(static_cast<u32>(stream->GetQueueSize())); | 186 | rb.Push(static_cast<u32>(stream->GetQueueSize())); |
| 187 | } | 187 | } |
| 188 | 188 | ||
| 189 | void GetAudioOutPlayedSampleCount(Kernel::HLERequestContext& ctx) { | ||
| 190 | LOG_DEBUG(Service_Audio, "called"); | ||
| 191 | |||
| 192 | IPC::ResponseBuilder rb{ctx, 4}; | ||
| 193 | rb.Push(ResultSuccess); | ||
| 194 | rb.Push(stream->GetPlayedSampleCount()); | ||
| 195 | } | ||
| 196 | |||
| 189 | void FlushAudioOutBuffers(Kernel::HLERequestContext& ctx) { | 197 | void FlushAudioOutBuffers(Kernel::HLERequestContext& ctx) { |
| 190 | LOG_DEBUG(Service_Audio, "called"); | 198 | LOG_DEBUG(Service_Audio, "called"); |
| 191 | 199 | ||