Skip to content
Snippets Groups Projects
Commit 42f3a8f5 authored by Tristan Matthews's avatar Tristan Matthews
Browse files

* #14027: alsa: try and recover from being in snd_pcm_setup state during write.

parent 4c43f650
Branches
No related tags found
No related merge requests found
...@@ -405,6 +405,24 @@ AlsaLayer::write(void* buffer, int length, snd_pcm_t * handle) ...@@ -405,6 +405,24 @@ AlsaLayer::write(void* buffer, int length, snd_pcm_t * handle)
break; break;
} }
case -EBADFD: {
snd_pcm_status_t* status;
snd_pcm_status_alloca(&status);
if (ALSA_CALL(snd_pcm_status(handle, status), "Cannot get playback handle status") >= 0) {
if (snd_pcm_status_get_state(status) == SND_PCM_STATE_SETUP) {
ERROR("Writing in state SND_PCM_STATE_SETUP, should be "
"SND_PCM_STATE_PREPARED or SND_PCM_STATE_RUNNING");
int error = snd_pcm_prepare(handle);
if (error < 0) {
ERROR("Failed to prepare handle: %s", snd_strerror(error));
stopPlaybackStream();
}
}
}
break;
}
default: default:
ERROR("Unknown write error, dropping frames: %s", snd_strerror(err)); ERROR("Unknown write error, dropping frames: %s", snd_strerror(err));
stopPlaybackStream(); stopPlaybackStream();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment