From b1737a8bcb3a259c9c57e76b818539191b96f045 Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Sat, 19 Jun 2004 08:58:14 +0200 Subject: Added cDevice::Flush() --- CONTRIBUTORS | 2 ++ HISTORY | 5 ++++- device.c | 7 ++++++- device.h | 8 +++++++- dvbdevice.c | 8 +++++++- dvbdevice.h | 3 ++- dvbplayer.c | 8 ++++++-- player.h | 3 ++- 8 files changed, 36 insertions(+), 8 deletions(-) diff --git a/CONTRIBUTORS b/CONTRIBUTORS index cf0a9c2d..a1e30c60 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -854,6 +854,8 @@ Reinhard Nissl when using other libraries that also implement a function by that name for reporting a bug in handling ':' characters in channel names when reading channels.conf + for adding cDevice::Flush() to make sure that all data in the video card's buffers + has been processed Richard Robson for reporting freezing replay if a timer starts while in Transfer Mode from the diff --git a/HISTORY b/HISTORY index 36761748..54945bd1 100644 --- a/HISTORY +++ b/HISTORY @@ -2893,7 +2893,7 @@ Video Disk Recorder Revision History strings in order to avoid buffer overflows (thanks to Philip Lawatsch for debugging a buffer overflow in eit.c). -2004-06-18: Version 1.3.11 +2004-06-19: Version 1.3.11 - In order to avoid problems on NPTL systems, VDR now checks for the presence of NPTL at program start, and if it is, exists and tells the user to do @@ -2921,3 +2921,6 @@ Video Disk Recorder Revision History If some external tool manipulates the video directory, it can touch the file '.update' in the video directory to trigger an update of the list of recordings. - Fixed a memory leak in theme description handling (thanks to Sascha Volkenandt). +- Added cDevice::Flush() to make sure that all data in the video card's buffers + has been processed (thanks to Reinhard Nissl). Currently this is not yet actually + implemented for FF DVB cards. diff --git a/device.c b/device.c index 0c2b76dc..d62b4563 100644 --- a/device.c +++ b/device.c @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: device.c 1.55 2004/05/16 12:14:47 kls Exp $ + * $Id: device.c 1.56 2004/06/19 08:51:05 kls Exp $ */ #include "device.h" @@ -619,6 +619,11 @@ bool cDevice::Poll(cPoller &Poller, int TimeoutMs) return false; } +bool cDevice::Flush(int TimeoutMs) +{ + return true; +} + int cDevice::PlayVideo(const uchar *Data, int Length) { return -1; diff --git a/device.h b/device.h index 6f0f70a7..10bca28c 100644 --- a/device.h +++ b/device.h @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: device.h 1.43 2004/05/23 10:10:08 kls Exp $ + * $Id: device.h 1.44 2004/06/19 08:50:37 kls Exp $ */ #ifndef __DEVICE_H @@ -373,6 +373,12 @@ public: ///< If TimeoutMs is not zero, the device will wait up to the given number ///< of milleseconds before returning in case there is no immediate ///< need for data. + virtual bool Flush(int TimeoutMs = 0); + ///< Returns true if the device's output buffers are empty, i. e. any + ///< data which was bufferd so far has been processed. + ///< If TimeoutMs is not zero, the device will wait up to the given + ///< number of milliseconds before returning in case there is still + ///< data in the buffers.. virtual int PlayVideo(const uchar *Data, int Length); ///< Actually plays the given data block as video. The data must be ///< part of a PES (Packetized Elementary Stream) which can contain diff --git a/dvbdevice.c b/dvbdevice.c index fae2408a..2f43bc8c 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.91 2004/06/12 14:50:23 kls Exp $ + * $Id: dvbdevice.c 1.92 2004/06/19 08:52:24 kls Exp $ */ #include "dvbdevice.h" @@ -1069,6 +1069,12 @@ bool cDvbDevice::Poll(cPoller &Poller, int TimeoutMs) return Poller.Poll(TimeoutMs); } +bool cDvbDevice::Flush(int TimeoutMs) +{ + //TODO actually this function should wait until all buffered data has been processed by the card, but how? + return true; +} + int cDvbDevice::PlayVideo(const uchar *Data, int Length) { int fd = (playMode == pmAudioOnly || playMode == pmAudioOnlyBlack) ? fd_audio : fd_video; diff --git a/dvbdevice.h b/dvbdevice.h index 2c5bd8eb..f7a4b925 100644 --- a/dvbdevice.h +++ b/dvbdevice.h @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: dvbdevice.h 1.27 2004/04/17 11:56:22 kls Exp $ + * $Id: dvbdevice.h 1.28 2004/06/19 08:51:33 kls Exp $ */ #ifndef __DVBDEVICE_H @@ -115,6 +115,7 @@ public: virtual void Mute(void); virtual void StillPicture(const uchar *Data, int Length); virtual bool Poll(cPoller &Poller, int TimeoutMs = 0); + virtual bool Flush(int TimeoutMs = 0); virtual int PlayVideo(const uchar *Data, int Length); virtual void PlayAudio(const uchar *Data, int Length); diff --git a/dvbplayer.c b/dvbplayer.c index c3bd542d..8b60c2e1 100644 --- a/dvbplayer.c +++ b/dvbplayer.c @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: dvbplayer.c 1.23 2003/10/18 11:31:54 kls Exp $ + * $Id: dvbplayer.c 1.24 2004/06/19 08:55:49 kls Exp $ */ #include "dvbplayer.h" @@ -418,7 +418,7 @@ void cDvbPlayer::Action(void) int AudioTrack = 0; // -1 = any, 0 = none, >0 = audioTrack running = true; - while (running && (NextFile() || readIndex >= 0 || ringBuffer->Available())) { + while (running && (NextFile() || readIndex >= 0 || ringBuffer->Available() || !DeviceFlush(100))) { cPoller Poller; if (DevicePoll(Poller, 100)) { @@ -438,6 +438,10 @@ void cDvbPlayer::Action(void) continue; } else { + // hit begin of recording: wait for device buffers to drain + // before changing play mode: + if (!DeviceFlush(100)) + continue; // can't call Play() here, because those functions may only be // called from the foreground thread - and we also don't need // to empty the buffer here diff --git a/player.h b/player.h index 85b7bd13..8c5392ae 100644 --- a/player.h +++ b/player.h @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: player.h 1.11 2004/04/30 13:45:59 kls Exp $ + * $Id: player.h 1.12 2004/06/19 08:53:07 kls Exp $ */ #ifndef __PLAYER_H @@ -20,6 +20,7 @@ private: ePlayMode playMode; protected: bool DevicePoll(cPoller &Poller, int TimeoutMs = 0) { return device ? device->Poll(Poller, TimeoutMs) : false; } + bool DeviceFlush(int TimeoutMs = 0) { return device ? device->Flush(TimeoutMs) : true; } void DeviceTrickSpeed(int Speed) { if (device) device->TrickSpeed(Speed); } void DeviceClear(void) { if (device) device->Clear(); } void DevicePlay(void) { if (device) device->Play(); } -- cgit v1.2.3