diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/xine-engine/audio_out.c | 68 | ||||
-rw-r--r-- | src/xine-engine/audio_out.h | 20 | ||||
-rw-r--r-- | src/xine-engine/xine_interface.c | 7 |
3 files changed, 59 insertions, 36 deletions
diff --git a/src/xine-engine/audio_out.c b/src/xine-engine/audio_out.c index 1625eb30b..756e696a2 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.137 2003/07/26 00:27:20 jcdutton Exp $ + * $Id: audio_out.c,v 1.138 2003/08/26 21:18:32 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> @@ -854,6 +854,7 @@ static int resample_rate_adjust(aos_t *this, int64_t gap, audio_buffer_t *buf) { return 0; } +static int ao_change_settings(aos_t *this, uint32_t bits, uint32_t rate, int mode); /* Audio output loop: - * 1) Check for pause. @@ -932,8 +933,21 @@ static void *ao_loop (void *this_gen) { continue; } - + /* change driver's settings as needed */ pthread_mutex_lock( &this->driver_lock ); + if( in_buf && in_buf->num_frames ) { + if( !this->driver_open || + in_buf->format.bits != this->input.bits || + in_buf->format.rate != this->input.rate || + in_buf->format.mode != this->input.mode ) { + lprintf("audio format has changed\n"); + ao_change_settings(this, + in_buf->format.bits, + in_buf->format.rate, + in_buf->format.mode); + } + } + if(this->driver_open) { delay = this->driver->delay(this->driver); while (delay < 0 && this->audio_loop_running) { @@ -1159,17 +1173,10 @@ void xine_free_audio_frame (xine_audio_port_t *this_gen, xine_audio_frame_t *fra static int ao_change_settings(aos_t *this, uint32_t bits, uint32_t rate, int mode) { int output_sample_rate; - if (this->audio_loop_running) { - /* make sure there are no more buffers on queue */ - fifo_wait_empty(this->out_fifo); - } - - pthread_mutex_lock( &this->driver_lock ); if(this->driver_open) this->driver->close(this->driver); this->driver_open = 0; - pthread_mutex_unlock( &this->driver_lock ); - + this->input.mode = mode; this->input.rate = rate; this->input.bits = bits; @@ -1197,10 +1204,8 @@ static int ao_change_settings(aos_t *this, uint32_t bits, uint32_t rate, int mod "stereo not supported by driver, converting to mono.\n"); } - pthread_mutex_lock( &this->driver_lock ); output_sample_rate=this->driver->open(this->driver,bits,(this->force_rate ? this->force_rate : rate),mode); this->driver_open = 1; - pthread_mutex_unlock( &this->driver_lock ); } else output_sample_rate = this->input.rate; @@ -1251,10 +1256,21 @@ static int ao_open(xine_audio_port_t *this_gen, xine_stream_t *stream, aos_t *this = (aos_t *) this_gen; - if( !this->driver_open || bits != this->input.bits || rate != this->input.rate || mode != this->input.mode ) - if( !ao_change_settings(this, bits, rate, mode) ) + if( !this->driver_open || bits != this->input.bits || rate != this->input.rate || mode != this->input.mode ) { + int ret; + + if (this->audio_loop_running) { + /* make sure there are no more buffers on queue */ + fifo_wait_empty(this->out_fifo); + } + + pthread_mutex_lock( &this->driver_lock ); + ret = ao_change_settings(this, bits, rate, mode); + pthread_mutex_unlock( &this->driver_lock ); + if( !ret ) return 0; - + } + pthread_mutex_lock(&this->streams_lock); xine_list_append_content(this->streams, stream); pthread_mutex_unlock(&this->streams_lock); @@ -1315,18 +1331,10 @@ static void ao_put_buffer (xine_audio_port_t *this_gen, return; } - /* change driver's settings if needed */ - if( stream->stream_info[XINE_STREAM_INFO_AUDIO_BITS] != this->input.bits || - stream->stream_info[XINE_STREAM_INFO_AUDIO_SAMPLERATE] != this->input.rate || - stream->stream_info[XINE_STREAM_INFO_AUDIO_MODE] != this->input.mode ) { - lprintf("audio format have changed\n"); - ao_change_settings(this, - stream->stream_info[XINE_STREAM_INFO_AUDIO_BITS], - stream->stream_info[XINE_STREAM_INFO_AUDIO_SAMPLERATE], - stream->stream_info[XINE_STREAM_INFO_AUDIO_MODE]); - } - buf->stream = stream; + buf->format.bits = stream->stream_info[XINE_STREAM_INFO_AUDIO_BITS]; + buf->format.rate = stream->stream_info[XINE_STREAM_INFO_AUDIO_SAMPLERATE]; + buf->format.mode = stream->stream_info[XINE_STREAM_INFO_AUDIO_MODE]; extra_info_merge( buf->extra_info, stream->audio_decoder_extra_info ); pts = buf->vpts; @@ -1621,6 +1629,14 @@ static int ao_set_property (xine_audio_port_t *this_gen, int property, int value ret = this->audio_paused; break; + case AO_PROP_CLOSE_DEVICE: + pthread_mutex_lock( &this->driver_lock ); + if(this->driver_open) + this->driver->close(this->driver); + this->driver_open = 0; + pthread_mutex_unlock( &this->driver_lock ); + break; + default: if (!this->grab_only) { pthread_mutex_lock( &this->driver_lock ); diff --git a/src/xine-engine/audio_out.h b/src/xine-engine/audio_out.h index 8859b454c..8b12d9e3c 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.56 2003/07/22 09:36:03 mroi Exp $ + * $Id: audio_out.h,v 1.57 2003/08/26 21:18:32 miguelfreitas Exp $ */ #ifndef HAVE_AUDIO_OUT_H #define HAVE_AUDIO_OUT_H @@ -138,6 +138,14 @@ struct ao_driver_s { typedef struct extra_info_s extra_info_t; #endif +typedef struct ao_format_s ao_format_t; + +struct ao_format_s { + uint32_t bits; + uint32_t rate; + int mode; +}; + typedef struct audio_fifo_s audio_fifo_t; typedef struct audio_buffer_s audio_buffer_t; @@ -159,14 +167,7 @@ struct audio_buffer_s { xine_stream_t *stream; /* stream that send that buffer */ -}; - -typedef struct ao_format_s ao_format_t; - -struct ao_format_s { - uint32_t bits; - uint32_t rate; - int mode; + ao_format_t format; /* let each buffer carry it's own format info */ }; /* @@ -305,6 +306,7 @@ xine_audio_port_t *ao_new_port (xine_t *xine, ao_driver_t *driver, int grab_only #define AO_PROP_EQ_4000HZ 14 /* equalizer */ #define AO_PROP_EQ_8000HZ 15 /* equalizer */ #define AO_PROP_EQ_16000HZ 16 /* equalizer */ +#define AO_PROP_CLOSE_DEVICE 17 /* force closing audio device */ /* audio device control ops */ #define AO_CTRL_PLAY_PAUSE 0 diff --git a/src/xine-engine/xine_interface.c b/src/xine-engine/xine_interface.c index 19a367f5b..c026bbca1 100644 --- a/src/xine-engine/xine_interface.c +++ b/src/xine-engine/xine_interface.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_interface.c,v 1.56 2003/08/24 08:31:30 f1rmb Exp $ + * $Id: xine_interface.c,v 1.57 2003/08/26 21:18:32 miguelfreitas Exp $ * * convenience/abstraction layer, functions to implement * libxine's public interface @@ -374,6 +374,11 @@ void xine_set_param (xine_stream_t *stream, int param, int value) { stream->audio_out->set_property (stream->audio_out, AO_PROP_AMP, value); break; + case XINE_PARAM_AUDIO_CLOSE_DEVICE: + if (stream->audio_out) + stream->audio_out->set_property (stream->audio_out, AO_PROP_CLOSE_DEVICE, value); + break; + case XINE_PARAM_EQ_30HZ: case XINE_PARAM_EQ_60HZ: case XINE_PARAM_EQ_125HZ: |