From 28d1affa3165b96cb6c7915f11b982786da6de5d Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Sun, 26 Jan 2003 09:59:35 +0100 Subject: Modified cRingBufferLinear to avoid excessive memmove() calls in 'Transfer Mode' and during recordings --- ringbuffer.h | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) (limited to 'ringbuffer.h') diff --git a/ringbuffer.h b/ringbuffer.h index f96143c9..9205df7f 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.8 2003/01/19 15:03:00 kls Exp $ + * $Id: ringbuffer.h 1.9 2003/01/26 09:47:39 kls Exp $ */ #ifndef __RINGBUFFER_H @@ -40,21 +40,31 @@ public: class cRingBufferLinear : public cRingBuffer { private: - int head, tail; + int margin, head, tail; + int lastGet; uchar *buffer; pid_t getThreadPid; public: - cRingBufferLinear(int Size, bool Statistics = false); + cRingBufferLinear(int Size, int Margin = 0, bool Statistics = false); + ///< Creates a linear ring buffer. + ///< The buffer will be able to hold at most Size bytes of data, and will + ///< be guaranteed to return at least Margin bytes in one consecutive block. virtual ~cRingBufferLinear(); virtual int Available(void); virtual void Clear(void); - // Immediately clears the ring buffer. + ///< 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. + ///< Puts at most Count bytes of Data into the ring buffer. + ///< \return Returns the number of bytes actually stored. + const uchar *Get(int &Count); + ///< Gets data from the ring buffer. + ///< The data will remain in the buffer until a call to Del() deletes it. + ///< \return Returns a pointer to the data, and stores the number of bytes + ///< actually retrieved in Count. If the returned pointer is NULL, Count has no meaning. + void 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(). }; enum eFrameType { ftUnknown, ftVideo, ftAudio, ftDolby }; -- cgit v1.2.3