summaryrefslogtreecommitdiff
path: root/src/audio_core/device
diff options
context:
space:
mode:
authorGravatar bunnei2022-09-16 23:51:31 -0700
committerGravatar GitHub2022-09-16 23:51:31 -0700
commit4a7a7713401983f94b6c07fa07cbbbfa4025556c (patch)
treeee9f4cac999d8c4f7e5c1d5d51e624ff82580607 /src/audio_core/device
parentMerge pull request #8916 from Docteh/muilti_build (diff)
parentaudio_renderer: Pass command buffer by const reference (diff)
downloadyuzu-4a7a7713401983f94b6c07fa07cbbbfa4025556c.tar.gz
yuzu-4a7a7713401983f94b6c07fa07cbbbfa4025556c.tar.xz
yuzu-4a7a7713401983f94b6c07fa07cbbbfa4025556c.zip
Merge pull request #8914 from lioncash/audio-const
audio_core: Mark several member functions as const
Diffstat (limited to 'src/audio_core/device')
-rw-r--r--src/audio_core/device/audio_buffers.h4
-rw-r--r--src/audio_core/device/device_session.cpp16
-rw-r--r--src/audio_core/device/device_session.h6
3 files changed, 13 insertions, 13 deletions
diff --git a/src/audio_core/device/audio_buffers.h b/src/audio_core/device/audio_buffers.h
index 3ecbbb63f..3dae1a3b7 100644
--- a/src/audio_core/device/audio_buffers.h
+++ b/src/audio_core/device/audio_buffers.h
@@ -36,7 +36,7 @@ public:
36 * 36 *
37 * @param buffer - The new buffer. 37 * @param buffer - The new buffer.
38 */ 38 */
39 void AppendBuffer(AudioBuffer& buffer) { 39 void AppendBuffer(const AudioBuffer& buffer) {
40 std::scoped_lock l{lock}; 40 std::scoped_lock l{lock};
41 buffers[appended_index] = buffer; 41 buffers[appended_index] = buffer;
42 appended_count++; 42 appended_count++;
@@ -93,7 +93,7 @@ public:
93 * 93 *
94 * @return Is the buffer was released. 94 * @return Is the buffer was released.
95 */ 95 */
96 bool ReleaseBuffers(Core::Timing::CoreTiming& core_timing, DeviceSession& session) { 96 bool ReleaseBuffers(const Core::Timing::CoreTiming& core_timing, const DeviceSession& session) {
97 std::scoped_lock l{lock}; 97 std::scoped_lock l{lock};
98 bool buffer_released{false}; 98 bool buffer_released{false};
99 while (registered_count > 0) { 99 while (registered_count > 0) {
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() {
73 } 73 }
74} 74}
75 75
76void DeviceSession::AppendBuffers(std::span<AudioBuffer> buffers) const { 76void 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,21 +86,21 @@ void DeviceSession::AppendBuffers(std::span<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 }
94} 94}
95 95
96void DeviceSession::ReleaseBuffer(AudioBuffer& buffer) const { 96void DeviceSession::ReleaseBuffer(const AudioBuffer& buffer) const {
97 if (type == Sink::StreamType::In) { 97 if (type == Sink::StreamType::In) {
98 auto samples{stream->ReleaseBuffer(buffer.size / sizeof(s16))}; 98 auto samples{stream->ReleaseBuffer(buffer.size / sizeof(s16))};
99 system.Memory().WriteBlockUnsafe(buffer.samples, samples.data(), buffer.size); 99 system.Memory().WriteBlockUnsafe(buffer.samples, samples.data(), buffer.size);
100 } 100 }
101} 101}
102 102
103bool DeviceSession::IsBufferConsumed(AudioBuffer& buffer) const { 103bool DeviceSession::IsBufferConsumed(const AudioBuffer& buffer) const {
104 return played_sample_count >= buffer.end_timestamp; 104 return played_sample_count >= buffer.end_timestamp;
105} 105}
106 106
diff --git a/src/audio_core/device/device_session.h b/src/audio_core/device/device_session.h
index 53b649c61..74f4dc085 100644
--- a/src/audio_core/device/device_session.h
+++ b/src/audio_core/device/device_session.h
@@ -62,14 +62,14 @@ public:
62 * 62 *
63 * @param buffers - The buffers to play. 63 * @param buffers - The buffers to play.
64 */ 64 */
65 void AppendBuffers(std::span<AudioBuffer> buffers) const; 65 void AppendBuffers(std::span<const AudioBuffer> buffers) const;
66 66
67 /** 67 /**
68 * (Audio In only) Pop samples from the backend, and write them back to this buffer's address. 68 * (Audio In only) Pop samples from the backend, and write them back to this buffer's address.
69 * 69 *
70 * @param buffer - The buffer to write to. 70 * @param buffer - The buffer to write to.
71 */ 71 */
72 void ReleaseBuffer(AudioBuffer& buffer) const; 72 void ReleaseBuffer(const AudioBuffer& buffer) const;
73 73
74 /** 74 /**
75 * Check if the buffer for the given tag has been consumed by the backend. 75 * Check if the buffer for the given tag has been consumed by the backend.
@@ -78,7 +78,7 @@ public:
78 * 78 *
79 * @return true if the buffer has been consumed, otherwise false. 79 * @return true if the buffer has been consumed, otherwise false.
80 */ 80 */
81 bool IsBufferConsumed(AudioBuffer& buffer) const; 81 bool IsBufferConsumed(const AudioBuffer& buffer) const;
82 82
83 /** 83 /**
84 * Start this device session, starting the backend stream. 84 * Start this device session, starting the backend stream.