diff --git a/core/src/dsp/buffer.h b/core/src/dsp/buffer.h index c9f96002..c5999f69 100644 --- a/core/src/dsp/buffer.h +++ b/core/src/dsp/buffer.h @@ -214,79 +214,4 @@ namespace dsp { std::condition_variable canReadVar; std::condition_variable canWriteVar; }; - - template - class BufferBlock : public generic_block> { - public: - BufferBlock() {} - - BufferBlock(stream* in, int bufferSize) { init(in, bufferSize); } - - ~BufferBlock(stream* in, int bufferSize) { - generic_block>::stop(); - delete[] buffer; - } - - void init(stream* in, int bufferSize) { - _in = in; - _bufferSize = bufferSize; - buffer = new T[_bufferSize]; - generic_block>::registerInput(_in); - } - - void setInput(stream* in) { - std::lock_guard lck(generic_block>::ctrlMtx); - generic_block>::tempStop(); - generic_block>::unregisterInput(_in); - _in = in; - generic_block>::registerInput(_in); - generic_block>::tempStart(); - } - - int run() { - int count = _in->read(); - if (count < 0) { return -1; } - - // If there's enough space in the buffer, write data. Otherwise, discard - { - std::lock_guard lck(bufferMtx); - if (dataInBuffer + count <= _bufferSize) { - memcpy(&buffer[dataInBuffer], _in->readBuf, count); - dataInBuffer += count; - } - } - - // Notify reader that data is available - cnd.notify_all(); - - _in->flush(); - return count; - } - - void readWorker() { - - } - - private: - void doStart() { - - } - - void doStop() { - - } - - stream* _in; - int _bufferSize; - - T* buffer; - int dataInBuffer = 0; - std::mutex bufferMtx; - - std::condition_variable cnd; - bool stopReaderThread = false; - - std::thread readerThread; - - }; }; \ No newline at end of file