From ded20935eac98983cb4412ba6a867cf92b6ec1d8 Mon Sep 17 00:00:00 2001 From: waker Date: Fri, 21 Aug 2009 21:02:01 +0200 Subject: fixed alsa snd_pcm_writei underrun detection --- palsa.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'palsa.c') diff --git a/palsa.c b/palsa.c index 02acfadd..c5611d7c 100644 --- a/palsa.c +++ b/palsa.c @@ -101,6 +101,7 @@ palsa_init (void) { goto open_error; } alsa_rate = val; + printf ("chosen samplerate: %d\n", alsa_rate); if ((err = snd_pcm_hw_params_set_channels (audio, hw_params, 2)) < 0) { fprintf (stderr, "cannot set channel count (%s)\n", @@ -323,7 +324,9 @@ palsa_thread (uintptr_t context) { char buf[bufsize]; palsa_callback (buf, frames_to_deliver*4); if ((err = snd_pcm_writei (audio, buf, frames_to_deliver)) < 0) { - fprintf (stderr, "write failed (%s)\n", snd_strerror (err)); + //fprintf (stderr, "write failed (%s)\n", snd_strerror (err)); + snd_pcm_prepare (audio); + snd_pcm_start (audio); } mutex_unlock (mutex); usleep (0); // let other threads gain some spin (avoid deadlock) -- cgit v1.2.3