# HG changeset patch # User attila # Date 1064137745 0 # Node ID 716edc005b18996bc7205c14b3ad0df01f7533ba # Parent ee9d3d88020ac840cd72ad164fa95058ee240a21 patch from Pierre Lombard If the sound channel is already busy the async open fails and returns -EBUSY. There's no need to try to open it synchronously as it will block mplayer till the sound channel is released. (Granted there's a very slight chance your sound device happen to be freed between those two calls but it's not the common case). The behavior is changed by this oneliner to match the ao_oss behavior (disable sound if the sound device is busy). diff -r ee9d3d88020a -r 716edc005b18 libao2/ao_alsa1x.c --- a/libao2/ao_alsa1x.c Sun Sep 21 09:09:46 2003 +0000 +++ b/libao2/ao_alsa1x.c Sun Sep 21 09:49:05 2003 +0000 @@ -503,7 +503,7 @@ //modes = 0, SND_PCM_NONBLOCK, SND_PCM_ASYNC if ((err = snd_pcm_open(&alsa_handler, alsa_device, SND_PCM_STREAM_PLAYBACK, open_mode)) < 0) { - if (ao_noblock) { + if (err != -EBUSY && ao_noblock) { printf("alsa-init: open in nonblock-mode failed, trying to open in block-mode\n"); if ((err = snd_pcm_open(&alsa_handler, alsa_device, SND_PCM_STREAM_PLAYBACK, 0)) < 0) { printf("alsa-init: playback open error: %s\n", snd_strerror(err)); diff -r ee9d3d88020a -r 716edc005b18 libao2/ao_alsa9.c --- a/libao2/ao_alsa9.c Sun Sep 21 09:09:46 2003 +0000 +++ b/libao2/ao_alsa9.c Sun Sep 21 09:49:05 2003 +0000 @@ -503,7 +503,7 @@ //modes = 0, SND_PCM_NONBLOCK, SND_PCM_ASYNC if ((err = snd_pcm_open(&alsa_handler, alsa_device, SND_PCM_STREAM_PLAYBACK, open_mode)) < 0) { - if (ao_noblock) { + if (err != -EBUSY && ao_noblock) { printf("alsa-init: open in nonblock-mode failed, trying to open in block-mode\n"); if ((err = snd_pcm_open(&alsa_handler, alsa_device, SND_PCM_STREAM_PLAYBACK, 0)) < 0) { printf("alsa-init: playback open error: %s\n", snd_strerror(err));