Browse Source

audio_buffers: Pass by const-ref in AppendBuffers

This function doesn't modify the passed in buffer, so we can make that
explicit.
nce_cpp
Lioncash 3 years ago
parent
commit
12b4a200e9
  1. 2
      src/audio_core/device/audio_buffers.h
  2. 14
      src/audio_core/in/audio_in_system.cpp
  3. 14
      src/audio_core/out/audio_out_system.cpp

2
src/audio_core/device/audio_buffers.h

@ -36,7 +36,7 @@ public:
* *
* @param buffer - The new buffer. * @param buffer - The new buffer.
*/ */
void AppendBuffer(AudioBuffer& buffer) {
void AppendBuffer(const AudioBuffer& buffer) {
std::scoped_lock l{lock}; std::scoped_lock l{lock};
buffers[appended_index] = buffer; buffers[appended_index] = buffer;
appended_count++; appended_count++;

14
src/audio_core/in/audio_in_system.cpp

@ -114,12 +114,14 @@ bool System::AppendBuffer(const AudioInBuffer& buffer, const u64 tag) {
} }
const auto timestamp{buffers.GetNextTimestamp()}; const auto timestamp{buffers.GetNextTimestamp()};
AudioBuffer new_buffer{.start_timestamp = timestamp,
.end_timestamp = timestamp + buffer.size / (channel_count * sizeof(s16)),
.played_timestamp = 0,
.samples = buffer.samples,
.tag = tag,
.size = buffer.size};
const AudioBuffer new_buffer{
.start_timestamp = timestamp,
.end_timestamp = timestamp + buffer.size / (channel_count * sizeof(s16)),
.played_timestamp = 0,
.samples = buffer.samples,
.tag = tag,
.size = buffer.size,
};
buffers.AppendBuffer(new_buffer); buffers.AppendBuffer(new_buffer);
RegisterBuffers(); RegisterBuffers();

14
src/audio_core/out/audio_out_system.cpp

@ -113,12 +113,14 @@ bool System::AppendBuffer(const AudioOutBuffer& buffer, u64 tag) {
} }
const auto timestamp{buffers.GetNextTimestamp()}; const auto timestamp{buffers.GetNextTimestamp()};
AudioBuffer new_buffer{.start_timestamp = timestamp,
.end_timestamp = timestamp + buffer.size / (channel_count * sizeof(s16)),
.played_timestamp = 0,
.samples = buffer.samples,
.tag = tag,
.size = buffer.size};
const AudioBuffer new_buffer{
.start_timestamp = timestamp,
.end_timestamp = timestamp + buffer.size / (channel_count * sizeof(s16)),
.played_timestamp = 0,
.samples = buffer.samples,
.tag = tag,
.size = buffer.size,
};
buffers.AppendBuffer(new_buffer); buffers.AppendBuffer(new_buffer);
RegisterBuffers(); RegisterBuffers();

Loading…
Cancel
Save