diff options
author | Eric Wong <normalperson@yhbt.net> | 2008-09-08 00:45:05 -0700 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2008-09-08 20:31:05 +0200 |
commit | 7bd98c08ce149a999c14352762cfe741e591c8fb (patch) | |
tree | 209596b6545c78b554208821b2ea66dbeb9cb0d0 /src | |
parent | da1e8584585af9c92b92a25c049829b7012af191 (diff) | |
download | mpd-7bd98c08ce149a999c14352762cfe741e591c8fb.tar.gz mpd-7bd98c08ce149a999c14352762cfe741e591c8fb.tar.xz mpd-7bd98c08ce149a999c14352762cfe741e591c8fb.zip |
alsa: optimistically try resuming from suspend
Apparently snd_pcm_hw_params_can_resume() can return false even
though my hardware does in fact support resuming. So stop
carrying that value in the canResume flag and just try to resume
when we're in the suspended state; falling back to
snd_pcm_prepare only if resuming fails. libao does something
similar on resume, too.
While we're at it, use the E() macro which will enable us to
have better error reporting.
[mk: remove the E() macro stuff]
Diffstat (limited to '')
-rw-r--r-- | src/audioOutputs/audioOutput_alsa.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/src/audioOutputs/audioOutput_alsa.c b/src/audioOutputs/audioOutput_alsa.c index 948e0ad2a..f2c68ce3f 100644 --- a/src/audioOutputs/audioOutput_alsa.c +++ b/src/audioOutputs/audioOutput_alsa.c @@ -47,7 +47,6 @@ typedef struct _AlsaData { int sampleSize; int useMmap; int canPause; - int canResume; } AlsaData; static AlsaData *newAlsaData(void) @@ -262,7 +261,6 @@ configure_hw: goto error; ad->canPause = snd_pcm_hw_params_can_pause(hwparams); - ad->canResume = snd_pcm_hw_params_can_resume(hwparams); /* configure SW params */ snd_pcm_sw_params_alloca(&swparams); @@ -334,10 +332,10 @@ static int alsa_errorRecovery(AlsaData * ad, int err) err = snd_pcm_pause(ad->pcmHandle, /* disable */ 0); break; case SND_PCM_STATE_SUSPENDED: - err = ad->canResume ? - snd_pcm_resume(ad->pcmHandle) : - snd_pcm_prepare(ad->pcmHandle); - break; + err = snd_pcm_resume(ad->pcmHandle); + if (err == -EAGAIN) + return 0; + /* fall-through to snd_pcm_prepare: */ case SND_PCM_STATE_SETUP: case SND_PCM_STATE_XRUN: err = snd_pcm_prepare(ad->pcmHandle); |