Mailing List archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[vdr] Re: vdr-1.3.13: buffer overflows and vdr-xine



Reinhard Nissl wrote:
> 
> Hi,
> 
> for any reason there are still some problems with the new buffer handling. I'd
> suggest the following change to transfer.c:
> 
> --- vdr-1.3.13-orig/transfer.c  2004-10-16 11:22:58.000000000 +0200
> +++ vdr-1.3.13/transfer.c       2004-10-20 13:21:40.778696440 +0200
> @@ -65,7 +75,7 @@
>           int Count;
>           uchar *b = ringBuffer->Get(Count);
>           if (b) {
> -           if (Count > TRANSFERBUFSIZE * 2 / 3) {
> +           if (ringBuffer->Available() > TRANSFERBUFSIZE * 2 / 3) {
>                 // If the buffer runs full, we have no chance of ever catching up
>                 // since the data comes in at the same rate as it goes out
> (it's "live").
>                 // So let's clear the buffer instead of suffering from permanent
> 
> For an explanation consider the following case: ringBuffer contains already
> data of a size greater than margin near the end of the buffer. Therefore Count
> will only contain the size of data till the end of the buffer. But the
> receiver thread keeps going on to put data into ringBuffer. The result were
> buffer overflows.
> 
> By considering all the data contained in ringBuffer by using it's method
> Available() a buffer clear will still happen even for this special case.

You're right. I also guess it makes sense to set the limit to 90%, because otherwise
the transfer buffer is unnecessarily big (2/3 of it would never be used).

> Next I'm looking into an issue why cRemux in not consuming any data in Put()
> but is also not delivering any data to cXineDevice::PlayVideo(). This is the
> main problem that triggered the above one.

This might be fixed by the patch I posted just a while ago:

--- remux.c     2004/10/16 09:11:52     1.19
+++ remux.c     2004/10/23 12:06:13     1.20
@@ -597,7 +597,7 @@
                Count += l;
                }
             else
-               resultSkipped = i;
+               resultSkipped = i + l;
             if (l > 0)
                i += l - 1; // the loop increments, too
             }


Klaus




Home | Main Index | Thread Index