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;