diff options
author | Klaus Schmidinger <vdr@tvdr.de> | 2002-09-08 09:03:10 +0200 |
---|---|---|
committer | Klaus Schmidinger <vdr@tvdr.de> | 2002-09-08 09:03:10 +0200 |
commit | c792c552979366bf781c9d9c817487bdd2926189 (patch) | |
tree | 788131b78d8485c53f294eaa4ad0cb439ab91d63 /dvbdevice.c | |
parent | f24f820e7deb5a9cadfb56f72ad39cb313c87092 (diff) | |
download | vdr-c792c552979366bf781c9d9c817487bdd2926189.tar.gz vdr-c792c552979366bf781c9d9c817487bdd2926189.tar.bz2 |
Implemented cTSBuffer
Diffstat (limited to 'dvbdevice.c')
-rw-r--r-- | dvbdevice.c | 38 |
1 files changed, 20 insertions, 18 deletions
diff --git a/dvbdevice.c b/dvbdevice.c index 83613358..3d971b59 100644 --- a/dvbdevice.c +++ b/dvbdevice.c @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: dvbdevice.c 1.10 2002/09/06 14:09:55 kls Exp $ + * $Id: dvbdevice.c 1.11 2002/09/07 13:39:49 kls Exp $ */ #include "dvbdevice.h" @@ -773,6 +773,8 @@ bool cDvbDevice::OpenDvr(void) { CloseDvr(); fd_dvr = DvbOpen(DEV_DVB_DVR, CardIndex(), O_RDONLY | O_NONBLOCK, true); + if (fd_dvr >= 0) + tsBuffer = new cTSBuffer(fd_dvr, MEGABYTE(2), CardIndex() + 1); return fd_dvr >= 0; } @@ -781,28 +783,28 @@ void cDvbDevice::CloseDvr(void) if (fd_dvr >= 0) { close(fd_dvr); fd_dvr = -1; + delete tsBuffer; + tsBuffer = NULL; } } -int cDvbDevice::GetTSPacket(uchar *Data) +bool cDvbDevice::GetTSPacket(uchar *&Data) { - if (fd_dvr >= 0) { - cPoller Poller(fd_dvr, false); - if (Poller.Poll(100)) { - int r = read(fd_dvr, Data, TS_SIZE); - if (r >= 0) - return r; - else if (FATALERRNO) { - if (errno == EBUFFEROVERFLOW) // this error code is not defined in the library - esyslog("ERROR: DVB driver buffer overflow on device %d", CardIndex() + 1); - else { - LOG_ERROR; - return -1; - } + if (tsBuffer) { + int r = tsBuffer->Read(); + if (r >= 0) { + Data = tsBuffer->Get(); + return true; + } + else if (FATALERRNO) { + if (errno == EBUFFEROVERFLOW) // this error code is not defined in the library + esyslog("ERROR: DVB driver buffer overflow on device %d", CardIndex() + 1); + else { + LOG_ERROR; + return false; } } - return 0; + return true; } - else - return -1; + return false; } |