summaryrefslogtreecommitdiffstats
path: root/audio
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2014-12-23 03:59:14 +0100
committerwm4 <wm4@nowhere>2014-12-23 03:59:14 +0100
commitd7b5484f51f271a63202aeffa6cb3a01b235b713 (patch)
treeac10beef28117381b3dd9b50a290fdaa63edc7b8 /audio
parent4cfd641f05861cc1dcff34b7c93a94c6e7a4cbaf (diff)
downloadmpv-d7b5484f51f271a63202aeffa6cb3a01b235b713.tar.bz2
mpv-d7b5484f51f271a63202aeffa6cb3a01b235b713.tar.xz
ao_alsa: fix resuming from suspend mode
snd_pcm_prepare() was not always called, which could result in an infinite loop. Whether snd_pcm_prepare() was actually called depended on whether the device was a hw device (or other characteristics; depending on snd_pcm_hw_params_can_pause()), and required real suspend (annoying for testing), so it was somewhat tricky to reproduce without knowing these things.
Diffstat (limited to 'audio')
-rw-r--r--audio/out/ao_alsa.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/audio/out/ao_alsa.c b/audio/out/ao_alsa.c
index 5a0c9071ec..9069494f01 100644
--- a/audio/out/ao_alsa.c
+++ b/audio/out/ao_alsa.c
@@ -745,7 +745,7 @@ static void audio_pause(struct ao *ao)
alsa_error: ;
}
-static void audio_resume(struct ao *ao)
+static void resume_device(struct ao *ao)
{
struct priv *p = ao->priv;
int err;
@@ -756,6 +756,12 @@ static void audio_resume(struct ao *ao)
while ((err = snd_pcm_resume(p->alsa)) == -EAGAIN)
sleep(1);
}
+}
+
+static void audio_resume(struct ao *ao)
+{
+ struct priv *p = ao->priv;
+ int err;
if (p->can_pause) {
if (snd_pcm_state(p->alsa) == SND_PCM_STATE_PAUSED) {
@@ -807,10 +813,12 @@ static int play(struct ao *ao, void **data, int samples, int flags)
if (res == -EINTR || res == -EAGAIN) { /* retry */
res = 0;
- } else if (res == -ESTRPIPE) { /* suspend */
- audio_resume(ao);
} else if (res < 0) {
- MP_ERR(ao, "Write error: %s\n", snd_strerror(res));
+ if (res == -ESTRPIPE) { /* suspend */
+ resume_device(ao);
+ } else {
+ MP_ERR(ao, "Write error: %s\n", snd_strerror(res));
+ }
res = snd_pcm_prepare(p->alsa);
int err = res;
CHECK_ALSA_ERROR("pcm prepare error");