vdr
2.2.0
|
#include <ringbuffer.h>
Public Member Functions | |
cRingBufferLinear (int Size, int Margin=0, bool Statistics=false, const char *Description=NULL) | |
virtual | ~cRingBufferLinear () |
virtual int | Available (void) |
virtual int | Free (void) |
virtual void | Clear (void) |
int | Read (int FileHandle, int Max=0) |
int | Read (cUnbufferedFile *File, int Max=0) |
int | Put (const uchar *Data, int Count) |
uchar * | Get (int &Count) |
void | Del (int Count) |
![]() | |
cRingBuffer (int Size, bool Statistics=false) | |
virtual | ~cRingBuffer () |
void | SetTimeouts (int PutTimeout, int GetTimeout) |
void | SetIoThrottle (void) |
void | ReportOverflow (int Bytes) |
Protected Member Functions | |
virtual int | DataReady (const uchar *Data, int Count) |
![]() | |
void | UpdatePercentage (int Fill) |
void | WaitForPut (void) |
void | WaitForGet (void) |
void | EnablePut (void) |
void | EnableGet (void) |
int | Size (void) |
Private Attributes | |
int | margin |
int | head |
int | tail |
int | gotten |
uchar * | buffer |
char * | description |
Additional Inherited Members | |
![]() | |
tThreadId | getThreadTid |
int | maxFill |
int | lastPercent |
bool | statistics |
Definition at line 48 of file ringbuffer.h.
cRingBufferLinear::cRingBufferLinear | ( | int | Size, |
int | Margin = 0 , |
||
bool | Statistics = false , |
||
const char * | Description = NULL |
||
) |
Creates a linear ring buffer.
The buffer will be able to hold at most Size-Margin-1 bytes of data, and will be guaranteed to return at least Margin bytes in one consecutive block. The optional Description is used for debugging only.
Definition at line 170 of file ringbuffer.c.
References buffer, Clear(), description, esyslog, gotten, head, MALLOC, margin, and tail.
|
virtual |
Definition at line 197 of file ringbuffer.c.
References buffer, and description.
|
virtual |
Implements cRingBuffer.
Definition at line 211 of file ringbuffer.c.
References head, margin, cRingBuffer::Size(), and tail.
Referenced by cIndexFileGenerator::Action().
|
virtual |
Immediately clears the ring buffer.
Implements cRingBuffer.
Definition at line 217 of file ringbuffer.c.
References cRingBuffer::EnablePut(), head, margin, cRingBuffer::maxFill, and tail.
Referenced by cIndexFileGenerator::Action(), and cRingBufferLinear().
|
protectedvirtual |
By default a ring buffer has data ready as soon as there are at least 'margin' bytes available.
A derived class can reimplement this function if it has other conditions that define when data is ready. The return value is either 0 if there is not yet enough data available, or the number of bytes from the beginning of Data that are "ready".
Definition at line 206 of file ringbuffer.c.
References margin.
Referenced by Get().
void cRingBufferLinear::Del | ( | int | Count | ) |
Deletes at most Count bytes from the ring buffer.
Count must be less or equal to the number that was returned by a previous call to Get().
Definition at line 370 of file ringbuffer.c.
References cRingBuffer::EnablePut(), esyslog, gotten, margin, cRingBuffer::Size(), and tail.
Referenced by cRecorder::Action(), and cIndexFileGenerator::Action().
|
inlinevirtual |
Reimplemented from cRingBuffer.
Definition at line 80 of file ringbuffer.h.
References cRingBuffer::Available(), cRingBuffer::Clear(), and cRingBuffer::Size().
uchar * cRingBufferLinear::Get | ( | int & | Count | ) |
Gets data from the ring buffer.
The data will remain in the buffer until a call to Del() deletes it. Returns a pointer to the data, and stores the number of bytes actually available in Count. If the returned pointer is NULL, Count has no meaning.
Definition at line 345 of file ringbuffer.c.
References buffer, DataReady(), cRingBuffer::getThreadTid, gotten, head, margin, cRingBuffer::Size(), tail, cThread::ThreadId(), and cRingBuffer::WaitForGet().
Referenced by cRecorder::Action(), and cIndexFileGenerator::Action().
int cRingBufferLinear::Put | ( | const uchar * | Data, |
int | Count | ||
) |
Puts at most Count bytes of Data into the ring buffer.
Returns the number of bytes actually stored.
Definition at line 305 of file ringbuffer.c.
References buffer, cRingBuffer::EnableGet(), head, margin, cRingBuffer::Size(), cRingBuffer::statistics, tail, cRingBuffer::UpdatePercentage(), and cRingBuffer::WaitForPut().
Referenced by cIndexFileGenerator::Action(), and cRecorder::Receive().
int cRingBufferLinear::Read | ( | int | FileHandle, |
int | Max = 0 |
||
) |
Reads at most Max bytes from FileHandle and stores them in the ring buffer.
If Max is 0, reads as many bytes as possible. Only one actual read() call is done. Returns the number of bytes actually read and stored, or an error value from the actual read() call.
Definition at line 229 of file ringbuffer.c.
References buffer, cRingBuffer::EnableGet(), head, margin, safe_read(), cRingBuffer::Size(), cRingBuffer::statistics, tail, cRingBuffer::UpdatePercentage(), and cRingBuffer::WaitForPut().
Referenced by cIndexFileGenerator::Action().
int cRingBufferLinear::Read | ( | cUnbufferedFile * | File, |
int | Max = 0 |
||
) |
Like Read(int FileHandle, int Max), but reads from a cUnbufferedFile).
Definition at line 267 of file ringbuffer.c.
References buffer, cRingBuffer::EnableGet(), head, margin, cUnbufferedFile::Read(), cRingBuffer::Size(), cRingBuffer::statistics, tail, cRingBuffer::UpdatePercentage(), and cRingBuffer::WaitForPut().
|
private |
Definition at line 63 of file ringbuffer.h.
Referenced by cRingBufferLinear(), Get(), Put(), Read(), and ~cRingBufferLinear().
|
private |
Definition at line 64 of file ringbuffer.h.
Referenced by cRingBufferLinear(), cRingBuffer::ReportOverflow(), and ~cRingBufferLinear().
|
private |
Definition at line 62 of file ringbuffer.h.
Referenced by cRingBufferLinear(), Del(), and Get().
|
private |
Definition at line 61 of file ringbuffer.h.
Referenced by Available(), Clear(), cRingBufferLinear(), Get(), Put(), and Read().
|
private |
Definition at line 61 of file ringbuffer.h.
Referenced by Available(), Clear(), cRingBufferLinear(), DataReady(), Del(), Get(), Put(), and Read().
|
private |
Definition at line 61 of file ringbuffer.h.
Referenced by Available(), Clear(), cRingBufferLinear(), Del(), Get(), Put(), and Read().