diff options
author | Klaus Schmidinger <vdr@tvdr.de> | 2006-02-19 14:23:17 +0100 |
---|---|---|
committer | Klaus Schmidinger <vdr@tvdr.de> | 2006-02-19 14:23:17 +0100 |
commit | 8186544e10ca36128e52e0391fdfc829f5fd3667 (patch) | |
tree | 2ccfc59e92fb9ef71b8225bb313d92dabeaa7a59 | |
parent | 8409c68e44d1545469cd70b7c257c83e69a21715 (diff) | |
download | vdr-8186544e10ca36128e52e0391fdfc829f5fd3667.tar.gz vdr-8186544e10ca36128e52e0391fdfc829f5fd3667.tar.bz2 |
Fixed replaying recordings of radio channels with many audio tracks
-rw-r--r-- | CONTRIBUTORS | 1 | ||||
-rw-r--r-- | HISTORY | 2 | ||||
-rw-r--r-- | dvbplayer.c | 27 |
3 files changed, 27 insertions, 3 deletions
diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 213c92a6..b3dc8e8b 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -1058,6 +1058,7 @@ Reinhard Nissl <rnissl@gmx.de> for fixing handling TS packets in cTS2PES for adding a mutex to synchronize cDevice::PlayPesPacket() and SetCurrentAudioTrack() for a suggestion that lead to implementing cDevice::Transferring() + for fixing replaying recordings of radio channels with many audio tracks Richard Robson <richard_robson@beeb.net> for reporting freezing replay if a timer starts while in Transfer Mode from the @@ -4355,3 +4355,5 @@ Video Disk Recorder Revision History information than the EPG's component data, the code from the channel is taken. - Fixed handling DPID when deciding whether to switch to 'Transfer Mode' (thanks to Marco Schlüßler). +- Fixed replaying recordings of radio channels with many audio tracks (thanks to + Reinhard Nissl). diff --git a/dvbplayer.c b/dvbplayer.c index efd767f1..f61e0c91 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.42 2006/01/08 11:39:41 kls Exp $ + * $Id: dvbplayer.c 1.43 2006/02/19 14:20:15 kls Exp $ */ #include "dvbplayer.h" @@ -80,6 +80,8 @@ private: int length; bool hasData; cCondWait newSet; + cCondVar newDataCond; + cMutex newDataMutex; protected: void Action(void); public: @@ -88,6 +90,7 @@ public: void Clear(void); int Read(cUnbufferedFile *File, uchar *Buffer, int Length); bool Reading(void) { return buffer; } + bool WaitForDataMs(int msToWait); }; cNonBlockingFileReader::cNonBlockingFileReader(void) @@ -150,8 +153,11 @@ void cNonBlockingFileReader::Action(void) int r = f->Read(buffer + length, wanted - length); if (r >= 0) { length += r; - if (!r || length == wanted) // r == 0 means EOF + if (!r || length == wanted) { // r == 0 means EOF + cMutexLock NewDataLock(&newDataMutex); hasData = true; + newDataCond.Broadcast(); + } } else if (r < 0 && FATALERRNO) { LOG_ERROR; @@ -164,6 +170,14 @@ void cNonBlockingFileReader::Action(void) } } +bool cNonBlockingFileReader::WaitForDataMs(int msToWait) +{ + cMutexLock NewDataLock(&newDataMutex); + if (hasData) + return true; + return newDataCond.TimedWait(newDataMutex, msToWait); +} + // --- cDvbPlayer ------------------------------------------------------------ #define PLAYERBUFSIZE MEGABYTE(1) @@ -362,10 +376,14 @@ void cDvbPlayer::Action(void) nonBlockingFileReader = new cNonBlockingFileReader; int Length = 0; bool Sleep = false; + bool WaitingForData = false; while (Running() && (NextFile() || readIndex >= 0 || ringBuffer->Available() || !DeviceFlush(100))) { if (Sleep) { - cCondWait::SleepMs(3); // this keeps the CPU load low + if (WaitingForData) + nonBlockingFileReader->WaitForDataMs(3); // this keeps the CPU load low, but reacts immediately on new data + else + cCondWait::SleepMs(3); // this keeps the CPU load low Sleep = false; } cPoller Poller; @@ -423,11 +441,14 @@ void cDvbPlayer::Action(void) } int r = nonBlockingFileReader->Read(replayFile, b, Length); if (r > 0) { + WaitingForData = false; readFrame = new cFrame(b, -r, ftUnknown, readIndex); // hands over b to the ringBuffer b = NULL; } else if (r == 0) eof = true; + else if (r < 0 && errno == EAGAIN) + WaitingForData = true; else if (r < 0 && FATALERRNO) { LOG_ERROR; break; |