From ce1b0d0170ac7ac9f776a3e53e48353d565627f2 Mon Sep 17 00:00:00 2001 From: AlexandreRouma Date: Sun, 19 Jun 2022 23:50:34 +0200 Subject: [PATCH] MacOS do be wasting my time --- core/src/dsp/sink/ring_buffer.h | 39 ++++++++++++++++++++++++ sink_modules/portaudio_sink/src/main.cpp | 10 +++--- 2 files changed, 44 insertions(+), 5 deletions(-) create mode 100644 core/src/dsp/sink/ring_buffer.h diff --git a/core/src/dsp/sink/ring_buffer.h b/core/src/dsp/sink/ring_buffer.h new file mode 100644 index 00000000..425d28d1 --- /dev/null +++ b/core/src/dsp/sink/ring_buffer.h @@ -0,0 +1,39 @@ +#pragma once +#include "../sink.h" +#include "../buffer/ring_buffer.h" + +// NOTE: THIS IS COMPLETELY UNTESTED AND PROBABLY BROKEN!!! + +namespace dsp::sink { + template + class RingBuffer : public Sink { + using base_type = Sink; + public: + RingBuffer() {} + + RingBuffer(stream* in) { base_type::init(in); } + + int run() { + int count = base_type::_in->read(); + if (count < 0) { return -1; } + + + + base_type::_in->flush(); + return count; + } + + buffer::RingBuffer data; + + private: + void doStop() { + base_type::_in->stopReader(); + data.stopWriter(); + if (base_type::workerThread.joinable()) { + base_type::workerThread.join(); + } + base_type::_in->clearReadStop(); + data.clearWriteStop(); + } + }; +} \ No newline at end of file diff --git a/sink_modules/portaudio_sink/src/main.cpp b/sink_modules/portaudio_sink/src/main.cpp index 9ad0c556..8f9f2e3c 100644 --- a/sink_modules/portaudio_sink/src/main.cpp +++ b/sink_modules/portaudio_sink/src/main.cpp @@ -4,8 +4,8 @@ #include #include #include -#include -#include +#include +#include #include #include @@ -249,9 +249,9 @@ private: SinkManager::Stream* _stream; - dsp::StereoToMono s2m; - dsp::RingBufferSink monoRB; - dsp::RingBufferSink stereoRB; + dsp::convert::StereoToMono s2m; + dsp::sink::RingBuffer monoRB; + dsp::sink::RingBuffer stereoRB; // dsp::Packer monoPacker; // dsp::Packer stereoPacker;