From 66f1aca41a4ff7668e5c21f59c3b2170d3d265e7 Mon Sep 17 00:00:00 2001 From: Thibaut Mattern Date: Thu, 5 Apr 2007 13:07:13 +0200 Subject: Fixed current audio sync, delay was always 0. Checked snd_pcm_delay return code, and don't trust negative values. --- src/audio_out/audio_alsa_out.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/audio_out/audio_alsa_out.c b/src/audio_out/audio_alsa_out.c index 3651d21da..f176b7594 100644 --- a/src/audio_out/audio_alsa_out.c +++ b/src/audio_out/audio_alsa_out.c @@ -663,15 +663,7 @@ static int ao_alsa_delay (ao_driver_t *this_gen) { struct timeval now; printf("audio_alsa_out:delay:ENTERED\n"); #endif - err=snd_pcm_delay( this->audio_fd, &delay ); - - int state = snd_pcm_state(this->audio_fd); - - /* check for idle states, which need to be handled as delay=0 */ - if(state == SND_PCM_STATE_PREPARED || state == SND_PCM_STATE_PAUSED || - state == SND_PCM_STATE_OPEN || SND_PCM_STATE_XRUN) { - return 0; - } + err = snd_pcm_delay( this->audio_fd, &delay ); #ifdef LOG_DEBUG printf("audio_alsa_out:delay:delay all=%ld err=%d\n",delay, err); @@ -679,8 +671,11 @@ static int ao_alsa_delay (ao_driver_t *this_gen) { printf("audio_alsa_out:delay: Time = %ld.%ld\n", now.tv_sec, now.tv_usec); printf("audio_alsa_out:delay:FINISHED\n"); #endif - return delay; + if (err || (delay < 0)) + delay = 0; + + return delay; } #if 0 -- cgit v1.2.3