diff options
author | Daniel Caujolle-Bert <f1rmb@users.sourceforge.net> | 2003-01-26 23:36:46 +0000 |
---|---|---|
committer | Daniel Caujolle-Bert <f1rmb@users.sourceforge.net> | 2003-01-26 23:36:46 +0000 |
commit | f66eaabcc458b656165b7abc18b1f25cbd22d81e (patch) | |
tree | 631461560bf648fcb456ec67803dfb9fa9f519d9 | |
parent | 29a4f937b0177135cf24496034756457b1be5113 (diff) | |
download | xine-lib-f66eaabcc458b656165b7abc18b1f25cbd22d81e.tar.gz xine-lib-f66eaabcc458b656165b7abc18b1f25cbd22d81e.tar.bz2 |
revert, commited by error, thibaut patch ;-)
CVS patchset: 4017
CVS date: 2003/01/26 23:36:46
-rw-r--r-- | src/input/net_buf_ctrl.c | 101 | ||||
-rw-r--r-- | src/xine-engine/buffer.c | 20 | ||||
-rw-r--r-- | src/xine-engine/buffer.h | 4 |
3 files changed, 36 insertions, 89 deletions
diff --git a/src/input/net_buf_ctrl.c b/src/input/net_buf_ctrl.c index 085f564d0..141fca768 100644 --- a/src/input/net_buf_ctrl.c +++ b/src/input/net_buf_ctrl.c @@ -30,8 +30,8 @@ #include "net_buf_ctrl.h" -#define DEFAULT_LOW_WATER_MARK 1 -#define DEFAULT_HIGH_WATER_MARK 5000 /* in millisecond */ +#define DEFAULT_LOW_WATER_MARK 2 +#define DEFAULT_HIGH_WATER_MARK 5 /* #define LOG @@ -66,82 +66,47 @@ static void report_progress (xine_stream_t *stream, int p) { void nbc_check_buffers (nbc_t *this) { - int fifo_fill, video_fifo_fill, audio_fifo_fill; - int data_length, video_data_length, audio_data_length; - int video_bitrate, audio_bitrate; - - video_fifo_fill = this->stream->video_fifo->size(this->stream->video_fifo); - if (this->stream->audio_fifo) - audio_fifo_fill = this->stream->audio_fifo->size(this->stream->audio_fifo); - else - audio_fifo_fill = 0; + int fifo_fill; + + fifo_fill = this->stream->video_fifo->size(this->stream->video_fifo); + if (this->stream->audio_fifo) { + fifo_fill += 8*this->stream->audio_fifo->size(this->stream->audio_fifo); + } + if (this->buffering) { - fifo_fill = audio_fifo_fill + video_fifo_fill; + report_progress (this->stream, fifo_fill*100 / this->high_water_mark); - /* start buffering if fifos are empty */ - if (fifo_fill == 0) { +#ifdef LOG + printf ("net_buf_ctl: buffering (%d/%d)...\n", + fifo_fill, this->high_water_mark); +#endif + } + if (fifo_fill<this->low_water_mark) { if (!this->buffering) { - /* increase marks to adapt to stream/network needs */ - this->high_water_mark += this->high_water_mark / 4; - /* this->low_water_mark = this->high_water_mark/4; */ - - this->buffering = 1; - report_progress (this->stream, 0); + if (this->high_water_mark<150) { + /* increase marks to adapt to stream/network needs */ + + this->high_water_mark += 10; + /* this->low_water_mark = this->high_water_mark/4; */ + } } - /* pause */ + this->stream->xine->clock->set_speed (this->stream->xine->clock, XINE_SPEED_PAUSE); this->stream->xine->clock->set_option (this->stream->xine->clock, CLOCK_SCR_ADJUSTABLE, 0); if (this->stream->audio_out) this->stream->audio_out->set_property(this->stream->audio_out,AO_PROP_PAUSED,2); + this->buffering = 1; + + } else if ( (fifo_fill>this->high_water_mark) && (this->buffering)) { + this->stream->xine->clock->set_speed (this->stream->xine->clock, XINE_SPEED_NORMAL); + this->stream->xine->clock->set_option (this->stream->xine->clock, CLOCK_SCR_ADJUSTABLE, 1); + if (this->stream->audio_out) + this->stream->audio_out->set_property(this->stream->audio_out,AO_PROP_PAUSED,0); + this->buffering = 0; - } else { - - if (this->buffering) { - - /* compute data length in fifos */ - video_bitrate = this->stream->stream_info[XINE_STREAM_INFO_VIDEO_BITRATE]; - audio_bitrate = this->stream->stream_info[XINE_STREAM_INFO_AUDIO_BITRATE]; - - if (video_bitrate) - video_data_length = (8000 * this->stream->video_fifo->data_size) / video_bitrate; - else - video_data_length = 0; - - if (audio_bitrate) - audio_data_length = (8000 * this->stream->audio_fifo->data_size) / audio_bitrate; - else - audio_data_length = 0; - - if (video_data_length > audio_data_length) { - data_length = video_data_length; - } else { - data_length = audio_data_length; - } - - - /* stop buffering if fifos are filled enough */ - if ((data_length >= this->high_water_mark) || - (video_fifo_fill == 512) || /* there is 512 video buffers */ - (audio_fifo_fill == 230) ) { /* there is 230 audio buffers */ - /* unpause */ - this->stream->xine->clock->set_speed (this->stream->xine->clock, XINE_SPEED_NORMAL); - this->stream->xine->clock->set_option (this->stream->xine->clock, CLOCK_SCR_ADJUSTABLE, 1); - if (this->stream->audio_out) - this->stream->audio_out->set_property(this->stream->audio_out,AO_PROP_PAUSED,0); - - report_progress (this->stream, 100); - this->buffering = 0; - } else { - report_progress (this->stream, (data_length * 100) / this->high_water_mark); - } - - } else { - /* fifos are ok */ - } - } } @@ -163,9 +128,9 @@ nbc_t *nbc_init (xine_stream_t *stream) { } void nbc_set_high_water_mark(nbc_t *this, int value) { -/* this->high_water_mark = value; */ + this->high_water_mark = value; } void nbc_set_low_water_mark(nbc_t *this, int value) { -/* this->low_water_mark = value; */ + this->low_water_mark = value; } diff --git a/src/xine-engine/buffer.c b/src/xine-engine/buffer.c index e3db4a75c..05b94fdd7 100644 --- a/src/xine-engine/buffer.c +++ b/src/xine-engine/buffer.c @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: buffer.c,v 1.21 2003/01/26 23:31:13 f1rmb Exp $ + * $Id: buffer.c,v 1.22 2003/01/26 23:36:46 f1rmb Exp $ * * * contents: @@ -163,10 +163,9 @@ static void fifo_buffer_put (fifo_buffer_t *fifo, buf_element_t *element) { else fifo->first = element; - fifo->last = element; + fifo->last = element; element->next = NULL; fifo->fifo_size++; - fifo->data_size += element->size; pthread_cond_signal (&fifo->not_empty); @@ -187,7 +186,6 @@ static void fifo_buffer_insert (fifo_buffer_t *fifo, buf_element_t *element) { fifo->last = element; fifo->fifo_size++; - fifo->data_size += element->size; pthread_cond_signal (&fifo->not_empty); @@ -215,7 +213,6 @@ static buf_element_t *fifo_buffer_get (fifo_buffer_t *fifo) { fifo->last = NULL; fifo->fifo_size--; - fifo->data_size -= buf->size; pthread_mutex_unlock (&fifo->mutex); @@ -276,19 +273,6 @@ static int fifo_buffer_size (fifo_buffer_t *this) { } /* - * Return the amount of the data in the fifo buffer - */ -static uint32_t fifo_buffer_data_size (fifo_buffer_t *this) { - int data_size; - - pthread_mutex_lock(&this->mutex); - data_size = this->data_size; - pthread_mutex_unlock(&this->mutex); - - return data_size; -} - -/* * Destroy the buffer */ static void fifo_buffer_dispose (fifo_buffer_t *this) { diff --git a/src/xine-engine/buffer.h b/src/xine-engine/buffer.h index 0bfabb127..64bbaa8d2 100644 --- a/src/xine-engine/buffer.h +++ b/src/xine-engine/buffer.h @@ -17,7 +17,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA * - * $Id: buffer.h,v 1.97 2003/01/26 23:31:13 f1rmb Exp $ + * $Id: buffer.h,v 1.98 2003/01/26 23:36:46 f1rmb Exp $ * * * contents: @@ -391,9 +391,7 @@ typedef struct fifo_buffer_s fifo_buffer_t; struct fifo_buffer_s { buf_element_t *first, *last; - int fifo_size; - uint32_t data_size; pthread_mutex_t mutex; pthread_cond_t not_empty; |