summaryrefslogtreecommitdiff
path: root/ringbuffer.c
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2009-11-22 11:30:27 +0100
committerKlaus Schmidinger <vdr@tvdr.de>2009-11-22 11:30:27 +0100
commit8ffbea3788d8c4cc1a83fbb8f3aae7f253cbaeef (patch)
tree25195cf9a30a26520d7b9fef16719a588f5bc3c6 /ringbuffer.c
parent2db303d6f50ad7452eaff13ee2c9213de89a13c1 (diff)
downloadvdr-8ffbea3788d8c4cc1a83fbb8f3aae7f253cbaeef.tar.gz
vdr-8ffbea3788d8c4cc1a83fbb8f3aae7f253cbaeef.tar.bz2
Fixed generating the index for recordings from channels that put a whole GOP into one payload unit; regenerating index file
Diffstat (limited to 'ringbuffer.c')
-rw-r--r--ringbuffer.c45
1 files changed, 42 insertions, 3 deletions
diff --git a/ringbuffer.c b/ringbuffer.c
index fd8123ec..1bdeaccc 100644
--- a/ringbuffer.c
+++ b/ringbuffer.c
@@ -7,7 +7,7 @@
* Parts of this file were inspired by the 'ringbuffy.c' from the
* LinuxDVB driver (see linuxtv.org).
*
- * $Id: ringbuffer.c 2.2 2009/05/17 10:05:17 kls Exp $
+ * $Id: ringbuffer.c 2.3 2009/11/22 11:14:36 kls Exp $
*/
#include "ringbuffer.h"
@@ -200,7 +200,7 @@ int cRingBufferLinear::Available(void)
void cRingBufferLinear::Clear(void)
{
- tail = head;
+ tail = head = margin;
#ifdef DEBUGRINGBUFFERS
lastHead = head;
lastTail = tail;
@@ -217,7 +217,8 @@ int cRingBufferLinear::Read(int FileHandle, int Max)
int free = (diff > 0) ? diff - 1 : Size() - head;
if (Tail <= margin)
free--;
- int Count = 0;
+ int Count = -1;
+ errno = EAGAIN;
if (free > 0) {
if (0 < Max && Max < free)
free = Max;
@@ -247,6 +248,44 @@ int cRingBufferLinear::Read(int FileHandle, int Max)
return Count;
}
+int cRingBufferLinear::Read(cUnbufferedFile *File, int Max)
+{
+ int Tail = tail;
+ int diff = Tail - head;
+ int free = (diff > 0) ? diff - 1 : Size() - head;
+ if (Tail <= margin)
+ free--;
+ int Count = -1;
+ errno = EAGAIN;
+ if (free > 0) {
+ if (0 < Max && Max < free)
+ free = Max;
+ Count = File->Read(buffer + head, free);
+ if (Count > 0) {
+ int Head = head + Count;
+ if (Head >= Size())
+ Head = margin;
+ head = Head;
+ if (statistics) {
+ int fill = head - Tail;
+ if (fill < 0)
+ fill = Size() + fill;
+ else if (fill >= Size())
+ fill = Size() - 1;
+ UpdatePercentage(fill);
+ }
+ }
+ }
+#ifdef DEBUGRINGBUFFERS
+ lastHead = head;
+ lastPut = Count;
+#endif
+ EnableGet();
+ if (free == 0)
+ WaitForPut();
+ return Count;
+}
+
int cRingBufferLinear::Put(const uchar *Data, int Count)
{
if (Count > 0) {