diff options
-rw-r--r-- | configure.ac | 4 | ||||
-rw-r--r-- | src/input/net_buf_ctrl.c | 101 | ||||
-rw-r--r-- | src/xine-engine/Makefile.am | 24 | ||||
-rw-r--r-- | src/xine-engine/buffer.c | 20 | ||||
-rw-r--r-- | src/xine-engine/buffer.h | 4 |
5 files changed, 108 insertions, 45 deletions
diff --git a/configure.ac b/configure.ac index cbe24ce39..958143262 100644 --- a/configure.ac +++ b/configure.ac @@ -163,6 +163,10 @@ dnl --------------------------------------------- AC_SUBST(DEBUG_CFLAGS) DEBUG_CFLAGS="$CFLAGS -g -DDEBUG" +dnl dummy +ASFLAGS="$ASFLAGS" +AC_SUBST(ASFLAGS) + dnl --------------------------------------------- dnl threads dnl --------------------------------------------- diff --git a/src/input/net_buf_ctrl.c b/src/input/net_buf_ctrl.c index 141fca768..085f564d0 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 2 -#define DEFAULT_HIGH_WATER_MARK 5 +#define DEFAULT_LOW_WATER_MARK 1 +#define DEFAULT_HIGH_WATER_MARK 5000 /* in millisecond */ /* #define LOG @@ -66,47 +66,82 @@ static void report_progress (xine_stream_t *stream, int p) { void nbc_check_buffers (nbc_t *this) { - 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) { + 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; - report_progress (this->stream, fifo_fill*100 / this->high_water_mark); + fifo_fill = audio_fifo_fill + video_fifo_fill; -#ifdef LOG - printf ("net_buf_ctl: buffering (%d/%d)...\n", - fifo_fill, this->high_water_mark); -#endif - } - if (fifo_fill<this->low_water_mark) { + /* start buffering if fifos are empty */ + if (fifo_fill == 0) { if (!this->buffering) { - if (this->high_water_mark<150) { + /* 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); - /* 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 */ + } + } } @@ -128,9 +163,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/Makefile.am b/src/xine-engine/Makefile.am index e2ff961ee..732eb4011 100644 --- a/src/xine-engine/Makefile.am +++ b/src/xine-engine/Makefile.am @@ -8,21 +8,24 @@ AM_CFLAGS = $(THREAD_CFLAGS) $(X_CFLAGS) @ANSI_FLAGS@ lib_LTLIBRARIES = libxine.la -XINEUTILS_LIB = $(top_builddir)/src/xine-utils/libxineutils.la - -if HAVE_NVTV -NVTVCLIENT_LIB = nvtv/libnvclient.la -endif +XINEUTILS_LIB = $(top_builddir)/src/xine-utils/libxineutils.la +NVTVCLIENT_LIB = $(top_builddir)/src/xine-engine/nvtv/libnvclient.la libxine_la_SOURCES = xine.c metronom.c configfile.c buffer.c \ load_plugins.c video_decoder.c buffer_types.c \ audio_decoder.c video_out.c audio_out.c resample.c events.c lrb.c \ video_overlay.c osd.c scratch.c locale.c demux.c vo_scale.c \ xine_interface.c post.c tvmode.c -libxine_la_DEPENDENCIES = @INTLLIBS@ $(XINEUTILS_LIB) $(NVTVCLIENT_LIB) -libxine_la_LIBADD = $(THREAD_LIBS) $(DYNAMIC_LD_LIBS) @INTLLIBS@ $(ZLIB_LIBS)\ - -lm $(XINEUTILS_LIB) $(NVTVCLIENT_LIB) +if HAVE_NVTV +libxine_la_DEPENDENCIES = @INTLLIBS@ $(XINEUTILS_LIB) $(NVTVCLIENT_LIB) +libxine_la_LIBADD = $(THREAD_LIBS) $(DYNAMIC_LD_LIBS) @INTLLIBS@ $(ZLIB_LIBS) \ + -lm $(XINEUTILS_LIB) $(NVTVCLIENT_LIB) +else +libxine_la_DEPENDENCIES = @INTLLIBS@ $(XINEUTILS_LIB) +libxine_la_LIBADD = $(THREAD_LIBS) $(DYNAMIC_LD_LIBS) @INTLLIBS@ $(ZLIB_LIBS) \ + -lm $(XINEUTILS_LIB) +endif libxine_la_LDFLAGS = \ -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) @@ -45,7 +48,10 @@ install-debug: debug @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am $(XINEUTILS_LIB): - cd $(top_srcdir)/src/xine-utils; make + cd $(top_srcdir)/src/xine-utils && $(MAKE) libxineutils.la + +$(NVTVCLIENT_LIB): + cd $(top_builddir)/src/xine-engine/nvtv && $(MAKE) libnvclient.la ### # Install header files (default=$includedir/xine) diff --git a/src/xine-engine/buffer.c b/src/xine-engine/buffer.c index 2e93009a1..e3db4a75c 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.20 2002/12/22 15:02:06 miguelfreitas Exp $ + * $Id: buffer.c,v 1.21 2003/01/26 23:31:13 f1rmb Exp $ * * * contents: @@ -163,9 +163,10 @@ 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); @@ -186,6 +187,7 @@ 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); @@ -213,6 +215,7 @@ 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); @@ -273,6 +276,19 @@ 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 c79bcf139..0bfabb127 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.96 2003/01/19 21:29:55 guenter Exp $ + * $Id: buffer.h,v 1.97 2003/01/26 23:31:13 f1rmb Exp $ * * * contents: @@ -391,7 +391,9 @@ 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; |