MacOS do be wasting my time

This commit is contained in:
AlexandreRouma 2022-06-19 23:50:34 +02:00
parent 927bbab330
commit ce1b0d0170
2 changed files with 44 additions and 5 deletions

View File

@ -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 T>
class RingBuffer : public Sink<T> {
using base_type = Sink<T>;
public:
RingBuffer() {}
RingBuffer(stream<T>* 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<T> 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();
}
};
}

View File

@ -4,8 +4,8 @@
#include <signal_path/signal_path.h>
#include <signal_path/sink.h>
#include <portaudio.h>
#include <dsp/audio.h>
#include <dsp/processing.h>
#include <dsp/convert/stereo_to_mono.h>
#include <dsp/sink/ring_buffer.h>
#include <spdlog/spdlog.h>
#include <core.h>
@ -249,9 +249,9 @@ private:
SinkManager::Stream* _stream;
dsp::StereoToMono s2m;
dsp::RingBufferSink<float> monoRB;
dsp::RingBufferSink<dsp::stereo_t> stereoRB;
dsp::convert::StereoToMono s2m;
dsp::sink::RingBuffer<float> monoRB;
dsp::sink::RingBuffer<dsp::stereo_t> stereoRB;
// dsp::Packer<float> monoPacker;
// dsp::Packer<dsp::stereo_t> stereoPacker;