mirror of
https://github.com/vdr-projects/vdr.git
synced 2025-03-01 10:50:46 +00:00
Merry Christmas to all VDR users! It's been a very busy year for me, in which I was unable to spend as much time on VDR as I would have liked to. But now things are settled again and I managed to prepare a new developer version with the most important fixes and improvements. Please feel free to tell me if I missed something important - some things may well have slipped under my radar ;-). So here's my Christmas gift for you! VDR developer version 2.3.2 is now available at ftp://ftp.tvdr.de/vdr/Developer/vdr-2.3.2.tar.bz2 A 'diff' against the previous version is available at ftp://ftp.tvdr.de/vdr/Developer/vdr-2.3.1-2.3.2.diff MD5 checksums: 6dbb208ea3d59658a18912b49af175b3 vdr-2.3.2.tar.bz2 68a0ed9f01048026333939d30e0a6474 vdr-2.3.1-2.3.2.diff WARNING: ======== This is a *developer* version. Even though *I* use it in my productive environment, I strongly recommend that you only use it under controlled conditions and for testing and debugging. From the HISTORY file: - Fixed a crash when deleting a recording (reported by Oliver Endriss). - Fixed an overflow of PIDs in a receiver (thanks to Robert Hannebauer). - Updated the Italian OSD texts (thanks to Diego Pierotto). - Fixed initializing device specific parameters in cDvbTransponderParameters. - The function SetCurrentChannel(const cChannel *Channel) is now deprecated and may be removed in a future version. Use SetCurrentChannel(int ChannelNumber) instead. - The SVDRP command DELC now refuses to delete the very last channel in the list, to avoid ending up with an empty channel list. - The cRwLock class now allows nested read locks within a write lock from the same thread. This fixes possible crashes when moving or deleting channels in the menu or through SVDRP (as well as other operations that try to acquire a read lock within a write lock). - Fixed a crash when trying to delete a channel that is being used by a timer. - Fixed setting the current item and counter values in the Recordings menu after deleting the last recording in a subfolder. - Fixed a crash when deleting a recording that is currently being replayed. - Fixed a crash when moving a recording to a folder on a different volume. The cRecordingsHandler now performs its actual operations in a separate thread, thus avoiding locking problems and reducing the time between subsequent operations. - Added a note to the description of cFont::Size(), regarding possible differences between it and cFont::Height() (suggested to Thomas Reufer). - Made the cPlayer member functions FramesPerSecond, GetIndex and GetReplayMode 'const' (thanks to Thomas Reufer). - Fixed resuming replay at a given position, which was off by one frame (thanks to Thomas Reufer). - Improved handling frame numbers to have a smoother progress display during replay of recordings with B-frames (thanks to Thomas Reufer). - Fixed replaying recordings to their very end, if they don't end with an I-frame (thanks to Thomas Reufer). - Implemented a frame parser for H.265 (HEVC) recordings (thanks to Thomas Reufer). - Added cFont::Width(void) to get the default character width and allow stretched font drawing in high level OSDs (thanks to Thomas Reufer). - Fixed regenerating the index of audio recordings (thanks to Thomas Reufer). - Fixed building VDR with systemd >= 230 (thanks to Ville Skyttä). - Sorted sources.conf by continous azimuth (thanks to Lucian Muresan). - Added 'S58.5E Kazsat 3' to sources.conf (thanks to Aitugan Sarbassov). - Fixed truncated date/time strings in the skins on multi-byte UTF-8 systems (reported by Sergey Chernyavskiy). - Updated the Estonian OSD texts (thanks to Arthur Konovalov). - Added a 'const' version of cTimers::GetTimer() (thanks to Lars Hanisch). - Fixed a typo in the description of cTimers::GetTimersRead() (thanks to Lars Hanisch). - Fixed a possible buffer overflow in handling CA descriptors (suggested by Lars Hanisch). - Avoiding some duplicate code and unnecessary work in nit.c (thanks to Ville Skyttä). - Added support for the systemd watchdog (thanks to Marc Perrudin), - Added a short sleep to cTSBuffer::Action() to avoid high CPU usage (thanks to Sergey Chernyavskiy).
156 lines
5.2 KiB
C++
156 lines
5.2 KiB
C++
/*
|
|
* ringbuffer.h: A ring buffer
|
|
*
|
|
* See the main source file 'vdr.c' for copyright information and
|
|
* how to reach the author.
|
|
*
|
|
* $Id: ringbuffer.h 4.1 2016/12/22 10:26:13 kls Exp $
|
|
*/
|
|
|
|
#ifndef __RINGBUFFER_H
|
|
#define __RINGBUFFER_H
|
|
|
|
#include "thread.h"
|
|
#include "tools.h"
|
|
|
|
class cRingBuffer {
|
|
private:
|
|
cCondWait readyForPut, readyForGet;
|
|
int putTimeout;
|
|
int getTimeout;
|
|
int size;
|
|
time_t lastOverflowReport;
|
|
int overflowCount;
|
|
int overflowBytes;
|
|
cIoThrottle *ioThrottle;
|
|
protected:
|
|
tThreadId getThreadTid;
|
|
int maxFill;//XXX
|
|
int lastPercent;
|
|
bool statistics;//XXX
|
|
void UpdatePercentage(int Fill);
|
|
void WaitForPut(void);
|
|
void WaitForGet(void);
|
|
void EnablePut(void);
|
|
void EnableGet(void);
|
|
virtual void Clear(void) = 0;
|
|
virtual int Available(void) = 0;
|
|
virtual int Free(void) { return Size() - Available() - 1; }
|
|
int Size(void) { return size; }
|
|
public:
|
|
cRingBuffer(int Size, bool Statistics = false);
|
|
virtual ~cRingBuffer();
|
|
void SetTimeouts(int PutTimeout, int GetTimeout);
|
|
void SetIoThrottle(void);
|
|
void ReportOverflow(int Bytes);
|
|
};
|
|
|
|
class cRingBufferLinear : public cRingBuffer {
|
|
//#define DEBUGRINGBUFFERS
|
|
#ifdef DEBUGRINGBUFFERS
|
|
private:
|
|
int lastHead, lastTail;
|
|
int lastPut, lastGet;
|
|
static cRingBufferLinear *RBLS[];
|
|
static void AddDebugRBL(cRingBufferLinear *RBL);
|
|
static void DelDebugRBL(cRingBufferLinear *RBL);
|
|
public:
|
|
static void PrintDebugRBL(void);
|
|
#endif
|
|
private:
|
|
int margin, head, tail;
|
|
int gotten;
|
|
uchar *buffer;
|
|
char *description;
|
|
protected:
|
|
virtual int DataReady(const uchar *Data, int Count);
|
|
///< 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".
|
|
public:
|
|
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();
|
|
virtual int Available(void);
|
|
virtual int Free(void) { return Size() - Available() - 1 - margin; }
|
|
virtual void Clear(void);
|
|
///< Immediately clears the ring buffer.
|
|
int 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.
|
|
int Read(cUnbufferedFile *File, int Max = 0);
|
|
///< Like Read(int FileHandle, int Max), but reads from a cUnbufferedFile).
|
|
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.
|
|
uchar *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.
|
|
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 };
|
|
|
|
class cFrame {
|
|
friend class cRingBufferFrame;
|
|
private:
|
|
cFrame *next;
|
|
uchar *data;
|
|
int count;
|
|
eFrameType type;
|
|
int index;
|
|
uint32_t pts;
|
|
bool independent;
|
|
public:
|
|
cFrame(const uchar *Data, int Count, eFrameType = ftUnknown, int Index = -1, uint32_t Pts = 0, bool independent = false);
|
|
///< Creates a new cFrame object.
|
|
///< If Count is negative, the cFrame object will take ownership of the given
|
|
///< Data. Otherwise it will allocate Count bytes of memory and copy Data.
|
|
~cFrame();
|
|
uchar *Data(void) const { return data; }
|
|
int Count(void) const { return count; }
|
|
eFrameType Type(void) const { return type; }
|
|
int Index(void) const { return index; }
|
|
uint32_t Pts(void) const { return pts; }
|
|
bool Independent(void) const { return independent; }
|
|
};
|
|
|
|
class cRingBufferFrame : public cRingBuffer {
|
|
private:
|
|
cMutex mutex;
|
|
cFrame *head;
|
|
int currentFill;
|
|
void Delete(cFrame *Frame);
|
|
void Lock(void) { mutex.Lock(); }
|
|
void Unlock(void) { mutex.Unlock(); }
|
|
public:
|
|
cRingBufferFrame(int Size, bool Statistics = false);
|
|
virtual ~cRingBufferFrame();
|
|
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.
|
|
cFrame *Get(void);
|
|
// Gets the next frame from the ring buffer.
|
|
// The actual data still remains in the buffer until Drop() is called.
|
|
void Drop(cFrame *Frame);
|
|
// Drops the Frame that has just been fetched with Get().
|
|
};
|
|
|
|
#endif // __RINGBUFFER_H
|