diff options
author | Andrea Odetti <mariofutire@gmail.com> | 2008-04-20 17:37:45 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2008-04-24 13:09:44 -0400 |
commit | 48c01a9c2d245b229f8b709040cb1776b00dc683 (patch) | |
tree | 8a33e3640fc89a061222abc9aaddc55be0650dd2 /drivers | |
parent | 3ff9a81b21c673fd91ad8456242ca68922f77ac4 (diff) |
V4L/DVB (7658): dvb-core: Fix DMX_SET_BUFFER_SIZE in case the buffer shrinks
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>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/media/dvb/dvb-core/dmxdev.c | 4 | ||||
-rw-r--r-- | drivers/media/dvb/dvb-core/dvb_ringbuffer.c | 6 | ||||
-rw-r--r-- | drivers/media/dvb/dvb-core/dvb_ringbuffer.h | 8 |
3 files changed, 16 insertions, 2 deletions
diff --git a/drivers/media/dvb/dvb-core/dmxdev.c b/drivers/media/dvb/dvb-core/dmxdev.c index 3415a3bb363..bbd52be552d 100644 --- a/drivers/media/dvb/dvb-core/dmxdev.c +++ b/drivers/media/dvb/dvb-core/dmxdev.c | |||
@@ -281,7 +281,9 @@ static int dvb_dmxdev_set_buffer_size(struct dmxdev_filter *dmxdevfilter, | |||
281 | mem = buf->data; | 281 | mem = buf->data; |
282 | buf->data = NULL; | 282 | buf->data = NULL; |
283 | buf->size = size; | 283 | buf->size = size; |
284 | dvb_ringbuffer_flush(buf); | 284 | |
285 | /* reset and not flush in case the buffer shrinks */ | ||
286 | dvb_ringbuffer_reset(buf); | ||
285 | spin_unlock_irq(&dmxdevfilter->dev->lock); | 287 | spin_unlock_irq(&dmxdevfilter->dev->lock); |
286 | vfree(mem); | 288 | vfree(mem); |
287 | 289 | ||
diff --git a/drivers/media/dvb/dvb-core/dvb_ringbuffer.c b/drivers/media/dvb/dvb-core/dvb_ringbuffer.c index ac9d93cf83c..872985b7912 100644 --- a/drivers/media/dvb/dvb-core/dvb_ringbuffer.c +++ b/drivers/media/dvb/dvb-core/dvb_ringbuffer.c | |||
@@ -90,7 +90,11 @@ void dvb_ringbuffer_flush(struct dvb_ringbuffer *rbuf) | |||
90 | rbuf->error = 0; | 90 | rbuf->error = 0; |
91 | } | 91 | } |
92 | 92 | ||
93 | 93 | void dvb_ringbuffer_reset(struct dvb_ringbuffer *rbuf) | |
94 | { | ||
95 | rbuf->pread = rbuf->pwrite = 0; | ||
96 | rbuf->error = 0; | ||
97 | } | ||
94 | 98 | ||
95 | void dvb_ringbuffer_flush_spinlock_wakeup(struct dvb_ringbuffer *rbuf) | 99 | void dvb_ringbuffer_flush_spinlock_wakeup(struct dvb_ringbuffer *rbuf) |
96 | { | 100 | { |
diff --git a/drivers/media/dvb/dvb-core/dvb_ringbuffer.h b/drivers/media/dvb/dvb-core/dvb_ringbuffer.h index d97714e7573..89082626296 100644 --- a/drivers/media/dvb/dvb-core/dvb_ringbuffer.h +++ b/drivers/media/dvb/dvb-core/dvb_ringbuffer.h | |||
@@ -69,6 +69,7 @@ struct dvb_ringbuffer { | |||
69 | ** to lock read or write operations. | 69 | ** to lock read or write operations. |
70 | ** Two or more readers must be locked against each other. | 70 | ** Two or more readers must be locked against each other. |
71 | ** Flushing the buffer counts as a read operation. | 71 | ** Flushing the buffer counts as a read operation. |
72 | ** Resetting the buffer counts as a read and write operation. | ||
72 | ** Two or more writers must be locked against each other. | 73 | ** Two or more writers must be locked against each other. |
73 | */ | 74 | */ |
74 | 75 | ||
@@ -85,6 +86,13 @@ extern ssize_t dvb_ringbuffer_free(struct dvb_ringbuffer *rbuf); | |||
85 | extern ssize_t dvb_ringbuffer_avail(struct dvb_ringbuffer *rbuf); | 86 | extern ssize_t dvb_ringbuffer_avail(struct dvb_ringbuffer *rbuf); |
86 | 87 | ||
87 | 88 | ||
89 | /* | ||
90 | ** Reset the read and write pointers to zero and flush the buffer | ||
91 | ** This counts as a read and write operation | ||
92 | */ | ||
93 | extern void dvb_ringbuffer_reset(struct dvb_ringbuffer *rbuf); | ||
94 | |||
95 | |||
88 | /* read routines & macros */ | 96 | /* read routines & macros */ |
89 | /* ---------------------- */ | 97 | /* ---------------------- */ |
90 | /* flush buffer */ | 98 | /* flush buffer */ |