vdr
1.7.27
|
#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) |
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) |
Protected Member Functions | |
virtual int | DataReady (const uchar *Data, int Count) |
virtual int | DataReady (const uchar *Data, int Count) |
Private Attributes | |
int | margin |
int | head |
int | tail |
int | gotten |
uchar * | buffer |
char * | description |
Definition at line 46 of file include/vdr/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 154 of file ringbuffer.c.
References buffer, Clear(), description, esyslog, gotten, head, MALLOC, margin, and tail.
cRingBufferLinear::~cRingBufferLinear | ( | ) | [virtual] |
Definition at line 181 of file ringbuffer.c.
References buffer, and description.
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.
virtual cRingBufferLinear::~cRingBufferLinear | ( | ) | [virtual] |
int cRingBufferLinear::Available | ( | void | ) | [virtual] |
Implements cRingBuffer.
Definition at line 195 of file ringbuffer.c.
References head, margin, cRingBuffer::Size(), and tail.
Referenced by Free().
virtual int cRingBufferLinear::Available | ( | void | ) | [virtual] |
Implements cRingBuffer.
void cRingBufferLinear::Clear | ( | void | ) | [virtual] |
Immediately clears the ring buffer.
Implements cRingBuffer.
Definition at line 201 of file ringbuffer.c.
References cRingBuffer::EnablePut(), head, margin, cRingBuffer::maxFill, and tail.
Referenced by cIndexFileGenerator::Action(), and cRingBufferLinear().
virtual void cRingBufferLinear::Clear | ( | void | ) | [virtual] |
Immediately clears the ring buffer.
Implements cRingBuffer.
int cRingBufferLinear::DataReady | ( | const uchar * | Data, |
int | Count | ||
) | [protected, virtual] |
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 190 of file ringbuffer.c.
References margin.
Referenced by Get().
virtual int cRingBufferLinear::DataReady | ( | const uchar * | Data, |
int | Count | ||
) | [protected, virtual] |
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".
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 354 of file ringbuffer.c.
References cRingBuffer::EnablePut(), esyslog, gotten, margin, cRingBuffer::Size(), and tail.
Referenced by cRecorder::Action(), cIndexFileGenerator::Action(), and cTSBuffer::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().
virtual int cRingBufferLinear::Free | ( | void | ) | [inline, virtual] |
Reimplemented from cRingBuffer.
Definition at line 78 of file include/vdr/ringbuffer.h.
References Available(), margin, and cRingBuffer::Size().
virtual int cRingBufferLinear::Free | ( | void | ) | [inline, virtual] |
Reimplemented from cRingBuffer.
Definition at line 78 of file ringbuffer.h.
References Available(), margin, 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.
Definition at line 329 of file ringbuffer.c.
References buffer, DataReady(), cRingBuffer::getThreadTid, gotten, head, margin, cRingBuffer::Size(), tail, cThread::ThreadId(), and cRingBuffer::WaitForGet().
Referenced by cRecorder::Action(), cIndexFileGenerator::Action(), and cTSBuffer::Get().
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.
int cRingBufferLinear::Put | ( | const uchar * | Data, |
int | Count | ||
) |
Puts at most Count bytes of Data into the ring buffer.
int cRingBufferLinear::Put | ( | const uchar * | Data, |
int | Count | ||
) |
Puts at most Count bytes of Data into the ring buffer.
Definition at line 289 of file ringbuffer.c.
References buffer, cRingBuffer::EnableGet(), head, margin, cRingBuffer::Size(), cRingBuffer::statistics, tail, cRingBuffer::UpdatePercentage(), and cRingBuffer::WaitForPut().
Referenced by 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.
Definition at line 213 of file ringbuffer.c.
References buffer, cRingBuffer::EnableGet(), head, margin, safe_read(), cRingBuffer::Size(), cRingBuffer::statistics, tail, cRingBuffer::UpdatePercentage(), and cRingBuffer::WaitForPut().
Referenced by cTSBuffer::Action(), and cIndexFileGenerator::Action().
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.
int cRingBufferLinear::Read | ( | cUnbufferedFile * | File, |
int | Max = 0 |
||
) |
Like Read(int FileHandle, int Max), but reads from a cUnbufferedFile).
int cRingBufferLinear::Read | ( | cUnbufferedFile * | File, |
int | Max = 0 |
||
) |
Like Read(int FileHandle, int Max), but reads from a cUnbufferedFile).
Definition at line 251 of file ringbuffer.c.
References buffer, cRingBuffer::EnableGet(), head, margin, cUnbufferedFile::Read(), cRingBuffer::Size(), cRingBuffer::statistics, tail, cRingBuffer::UpdatePercentage(), and cRingBuffer::WaitForPut().
uchar * cRingBufferLinear::buffer [private] |
Definition at line 61 of file include/vdr/ringbuffer.h.
Referenced by cRingBufferLinear(), Get(), Put(), Read(), and ~cRingBufferLinear().
char * cRingBufferLinear::description [private] |
Definition at line 62 of file include/vdr/ringbuffer.h.
Referenced by cRingBufferLinear(), and ~cRingBufferLinear().
int cRingBufferLinear::gotten [private] |
Definition at line 60 of file include/vdr/ringbuffer.h.
Referenced by cRingBufferLinear(), Del(), and Get().
int cRingBufferLinear::head [private] |
Definition at line 59 of file include/vdr/ringbuffer.h.
Referenced by Available(), Clear(), cRingBufferLinear(), Get(), Put(), and Read().
int cRingBufferLinear::margin [private] |
Definition at line 59 of file include/vdr/ringbuffer.h.
Referenced by Available(), Clear(), cRingBufferLinear(), DataReady(), Del(), Free(), Get(), Put(), and Read().
int cRingBufferLinear::tail [private] |
Definition at line 59 of file include/vdr/ringbuffer.h.
Referenced by Available(), Clear(), cRingBufferLinear(), Del(), Get(), Put(), and Read().