diff options
author | Eric Wong <normalperson@yhbt.net> | 2008-09-08 04:30:30 -0700 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2008-09-08 04:34:36 -0700 |
commit | dccdfce721ffe730de2f55a67ecd1acfcb19bb0a (patch) | |
tree | a9520f9e98e40c3971954ea05596f76074f96762 | |
parent | 92451cbdf0cbfd8c27daf3792e1a1cb68def91fc (diff) | |
download | mpd-dccdfce721ffe730de2f55a67ecd1acfcb19bb0a.tar.gz mpd-dccdfce721ffe730de2f55a67ecd1acfcb19bb0a.tar.xz mpd-dccdfce721ffe730de2f55a67ecd1acfcb19bb0a.zip |
alsa: use blocking instead of non-blocking write
The way we used non-blocking mode was HORRIBLE.
It was non-blocking to ALSA, but we end up blocking in a busy
loop that does absolutely NOTHING but retry. We don't check
for playback cancellation (like we do in decoders) or anything.
This is seriously broken and I can imagine it affects people on
fast CPUs more because we do asynchronous output buffering and
our ALSA device will always have data ready.
-rw-r--r-- | src/audioOutputs/audioOutput_alsa.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/audioOutputs/audioOutput_alsa.c b/src/audioOutputs/audioOutput_alsa.c index 1f6d75d9d..b7b0a1151 100644 --- a/src/audioOutputs/audioOutput_alsa.c +++ b/src/audioOutputs/audioOutput_alsa.c @@ -38,6 +38,9 @@ static const char default_device[] = "default"; #include <alsa/asoundlib.h> +/* #define MPD_SND_PCM_NONBLOCK SND_PCM_NONBLOCK */ +#define MPD_SND_PCM_NONBLOCK 0 + /* * This macro will evaluate both statements, but only returns the result * of the second statement to the reader. Thus it'll stringify the @@ -172,14 +175,16 @@ static int alsa_openDevice(AudioOutput * audioOutput) ad->device, audioFormat->bits); err = E(snd_pcm_open, &ad->pcmHandle, ad->device, - SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK); + SND_PCM_STREAM_PLAYBACK, MPD_SND_PCM_NONBLOCK); if (err < 0) { ad->pcmHandle = NULL; goto error; } +#if MPD_SND_PCM_NONBLOCK == SND_PCM_NONBLOCK if ((err = E(snd_pcm_nonblock, ad->pcmHandle, 0)) < 0) goto error; +#endif /* MPD_SND_PCM_NONBLOCK == SND_PCM_NONBLOCK */ period_time_ro = period_time = ad->period_time; configure_hw: |