Commit 7bd98c08 authored by Eric Wong's avatar Eric Wong Committed by Max Kellermann

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]
parent da1e8584
...@@ -47,7 +47,6 @@ typedef struct _AlsaData { ...@@ -47,7 +47,6 @@ typedef struct _AlsaData {
int sampleSize; int sampleSize;
int useMmap; int useMmap;
int canPause; int canPause;
int canResume;
} AlsaData; } AlsaData;
static AlsaData *newAlsaData(void) static AlsaData *newAlsaData(void)
...@@ -262,7 +261,6 @@ configure_hw: ...@@ -262,7 +261,6 @@ configure_hw:
goto error; goto error;
ad->canPause = snd_pcm_hw_params_can_pause(hwparams); ad->canPause = snd_pcm_hw_params_can_pause(hwparams);
ad->canResume = snd_pcm_hw_params_can_resume(hwparams);
/* configure SW params */ /* configure SW params */
snd_pcm_sw_params_alloca(&swparams); snd_pcm_sw_params_alloca(&swparams);
...@@ -334,10 +332,10 @@ static int alsa_errorRecovery(AlsaData * ad, int err) ...@@ -334,10 +332,10 @@ static int alsa_errorRecovery(AlsaData * ad, int err)
err = snd_pcm_pause(ad->pcmHandle, /* disable */ 0); err = snd_pcm_pause(ad->pcmHandle, /* disable */ 0);
break; break;
case SND_PCM_STATE_SUSPENDED: case SND_PCM_STATE_SUSPENDED:
err = ad->canResume ? err = snd_pcm_resume(ad->pcmHandle);
snd_pcm_resume(ad->pcmHandle) : if (err == -EAGAIN)
snd_pcm_prepare(ad->pcmHandle); return 0;
break; /* fall-through to snd_pcm_prepare: */
case SND_PCM_STATE_SETUP: case SND_PCM_STATE_SETUP:
case SND_PCM_STATE_XRUN: case SND_PCM_STATE_XRUN:
err = snd_pcm_prepare(ad->pcmHandle); err = snd_pcm_prepare(ad->pcmHandle);
......
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