AudioTrack: recover underruns properly

This commit is contained in:
Julian Winkler 2025-01-04 17:49:10 +01:00
parent 57dd86fc98
commit e6a22df315

View file

@ -238,7 +238,9 @@ JNIEXPORT jint JNICALL Java_android_media_AudioTrack_native_1write(JNIEnv *env,
if (ret < 0) {
if (ret == -EPIPE) {
printf("XRUN.\n");
snd_pcm_prepare(pcm_handle);
snd_pcm_recover(pcm_handle, ret, 0);
ret = frames_written = snd_pcm_writei(pcm_handle, buffer + offset_in_bytes, frames_to_write);
snd_pcm_start(pcm_handle);
} else {
printf("ERROR. Can't write to PCM device. %s\n", snd_strerror(ret));
}