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]
This commit is contained in:
Eric Wong 2008-09-08 00:45:05 -07:00 committed by Max Kellermann
parent da1e858458
commit 7bd98c08ce

View File

@ -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);