diff options
Diffstat (limited to 'src/xine-engine')
-rw-r--r-- | src/xine-engine/audio_out.c | 20 | ||||
-rw-r--r-- | src/xine-engine/audio_out.h | 30 | ||||
-rw-r--r-- | src/xine-engine/xine.c | 57 |
3 files changed, 75 insertions, 32 deletions
diff --git a/src/xine-engine/audio_out.c b/src/xine-engine/audio_out.c index 56f777469..4d97da9d1 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.44 2002/03/11 12:31:26 guenter Exp $ + * $Id: audio_out.c,v 1.45 2002/03/11 19:58:01 jkeil Exp $ * * 22-8-2001 James imported some useful AC3 sections from the previous alsa driver. * (c) 2001 Andy Lo A Foe <andy@alsaplayer.org> @@ -240,7 +240,8 @@ static void *ao_loop (void *this_gen) { int64_t cur_time; int num_output_frames ; int paused_wait; - + + while ((this->audio_loop_running) || (!this->audio_loop_running && this->out_fifo->first)) { @@ -564,6 +565,20 @@ static int ao_set_property (ao_instance_t *this, int property, int value) { return(this->driver->set_property(this->driver, property, value)); } +static int ao_control (ao_instance_t *this, int cmd, ...) { + + va_list args; + void *arg; + int rval; + + va_start(args, cmd); + arg = va_arg(args, void*); + rval = this->driver->control(this->driver, cmd, arg); + va_end(args); + + return rval; +} + ao_instance_t *ao_new_instance (ao_driver_t *driver, xine_t *xine) { config_values_t *config = xine->config; @@ -585,6 +600,7 @@ ao_instance_t *ao_new_instance (ao_driver_t *driver, xine_t *xine) { this->get_capabilities = ao_get_capabilities; this->get_property = ao_get_property; this->set_property = ao_set_property; + this->control = ao_control; this->audio_loop_running = 0; this->audio_paused = 0; /* FIXME: is 4* good enough for all resample cases?? */ diff --git a/src/xine-engine/audio_out.h b/src/xine-engine/audio_out.h index dd820a6f4..471c21a2e 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.25 2002/03/11 12:31:26 guenter Exp $ + * $Id: audio_out.h,v 1.26 2002/03/11 19:58:01 jkeil Exp $ */ #ifndef HAVE_AUDIO_OUT_H #define HAVE_AUDIO_OUT_H @@ -37,7 +37,7 @@ extern "C" { #endif -#define AUDIO_OUT_IFACE_VERSION 3 +#define AUDIO_OUT_IFACE_VERSION 4 /* * ao_driver_s contains the driver every audio output @@ -113,12 +113,19 @@ struct ao_driver_s { * get_property() return 1 in success, 0 on failure. * set_property() return value on success, ~value on failure. * - * See AC_PROP_* bellow for available properties. + * See AO_PROP_* below for available properties. */ int (*get_property) (ao_driver_t *this, int property); - int (*set_property) (ao_driver_t *this, int property, int value); + int (*set_property) (ao_driver_t *this, int property, int value); + + /* + * misc control operations on the audio device. + * + * See AO_CTRL_* below. + */ + int (*control) (ao_driver_t *this, int cmd, /* arg */ ...); }; /* @@ -179,6 +186,14 @@ struct ao_instance_s { /* called on xine exit */ void (*exit) (ao_instance_t *this); + /* + * misc control operations on the audio device. + * + * See AO_CTRL_* below. + */ + int (*control) (ao_driver_t *this, int cmd, /* arg */ ...); + + /* private stuff */ ao_driver_t *driver; @@ -252,6 +267,13 @@ ao_instance_t *ao_new_instance (ao_driver_t *driver, xine_t *xine) ; #define AO_PROP_PCM_VOL 1 #define AO_PROP_MUTE_VOL 2 + +/* audio device control ops */ +#define AO_CTRL_PLAY_PAUSE 0 +#define AO_CTRL_PLAY_RESUME 1 +#define AO_CTRL_FLUSH_BUFFERS 2 + + typedef struct ao_info_s { int interface_version; diff --git a/src/xine-engine/xine.c b/src/xine-engine/xine.c index 691700e91..2e0a2f527 100644 --- a/src/xine-engine/xine.c +++ b/src/xine-engine/xine.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: xine.c,v 1.106 2002/03/11 12:31:26 guenter Exp $ + * $Id: xine.c,v 1.107 2002/03/11 19:58:01 jkeil Exp $ * * top-level xine functions * @@ -144,6 +144,27 @@ static void update_osd_display(void *this_gen, cfg_entry_t *entry) this->osd_display = entry->num_value; } + +static void xine_set_speed_internal (xine_t *this, int speed) { + + this->metronom->set_speed (this->metronom, speed); + + /* see coment on audio_out loop about audio_paused */ + if( this->audio_out ) { + this->audio_out->audio_paused = (speed != SPEED_NORMAL) + + (speed == SPEED_PAUSE); + + if (speed != SPEED_NORMAL && speed != SPEED_PAUSE) + this->audio_out->control(this->audio_out, AO_CTRL_FLUSH_BUFFERS); + + this->audio_out->control(this->audio_out, + speed == SPEED_PAUSE ? AO_CTRL_PLAY_PAUSE : AO_CTRL_PLAY_RESUME); + } + + this->speed = speed; +} + + void xine_stop_internal (xine_t *this) { pthread_mutex_lock (&this->xine_lock); @@ -158,12 +179,10 @@ void xine_stop_internal (xine_t *this) { return; } + if (this->audio_out) + this->audio_out->control(this->audio_out, AO_CTRL_FLUSH_BUFFERS); - this->metronom->set_speed (this->metronom, SPEED_NORMAL); - this->speed = SPEED_NORMAL; - - if( this->audio_out ) - this->audio_out->audio_paused = 0; + xine_set_speed_internal(this, SPEED_NORMAL); this->status = XINE_STOP; LOG_MSG(this, _("xine_stop: stopping demuxer\n")); @@ -300,6 +319,9 @@ int xine_play (xine_t *this, char *mrl, this->cur_input_plugin->stop(this->cur_input_plugin); } + if (this->audio_out) + this->audio_out->control(this->audio_out, AO_CTRL_FLUSH_BUFFERS); + this->status = XINE_STOP; } @@ -378,11 +400,7 @@ int xine_play (xine_t *this, char *mrl, this->status = XINE_PLAY; strncpy (this->cur_mrl, mrl, 1024); - this->metronom->set_speed (this->metronom, SPEED_NORMAL); - - if( this->audio_out ) - this->audio_out->audio_paused = 0; - this->speed = SPEED_NORMAL; + xine_set_speed_internal (this, SPEED_NORMAL); /* osd */ xine_internal_osd (this, ">", 0, 300000); @@ -679,8 +697,6 @@ int xine_get_av_offset (xine_t *this) { void xine_set_speed (xine_t *this, int speed) { - struct timespec tenth_sec; - pthread_mutex_lock (&this->xine_lock); if (speed <= SPEED_PAUSE) @@ -712,21 +728,10 @@ void xine_set_speed (xine_t *this, int speed) { } /* make sure osd can be displayed */ - tenth_sec.tv_sec = 0; - tenth_sec.tv_nsec = 100000000; - - nanosleep (&tenth_sec, NULL); + xine_usec_sleep(100000); LOG_MSG(this, _("xine: set_speed %d\n"), speed); - - this->metronom->set_speed (this->metronom, speed); - - /* see coment on audio_out loop about audio_paused */ - if( this->audio_out ) - this->audio_out->audio_paused = (speed != SPEED_NORMAL) + - (speed == SPEED_PAUSE); - - this->speed = speed; + xine_set_speed_internal (this, speed); pthread_mutex_unlock (&this->xine_lock); } |