diff options
-rw-r--r-- | ChangeLog | 1 | ||||
-rw-r--r-- | src/audio_out/audio_alsa_out.c | 19 |
2 files changed, 18 insertions, 2 deletions
@@ -17,6 +17,7 @@ xine-lib (1.1.3) supported by upstream, and it's replaced by PulseAudio. * Allow 0 for DVD title/chapter (navigation or full title). * New experimental JACK audio driver. + * fix switch from alsa/dmix 2.0 to 5.1 [bug #1226595] xine-lib (1.1.2) * Security fixes: diff --git a/src/audio_out/audio_alsa_out.c b/src/audio_out/audio_alsa_out.c index 024cf0b81..da8b87fc5 100644 --- a/src/audio_out/audio_alsa_out.c +++ b/src/audio_out/audio_alsa_out.c @@ -26,7 +26,7 @@ * (c) 2001 James Courtier-Dutton <James@superbug.demon.co.uk> * * - * $Id: audio_alsa_out.c,v 1.164 2006/08/08 03:16:23 miguelfreitas Exp $ + * $Id: audio_alsa_out.c,v 1.165 2006/09/08 20:40:34 miguelfreitas Exp $ */ #ifdef HAVE_CONFIG_H @@ -309,6 +309,8 @@ static int ao_alsa_open(ao_driver_t *this_gen, uint32_t bits, uint32_t rate, int int err, dir; int open_mode=1; /* NONBLOCK */ /* int open_mode=0; BLOCK */ + struct timeval start_time; + struct timeval end_time; snd_pcm_hw_params_alloca(¶ms); snd_pcm_sw_params_alloca(&swparams); @@ -361,8 +363,21 @@ static int ao_alsa_open(ao_driver_t *this_gen, uint32_t bits, uint32_t rate, int this->bytes_in_buffer = 0; /* * open audio device + * When switching to surround, dmix blocks the device some time, so we just keep trying for 0.8sec. */ - err=snd_pcm_open(&this->audio_fd, pcm_device, direction, open_mode); + gettimeofday(&start_time, NULL); + do { + err = snd_pcm_open(&this->audio_fd, pcm_device, direction, open_mode); + gettimeofday(&end_time, NULL); + if( err == -EBUSY ) { + if( (double)end_time.tv_sec + 1E-6*end_time.tv_usec + - (double)start_time.tv_sec - 1E-6*start_time.tv_usec > 0.8) + break; + else + usleep(10000); + } + } while( err == -EBUSY ); + if(err <0 ) { xprintf (this->class->xine, XINE_VERBOSITY_LOG, _("audio_alsa_out: snd_pcm_open() of %s failed: %s\n"), pcm_device, snd_strerror(err)); |