1
0
mirror of https://github.com/VDR4Arch/vdr.git synced 2023-10-10 13:36:52 +02:00

Removed the WaitForPut/WaitForGet stuff from cRingBuffer

This commit is contained in:
Klaus Schmidinger 2003-05-11 10:30:27 +02:00
parent d067e5eda4
commit e3e21837d0
4 changed files with 9 additions and 44 deletions

View File

@ -587,6 +587,8 @@ Sascha Volkenandt <sascha@akv-soft.de>
for helping to fix a faulty behaviour of the "Mute" key in case the channel display for helping to fix a faulty behaviour of the "Mute" key in case the channel display
is visible is visible
for making the 'epg.data' file being read after all plugins have been started for making the 'epg.data' file being read after all plugins have been started
for reporting a problem with cReceivers that use a ring buffer and didn't immediately
return from their Receive() function if the buffer runs full
Malcolm Caldwell <malcolm.caldwell@ntu.edu.au> Malcolm Caldwell <malcolm.caldwell@ntu.edu.au>
for modifying LOF handling to allow for C-band reception for modifying LOF handling to allow for C-band reception

View File

@ -2124,3 +2124,8 @@ Video Disk Recorder Revision History
is actually coming from. is actually coming from.
- Added VDRVERSNUM to config.h, which can be used by the preprocessor to check the - Added VDRVERSNUM to config.h, which can be used by the preprocessor to check the
actual VDR version (suggested by Stefan Huelswitt). actual VDR version (suggested by Stefan Huelswitt).
- Removed the WaitForPut/WaitForGet stuff from cRingBuffer, since it appears to
no longer be necessary due to the implementation of cNonBlockingFileReader in
dvbplayer.c. Also, the long timeout in WaitForPut caused problems with cReceivers
that use a ring buffer and didn't immediately return from their Receive() function
if the buffer runs full (thanks to Sascha Volkenandt for reporting this one).

View File

@ -7,7 +7,7 @@
* Parts of this file were inspired by the 'ringbuffy.c' from the * Parts of this file were inspired by the 'ringbuffy.c' from the
* LinuxDVB driver (see linuxtv.org). * LinuxDVB driver (see linuxtv.org).
* *
* $Id: ringbuffer.c 1.15 2003/04/27 09:54:32 kls Exp $ * $Id: ringbuffer.c 1.16 2003/05/11 09:47:56 kls Exp $
*/ */
#include "ringbuffer.h" #include "ringbuffer.h"
@ -31,30 +31,6 @@ cRingBuffer::~cRingBuffer()
dsyslog("buffer stats: %d (%d%%) used", maxFill, maxFill * 100 / (size - 1)); dsyslog("buffer stats: %d (%d%%) used", maxFill, maxFill * 100 / (size - 1));
} }
void cRingBuffer::WaitForPut(void)
{
putMutex.Lock();
readyForPut.TimedWait(putMutex, 1000);
putMutex.Unlock();
}
void cRingBuffer::WaitForGet(void)
{
getMutex.Lock();
readyForGet.TimedWait(getMutex, 10);
getMutex.Unlock();
}
void cRingBuffer::EnablePut(void)
{
readyForPut.Broadcast();
}
void cRingBuffer::EnableGet(void)
{
readyForGet.Broadcast();
}
// --- cRingBufferLinear ----------------------------------------------------- // --- cRingBufferLinear -----------------------------------------------------
cRingBufferLinear::cRingBufferLinear(int Size, int Margin, bool Statistics) cRingBufferLinear::cRingBufferLinear(int Size, int Margin, bool Statistics)
@ -92,8 +68,6 @@ void cRingBufferLinear::Clear(void)
head = tail = margin; head = tail = margin;
lastGet = -1; lastGet = -1;
Unlock(); Unlock();
EnablePut();
EnableGet();
} }
int cRingBufferLinear::Put(const uchar *Data, int Count) int cRingBufferLinear::Put(const uchar *Data, int Count)
@ -135,9 +109,6 @@ int cRingBufferLinear::Put(const uchar *Data, int Count)
else else
Count = 0; Count = 0;
Unlock(); Unlock();
EnableGet();
if (Count == 0)
WaitForPut();
} }
return Count; return Count;
} }
@ -163,8 +134,6 @@ uchar *cRingBufferLinear::Get(int &Count)
Count = lastGet = cont; Count = lastGet = cont;
} }
Unlock(); Unlock();
if (!p)
WaitForGet();
return p; return p;
} }
@ -177,7 +146,6 @@ void cRingBufferLinear::Del(int Count)
if (tail >= Size()) if (tail >= Size())
tail = margin; tail = margin;
Unlock(); Unlock();
EnablePut();
} }
else else
esyslog("ERROR: invalid Count in cRingBufferLinear::Del: %d", Count); esyslog("ERROR: invalid Count in cRingBufferLinear::Del: %d", Count);
@ -228,8 +196,6 @@ void cRingBufferFrame::Clear(void)
while ((p = Get()) != NULL) while ((p = Get()) != NULL)
Drop(p); Drop(p);
Unlock(); Unlock();
EnablePut();
EnableGet();
} }
bool cRingBufferFrame::Put(cFrame *Frame) bool cRingBufferFrame::Put(cFrame *Frame)
@ -246,7 +212,6 @@ bool cRingBufferFrame::Put(cFrame *Frame)
} }
currentFill += Frame->Count(); currentFill += Frame->Count();
Unlock(); Unlock();
EnableGet();
return true; return true;
} }
return false; return false;
@ -284,7 +249,6 @@ void cRingBufferFrame::Drop(cFrame *Frame)
esyslog("ERROR: attempt to drop wrong frame from ring buffer!"); esyslog("ERROR: attempt to drop wrong frame from ring buffer!");
} }
Unlock(); Unlock();
EnablePut();
} }
int cRingBufferFrame::Available(void) int cRingBufferFrame::Available(void)

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: ringbuffer.h 1.10 2003/04/27 09:55:08 kls Exp $ * $Id: ringbuffer.h 1.11 2003/05/11 09:48:23 kls Exp $
*/ */
#ifndef __RINGBUFFER_H #ifndef __RINGBUFFER_H
@ -16,17 +16,11 @@
class cRingBuffer { class cRingBuffer {
private: private:
cMutex mutex; cMutex mutex;
cCondVar readyForPut, readyForGet;
cMutex putMutex, getMutex;
int size; int size;
protected: protected:
int maxFill;//XXX int maxFill;//XXX
int lastPercent; int lastPercent;
bool statistics;//XXX bool statistics;//XXX
void WaitForPut(void);
void WaitForGet(void);
void EnablePut(void);
void EnableGet(void);
virtual void Clear(void) = 0; virtual void Clear(void) = 0;
virtual int Available(void) = 0; virtual int Available(void) = 0;
int Free(void) { return size - Available() - 1; } int Free(void) { return size - Available() - 1; }