diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/audio_out/Makefile.am | 15 | ||||
-rw-r--r-- | src/audio_out/audio_alsa_out.c | 192 | ||||
-rw-r--r-- | src/audio_out/audio_arts_out.c | 24 | ||||
-rw-r--r-- | src/audio_out/audio_esd_out.c | 256 | ||||
-rw-r--r-- | src/audio_out/audio_oss_out.c | 8 | ||||
-rw-r--r-- | src/audio_out/audio_sun_out.c | 176 | ||||
-rw-r--r-- | src/xine-engine/audio_out.c | 15 | ||||
-rw-r--r-- | src/xine-engine/audio_out.h | 10 |
8 files changed, 309 insertions, 387 deletions
diff --git a/src/audio_out/Makefile.am b/src/audio_out/Makefile.am index ae6713e04..a13d56df0 100644 --- a/src/audio_out/Makefile.am +++ b/src/audio_out/Makefile.am @@ -25,9 +25,9 @@ alsa_module = xineplug_ao_out_alsa.la endif endif -#if HAVE_ESD -#esd_module = xineplug_ao_out_esd.la -#endif +if HAVE_ESD +esd_module = xineplug_ao_out_esd.la +endif if HAVE_SUNAUDIO sun_module = xineplug_ao_out_sun.la @@ -50,7 +50,7 @@ endif #lib_LTLIBRARIES = $(oss_module) $(alsa05_module) $(alsa_module) $(sun_module) \ # $(arts_module) $(esd_module) -lib_LTLIBRARIES = $(oss_module) $(alsa_module) $(sun_module) $(arts_module) +lib_LTLIBRARIES = $(oss_module) $(alsa_module) $(esd_module) $(sun_module) $(arts_module) ## $(irixal_module) @@ -65,9 +65,9 @@ xineplug_ao_out_alsa_la_SOURCES = audio_alsa_out.c xineplug_ao_out_alsa_la_LIBADD = $(ALSA_LIBS) xineplug_ao_out_alsa_la_LDFLAGS = -avoid-version -module -#xineplug_ao_out_esd_la_SOURCES = audio_esd_out.c resample.c -#xineplug_ao_out_esd_la_LIBADD = $(ESD_LIBS) -#xineplug_ao_out_esd_la_LDFLAGS = -avoid-version -module +xineplug_ao_out_esd_la_SOURCES = audio_esd_out.c resample.c +xineplug_ao_out_esd_la_LIBADD = $(ESD_LIBS) +xineplug_ao_out_esd_la_LDFLAGS = -avoid-version -module xineplug_ao_out_sun_la_SOURCES = audio_sun_out.c xineplug_ao_out_sun_la_LDFLAGS = -avoid-version -module @@ -101,3 +101,4 @@ maintainer-clean-generic: -@echo "This command is intended for maintainers to use;" -@echo "it deletes files that may require special tools to rebuild." -rm -f Makefile.in + diff --git a/src/audio_out/audio_alsa_out.c b/src/audio_out/audio_alsa_out.c index 3e454f9b6..27b698f1c 100644 --- a/src/audio_out/audio_alsa_out.c +++ b/src/audio_out/audio_alsa_out.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2000 the xine project + * Copyright (C) 2000, 2001 the xine project * * This file is part of xine, a unix video player. * @@ -25,7 +25,7 @@ * (c) 2001 James Courtier-Dutton <James@superbug.demon.co.uk> * * - * $Id: audio_alsa_out.c,v 1.16 2001/08/22 10:51:05 jcdutton Exp $ + * $Id: audio_alsa_out.c,v 1.17 2001/08/24 01:05:30 guenter Exp $ */ #ifdef HAVE_CONFIG_H @@ -75,7 +75,7 @@ #define AO_OUT_ALSA_IFACE_VERSION 2 -#define GAP_TOLERANCE 15000 +#define GAP_TOLERANCE 5000 #define MAX_MASTER_CLOCK_DIV 5000 #define MAX_GAP 90000 @@ -104,9 +104,9 @@ typedef struct alsa_driver_s { /* * open the audio device for writing to */ -static int ao_alsa_open(ao_driver_t *self_gen, uint32_t bits, uint32_t rate, int mode) +static int ao_alsa_open(ao_driver_t *this_gen, uint32_t bits, uint32_t rate, int mode) { - alsa_driver_t *self = (alsa_driver_t *) self_gen; + alsa_driver_t *this = (alsa_driver_t *) this_gen; snd_pcm_stream_t direction = SND_PCM_STREAM_PLAYBACK; snd_pcm_hw_params_t *params; snd_pcm_sw_params_t *swparams; @@ -132,26 +132,26 @@ static int ao_alsa_open(ao_driver_t *self_gen, uint32_t bits, uint32_t rate, int error ("ALSA Driver only supports AC3/stereo output modes at the moment"); return -1; } else { - self->num_channels = 2; + this->num_channels = 2; } - if (self->audio_fd != NULL) { + if (this->audio_fd != NULL) { error ("Already open...WHY!"); - snd_pcm_close (self->audio_fd); + snd_pcm_close (this->audio_fd); } - self->open_mode = mode; - self->input_sample_rate = rate; - self->bits_per_sample = bits; - self->bytes_in_buffer = 0; - self->output_rate_correction = 0; - self->audio_started = 0; + this->open_mode = mode; + this->input_sample_rate = rate; + this->bits_per_sample = bits; + this->bytes_in_buffer = 0; + this->output_rate_correction = 0; + this->audio_started = 0; /* FIXME: Can use an ALSA function here */ - self->bytes_per_frame=(self->bits_per_sample*self->num_channels)/8; + this->bytes_per_frame=(this->bits_per_sample*this->num_channels)/8; /* * open audio device */ - err=snd_pcm_open(&self->audio_fd, self->audio_dev, direction, open_mode); + err=snd_pcm_open(&this->audio_fd, this->audio_dev, direction, open_mode); if(err <0 ) { error("snd_pcm_open() failed: %s", snd_strerror(err)); error(">>> Check if another program don't already use PCM <<<"); @@ -162,7 +162,7 @@ static int ao_alsa_open(ao_driver_t *self_gen, uint32_t bits, uint32_t rate, int snd_pcm_info_alloca(&info); - if ((err = snd_pcm_info(self->audio_fd, info)) < 0) { + if ((err = snd_pcm_info(this->audio_fd, info)) < 0) { fprintf(stderr, "info: %s\n", snd_strerror(err)); goto __close; } @@ -207,38 +207,38 @@ static int ao_alsa_open(ao_driver_t *self_gen, uint32_t bits, uint32_t rate, int /* We wanted non blocking open but now put it back to normal */ - snd_pcm_nonblock(self->audio_fd, 0); + snd_pcm_nonblock(this->audio_fd, 0); /* * configure audio device */ - err = snd_pcm_hw_params_any(self->audio_fd, params); + err = snd_pcm_hw_params_any(this->audio_fd, params); if (err < 0) { error("Broken configuration for this PCM: no configurations available"); goto __close; } /* set interleaved access */ - err = snd_pcm_hw_params_set_access(self->audio_fd, params, + err = snd_pcm_hw_params_set_access(this->audio_fd, params, SND_PCM_ACCESS_RW_INTERLEAVED); if (err < 0) { error("Access type not available"); goto __close; } - err = snd_pcm_hw_params_set_format(self->audio_fd, params, bits == 16 ? SND_PCM_FORMAT_S16_LE : SND_PCM_FORMAT_U8); + err = snd_pcm_hw_params_set_format(this->audio_fd, params, bits == 16 ? SND_PCM_FORMAT_S16_LE : SND_PCM_FORMAT_U8); if (err < 0) { error("Sample format non available"); goto __close; } - err = snd_pcm_hw_params_set_channels(self->audio_fd, params, self->num_channels); + err = snd_pcm_hw_params_set_channels(this->audio_fd, params, this->num_channels); if (err < 0) { error("Channels count non available"); goto __close; } - err = snd_pcm_hw_params_set_rate_near(self->audio_fd, params, rate, 0); + err = snd_pcm_hw_params_set_rate_near(this->audio_fd, params, rate, 0); if (err < 0) { error("Rate not available"); goto __close; } - buffer_time = snd_pcm_hw_params_set_buffer_time_near(self->audio_fd, params, + buffer_time = snd_pcm_hw_params_set_buffer_time_near(this->audio_fd, params, 500000, 0); if (buffer_time < 0) { error("Buffer time not available"); @@ -248,11 +248,11 @@ static int ao_alsa_open(ao_driver_t *self_gen, uint32_t bits, uint32_t rate, int period_time = 10000 * 2; do { period_time /= 2; - tmp = snd_pcm_hw_params_set_period_time_near(self->audio_fd, params, + tmp = snd_pcm_hw_params_set_period_time_near(this->audio_fd, params, period_time, 0); if (tmp == period_time) { period_time /= 3; - tmp = snd_pcm_hw_params_set_period_time_near(self->audio_fd, params, + tmp = snd_pcm_hw_params_set_period_time_near(this->audio_fd, params, period_time, 0); if (tmp == period_time) period_time = 10000 * 2; @@ -266,7 +266,7 @@ static int ao_alsa_open(ao_driver_t *self_gen, uint32_t bits, uint32_t rate, int error("Buffer time and period time match, could not use"); goto __close; } - if ((err = snd_pcm_hw_params(self->audio_fd, params)) < 0) { + if ((err = snd_pcm_hw_params(this->audio_fd, params)) < 0) { error("PCM hw_params failed: %s", snd_strerror(err)); goto __close; } @@ -274,61 +274,64 @@ static int ao_alsa_open(ao_driver_t *self_gen, uint32_t bits, uint32_t rate, int - self->output_sample_rate = self->input_sample_rate; - self->sample_rate_factor = (double) self->output_sample_rate / (double) self->input_sample_rate; + this->output_sample_rate = this->input_sample_rate; + this->sample_rate_factor = (double) this->output_sample_rate / (double) this->input_sample_rate; /* * audio buffer size handling */ /* Copy current parameters into swparams */ - snd_pcm_sw_params_current(self->audio_fd, swparams); - tmp=snd_pcm_sw_params_set_xfer_align(self->audio_fd, swparams, 4); - tmp=snd_pcm_sw_params_set_avail_min(self->audio_fd, swparams, 1); - tmp=snd_pcm_sw_params_set_start_threshold(self->audio_fd, swparams, 1); + snd_pcm_sw_params_current(this->audio_fd, swparams); + tmp=snd_pcm_sw_params_set_xfer_align(this->audio_fd, swparams, 4); + tmp=snd_pcm_sw_params_set_avail_min(this->audio_fd, swparams, 1); + tmp=snd_pcm_sw_params_set_start_threshold(this->audio_fd, swparams, 1); /* Install swparams into current parameters */ - snd_pcm_sw_params(self->audio_fd, swparams); + snd_pcm_sw_params(this->audio_fd, swparams); - snd_pcm_dump_setup(self->audio_fd, jcd_out); + snd_pcm_dump_setup(this->audio_fd, jcd_out); snd_pcm_sw_params_dump(swparams, jcd_out); - // write_pause_burst(self,0); + // write_pause_burst(this,0); return 1; __close: - snd_pcm_close (self->audio_fd); - self->audio_fd=NULL; + snd_pcm_close (this->audio_fd); + this->audio_fd=NULL; return -1; } -static int ao_alsa_num_channels(ao_driver_t *self_gen) +static int ao_alsa_num_channels(ao_driver_t *this_gen) { - alsa_driver_t *self = (alsa_driver_t *) self_gen; - return self->num_channels; + alsa_driver_t *this = (alsa_driver_t *) this_gen; + return this->num_channels; } -static int ao_alsa_bytes_per_frame(ao_driver_t *self_gen) +static int ao_alsa_bytes_per_frame(ao_driver_t *this_gen) { - alsa_driver_t *self = (alsa_driver_t *) self_gen; - return self->bytes_per_frame; + alsa_driver_t *this = (alsa_driver_t *) this_gen; + return this->bytes_per_frame; } +static int ao_alsa_get_gap_tolerance (ao_driver_t *this_gen) +{ + return GAP_TOLERANCE; +} - -static int ao_alsa_delay (ao_driver_t *self_gen) +static int ao_alsa_delay (ao_driver_t *this_gen) { snd_pcm_sframes_t pos ; snd_pcm_status_t *pcm_stat; snd_pcm_sframes_t delay; int err; - alsa_driver_t *self = (alsa_driver_t *) self_gen; + alsa_driver_t *this = (alsa_driver_t *) this_gen; snd_pcm_status_alloca(&pcm_stat); - snd_pcm_status(self->audio_fd, pcm_stat); + snd_pcm_status(this->audio_fd, pcm_stat); /* Dump ALSA info to stderr */ /* snd_pcm_status_dump(pcm_stat, jcd_out); */ - if (self->audio_started) { - err=snd_pcm_delay( self->audio_fd, &delay); + if (this->audio_started) { + err=snd_pcm_delay( this->audio_fd, &delay); if(err < 0) { //Hide error report error("snd_pcm_delay() failed"); @@ -338,13 +341,13 @@ static int ao_alsa_delay (ao_driver_t *self_gen) return delay; } -void xrun(alsa_driver_t *self) +void xrun(alsa_driver_t *this) { snd_pcm_status_t *status; int res; snd_pcm_status_alloca(&status); - if ((res = snd_pcm_status(self->audio_fd, status))<0) { + if ((res = snd_pcm_status(this->audio_fd, status))<0) { printf("status error: %s", snd_strerror(res)); return; } @@ -355,7 +358,7 @@ void xrun(alsa_driver_t *self) timersub(&now, &tstamp, &diff); fprintf(stderr, "xrun!!! (at least %.3f ms long)\n", diff.tv_sec * 1000 + diff.tv_usec / 1000.0); - if ((res = snd_pcm_prepare(self->audio_fd))<0) { + if ((res = snd_pcm_prepare(this->audio_fd))<0) { printf("xrun: prepare error: %s", snd_strerror(res)); return; } @@ -363,51 +366,51 @@ void xrun(alsa_driver_t *self) } } -static int ao_alsa_write(ao_driver_t *self_gen,int16_t *data, uint32_t count) +static int ao_alsa_write(ao_driver_t *this_gen,int16_t *data, uint32_t count) { ssize_t r; - alsa_driver_t *self = (alsa_driver_t *) self_gen; + alsa_driver_t *this = (alsa_driver_t *) this_gen; while( count > 0) { - r = snd_pcm_writei(self->audio_fd, data, count); + r = snd_pcm_writei(this->audio_fd, data, count); if (r == -EAGAIN || (r >=0 && r < count)) { - snd_pcm_wait(self->audio_fd, 1000); + snd_pcm_wait(this->audio_fd, 1000); } else if (r == -EPIPE) { - xrun(self); + xrun(this); } if (r > 0) { count -= r; /* FIXME: maybe not *2 as int16 */ - data += r * 2 * self->num_channels; + data += r * 2 * this->num_channels; } } /* FIXME: What should this really be? */ return 1; } -static void ao_alsa_close(ao_driver_t *self_gen) +static void ao_alsa_close(ao_driver_t *this_gen) { - alsa_driver_t *self = (alsa_driver_t *) self_gen; - if(self->audio_fd) snd_pcm_close(self->audio_fd); - self->audio_fd = NULL; + alsa_driver_t *this = (alsa_driver_t *) this_gen; + if(this->audio_fd) snd_pcm_close(this->audio_fd); + this->audio_fd = NULL; } -static uint32_t ao_alsa_get_capabilities (ao_driver_t *self_gen) { - alsa_driver_t *self = (alsa_driver_t *) self_gen; - return self->capabilities; +static uint32_t ao_alsa_get_capabilities (ao_driver_t *this_gen) { + alsa_driver_t *this = (alsa_driver_t *) this_gen; + return this->capabilities; } -static void ao_alsa_exit(ao_driver_t *self_gen) +static void ao_alsa_exit(ao_driver_t *this_gen) { - alsa_driver_t *self = (alsa_driver_t *) self_gen; - if (self->audio_fd) snd_pcm_close(self->audio_fd); - free (self); + alsa_driver_t *this = (alsa_driver_t *) this_gen; + if (this->audio_fd) snd_pcm_close(this->audio_fd); + free (this); } /* * */ -static int ao_alsa_get_property (ao_driver_t *self, int property) { +static int ao_alsa_get_property (ao_driver_t *this, int property) { /* FIXME: implement some properties switch(property) { @@ -425,7 +428,7 @@ static int ao_alsa_get_property (ao_driver_t *self, int property) { /* * */ -static int ao_alsa_set_property (ao_driver_t *self, int property, int value) { +static int ao_alsa_set_property (ao_driver_t *this, int property, int value) { /* FIXME: Implement property support. switch(property) { @@ -443,20 +446,20 @@ static int ao_alsa_set_property (ao_driver_t *self, int property, int value) { ao_driver_t *init_audio_out_plugin (config_values_t *config) { - alsa_driver_t *self; + alsa_driver_t *this; int card; int dev; int err; char *pcm_device; char *ac3_device; - self = (alsa_driver_t *) malloc (sizeof (alsa_driver_t)); + this = (alsa_driver_t *) malloc (sizeof (alsa_driver_t)); pcm_device = config->lookup_str(config,"alsa_pcm_device", "hw:0,0"); ac3_device = config->lookup_str(config,"alsa_ac3_device", "hw:0,2"); - strcpy(self->audio_dev,pcm_device); + strcpy(this->audio_dev,pcm_device); /* * find best device driver/channel @@ -465,34 +468,35 @@ ao_driver_t *init_audio_out_plugin (config_values_t *config) { * open that device */ - err=snd_pcm_open(&self->audio_fd, self->audio_dev, SND_PCM_STREAM_PLAYBACK, 0); + err=snd_pcm_open(&this->audio_fd, this->audio_dev, SND_PCM_STREAM_PLAYBACK, 0); if(err <0 ) { error("snd_pcm_open() failed: %d", err); error(">>> Check if another program don't already use PCM <<<"); return NULL; } - snd_pcm_close (self->audio_fd); - self->audio_fd=NULL; - self->output_sample_rate = 0; - self->capabilities = AO_CAP_MODE_STEREO; + snd_pcm_close (this->audio_fd); + this->audio_fd=NULL; + this->output_sample_rate = 0; + this->capabilities = AO_CAP_MODE_STEREO; if (config->lookup_int (config, "ac3_pass_through", 0)) { - self->capabilities |= AO_CAP_MODE_AC3; - strcpy(self->audio_dev,ac3_device); + this->capabilities |= AO_CAP_MODE_AC3; + strcpy(this->audio_dev,ac3_device); printf("AC3 pass through activated\n"); } - self->ao_driver.get_capabilities = ao_alsa_get_capabilities; - self->ao_driver.get_property = ao_alsa_get_property; - self->ao_driver.set_property = ao_alsa_set_property; - self->ao_driver.open = ao_alsa_open; - self->ao_driver.num_channels = ao_alsa_num_channels; - self->ao_driver.bytes_per_frame = ao_alsa_bytes_per_frame; - self->ao_driver.delay = ao_alsa_delay; - self->ao_driver.write = ao_alsa_write; - self->ao_driver.close = ao_alsa_close; - self->ao_driver.exit = ao_alsa_exit; - - return &self->ao_driver; + this->ao_driver.get_capabilities = ao_alsa_get_capabilities; + this->ao_driver.get_property = ao_alsa_get_property; + this->ao_driver.set_property = ao_alsa_set_property; + this->ao_driver.open = ao_alsa_open; + this->ao_driver.num_channels = ao_alsa_num_channels; + this->ao_driver.bytes_per_frame = ao_alsa_bytes_per_frame; + this->ao_driver.delay = ao_alsa_delay; + this->ao_driver.write = ao_alsa_write; + this->ao_driver.close = ao_alsa_close; + this->ao_driver.exit = ao_alsa_exit; + this->ao_driver.get_gap_tolerance = ao_alsa_get_gap_tolerance; + + return &this->ao_driver; } static ao_info_t ao_info_alsa9 = { diff --git a/src/audio_out/audio_arts_out.c b/src/audio_out/audio_arts_out.c index e92bc7e9c..0bf7c5f90 100644 --- a/src/audio_out/audio_arts_out.c +++ b/src/audio_out/audio_arts_out.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: audio_arts_out.c,v 1.3 2001/08/23 19:36:41 jcdutton Exp $ + * $Id: audio_arts_out.c,v 1.4 2001/08/24 01:05:30 guenter Exp $ */ /* required for swab() */ @@ -81,13 +81,13 @@ static int ao_arts_open(ao_driver_t *this_gen, if ( (mode & this->capabilities) == 0 ) { printf ("audio_arts_out: unsupported mode %08x\n", mode); - return -1; + return 0; } if (this->audio_stream) { if ( (mode == this->mode) && (rate == this->sample_rate) ) - return 1; + return this->sample_rate; arts_close_stream(this->audio_stream); } @@ -121,7 +121,7 @@ static int ao_arts_open(ao_driver_t *this_gen, printf ("audio_arts_out : latency %d ms\n", this->latency); - return 1; + return this->sample_rate; } @@ -134,7 +134,12 @@ static int ao_arts_num_channels(ao_driver_t *this_gen) static int ao_arts_bytes_per_frame(ao_driver_t *this_gen) { arts_driver_t *this = (arts_driver_t *) this_gen; - return this->bytes_per_frame; + return this->bytes_per_frame; +} + +static int ao_arts_get_gap_tolerance (ao_driver_t *this_gen) +{ + return GAP_TOLERANCE; } static int ao_arts_write(ao_driver_t *this_gen, int16_t *data, @@ -157,8 +162,10 @@ static int ao_arts_delay (ao_driver_t *this_gen) get the current buffer utilization. This is, at best, a very roughly aproximation. */ - return this->latency * this->sample_rate / 1000; -// return 0; + + return arts_stream_get (this->audio_stream, ARTS_P_TOTAL_LATENCY) * this->sample_rate / 1000; + +/* return this->latency * this->sample_rate / 1000; */ } static void ao_arts_close(ao_driver_t *this_gen) @@ -261,7 +268,8 @@ ao_driver_t *init_audio_out_plugin (config_values_t *config) { this->ao_driver.write = ao_arts_write; this->ao_driver.close = ao_arts_close; this->ao_driver.exit = ao_arts_exit; - + this->ao_driver.get_gap_tolerance = ao_arts_get_gap_tolerance; + return &this->ao_driver; } diff --git a/src/audio_out/audio_esd_out.c b/src/audio_out/audio_esd_out.c index 4669c5b32..8434e91c8 100644 --- a/src/audio_out/audio_esd_out.c +++ b/src/audio_out/audio_esd_out.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: audio_esd_out.c,v 1.6 2001/08/14 01:38:17 guenter Exp $ + * $Id: audio_esd_out.c,v 1.7 2001/08/24 01:05:30 guenter Exp $ */ #ifdef HAVE_CONFIG_H @@ -43,17 +43,9 @@ #define AO_OUT_ESD_IFACE_VERSION 1 -#define AUDIO_NUM_FRAGMENTS 15 -#define AUDIO_FRAGMENT_SIZE 8192 +typedef struct esd_driver_s { -#define GAP_TOLERANCE 15000 -#define MAX_GAP 90000 - -typedef struct esd_functions_s { - - ao_functions_t ao_functions; - - metronom_t *metronom; + ao_driver_t ao_driver; int audio_fd; int capabilities; @@ -62,52 +54,40 @@ typedef struct esd_functions_s { int32_t output_sample_rate, input_sample_rate; double sample_rate_factor; uint32_t num_channels; + uint32_t bytes_per_frame; - uint32_t bytes_in_buffer; /* number of bytes writen to audio hardware */ - - int audio_step; /* pts per 32 768 samples (sample = #bytes/2) */ - int32_t bytes_per_kpts; /* bytes per 1024/90000 sec */ - - uint16_t *sample_buffer; - int16_t *zero_space; - - int audio_started; - uint32_t last_audio_vpts; - - uint32_t latency; + int latency, gap_tolerance; -} esd_functions_t; +} esd_driver_t; /* * connect to esd */ -static int ao_open(ao_functions_t *this_gen, - uint32_t bits, uint32_t rate, int mode) +static int ao_esd_open(ao_driver_t *this_gen, + uint32_t bits, uint32_t rate, int mode) { - esd_functions_t *this = (esd_functions_t *) this_gen; + esd_driver_t *this = (esd_driver_t *) this_gen; esd_format_t format; - printf ("audio_esd_out: ao_open bits=%d rate=%d, mode=%d\n", bits, rate, mode); + printf ("audio_esd_out: ao_open bits=%d rate=%d, mode=%d\n", + bits, rate, mode); if ( (mode & this->capabilities) == 0 ) { printf ("audio_esd_out: unsupported mode %08x\n", mode); - return -1; + return 0; } if (this->audio_fd>=0) { if ( (mode == this->mode) && (rate == this->input_sample_rate) ) - return 1; + return this->output_sample_rate; close (this->audio_fd); } this->mode = mode; this->input_sample_rate = rate; - this->bytes_in_buffer = 0; - this->audio_started = 0; - this->last_audio_vpts = 0; this->output_sample_rate = rate; /* @@ -127,6 +107,8 @@ static int ao_open(ao_functions_t *this_gen, } printf ("audio_esd_out: %d channels output\n",this->num_channels); + this->bytes_per_frame=(bits*this->num_channels)/8; + if (this->output_sample_rate > 44100) this->output_sample_rate = 44100; @@ -135,176 +117,81 @@ static int ao_open(ao_functions_t *this_gen, if (this->audio_fd < 0) { printf("audio_esd_out: connecting to ESD server %s: %s\n", getenv("ESPEAKER"), strerror(errno)); - return -1; + return 0; } - this->sample_rate_factor = (double) this->output_sample_rate / (double) this->input_sample_rate; - this->audio_step = (uint32_t) 90000 * (uint32_t) 32768 - / this->input_sample_rate; - this->bytes_per_kpts = this->output_sample_rate * this->num_channels * 2 * 1024 / 90000; - - printf ("audio_out : audio_step %d pts per 32768 samples\n", this->audio_step); + return this->output_sample_rate; +} - return 1; +static int ao_esd_num_channels(ao_driver_t *this_gen) +{ + esd_driver_t *this = (esd_driver_t *) this_gen; + return this->num_channels; } -static void ao_fill_gap (esd_functions_t *this, uint32_t pts_len) { +static int ao_esd_bytes_per_frame(ao_driver_t *this_gen) +{ + esd_driver_t *this = (esd_driver_t *) this_gen; + return this->bytes_per_frame; +} - int num_bytes ; - if (pts_len > MAX_GAP) - pts_len = MAX_GAP; - num_bytes = pts_len * this->bytes_per_kpts / 1024; - num_bytes = (num_bytes / (2*this->num_channels)) * (2*this->num_channels); +static int ao_esd_delay(ao_driver_t *this_gen) +{ + esd_driver_t *this = (esd_driver_t *) this_gen; - printf ("audio_esd_out: inserting %d 0-bytes to fill a gap of %d pts\n",num_bytes, pts_len); - - this->bytes_in_buffer += num_bytes; - - while (num_bytes>0) { - if (num_bytes>8192) { - write(this->audio_fd, this->zero_space, 8192); - num_bytes -= 8192; - } else { - write(this->audio_fd, this->zero_space, num_bytes); - num_bytes = 0; - } - } + return this->latency; } -static int ao_write_audio_data(ao_functions_t *this_gen, - int16_t* output_samples, uint32_t num_samples, - uint32_t pts_) +static int ao_esd_write(ao_driver_t *this_gen, + int16_t* frame_buffer, uint32_t num_frames) { - esd_functions_t *this = (esd_functions_t *) this_gen; - uint32_t vpts, buffer_vpts; - int32_t gap; - int bDropPackage; + esd_driver_t *this = (esd_driver_t *) this_gen; if (this->audio_fd<0) return 1; - vpts = this->metronom->got_audio_samples (this->metronom, pts_, num_samples); - - xprintf (VERBOSE|AUDIO, "audio_esd_out: got %d samples, vpts=%d\n", - num_samples, vpts); - - if (vpts<this->last_audio_vpts) { - /* reject this */ - - return 1; - } - - this->last_audio_vpts = vpts; - - /* - * where, in the timeline is the "end" of the audio buffer at the moment? - */ - - buffer_vpts = this->metronom->get_current_time (this->metronom); - - buffer_vpts += 3000; /* FIXME - esd doesn't have sync capabilities */ - - /* - printf ("audio_esd_out: got audio package vpts = %d, buffer_vpts = %d\n", - vpts, buffer_vpts); - */ - - /* - * calculate gap: - */ - - gap = vpts - buffer_vpts; - - bDropPackage = 0; - - if (gap>GAP_TOLERANCE) { - ao_fill_gap (this, gap); - - /* keep xine responsive */ - - if (gap>MAX_GAP) - return 0; - - } else if (gap<-GAP_TOLERANCE) { - bDropPackage = 1; - } - - /* - * resample and output samples - */ - - if (!bDropPackage) { - int num_output_samples = num_samples * (this->output_sample_rate) / this->input_sample_rate; - - switch (this->mode) { - case AO_CAP_MODE_MONO: - audio_out_resample_mono (output_samples, num_samples, - this->sample_buffer, num_output_samples); - write(this->audio_fd, this->sample_buffer, num_output_samples * 2); - break; - case AO_CAP_MODE_STEREO: - audio_out_resample_stereo (output_samples, num_samples, - this->sample_buffer, num_output_samples); - write(this->audio_fd, this->sample_buffer, num_output_samples * 4); - break; - } - - xprintf (AUDIO|VERBOSE, "audio_esd_out :audio package written\n"); - - /* - * step values - */ - - this->bytes_in_buffer += num_output_samples * 2 * this->num_channels; - this->audio_started = 1; - } else { - printf ("audio_esd_out: audio package (vpts = %d) dropped\n", vpts); - } + write(this->audio_fd, frame_buffer, num_frames * this->bytes_per_frame); return 1; - } -static void ao_close(ao_functions_t *this_gen) +static void ao_esd_close(ao_driver_t *this_gen) { - esd_functions_t *this = (esd_functions_t *) this_gen; + esd_driver_t *this = (esd_driver_t *) this_gen; esd_close(this->audio_fd); this->audio_fd = -1; } -static uint32_t ao_get_capabilities (ao_functions_t *this_gen) { - esd_functions_t *this = (esd_functions_t *) this_gen; +static uint32_t ao_esd_get_capabilities (ao_driver_t *this_gen) { + esd_driver_t *this = (esd_driver_t *) this_gen; return this->capabilities; } -static void ao_connect (ao_functions_t *this_gen, metronom_t *metronom) { - esd_functions_t *this = (esd_functions_t *) this_gen; - - this->metronom = metronom; +static int ao_esd_get_gap_tolerance (ao_driver_t *this_gen) { + esd_driver_t *this = (esd_driver_t *) this_gen; + return this->gap_tolerance ; } -static void ao_exit(ao_functions_t *this_gen) +static void ao_esd_exit(ao_driver_t *this_gen) { - esd_functions_t *this = (esd_functions_t *) this_gen; + esd_driver_t *this = (esd_driver_t *) this_gen; if (this->audio_fd != -1) esd_close(this->audio_fd); - free (this->sample_buffer); - free (this->zero_space); free (this); } -static int ao_get_property (ao_functions_t *this, int property) { +static int ao_esd_get_property (ao_driver_t *this, int property) { /* FIXME: implement some properties */ return 0; } -static int ao_set_property (ao_functions_t *this, int property, int value) { +static int ao_esd_set_property (ao_driver_t *this, int property, int value) { /* FIXME: Implement property support. */ @@ -312,10 +199,10 @@ static int ao_set_property (ao_functions_t *this, int property, int value) { return ~value; } -ao_functions_t *init_audio_out_plugin (config_values_t *config) { +ao_driver_t *init_audio_out_plugin (config_values_t *config) { - esd_functions_t *this; - int audio_fd; + esd_driver_t *this; + int audio_fd; /* * open stream to ESD server @@ -324,11 +211,10 @@ ao_functions_t *init_audio_out_plugin (config_values_t *config) { xprintf(VERBOSE|AUDIO, "Connecting to ESD server..."); audio_fd = esd_open_sound(NULL); - if(audio_fd < 0) - { + if(audio_fd < 0) { char *server = getenv("ESPEAKER"); - // print a message so the user knows why ESD failed + /* print a message so the user knows why ESD failed */ printf("audio_esd_out: can't connect to %s ESD server: %s\n", server ? server : "local", strerror(errno)); @@ -338,30 +224,30 @@ ao_functions_t *init_audio_out_plugin (config_values_t *config) { esd_close(audio_fd); - this = (esd_functions_t *) malloc (sizeof (esd_functions_t)); + this = (esd_driver_t *) malloc (sizeof (esd_driver_t)); this->output_sample_rate = 0; - this->audio_fd = -1; - this->capabilities = AO_CAP_MODE_MONO | AO_CAP_MODE_STEREO; - - this->sample_buffer = malloc (40000); - memset (this->sample_buffer, 0, 40000); - this->zero_space = malloc (8192); - memset (this->zero_space, 0, 8192); - - this->ao_functions.get_capabilities = ao_get_capabilities; - this->ao_functions.get_property = ao_get_property; - this->ao_functions.set_property = ao_set_property; - this->ao_functions.connect = ao_connect; - this->ao_functions.open = ao_open; - this->ao_functions.write_audio_data = ao_write_audio_data; - this->ao_functions.close = ao_close; - this->ao_functions.exit = ao_exit; - - return &this->ao_functions; + this->audio_fd = -1; + this->capabilities = AO_CAP_MODE_MONO | AO_CAP_MODE_STEREO; + this->latency = config->lookup_int (config, "esd_latency", 30000); + this->gap_tolerance = config->lookup_int (config, "esd_gap_tolerance", 15000); + + this->ao_driver.get_capabilities = ao_esd_get_capabilities; + this->ao_driver.get_property = ao_esd_get_property; + this->ao_driver.set_property = ao_esd_set_property; + this->ao_driver.open = ao_esd_open; + this->ao_driver.num_channels = ao_esd_num_channels; + this->ao_driver.bytes_per_frame = ao_esd_bytes_per_frame; + this->ao_driver.get_gap_tolerance = ao_esd_get_gap_tolerance; + this->ao_driver.delay = ao_esd_delay; + this->ao_driver.write = ao_esd_write; + this->ao_driver.close = ao_esd_close; + this->ao_driver.exit = ao_esd_exit; + + return &this->ao_driver; } static ao_info_t ao_info_esd = { - AUDIO_OUT_IFACE_VERSION, + AO_OUT_ESD_IFACE_VERSION, "esd", "xine audio output plugin using esd", 5 diff --git a/src/audio_out/audio_oss_out.c b/src/audio_out/audio_oss_out.c index 76abc62e8..006ec600f 100644 --- a/src/audio_out/audio_oss_out.c +++ b/src/audio_out/audio_oss_out.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: audio_oss_out.c,v 1.32 2001/08/23 21:40:05 guenter Exp $ + * $Id: audio_oss_out.c,v 1.33 2001/08/24 01:05:30 guenter Exp $ * * 20-8-2001 First implementation of Audio sync and Audio driver separation. * Copyright (C) 2001 James Courtier-Dutton James@superbug.demon.co.uk @@ -292,6 +292,11 @@ static int ao_oss_bytes_per_frame(ao_driver_t *this_gen) return this->bytes_per_frame; } +static int ao_oss_get_gap_tolerance (ao_driver_t *this_gen) +{ + return GAP_TOLERANCE; +} + static int ao_oss_delay(ao_driver_t *this_gen) { count_info info; @@ -568,6 +573,7 @@ ao_driver_t *init_audio_out_plugin (config_values_t *config) { this->ao_driver.write = ao_oss_write; this->ao_driver.close = ao_oss_close; this->ao_driver.exit = ao_oss_exit; + this->ao_driver.get_gap_tolerance = ao_oss_get_gap_tolerance; return &this->ao_driver; } diff --git a/src/audio_out/audio_sun_out.c b/src/audio_out/audio_sun_out.c index eac29f8c4..e53c9d4dd 100644 --- a/src/audio_out/audio_sun_out.c +++ b/src/audio_out/audio_sun_out.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: audio_sun_out.c,v 1.6 2001/08/23 15:21:07 jkeil Exp $ + * $Id: audio_sun_out.c,v 1.7 2001/08/24 01:05:30 guenter Exp $ */ #ifdef HAVE_CONFIG_H @@ -206,44 +206,44 @@ error: /* * open the audio device for writing to */ -static int ao_sun_open(ao_driver_t *self_gen, +static int ao_sun_open(ao_driver_t *this_gen, uint32_t bits, uint32_t rate, int mode) { - sun_driver_t *self = (sun_driver_t *) self_gen; + sun_driver_t *this = (sun_driver_t *) this_gen; audio_info_t info; printf ("audio_sun_out: ao_sun_open rate=%d, mode=%d\n", rate, mode); - if ( (mode & self->capabilities) == 0 ) { + if ( (mode & this->capabilities) == 0 ) { printf ("audio_sun_out: unsupported mode %08x\n", mode); - return -1; + return 0; } - if (self->audio_fd > -1) { + if (this->audio_fd > -1) { - if ( (mode == self->mode) && (rate == self->input_sample_rate) ) - return 1; + if ( (mode == this->mode) && (rate == this->input_sample_rate) ) + return this->output_sample_rate; - close (self->audio_fd); + close (this->audio_fd); } - self->mode = mode; - self->input_sample_rate = rate; - self->frames_in_buffer = 0; + this->mode = mode; + this->input_sample_rate = rate; + this->frames_in_buffer = 0; /* * open audio device */ - self->audio_fd=open(self->audio_dev,O_WRONLY|O_NDELAY); - if(self->audio_fd < 0) { + this->audio_fd=open(this->audio_dev,O_WRONLY|O_NDELAY); + if(this->audio_fd < 0) { printf("audio_sun_out: Opening audio device %s: %s\n", - self->audio_dev, strerror(errno)); - return -1; + this->audio_dev, strerror(errno)); + return 0; } /* We wanted non blocking open but now put it back to normal */ - fcntl(self->audio_fd, F_SETFL, fcntl(self->audio_fd, F_GETFL)&~O_NDELAY); + fcntl(this->audio_fd, F_SETFL, fcntl(this->audio_fd, F_GETFL)&~O_NDELAY); /* * configure audio device @@ -255,111 +255,116 @@ static int ao_sun_open(ao_driver_t *self_gen, : AUDIO_CHANNELS_MONO; info.play.precision = bits; info.play.encoding = AUDIO_ENCODING_LINEAR; - info.play.sample_rate = self->input_sample_rate; + info.play.sample_rate = this->input_sample_rate; info.play.eof = 0; info.play.samples = 0; - ioctl(self->audio_fd, AUDIO_SETINFO, &info); + ioctl(this->audio_fd, AUDIO_SETINFO, &info); - self->output_sample_rate = info.play.sample_rate; - self->num_channels = info.play.channels; + this->output_sample_rate = info.play.sample_rate; + this->num_channels = info.play.channels; - self->bytes_per_frame = 1; + this->bytes_per_frame = 1; if (info.play.channels == AUDIO_CHANNELS_STEREO) - self->bytes_per_frame *= 2; + this->bytes_per_frame *= 2; if (info.play.precision == 16) - self->bytes_per_frame *= 2; + this->bytes_per_frame *= 2; xprintf (VERBOSE|AUDIO, "audio_sun_out: audio rate : %d requested, %d provided by device/sec\n", - self->input_sample_rate, self->output_sample_rate); + this->input_sample_rate, this->output_sample_rate); - printf ("audio_sun_out : %d channels output\n",self->num_channels); + printf ("audio_sun_out : %d channels output\n",this->num_channels); - return 1; + return this->output_sample_rate; } -static int ao_sun_num_channels(ao_driver_t *self_gen) +static int ao_sun_num_channels(ao_driver_t *this_gen) { - sun_driver_t *self = (sun_driver_t *) self_gen; - return self->num_channels; + sun_driver_t *this = (sun_driver_t *) this_gen; + return this->num_channels; } -static int ao_sun_bytes_per_frame(ao_driver_t *self_gen) +static int ao_sun_bytes_per_frame(ao_driver_t *this_gen) { - sun_driver_t *self = (sun_driver_t *) self_gen; - return self->bytes_per_frame; + sun_driver_t *this = (sun_driver_t *) this_gen; + return this->bytes_per_frame; } -static int ao_sun_delay(ao_driver_t *self_gen) +static int ao_sun_delay(ao_driver_t *this_gen) { - sun_driver_t *self = (sun_driver_t *) self_gen; + sun_driver_t *this = (sun_driver_t *) this_gen; audio_info_t info; - if (ioctl(self->audio_fd, AUDIO_GETINFO, &info) == 0 + if (ioctl(this->audio_fd, AUDIO_GETINFO, &info) == 0 && info.play.samples - && self->use_rtsc == RTSC_ENABLED) { - return self->frames_in_buffer - info.play.samples; + && this->use_rtsc == RTSC_ENABLED) { + return this->frames_in_buffer - info.play.samples; } return 0; } +static int ao_sun_get_gap_tolerance (ao_driver_t *this_gen) +{ + return GAP_TOLERANCE; +} + /* Write audio samples * num_frames is the number of audio frames present * audio frames are equivalent one sample on each channel. * I.E. Stereo 16 bits audio frames are 4 bytes. */ -static int ao_sun_write(ao_driver_t *self_gen, +static int ao_sun_write(ao_driver_t *this_gen, int16_t* frame_buffer, uint32_t num_frames) { - sun_driver_t *self = (sun_driver_t *) self_gen; + sun_driver_t *this = (sun_driver_t *) this_gen; int num_written; - num_written = write(self->audio_fd, frame_buffer, num_frames * self->bytes_per_frame); + num_written = write(this->audio_fd, frame_buffer, num_frames * this->bytes_per_frame); if (num_written > 0) { - self->frames_in_buffer += num_written / self->bytes_per_frame; + this->frames_in_buffer += num_written / this->bytes_per_frame; } return num_written; } -static void ao_sun_close(ao_driver_t *self_gen) +static void ao_sun_close(ao_driver_t *this_gen) { - sun_driver_t *self = (sun_driver_t *) self_gen; - close(self->audio_fd); - self->audio_fd = -1; + sun_driver_t *this = (sun_driver_t *) this_gen; + close(this->audio_fd); + this->audio_fd = -1; } -static uint32_t ao_sun_get_capabilities (ao_driver_t *self_gen) { - sun_driver_t *self = (sun_driver_t *) self_gen; - return self->capabilities; +static uint32_t ao_sun_get_capabilities (ao_driver_t *this_gen) { + sun_driver_t *this = (sun_driver_t *) this_gen; + return this->capabilities; } -static void ao_sun_exit(ao_driver_t *self_gen) +static void ao_sun_exit(ao_driver_t *this_gen) { - sun_driver_t *self = (sun_driver_t *) self_gen; + sun_driver_t *this = (sun_driver_t *) this_gen; - if (self->audio_fd != -1) - close(self->audio_fd); + if (this->audio_fd != -1) + close(this->audio_fd); - free (self); + free (this); } /* * Get a property of audio driver. * return 1 in success, 0 on failure. (and the property value?) */ -static int ao_sun_get_property (ao_driver_t *self_gen, int property) { - sun_driver_t *self = (sun_driver_t *) self_gen; +static int ao_sun_get_property (ao_driver_t *this_gen, int property) { + sun_driver_t *this = (sun_driver_t *) this_gen; audio_info_t info; switch(property) { case AO_PROP_MIXER_VOL: break; case AO_PROP_PCM_VOL: - if (ioctl(self->audio_fd, AUDIO_GETINFO, &info) < 0) + if (ioctl(this->audio_fd, AUDIO_GETINFO, &info) < 0) return 0; return info.play.gain; #if !defined(__NetBSD__) /* audio_info.output_muted is missing on NetBSD */ case AO_PROP_MUTE_VOL: - if (ioctl(self->audio_fd, AUDIO_GETINFO, &info) < 0) + if (ioctl(this->audio_fd, AUDIO_GETINFO, &info) < 0) return 0; return info.output_muted; #endif @@ -372,8 +377,8 @@ static int ao_sun_get_property (ao_driver_t *self_gen, int property) { * Set a property of audio driver. * return value on success, ~value on failure */ -static int ao_sun_set_property (ao_driver_t *self_gen, int property, int value) { - sun_driver_t *self = (sun_driver_t *) self_gen; +static int ao_sun_set_property (ao_driver_t *this_gen, int property, int value) { + sun_driver_t *this = (sun_driver_t *) this_gen; audio_info_t info; AUDIO_INITINFO(&info); @@ -383,13 +388,13 @@ static int ao_sun_set_property (ao_driver_t *self_gen, int property, int value) break; case AO_PROP_PCM_VOL: info.play.gain = value; - if (ioctl(self->audio_fd, AUDIO_SETINFO, &info) < 0) + if (ioctl(this->audio_fd, AUDIO_SETINFO, &info) < 0) return ~value; return value; #if !defined(__NetBSD__) /* audio_info.output_muted is missing on NetBSD */ case AO_PROP_MUTE_VOL: info.output_muted = value != 0; - if (ioctl(self->audio_fd, AUDIO_SETINFO, &info) < 0) + if (ioctl(this->audio_fd, AUDIO_SETINFO, &info) < 0) return ~value; return value; #endif @@ -400,13 +405,13 @@ static int ao_sun_set_property (ao_driver_t *self_gen, int property, int value) ao_driver_t *init_audio_out_plugin (config_values_t *config) { - sun_driver_t *self; + sun_driver_t *this; char *devname = "/dev/audio"; int audio_fd; int status; audio_info_t info; - self = (sun_driver_t *) malloc (sizeof (sun_driver_t)); + this = (sun_driver_t *) malloc (sizeof (sun_driver_t)); /* * find best device driver/channel @@ -419,14 +424,14 @@ ao_driver_t *init_audio_out_plugin (config_values_t *config) { * open the device */ - audio_fd=open(self->audio_dev = devname, O_WRONLY|O_NDELAY); + audio_fd=open(this->audio_dev = devname, O_WRONLY|O_NDELAY); if(audio_fd < 0) { printf("audio_sun_out: opening audio device %s failed:\n%s\n", devname, strerror(errno)); - free (self); + free (this); return NULL; } else @@ -446,36 +451,37 @@ ao_driver_t *init_audio_out_plugin (config_values_t *config) { * get capabilities */ - self->capabilities = 0; + this->capabilities = 0; printf ("audio_sun_out : supported modes are "); - self->capabilities |= AO_CAP_MODE_MONO; + this->capabilities |= AO_CAP_MODE_MONO; printf ("mono "); - self->capabilities |= AO_CAP_MODE_STEREO; + this->capabilities |= AO_CAP_MODE_STEREO; printf ("stereo "); - self->capabilities |= AO_CAP_PCM_VOL | AO_CAP_MUTE_VOL; + this->capabilities |= AO_CAP_PCM_VOL | AO_CAP_MUTE_VOL; printf ("\n"); close (audio_fd); - self->use_rtsc = realtime_samplecounter_available(self->audio_dev); - self->output_sample_rate = 0; - - self->ao_driver.get_capabilities = ao_sun_get_capabilities; - self->ao_driver.get_property = ao_sun_get_property; - self->ao_driver.set_property = ao_sun_set_property; - self->ao_driver.open = ao_sun_open; - self->ao_driver.num_channels = ao_sun_num_channels; - self->ao_driver.bytes_per_frame = ao_sun_bytes_per_frame; - self->ao_driver.delay = ao_sun_delay; - self->ao_driver.write = ao_sun_write; - self->ao_driver.close = ao_sun_close; - self->ao_driver.exit = ao_sun_exit; - - return &self->ao_driver; + this->use_rtsc = realtime_samplecounter_available(this->audio_dev); + this->output_sample_rate = 0; + + this->ao_driver.get_capabilities = ao_sun_get_capabilities; + this->ao_driver.get_property = ao_sun_get_property; + this->ao_driver.set_property = ao_sun_set_property; + this->ao_driver.open = ao_sun_open; + this->ao_driver.num_channels = ao_sun_num_channels; + this->ao_driver.bytes_per_frame = ao_sun_bytes_per_frame; + this->ao_driver.delay = ao_sun_delay; + this->ao_driver.write = ao_sun_write; + this->ao_driver.close = ao_sun_close; + this->ao_driver.exit = ao_sun_exit; + this->ao_driver.get_gap_tolerance = ao_sun_get_gap_tolerance; + + return &this->ao_driver; } static ao_info_t ao_info_sun = { diff --git a/src/xine-engine/audio_out.c b/src/xine-engine/audio_out.c index 1547ea8a7..c080866cc 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.7 2001/08/23 21:40:05 guenter Exp $ + * $Id: audio_out.c,v 1.8 2001/08/24 01:05:31 guenter Exp $ * * 22-8-2001 James imported some useful AC3 sections from the previous alsa driver. * (c) 2001 Andy Lo A Foe <andy@alsaplayer.org> @@ -68,7 +68,6 @@ #define ZERO_BUF_SIZE 5000 -#define GAP_TOLERANCE 5000 #define MAX_GAP 90000 struct frmsize_s @@ -276,8 +275,13 @@ static int ao_write(ao_instance_t *this, */ gap = vpts - buffer_vpts; - - if (gap>GAP_TOLERANCE) { + + /* + printf ("vpts : %d buffer_vpts : %d gap %d\n", + vpts, buffer_vpts, gap); + */ + + if (gap>this->gap_tolerance) { ao_fill_gap (this, gap); /* keep xine responsive */ @@ -285,7 +289,7 @@ static int ao_write(ao_instance_t *this, if (gap>MAX_GAP) return 0; - } else if (gap<-GAP_TOLERANCE) { + } else if (gap < (-1 * this->gap_tolerance)) { bDropPackage = 1; xprintf (VERBOSE|AUDIO, "audio_out: audio package (vpts = %d %d)" "dropped\n", vpts, gap); @@ -393,6 +397,7 @@ ao_instance_t *ao_new_instance (ao_driver_t *driver, metronom_t *metronom, this->audio_loop_running = 0; this->frame_buffer = xmalloc (40000); this->zero_space = xmalloc (ZERO_BUF_SIZE * 2 * 6); + this->gap_tolerance = driver->get_gap_tolerance (this->driver); this->resample_conf = config->lookup_int (config, "audio_resample_mode", 0); diff --git a/src/xine-engine/audio_out.h b/src/xine-engine/audio_out.h index c7ea69b3e..047529492 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.10 2001/08/23 21:40:05 guenter Exp $ + * $Id: audio_out.h,v 1.11 2001/08/24 01:05:31 guenter Exp $ */ #ifndef HAVE_AUDIO_OUT_H #define HAVE_AUDIO_OUT_H @@ -76,6 +76,11 @@ struct ao_driver_s { */ int (*delay)(ao_driver_t *self_gen); + /* + * return gap tolerance (in pts) needed for this driver + */ + int (*get_gap_tolerance) (ao_driver_t *self_gen); + /* * write audio data to output buffer * audio driver must sync sample playback with metronom @@ -134,7 +139,7 @@ struct ao_instance_s { * call write_audio_data with the _same_ samples again */ - int (*write)(ao_driver_t *this, + int (*write)(ao_instance_t *this, int16_t* audio_data, uint32_t num_frames, uint32_t pts); @@ -162,6 +167,7 @@ struct ao_instance_s { int resample_conf; int do_resample; int mode; + int gap_tolerance; uint16_t *frame_buffer; int16_t *zero_space; }; |