From cbdd29c403137e2517441c1f66c8547e337aee39 Mon Sep 17 00:00:00 2001 From: Alexandre Ratchov Date: Mon, 1 Jul 2019 17:12:00 +0200 Subject: [PATCH] alsa: use (blksz - round) as start threshold. The threshold making poll() return POLLOUT is one block (according to alsa library sources). If a poll-based program writes blksz - 1 samples, playback never starts but poll won't return POLLOUT either. In turn the program deadlocks. The problem could be observed in the sio_alsa_xrun() routine. --- libsndio/sio_alsa.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libsndio/sio_alsa.c b/libsndio/sio_alsa.c index 615cbed..d8df57f 100644 --- a/libsndio/sio_alsa.c +++ b/libsndio/sio_alsa.c @@ -875,7 +875,7 @@ sio_alsa_setpar(struct sio_hdl *sh, struct sio_par *par) return 0; } err = snd_pcm_sw_params_set_start_threshold(hdl->opcm, - oswp, hdl->par.bufsz); + oswp, hdl->par.bufsz - hdl->par.round); if (err < 0) { DALSA("couldn't set play start threshold", err); hdl->sio.eof = 1;