summaryrefslogtreecommitdiffstats
path: root/src/audio_core/cubeb_sink.cpp
diff options
context:
space:
mode:
authorMerryMage <MerryMage@users.noreply.github.com>2018-09-12 19:07:16 +0200
committerMerryMage <MerryMage@users.noreply.github.com>2018-09-12 19:09:14 +0200
commit957ddab6796cb6f644c60993c3035d8bd9c0a398 (patch)
tree17c3d0a96f47959a9c26d4f202003e5c2858fde3 /src/audio_core/cubeb_sink.cpp
parentcubeb_sink: Downsample arbitrary number of channels (diff)
downloadyuzu-957ddab6796cb6f644c60993c3035d8bd9c0a398.tar
yuzu-957ddab6796cb6f644c60993c3035d8bd9c0a398.tar.gz
yuzu-957ddab6796cb6f644c60993c3035d8bd9c0a398.tar.bz2
yuzu-957ddab6796cb6f644c60993c3035d8bd9c0a398.tar.lz
yuzu-957ddab6796cb6f644c60993c3035d8bd9c0a398.tar.xz
yuzu-957ddab6796cb6f644c60993c3035d8bd9c0a398.tar.zst
yuzu-957ddab6796cb6f644c60993c3035d8bd9c0a398.zip
Diffstat (limited to 'src/audio_core/cubeb_sink.cpp')
-rw-r--r--src/audio_core/cubeb_sink.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/audio_core/cubeb_sink.cpp b/src/audio_core/cubeb_sink.cpp
index 067dc98d2..79155a7a0 100644
--- a/src/audio_core/cubeb_sink.cpp
+++ b/src/audio_core/cubeb_sink.cpp
@@ -3,6 +3,7 @@
// Refer to the license.txt file included.
#include <algorithm>
+#include <atomic>
#include <cstring>
#include "audio_core/cubeb_sink.h"
#include "audio_core/stream.h"
@@ -81,6 +82,10 @@ public:
return queue.Size() / num_channels;
}
+ void Flush() override {
+ should_flush = true;
+ }
+
u32 GetNumChannels() const {
return num_channels;
}
@@ -94,6 +99,7 @@ private:
Common::RingBuffer<s16, 0x10000> queue;
std::array<s16, 2> last_frame;
+ std::atomic<bool> should_flush{};
TimeStretcher time_stretch;
static long DataCallback(cubeb_stream* stream, void* user_data, const void* input_buffer,
@@ -163,6 +169,11 @@ long CubebSinkStream::DataCallback(cubeb_stream* stream, void* user_data, const
s16* const out{reinterpret_cast<s16*>(buffer)};
const size_t out_frames = impl->time_stretch.Process(in.data(), num_in, out, num_frames);
samples_written = out_frames * num_channels;
+
+ if (impl->should_flush) {
+ impl->time_stretch.Flush();
+ impl->should_flush = false;
+ }
} else {
samples_written = impl->queue.Pop(buffer, samples_to_write);
}