[linux-dvb] [PATCH] make dvb_ringbuffer compatible to dmxdev_buffer

Oliver Endriss o.endriss at gmx.de
Tue Mar 14 01:03:56 CET 2006


Andreas Oberritter wrote:
> From: Andreas Oberritter <obi at linuxtv.org>
> 
> Added variable 'error' to struct dvb_ringbuffer, which is set to zero on
> init() and flush(). Also reset read an write pointers to zero on flush()
> to get less fragmented data.
> 
> Signed-off-by: Andreas Oberritter <obi at linuxtv.org>
> ---
> 
> A patch to make dmxdev use dvb_ringbuffer will follow.
> 
> diff -r 427667c87c7b linux/drivers/media/dvb/dvb-core/dvb_ringbuffer.c
> --- a/linux/drivers/media/dvb/dvb-core/dvb_ringbuffer.c	Sun Mar 12 00:03:47 2006 -0300
> +++ b/linux/drivers/media/dvb/dvb-core/dvb_ringbuffer.c	Mon Mar 13 16:02:46 2006 +0100
> ...
> @@ -86,7 +87,8 @@ ssize_t dvb_ringbuffer_avail(struct dvb_
>  
>  void dvb_ringbuffer_flush(struct dvb_ringbuffer *rbuf)
>  {
> -	rbuf->pread = rbuf->pwrite;
> +	rbuf->pread = rbuf->pwrite = 0;
                                   +++

Attention, this will convert dvb_ringbuffer_flush() into a writer!

from dvb_ringbuffer.h:
| ** (2) If there is exactly one reader and one writer, there is no need
| **     to lock read or write operations.
| **     Two or more readers must be locked against each other.
| **     Flushing the buffer counts as a read operation.
         +++++++++++++++++++++++++++++++++++++++++++++++
| **     Two or more writers must be locked against each other.

With this patch flushing the ring buffer is a read _and_ a write
operation. It might break existing code. Are you aware of that?

CU
Oliver

-- 
--------------------------------------------------------
VDR Remote Plugin available at
http://www.escape-edv.de/endriss/vdr/
--------------------------------------------------------



More information about the linux-dvb mailing list