summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiguel Freitas <miguelfreitas@users.sourceforge.net>2002-12-24 14:00:55 +0000
committerMiguel Freitas <miguelfreitas@users.sourceforge.net>2002-12-24 14:00:55 +0000
commitb18d857dad27367e9c517d68a5fe501a48fec164 (patch)
treef12827081644ed85c610b22abb1dcfa3d4a17dff
parent359d8d8860cc1748a0f0e18bc791c80392cf7e48 (diff)
downloadxine-lib-b18d857dad27367e9c517d68a5fe501a48fec164.tar.gz
xine-lib-b18d857dad27367e9c517d68a5fe501a48fec164.tar.bz2
discard buffers on flush so decoder will return faster. seeking should be
faster as well. (on a problematic stream i have, seeking time was reduced from 2.5s to 0.8s) CVS patchset: 3665 CVS date: 2002/12/24 14:00:55
-rw-r--r--src/xine-engine/audio_out.c45
-rw-r--r--src/xine-engine/audio_out.h4
-rw-r--r--src/xine-engine/demux.c5
3 files changed, 29 insertions, 25 deletions
diff --git a/src/xine-engine/audio_out.c b/src/xine-engine/audio_out.c
index 6a786f2fc..42f78f335 100644
--- a/src/xine-engine/audio_out.c
+++ b/src/xine-engine/audio_out.c
@@ -17,7 +17,7 @@
* along with self program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
*
- * $Id: audio_out.c,v 1.92 2002/12/22 23:30:29 miguelfreitas Exp $
+ * $Id: audio_out.c,v 1.93 2002/12/24 14:00:55 miguelfreitas Exp $
*
* 22-8-2001 James imported some useful AC3 sections from the previous alsa driver.
* (c) 2001 Andy Lo A Foe <andy@alsaplayer.org>
@@ -523,30 +523,15 @@ static void *ao_loop (void *this_gen) {
#endif
}
+ if (this->discard_buffers) {
+ fifo_append (this->free_fifo, in_buf);
+ in_buf = NULL;
+
+ if( !this->flush_audio_driver )
+ continue;
+ }
+
if (this->flush_audio_driver) {
- audio_buffer_t *buf;
- int num_buffers;
-#ifdef LOG
- printf ("audio_out: flush audio driver\n");
-#endif
- pthread_mutex_lock (&this->out_fifo->mutex);
-
- num_buffers = this->out_fifo->num_buffers;
-
- printf ("audio_out: flush fifo (%d buffers)\n", num_buffers);
-
- while ( num_buffers-- ) {
- buf = fifo_remove_int (this->out_fifo);
- fifo_append (this->free_fifo, buf);
- }
-
- pthread_mutex_unlock (&this->out_fifo->mutex);
-
- if (in_buf) {
- fifo_append (this->free_fifo, in_buf);
- in_buf = NULL;
- }
-
this->control(this, AO_CTRL_FLUSH_BUFFERS);
this->flush_audio_driver = 0;
continue;
@@ -1003,6 +988,10 @@ static int ao_get_property (xine_audio_port_t *this, int property) {
case AO_PROP_COMPRESSOR:
ret = this->compression_factor_max*100;
break;
+
+ case AO_PROP_DISCARD_BUFFERS:
+ ret = this->discard_buffers;
+ break;
default:
pthread_mutex_lock( &this->driver_lock );
@@ -1023,6 +1012,11 @@ static int ao_set_property (xine_audio_port_t *this, int property, int value) {
ret = this->compression_factor_max*100;
break;
+
+ case AO_PROP_DISCARD_BUFFERS:
+ this->discard_buffers = value;
+ ret = this->discard_buffers;
+ break;
default:
pthread_mutex_lock( &this->driver_lock );
@@ -1053,6 +1047,7 @@ static void ao_flush (xine_audio_port_t *this) {
audio_buffer_t *buf;
if( this->audio_loop_running ) {
+ this->discard_buffers = 1;
this->flush_audio_driver = 1;
buf = fifo_remove (this->free_fifo);
@@ -1062,6 +1057,7 @@ static void ao_flush (xine_audio_port_t *this) {
/* do not try this in paused mode */
while( this->flush_audio_driver )
xine_usec_sleep (20000); /* pthread_cond_t could be used here */
+ this->discard_buffers = 0;
}
}
@@ -1095,6 +1091,7 @@ xine_audio_port_t *ao_new_port (xine_t *xine, ao_driver_t *driver) {
this->audio_loop_running = 0;
this->audio_paused = 0;
this->flush_audio_driver = 0;
+ this->discard_buffers = 0;
this->zero_space = xine_xmalloc (ZERO_BUF_SIZE * 2 * 6);
this->gap_tolerance = driver->get_gap_tolerance (this->driver);
diff --git a/src/xine-engine/audio_out.h b/src/xine-engine/audio_out.h
index 99fb40496..fd63e762f 100644
--- a/src/xine-engine/audio_out.h
+++ b/src/xine-engine/audio_out.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: audio_out.h,v 1.44 2002/12/21 12:56:52 miguelfreitas Exp $
+ * $Id: audio_out.h,v 1.45 2002/12/24 14:00:57 miguelfreitas Exp $
*/
#ifndef HAVE_AUDIO_OUT_H
#define HAVE_AUDIO_OUT_H
@@ -253,6 +253,7 @@ struct xine_audio_port_s {
int64_t passthrough_offset;
int flush_audio_driver;
+ int discard_buffers;
int do_compress;
double compression_factor; /* current compression */
@@ -320,6 +321,7 @@ xine_audio_port_t *ao_new_port (xine_t *xine, ao_driver_t *driver) ;
#define AO_PROP_PCM_VOL 1
#define AO_PROP_MUTE_VOL 2
#define AO_PROP_COMPRESSOR 3
+#define AO_PROP_DISCARD_BUFFERS 4
/* audio device control ops */
diff --git a/src/xine-engine/demux.c b/src/xine-engine/demux.c
index 20474d71f..63189d5f4 100644
--- a/src/xine-engine/demux.c
+++ b/src/xine-engine/demux.c
@@ -59,6 +59,10 @@ void xine_demux_flush_engine (xine_stream_t *stream) {
stream->audio_fifo->put (stream->audio_fifo, buf);
}
+ if (stream->audio_out) {
+ stream->audio_out->set_property(stream->audio_out, AO_PROP_DISCARD_BUFFERS, 1);
+ }
+
/* on seeking we must wait decoder fifos to process before doing flush.
* otherwise we flush too early (before the old data has left decoders)
*/
@@ -70,6 +74,7 @@ void xine_demux_flush_engine (xine_stream_t *stream) {
if (stream->audio_out) {
stream->audio_out->flush(stream->audio_out);
+ stream->audio_out->set_property(stream->audio_out, AO_PROP_DISCARD_BUFFERS, 0);
}
}