From 7bd98c08ce149a999c14352762cfe741e591c8fb Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 8 Sep 2008 00:45:05 -0700 Subject: 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] --- src/audioOutputs/audioOutput_alsa.c | 10 ++++------ 1 file 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); -- cgit v1.2.3