summaryrefslogtreecommitdiff
path: root/src/audio_core/device
diff options
context:
space:
mode:
authorGravatar liamwhite2022-12-17 10:21:19 -0500
committerGravatar GitHub2022-12-17 10:21:19 -0500
commitfa10374d39effc79b5b9ed789bf873030cb08d7f (patch)
tree0e4cac7d6e87771e8f18c0d3bba7d8e3cddbb2c7 /src/audio_core/device
parentMerge pull request #9457 from Kelebek1/silence_tfb (diff)
parentSignal buffer event on audio in/out system stop, and force remove all registe... (diff)
downloadyuzu-fa10374d39effc79b5b9ed789bf873030cb08d7f.tar.gz
yuzu-fa10374d39effc79b5b9ed789bf873030cb08d7f.tar.xz
yuzu-fa10374d39effc79b5b9ed789bf873030cb08d7f.zip
Merge pull request #9455 from Kelebek1/audio_signal
[audio_core] Signal buffer event on audio in/out system stop
Diffstat (limited to 'src/audio_core/device')
-rw-r--r--src/audio_core/device/audio_buffers.h8
-rw-r--r--src/audio_core/device/device_session.cpp6
-rw-r--r--src/audio_core/device/device_session.h5
3 files changed, 16 insertions, 3 deletions
diff --git a/src/audio_core/device/audio_buffers.h b/src/audio_core/device/audio_buffers.h
index 3dae1a3b7..15082f6c6 100644
--- a/src/audio_core/device/audio_buffers.h
+++ b/src/audio_core/device/audio_buffers.h
@@ -91,9 +91,10 @@ public:
91 * @param core_timing - The CoreTiming instance 91 * @param core_timing - The CoreTiming instance
92 * @param session - The device session 92 * @param session - The device session
93 * 93 *
94 * @return Is the buffer was released. 94 * @return If any buffer was released.
95 */ 95 */
96 bool ReleaseBuffers(const Core::Timing::CoreTiming& core_timing, const DeviceSession& session) { 96 bool ReleaseBuffers(const Core::Timing::CoreTiming& core_timing, const DeviceSession& session,
97 bool force) {
97 std::scoped_lock l{lock}; 98 std::scoped_lock l{lock};
98 bool buffer_released{false}; 99 bool buffer_released{false};
99 while (registered_count > 0) { 100 while (registered_count > 0) {
@@ -103,7 +104,8 @@ public:
103 } 104 }
104 105
105 // Check with the backend if this buffer can be released yet. 106 // Check with the backend if this buffer can be released yet.
106 if (!session.IsBufferConsumed(buffers[index])) { 107 // If we're shutting down, we don't care if it's been played or not.
108 if (!force && !session.IsBufferConsumed(buffers[index])) {
107 break; 109 break;
108 } 110 }
109 111
diff --git a/src/audio_core/device/device_session.cpp b/src/audio_core/device/device_session.cpp
index 995060414..5a327a606 100644
--- a/src/audio_core/device/device_session.cpp
+++ b/src/audio_core/device/device_session.cpp
@@ -73,6 +73,12 @@ void DeviceSession::Stop() {
73 } 73 }
74} 74}
75 75
76void DeviceSession::ClearBuffers() {
77 if (stream) {
78 stream->ClearQueue();
79 }
80}
81
76void DeviceSession::AppendBuffers(std::span<const AudioBuffer> buffers) const { 82void DeviceSession::AppendBuffers(std::span<const AudioBuffer> buffers) const {
77 for (const auto& buffer : buffers) { 83 for (const auto& buffer : buffers) {
78 Sink::SinkBuffer new_buffer{ 84 Sink::SinkBuffer new_buffer{
diff --git a/src/audio_core/device/device_session.h b/src/audio_core/device/device_session.h
index 74f4dc085..75f766c68 100644
--- a/src/audio_core/device/device_session.h
+++ b/src/audio_core/device/device_session.h
@@ -91,6 +91,11 @@ public:
91 void Stop(); 91 void Stop();
92 92
93 /** 93 /**
94 * Clear out the underlying audio buffers in the backend stream.
95 */
96 void ClearBuffers();
97
98 /**
94 * Set this device session's volume. 99 * Set this device session's volume.
95 * 100 *
96 * @param volume - New volume for this session. 101 * @param volume - New volume for this session.