mirror of https://github.com/mpv-player/mpv
ao_alsa: check ALSA PCM state before pause and resume
It is possible to have ao->reset() called between ao->pause() and ao->resume() when seeking during the pause. If the underlying PCM supports pausing, resuming an already reset PCM will produce an error. Avoid that by explicitly checking PCM state before calling snd_pcm_pause(). Signed-off-by: wm4 <wm4@nowhere>
This commit is contained in:
parent
5c9c81efcc
commit
d350181aaf
|
@ -565,9 +565,11 @@ static void audio_pause(struct ao *ao)
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
if (p->can_pause) {
|
if (p->can_pause) {
|
||||||
p->delay_before_pause = get_delay(ao);
|
if (snd_pcm_state(p->alsa) == SND_PCM_STATE_RUNNING) {
|
||||||
err = snd_pcm_pause(p->alsa, 1);
|
p->delay_before_pause = get_delay(ao);
|
||||||
CHECK_ALSA_ERROR("pcm pause error");
|
err = snd_pcm_pause(p->alsa, 1);
|
||||||
|
CHECK_ALSA_ERROR("pcm pause error");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
MP_VERBOSE(ao, "pause not supported by hardware\n");
|
MP_VERBOSE(ao, "pause not supported by hardware\n");
|
||||||
if (snd_pcm_delay(p->alsa, &p->prepause_frames) < 0
|
if (snd_pcm_delay(p->alsa, &p->prepause_frames) < 0
|
||||||
|
@ -595,8 +597,10 @@ static void audio_resume(struct ao *ao)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p->can_pause) {
|
if (p->can_pause) {
|
||||||
err = snd_pcm_pause(p->alsa, 0);
|
if (snd_pcm_state(p->alsa) == SND_PCM_STATE_PAUSED) {
|
||||||
CHECK_ALSA_ERROR("pcm resume error");
|
err = snd_pcm_pause(p->alsa, 0);
|
||||||
|
CHECK_ALSA_ERROR("pcm resume error");
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
MP_VERBOSE(ao, "resume not supported by hardware\n");
|
MP_VERBOSE(ao, "resume not supported by hardware\n");
|
||||||
err = snd_pcm_prepare(p->alsa);
|
err = snd_pcm_prepare(p->alsa);
|
||||||
|
|
Loading…
Reference in New Issue