Skip to content
Snippets Groups Projects
Commit e9109cb5 authored by Lioncash's avatar Lioncash
Browse files

audio_buffers: Pass by const-ref in AppendBuffers

This function doesn't modify the passed in buffer, so we can make that
explicit.
parent cb2a33ba
No related branches found
No related tags found
No related merge requests found
...@@ -36,7 +36,7 @@ public: ...@@ -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++;
......
...@@ -114,12 +114,14 @@ bool System::AppendBuffer(const AudioInBuffer& buffer, const u64 tag) { ...@@ -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, const AudioBuffer new_buffer{
.end_timestamp = timestamp + buffer.size / (channel_count * sizeof(s16)), .start_timestamp = timestamp,
.played_timestamp = 0, .end_timestamp = timestamp + buffer.size / (channel_count * sizeof(s16)),
.samples = buffer.samples, .played_timestamp = 0,
.tag = tag, .samples = buffer.samples,
.size = buffer.size}; .tag = tag,
.size = buffer.size,
};
buffers.AppendBuffer(new_buffer); buffers.AppendBuffer(new_buffer);
RegisterBuffers(); RegisterBuffers();
......
...@@ -113,12 +113,14 @@ bool System::AppendBuffer(const AudioOutBuffer& buffer, u64 tag) { ...@@ -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, const AudioBuffer new_buffer{
.end_timestamp = timestamp + buffer.size / (channel_count * sizeof(s16)), .start_timestamp = timestamp,
.played_timestamp = 0, .end_timestamp = timestamp + buffer.size / (channel_count * sizeof(s16)),
.samples = buffer.samples, .played_timestamp = 0,
.tag = tag, .samples = buffer.samples,
.size = buffer.size}; .tag = tag,
.size = buffer.size,
};
buffers.AppendBuffer(new_buffer); buffers.AppendBuffer(new_buffer);
RegisterBuffers(); RegisterBuffers();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment