Ring Daemon 16.0.0
|
A ring buffer for mutichannel audio samples. More...
#include <ringbuffer.h>
Public Types | |
using | clock = std::chrono::high_resolution_clock |
using | FrameCallback = std::function< void(const std::shared_ptr< AudioFrame > &)> |
using | time_point = clock::time_point |
Public Member Functions | |
size_t | availableForGet (const std::string &ringbufferId) const |
To get how much samples are available in the buffer to read in. | |
void | createReadOffset (const std::string &ringbufferId) |
Add a new readoffset for this ringbuffer. | |
void | createReadOffset (const std::string &ringbufferId, FrameCallback cb) |
void | debug () |
Debug function print mEnd, mStart, mBufferSize. | |
size_t | discard (size_t toDiscard, const std::string &ringbufferId) |
Discard data from the buffer. | |
void | flush (const std::string &ringbufferId) |
Reset the counters to 0 for this read offset. | |
void | flushAll () |
std::shared_ptr< AudioFrame > | get (const std::string &ringbufferId) |
Get data in the ring buffer. | |
AudioFormat | getFormat () const |
const std::string & | getId () const |
size_t | getLength (const std::string &ringbufferId) const |
std::vector< std::string > | getSubscribers () |
Return the list of subscribers (Ring buffers Id that are reading this ring buffer). | |
bool | isAudioMeterActive () const |
bool | isEmpty () const |
bool | isFull () const |
void | put (std::shared_ptr< AudioFrame > &&data) |
Write data in the ring buffer. | |
size_t | putLength () const |
Total length of the ring buffer which is available for "putting". | |
size_t | readOffsetCount () const |
void | removeReadOffset (const std::string &ringbufferId) |
Remove a readoffset for this ringbuffer. | |
RingBuffer (const std::string &id, size_t size, AudioFormat format=AudioFormat::MONO()) | |
Constructor. | |
void | setAudioMeterState (bool state) |
void | setFormat (const AudioFormat &format) |
void | setFrameSize (int nb_samples) |
size_t | waitForDataAvailable (const std::string &ringbufferId, const time_point &deadline=time_point::max()) const |
Blocks until min_data_length samples of data is available, or until deadline has passed. | |
~RingBuffer () | |
Destructor. | |
A ring buffer for mutichannel audio samples.
Definition at line 37 of file ringbuffer.h.
using jami::RingBuffer::clock = std::chrono::high_resolution_clock |
Definition at line 40 of file ringbuffer.h.
using jami::RingBuffer::FrameCallback = std::function<void(const std::shared_ptr<AudioFrame>&)> |
Definition at line 42 of file ringbuffer.h.
using jami::RingBuffer::time_point = clock::time_point |
Definition at line 41 of file ringbuffer.h.
jami::RingBuffer::RingBuffer | ( | const std::string & | id, |
size_t | size, | ||
AudioFormat | format = AudioFormat::MONO() |
||
) |
Constructor.
size | Size of the buffer to create |
Definition at line 36 of file ringbuffer.cpp.
References jami::emitSignal().
jami::RingBuffer::~RingBuffer | ( | ) |
To get how much samples are available in the buffer to read in.
Definition at line 214 of file ringbuffer.cpp.
References jami::emitSignal(), and getLength().
Add a new readoffset for this ringbuffer.
Definition at line 131 of file ringbuffer.cpp.
References jami::emitSignal().
Referenced by jami::AudioLayer::AudioLayer().
void jami::RingBuffer::createReadOffset | ( | const std::string & | ringbufferId, |
FrameCallback | cb | ||
) |
void jami::RingBuffer::debug | ( | ) |
Debug function print mEnd, mStart, mBufferSize.
Definition at line 96 of file ringbuffer.cpp.
References JAMI_DBG.
Discard data from the buffer.
toDiscard | Number of samples to discard |
Definition at line 275 of file ringbuffer.cpp.
References jami::emitSignal().
Reset the counters to 0 for this read offset.
Definition at line 56 of file ringbuffer.cpp.
References jami::emitSignal().
void jami::RingBuffer::flushAll | ( | ) |
Definition at line 62 of file ringbuffer.cpp.
Referenced by jami::AudioLayer::flush(), jami::AudioLayer::flushUrgent(), and jami::AudioLayer::notifyIncomingCall().
std::shared_ptr< AudioFrame > jami::RingBuffer::get | ( | const std::string & | ringbufferId | ) |
Get data in the ring buffer.
ringbufferId |
Definition at line 221 of file ringbuffer.cpp.
References jami::emitSignal().
Referenced by jami::AudioLayer::getToPlay().
|
inline |
Definition at line 70 of file ringbuffer.h.
|
inline |
Definition at line 55 of file ringbuffer.h.
Definition at line 87 of file ringbuffer.cpp.
References jami::emitSignal().
Referenced by availableForGet().
std::vector< std::string > jami::RingBuffer::getSubscribers | ( | ) |
Return the list of subscribers (Ring buffers Id that are reading this ring buffer).
Definition at line 68 of file ringbuffer.cpp.
References jami::emitSignal().
|
inline |
Definition at line 150 of file ringbuffer.h.
|
inline |
Definition at line 129 of file ringbuffer.h.
References putLength().
|
inline |
Definition at line 127 of file ringbuffer.h.
References putLength().
void jami::RingBuffer::put | ( | std::shared_ptr< AudioFrame > && | data | ) |
Write data in the ring buffer.
AudioFrame |
Definition at line 164 of file ringbuffer.cpp.
References jami::emitSignal(), jami::AudioFrameResizer::enqueue(), and jami::Resampler::resample().
Referenced by jami::AudioLayer::notifyIncomingCall(), and jami::AudioLayer::putUrgent().
size_t jami::RingBuffer::putLength | ( | ) | const |
Total length of the ring buffer which is available for "putting".
Definition at line 77 of file ringbuffer.cpp.
References jami::emitSignal().
Referenced by isEmpty(), and isFull().
|
inline |
Definition at line 91 of file ringbuffer.h.
Remove a readoffset for this ringbuffer.
Definition at line 139 of file ringbuffer.cpp.
References jami::emitSignal().
Definition at line 151 of file ringbuffer.h.
|
inline |
Definition at line 72 of file ringbuffer.h.
References jami::emitSignal(), jami::AudioFormat::sample_rate, and jami::AudioFrameResizer::setFormat().
Referenced by jami::AudioLayer::hardwareFormatAvailable().
Definition at line 131 of file ringbuffer.h.
References jami::emitSignal(), and jami::AudioFrameResizer::setFrameSize().
size_t jami::RingBuffer::waitForDataAvailable | ( | const std::string & | ringbufferId, |
const time_point & | deadline = time_point::max() |
||
) | const |
Blocks until min_data_length samples of data is available, or until deadline has passed.
ringbufferId | The read offset for which data should be available. |
min_data_length | Minimum number of samples that should be available for the call to return |
deadline | The ringbufferId is guaranteed to end after this time point. If no deadline is provided, the call blocks indefinitely. |
Definition at line 244 of file ringbuffer.cpp.
References jami::emitSignal().