Commit bcc443a8 authored by Max Kellermann's avatar Max Kellermann

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.
parent 215d8aa8
......@@ -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) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment