diff options
author | bunnei <bunneidev@gmail.com> | 2022-09-17 08:51:31 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-17 08:51:31 +0200 |
commit | 4a7a7713401983f94b6c07fa07cbbbfa4025556c (patch) | |
tree | ee9f4cac999d8c4f7e5c1d5d51e624ff82580607 /src/audio_core/device/device_session.cpp | |
parent | Merge pull request #8916 from Docteh/muilti_build (diff) | |
parent | audio_renderer: Pass command buffer by const reference (diff) | |
download | yuzu-4a7a7713401983f94b6c07fa07cbbbfa4025556c.tar yuzu-4a7a7713401983f94b6c07fa07cbbbfa4025556c.tar.gz yuzu-4a7a7713401983f94b6c07fa07cbbbfa4025556c.tar.bz2 yuzu-4a7a7713401983f94b6c07fa07cbbbfa4025556c.tar.lz yuzu-4a7a7713401983f94b6c07fa07cbbbfa4025556c.tar.xz yuzu-4a7a7713401983f94b6c07fa07cbbbfa4025556c.tar.zst yuzu-4a7a7713401983f94b6c07fa07cbbbfa4025556c.zip |
Diffstat (limited to '')
-rw-r--r-- | src/audio_core/device/device_session.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/audio_core/device/device_session.cpp b/src/audio_core/device/device_session.cpp index c71c3a376..995060414 100644 --- a/src/audio_core/device/device_session.cpp +++ b/src/audio_core/device/device_session.cpp @@ -73,12 +73,12 @@ void DeviceSession::Stop() { } } -void DeviceSession::AppendBuffers(std::span<AudioBuffer> buffers) const { - for (size_t i = 0; i < buffers.size(); i++) { +void DeviceSession::AppendBuffers(std::span<const AudioBuffer> buffers) const { + for (const auto& buffer : buffers) { Sink::SinkBuffer new_buffer{ - .frames = buffers[i].size / (channel_count * sizeof(s16)), + .frames = buffer.size / (channel_count * sizeof(s16)), .frames_played = 0, - .tag = buffers[i].tag, + .tag = buffer.tag, .consumed = false, }; @@ -86,21 +86,21 @@ void DeviceSession::AppendBuffers(std::span<AudioBuffer> buffers) const { std::vector<s16> samples{}; stream->AppendBuffer(new_buffer, samples); } else { - std::vector<s16> samples(buffers[i].size / sizeof(s16)); - system.Memory().ReadBlockUnsafe(buffers[i].samples, samples.data(), buffers[i].size); + std::vector<s16> samples(buffer.size / sizeof(s16)); + system.Memory().ReadBlockUnsafe(buffer.samples, samples.data(), buffer.size); stream->AppendBuffer(new_buffer, samples); } } } -void DeviceSession::ReleaseBuffer(AudioBuffer& buffer) const { +void DeviceSession::ReleaseBuffer(const AudioBuffer& buffer) const { if (type == Sink::StreamType::In) { auto samples{stream->ReleaseBuffer(buffer.size / sizeof(s16))}; system.Memory().WriteBlockUnsafe(buffer.samples, samples.data(), buffer.size); } } -bool DeviceSession::IsBufferConsumed(AudioBuffer& buffer) const { +bool DeviceSession::IsBufferConsumed(const AudioBuffer& buffer) const { return played_sample_count >= buffer.end_timestamp; } |