From bcc443a8aa6899de79d2c5a01528afbe1fa52db8 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sat, 11 Oct 2008 12:47:20 +0200 Subject: alsa: re-enable blocking mode Revert e4f5d6bd "re-enable-nonblocking, but sleep if busy". Non-blocking mode with manual sleeping doesn't help at all (by the way, the patch should have used snd_pcm_wait() instead of my_usleep()). ALSA knows much more about the hardware quirks, so we just let it do the job. --- src/audioOutputs/audioOutput_alsa.c | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/audioOutputs/audioOutput_alsa.c b/src/audioOutputs/audioOutput_alsa.c index 9d47ff244..52603cc62 100644 --- a/src/audioOutputs/audioOutput_alsa.c +++ b/src/audioOutputs/audioOutput_alsa.c @@ -46,7 +46,6 @@ typedef struct _AlsaData { alsa_writei_t *writei; unsigned int buffer_time; unsigned int period_time; - unsigned int period_sleep; int sampleSize; int useMmap; } AlsaData; @@ -157,17 +156,12 @@ static int alsa_openDevice(void *data, struct audio_format *audioFormat) ad->device, audioFormat->bits); err = snd_pcm_open(&ad->pcmHandle, ad->device, - SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK); + SND_PCM_STREAM_PLAYBACK, 0); if (err < 0) { ad->pcmHandle = NULL; goto error; } - cmd = "snd_pcm_nonblock"; - err = snd_pcm_nonblock(ad->pcmHandle, 0); - if (err < 0) - goto error; - period_time_ro = period_time = ad->period_time; configure_hw: /* configure HW params */ @@ -249,8 +243,6 @@ configure_hw: if (retry != MPD_ALSA_RETRY_NR) DEBUG("ALSA period_time set to %d\n", period_time); - ad->period_sleep = period_time >> 1; - cmd = "snd_pcm_hw_params_get_buffer_size"; err = snd_pcm_hw_params_get_buffer_size(hwparams, &alsa_buffer_size); if (err < 0) @@ -379,12 +371,7 @@ static int alsa_playAudio(void *data, const char *playChunk, size_t size) while (size > 0) { ret = ad->writei(ad->pcmHandle, playChunk, size); - if (ret == -EAGAIN) { - DEBUG("ALSA busy, sleeping %d\n", ad->period_sleep); - my_usleep(ad->period_sleep); - continue; - } - if (ret == -EINTR) + if (ret == -EAGAIN || ret == -EINTR) continue; if (ret < 0) { -- cgit v1.2.3