summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOliver Endriss <o.endriss@gmx.de>2008-04-20 20:37:45 +0200
committerOliver Endriss <o.endriss@gmx.de>2008-04-20 20:37:45 +0200
commitfeb0491ab7d2fa9ebf1665bfb15df725b1ecd9db (patch)
tree2883bd37298f90bf8388e7134e2a948f4d04671c
parenteb66d59f64f9a1ef31afcc6225abc5e39aa7fa40 (diff)
downloadmediapointer-dvb-s2-feb0491ab7d2fa9ebf1665bfb15df725b1ecd9db.tar.gz
mediapointer-dvb-s2-feb0491ab7d2fa9ebf1665bfb15df725b1ecd9db.tar.bz2
dvb-core: Fix DMX_SET_BUFFER_SIZE in case the buffer shrinks
From: Andrea Odetti <mariofutire@gmail.com> This patch fixes the bug in DMX_SET_BUFFER_SIZE for the demux. Basically it resets read and write pointers to 0 in case they are beyond the new size of the buffer. Signed-off-by: Andrea Odetti <mariofutire@gmail.com> Signed-off-by: Oliver Endriss <o.endriss@gmx.de>
-rw-r--r--linux/drivers/media/dvb/dvb-core/dmxdev.c4
-rw-r--r--linux/drivers/media/dvb/dvb-core/dvb_ringbuffer.c6
-rw-r--r--linux/drivers/media/dvb/dvb-core/dvb_ringbuffer.h8
3 files changed, 16 insertions, 2 deletions
diff --git a/linux/drivers/media/dvb/dvb-core/dmxdev.c b/linux/drivers/media/dvb/dvb-core/dmxdev.c
index 3415a3bb3..bbd52be55 100644
--- a/linux/drivers/media/dvb/dvb-core/dmxdev.c
+++ b/linux/drivers/media/dvb/dvb-core/dmxdev.c
@@ -281,7 +281,9 @@ static int dvb_dmxdev_set_buffer_size(struct dmxdev_filter *dmxdevfilter,
mem = buf->data;
buf->data = NULL;
buf->size = size;
- dvb_ringbuffer_flush(buf);
+
+ /* reset and not flush in case the buffer shrinks */
+ dvb_ringbuffer_reset(buf);
spin_unlock_irq(&dmxdevfilter->dev->lock);
vfree(mem);
diff --git a/linux/drivers/media/dvb/dvb-core/dvb_ringbuffer.c b/linux/drivers/media/dvb/dvb-core/dvb_ringbuffer.c
index ac9d93cf8..872985b79 100644
--- a/linux/drivers/media/dvb/dvb-core/dvb_ringbuffer.c
+++ b/linux/drivers/media/dvb/dvb-core/dvb_ringbuffer.c
@@ -90,7 +90,11 @@ void dvb_ringbuffer_flush(struct dvb_ringbuffer *rbuf)
rbuf->error = 0;
}
-
+void dvb_ringbuffer_reset(struct dvb_ringbuffer *rbuf)
+{
+ rbuf->pread = rbuf->pwrite = 0;
+ rbuf->error = 0;
+}
void dvb_ringbuffer_flush_spinlock_wakeup(struct dvb_ringbuffer *rbuf)
{
diff --git a/linux/drivers/media/dvb/dvb-core/dvb_ringbuffer.h b/linux/drivers/media/dvb/dvb-core/dvb_ringbuffer.h
index d97714e75..890826262 100644
--- a/linux/drivers/media/dvb/dvb-core/dvb_ringbuffer.h
+++ b/linux/drivers/media/dvb/dvb-core/dvb_ringbuffer.h
@@ -69,6 +69,7 @@ struct dvb_ringbuffer {
** to lock read or write operations.
** Two or more readers must be locked against each other.
** Flushing the buffer counts as a read operation.
+** Resetting the buffer counts as a read and write operation.
** Two or more writers must be locked against each other.
*/
@@ -85,6 +86,13 @@ extern ssize_t dvb_ringbuffer_free(struct dvb_ringbuffer *rbuf);
extern ssize_t dvb_ringbuffer_avail(struct dvb_ringbuffer *rbuf);
+/*
+** Reset the read and write pointers to zero and flush the buffer
+** This counts as a read and write operation
+*/
+extern void dvb_ringbuffer_reset(struct dvb_ringbuffer *rbuf);
+
+
/* read routines & macros */
/* ---------------------- */
/* flush buffer */