summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Herkt <lachs0r@srsfckn.biz>2014-01-02 18:44:49 +0100
committerwm4 <wm4@nowhere>2014-01-06 20:20:57 +0100
commitf9bdfc0782eeb8c29d21be82d872954c2630d6fc (patch)
tree8028020be6a3b1308272aa7c14e3af5d92b02989
parent5c9a7e24f6a69e5c4087e623fd4004e04020be6b (diff)
downloadmpv-f9bdfc0782eeb8c29d21be82d872954c2630d6fc.tar.bz2
mpv-f9bdfc0782eeb8c29d21be82d872954c2630d6fc.tar.xz
ao_alsa: Unbreak pause/resume
Well that was dumb.
-rw-r--r--audio/out/ao_alsa.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/audio/out/ao_alsa.c b/audio/out/ao_alsa.c
index cdbd02fa76..e8b3405bb0 100644
--- a/audio/out/ao_alsa.c
+++ b/audio/out/ao_alsa.c
@@ -53,7 +53,6 @@ struct priv {
snd_pcm_t *alsa;
snd_pcm_format_t alsa_fmt;
int can_pause;
- int can_resume;
snd_pcm_sframes_t prepause_frames;
float delay_before_pause;
int buffersize; // in frames
@@ -522,7 +521,6 @@ static int init(struct ao *ao)
/* end setting sw-params */
p->can_pause = snd_pcm_hw_params_can_pause(alsa_hwparams);
- p->can_resume = snd_pcm_hw_params_can_resume(alsa_hwparams);
MP_VERBOSE(ao, "opened: %d Hz/%d channels/%d bps/%d samples buffer/%s\n",
ao->samplerate, ao->channels.num, af_fmt2bits(ao->format),
@@ -590,16 +588,17 @@ static void audio_resume(struct ao *ao)
while ((err = snd_pcm_resume(p->alsa)) == -EAGAIN)
sleep(1);
+ }
- if (err < 0 || !p->can_resume) {
- /* Some ALSA drivers that cannot resume playback are buggy and
- fail to work even after snd_pcm_resume (or the high-level
- snd_pcm_recover) indicates success, so always call
- snd_pcm_prepare here. */
- MP_VERBOSE(ao, "hardware does not support resume\n");
- err = snd_pcm_prepare(p->alsa);
- CHECK_ALSA_ERROR("pcm prepare error");
- }
+ if (p->can_pause) {
+ err = snd_pcm_pause(p->alsa, 0);
+ CHECK_ALSA_ERROR("pcm resume error");
+ } else {
+ MP_VERBOSE(ao, "resume not supported by hardware\n");
+ err = snd_pcm_prepare(p->alsa);
+ CHECK_ALSA_ERROR("pcm prepare error");
+ if (p->prepause_frames)
+ ao_play_silence(ao, p->prepause_frames);
}
alsa_error: ;