summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDarren Salt <linux@youmustbejoking.demon.co.uk>2007-03-17 19:15:58 +0000
committerDarren Salt <linux@youmustbejoking.demon.co.uk>2007-03-17 19:15:58 +0000
commitfa60bd19a16595b147477d49215f2aefde5b0d5b (patch)
treeb7a2e83adc1975a186824e6a0668888e7ad7e166 /src
parent01f379bf544c35cf3c17d3dacfbb2eec2cc6d7d2 (diff)
downloadxine-lib-fa60bd19a16595b147477d49215f2aefde5b0d5b.tar.gz
xine-lib-fa60bd19a16595b147477d49215f2aefde5b0d5b.tar.bz2
Avoid a possible floating-point exception when starting stream playback.
CVS patchset: 8707 CVS date: 2007/03/17 19:15:58
Diffstat (limited to 'src')
-rw-r--r--src/input/net_buf_ctrl.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/input/net_buf_ctrl.c b/src/input/net_buf_ctrl.c
index 75743a070..86514cdea 100644
--- a/src/input/net_buf_ctrl.c
+++ b/src/input/net_buf_ctrl.c
@@ -149,7 +149,7 @@ static void nbc_compute_fifo_length(nbc_t *this,
fifo_buffer_t *fifo,
buf_element_t *buf,
int action) {
- int fifo_free, fifo_fill;
+ int fifo_free, fifo_fill, fifo_div;
int64_t video_br, audio_br, diff;
int has_video, has_audio;
@@ -160,10 +160,13 @@ static void nbc_compute_fifo_length(nbc_t *this,
fifo_free = fifo->buffer_pool_num_free;
fifo_fill = fifo->fifo_size;
+ fifo_div = fifo_fill + fifo_free - 1;
+ if (fifo_div == 0)
+ fifo_div = 1; /* avoid a possible divide-by-zero */
if (fifo == this->video_fifo) {
this->video_fifo_free = fifo_free;
- this->video_fifo_fill = (100 * fifo_fill) / (fifo_fill + fifo_free - 1);
+ this->video_fifo_fill = (100 * fifo_fill) / fifo_div;
this->video_fifo_size = fifo->fifo_data_size;
if (buf->pts && (this->video_in_disc == 0)) {
@@ -196,7 +199,7 @@ static void nbc_compute_fifo_length(nbc_t *this,
} else {
this->audio_fifo_free = fifo_free;
- this->audio_fifo_fill = (100 * fifo_fill) / (fifo_fill + fifo_free - 1);
+ this->audio_fifo_fill = (100 * fifo_fill) / fifo_div;
this->audio_fifo_size = fifo->fifo_data_size;
if (buf->pts && (this->audio_in_disc == 0)) {