diff options
| author | 2022-09-16 09:32:55 -0400 | |
|---|---|---|
| committer | 2022-09-16 09:32:57 -0400 | |
| commit | cb2a33babc831fa39c86663714f0951743530b2b (patch) | |
| tree | a6e21ee075ee53a9b3dede5a58e028d0503a6c77 /src | |
| parent | device_session: Pass arguments by const-ref in relevant functions (diff) | |
| download | yuzu-cb2a33babc831fa39c86663714f0951743530b2b.tar.gz yuzu-cb2a33babc831fa39c86663714f0951743530b2b.tar.xz yuzu-cb2a33babc831fa39c86663714f0951743530b2b.zip | |
device_session: Convert for loop into ranged for in AppendBuffers
Simplifies the indexing code a little bit.
Diffstat (limited to 'src')
| -rw-r--r-- | src/audio_core/device/device_session.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/audio_core/device/device_session.cpp b/src/audio_core/device/device_session.cpp index 6cde33f93..995060414 100644 --- a/src/audio_core/device/device_session.cpp +++ b/src/audio_core/device/device_session.cpp | |||
| @@ -74,11 +74,11 @@ void DeviceSession::Stop() { | |||
| 74 | } | 74 | } |
| 75 | 75 | ||
| 76 | void DeviceSession::AppendBuffers(std::span<const AudioBuffer> buffers) const { | 76 | void DeviceSession::AppendBuffers(std::span<const AudioBuffer> buffers) const { |
| 77 | for (size_t i = 0; i < buffers.size(); i++) { | 77 | for (const auto& buffer : buffers) { |
| 78 | Sink::SinkBuffer new_buffer{ | 78 | Sink::SinkBuffer new_buffer{ |
| 79 | .frames = buffers[i].size / (channel_count * sizeof(s16)), | 79 | .frames = buffer.size / (channel_count * sizeof(s16)), |
| 80 | .frames_played = 0, | 80 | .frames_played = 0, |
| 81 | .tag = buffers[i].tag, | 81 | .tag = buffer.tag, |
| 82 | .consumed = false, | 82 | .consumed = false, |
| 83 | }; | 83 | }; |
| 84 | 84 | ||
| @@ -86,8 +86,8 @@ void DeviceSession::AppendBuffers(std::span<const AudioBuffer> buffers) const { | |||
| 86 | std::vector<s16> samples{}; | 86 | std::vector<s16> samples{}; |
| 87 | stream->AppendBuffer(new_buffer, samples); | 87 | stream->AppendBuffer(new_buffer, samples); |
| 88 | } else { | 88 | } else { |
| 89 | std::vector<s16> samples(buffers[i].size / sizeof(s16)); | 89 | std::vector<s16> samples(buffer.size / sizeof(s16)); |
| 90 | system.Memory().ReadBlockUnsafe(buffers[i].samples, samples.data(), buffers[i].size); | 90 | system.Memory().ReadBlockUnsafe(buffer.samples, samples.data(), buffer.size); |
| 91 | stream->AppendBuffer(new_buffer, samples); | 91 | stream->AppendBuffer(new_buffer, samples); |
| 92 | } | 92 | } |
| 93 | } | 93 | } |