diff options
author | Klaus Schmidinger <kls (at) cadsoft (dot) de> | 2001-08-06 18:00:00 +0200 |
---|---|---|
committer | Klaus Schmidinger <kls (at) cadsoft (dot) de> | 2001-08-06 18:00:00 +0200 |
commit | f1d1c9849c8e27cccb46cf9c0d0ccb59da3f91f9 (patch) | |
tree | b5a5f73f7b7595c7371cab1fc11f2ea60aa2b392 /ringbuffer.h | |
parent | 8f9cc68f76c4fd0960f919a77fb16a6455922deb (diff) | |
download | vdr-patch-lnbsharing-f1d1c9849c8e27cccb46cf9c0d0ccb59da3f91f9.tar.gz vdr-patch-lnbsharing-f1d1c9849c8e27cccb46cf9c0d0ccb59da3f91f9.tar.bz2 |
Version 0.90vdr-0.90
- Modified the display of the channel group separators (thanks to Markus Lang
for this suggestion).
- Added support for replaying DVDs (thanks to Andreas Schultz). See INSTALL for
instructions on how to compile VDR with DVD support.
- Fixed replay progress display in case replay is paused while watching an
ongoing recording.
- Ringbuffer uses semaphores to signal empty/full conditions.
- Fixed calculating the timeout value in cFile::FileReady() (thanks to
Wolfgang Henselmann-Weiss).
Diffstat (limited to 'ringbuffer.h')
-rw-r--r-- | ringbuffer.h | 84 |
1 files changed, 70 insertions, 14 deletions
diff --git a/ringbuffer.h b/ringbuffer.h index 49be769..f61d9e0 100644 --- a/ringbuffer.h +++ b/ringbuffer.h @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: ringbuffer.h 1.2 2001/05/20 11:56:44 kls Exp $ + * $Id: ringbuffer.h 1.4 2001/08/05 11:12:06 kls Exp $ */ #ifndef __RINGBUFFER_H @@ -24,24 +24,24 @@ private: cRingBufferInputThread *inputThread; cRingBufferOutputThread *outputThread; cMutex mutex; - int size, head, tail; - uchar *buffer; - int maxFill; + cCondVar readyForPut, readyForGet; + cMutex putMutex, getMutex; + int size; bool busy; - bool statistics; protected: + int maxFill;//XXX + bool statistics;//XXX + void WaitForPut(void); + void WaitForGet(void); + void EnablePut(void); + void EnableGet(void); + virtual void Clear(void) = 0; + virtual int Available(void) = 0; + int Free(void) { return size - Available() - 1; } void Lock(void) { mutex.Lock(); } void Unlock(void) { mutex.Unlock(); } - int Available(void); + int Size(void) { return size; } bool Busy(void) { return busy; } - void Clear(void); - // Immediately clears the ring buffer. - int Put(const uchar *Data, int Count); - // Puts at most Count bytes of Data into the ring buffer. - // Returns the number of bytes actually stored. - int Get(uchar *Data, int Count); - // Gets at most Count bytes of Data from the ring buffer. - // Returns the number of bytes actually retrieved. virtual void Input(void) = 0; // Runs as a separate thread and shall continuously read data from // a source and call Put() to store the data in the ring buffer. @@ -56,4 +56,60 @@ public: void Stop(void); }; +class cRingBufferLinear : public cRingBuffer { +private: + int head, tail; + uchar *buffer; +protected: + virtual int Available(void); + virtual void Clear(void); + // Immediately clears the ring buffer. + int Put(const uchar *Data, int Count); + // Puts at most Count bytes of Data into the ring buffer. + // Returns the number of bytes actually stored. + int Get(uchar *Data, int Count); + // Gets at most Count bytes of Data from the ring buffer. + // Returns the number of bytes actually retrieved. +public: + cRingBufferLinear(int Size, bool Statistics = false); + virtual ~cRingBufferLinear(); + }; + +class cFrame { + friend class cRingBufferFrame; +private: + cFrame *next; + uchar *data; + int count; + int index; +public: + cFrame(const uchar *Data, int Count, int Index = -1); + ~cFrame(); + const uchar *Data(void) const { return data; } + int Count(void) const { return count; } + int Index(void) const { return index; } + }; + +class cRingBufferFrame : public cRingBuffer { +private: + cFrame *head; + int currentFill; + void Delete(const cFrame *Frame); +protected: + virtual int Available(void); + virtual void Clear(void); + // Immediately clears the ring buffer. + bool Put(cFrame *Frame); + // Puts the Frame into the ring buffer. + // Returns true if this was possible. + const cFrame *Get(bool Wait = true); + // Gets the next frame from the ring buffer. + // The actual data still remains in the buffer until Drop() is called. + void Drop(const cFrame *Frame); + // Drops the Frame that has just been fetched with Get(). +public: + cRingBufferFrame(int Size, bool Statistics = false); + virtual ~cRingBufferFrame(); + }; + #endif // __RINGBUFFER_H |