summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMerryMage <MerryMage@users.noreply.github.com>2018-08-12 21:41:46 +0200
committerMerryMage <MerryMage@users.noreply.github.com>2018-08-12 21:41:46 +0200
commitfcc5ffdfddee85e59e36621bbc8a1c3cb797ca51 (patch)
treeb97ab6591a3f689a786740e8897b249da8130077
parentMerge pull request #1028 from ogniK5377/aoa (diff)
downloadyuzu-fcc5ffdfddee85e59e36621bbc8a1c3cb797ca51.tar
yuzu-fcc5ffdfddee85e59e36621bbc8a1c3cb797ca51.tar.gz
yuzu-fcc5ffdfddee85e59e36621bbc8a1c3cb797ca51.tar.bz2
yuzu-fcc5ffdfddee85e59e36621bbc8a1c3cb797ca51.tar.lz
yuzu-fcc5ffdfddee85e59e36621bbc8a1c3cb797ca51.tar.xz
yuzu-fcc5ffdfddee85e59e36621bbc8a1c3cb797ca51.tar.zst
yuzu-fcc5ffdfddee85e59e36621bbc8a1c3cb797ca51.zip
Diffstat (limited to '')
-rw-r--r--src/audio_core/cubeb_sink.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/audio_core/cubeb_sink.cpp b/src/audio_core/cubeb_sink.cpp
index 1501ef1f4..5a1177d0c 100644
--- a/src/audio_core/cubeb_sink.cpp
+++ b/src/audio_core/cubeb_sink.cpp
@@ -4,6 +4,7 @@
#include <algorithm>
#include <cstring>
+#include <mutex>
#include "audio_core/cubeb_sink.h"
#include "audio_core/stream.h"
@@ -66,6 +67,8 @@ public:
return;
}
+ std::lock_guard lock{queue_mutex};
+
queue.reserve(queue.size() + samples.size() * GetNumChannels());
if (is_6_channel) {
@@ -94,6 +97,7 @@ private:
u32 num_channels{};
bool is_6_channel{};
+ std::mutex queue_mutex;
std::vector<s16> queue;
static long DataCallback(cubeb_stream* stream, void* user_data, const void* input_buffer,
@@ -153,6 +157,8 @@ long SinkStreamImpl::DataCallback(cubeb_stream* stream, void* user_data, const v
return {};
}
+ std::lock_guard lock{impl->queue_mutex};
+
const size_t frames_to_write{
std::min(impl->queue.size() / impl->GetNumChannels(), static_cast<size_t>(num_frames))};