From fa60bd19a16595b147477d49215f2aefde5b0d5b Mon Sep 17 00:00:00 2001 From: Darren Salt Date: Sat, 17 Mar 2007 19:15:58 +0000 Subject: Avoid a possible floating-point exception when starting stream playback. CVS patchset: 8707 CVS date: 2007/03/17 19:15:58 --- src/input/net_buf_ctrl.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src') 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)) { -- cgit v1.2.3