summaryrefslogtreecommitdiffstats
path: root/src/audio_core/device
diff options
context:
space:
mode:
authorKelebek1 <eeeedddccc@hotmail.co.uk>2022-12-16 17:01:35 +0100
committerKelebek1 <eeeedddccc@hotmail.co.uk>2022-12-16 17:07:24 +0100
commit6a56f42f5d94e2be405a736a74b86ffe3ab1b37b (patch)
treef110ff43899da31442d31c219c36f2b8a20ef974 /src/audio_core/device
parentMerge pull request #9431 from liamwhite/sixty-five-oh-two (diff)
downloadyuzu-6a56f42f5d94e2be405a736a74b86ffe3ab1b37b.tar
yuzu-6a56f42f5d94e2be405a736a74b86ffe3ab1b37b.tar.gz
yuzu-6a56f42f5d94e2be405a736a74b86ffe3ab1b37b.tar.bz2
yuzu-6a56f42f5d94e2be405a736a74b86ffe3ab1b37b.tar.lz
yuzu-6a56f42f5d94e2be405a736a74b86ffe3ab1b37b.tar.xz
yuzu-6a56f42f5d94e2be405a736a74b86ffe3ab1b37b.tar.zst
yuzu-6a56f42f5d94e2be405a736a74b86ffe3ab1b37b.zip
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:
* @param core_timing - The CoreTiming instance
* @param session - The device session
*
- * @return Is the buffer was released.
+ * @return If any buffer was released.
*/
- bool ReleaseBuffers(const Core::Timing::CoreTiming& core_timing, const DeviceSession& session) {
+ bool ReleaseBuffers(const Core::Timing::CoreTiming& core_timing, const DeviceSession& session,
+ bool force) {
std::scoped_lock l{lock};
bool buffer_released{false};
while (registered_count > 0) {
@@ -103,7 +104,8 @@ public:
}
// Check with the backend if this buffer can be released yet.
- if (!session.IsBufferConsumed(buffers[index])) {
+ // If we're shutting down, we don't care if it's been played or not.
+ if (!force && !session.IsBufferConsumed(buffers[index])) {
break;
}
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() {
}
}
+void DeviceSession::ClearBuffers() {
+ if (stream) {
+ stream->ClearQueue();
+ }
+}
+
void DeviceSession::AppendBuffers(std::span<const AudioBuffer> buffers) const {
for (const auto& buffer : buffers) {
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:
void Stop();
/**
+ * Clear out the underlying audio buffers in the backend stream.
+ */
+ void ClearBuffers();
+
+ /**
* Set this device session's volume.
*
* @param volume - New volume for this session.