There's no need to throw away the data if a buffer underrun occurs.
Just try to write the same data again after the snd_pcm_prepare().
if (ret == -EPIPE) {
PARA_WARNING_LOG("EPIPE\n");
snd_pcm_prepare(pad->handle);
if (ret == -EPIPE) {
PARA_WARNING_LOG("EPIPE\n");
snd_pcm_prepare(pad->handle);
+ /* try to write the same data again */
+ ret = snd_pcm_writei(pad->handle, data, frames);
return 1;
}
if (ret < 0 && ret != -EAGAIN) {
return 1;
}
if (ret < 0 && ret != -EAGAIN) {