mirror of
https://github.com/AlexandreRouma/SDRPlusPlus.git
synced 2025-06-26 12:27:51 +02:00
MacOS do be wasting my time
This commit is contained in:
39
core/src/dsp/sink/ring_buffer.h
Normal file
39
core/src/dsp/sink/ring_buffer.h
Normal 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();
|
||||
}
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user