summaryrefslogtreecommitdiff
path: root/src/audio_out
diff options
context:
space:
mode:
authorDarren Salt <linux@youmustbejoking.demon.co.uk>2010-06-14 22:22:18 +0100
committerDarren Salt <linux@youmustbejoking.demon.co.uk>2010-06-14 22:22:18 +0100
commit683cd0f89680fdb989e5166cf57ef9d1787c9044 (patch)
tree560441af7ccfe453f1f2bd752df14cce7ec2f3ed /src/audio_out
parent71ea5354dab942e485ba93505990e010f551ad86 (diff)
parent3da8e08c83e25577c47b0117155b3c36198e0277 (diff)
downloadxine-lib-683cd0f89680fdb989e5166cf57ef9d1787c9044.tar.gz
xine-lib-683cd0f89680fdb989e5166cf57ef9d1787c9044.tar.bz2
Merge from 1.1.
--HG-- rename : include/xine.h.in => include/xine.h rename : po/libxine1.pot => po/libxine2.pot
Diffstat (limited to 'src/audio_out')
-rw-r--r--src/audio_out/audio_alsa_out.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/audio_out/audio_alsa_out.c b/src/audio_out/audio_alsa_out.c
index 8bc0c241d..3e3564a3b 100644
--- a/src/audio_out/audio_alsa_out.c
+++ b/src/audio_out/audio_alsa_out.c
@@ -668,6 +668,34 @@ static int ao_alsa_delay (ao_driver_t *this_gen) {
printf("audio_alsa_out:delay:FINISHED\n");
#endif
+ /*
+ * try to recover from errors and recalculate delay
+ */
+ if(err) {
+#ifdef LOG_DEBUG
+ printf("gap audio_alsa_out:delay: recovery\n");
+#endif
+ err = snd_pcm_recover( this->audio_fd, err, 1 );
+ err = snd_pcm_delay( this->audio_fd, &delay );
+ }
+
+ /*
+ * if we have a negative delay try to forward within the buffer
+ */
+ if(!err && (delay < 0)) {
+#ifdef LOG_DEBUG
+ printf("gap audio_alsa_out:delay: forwarding frames: %d\n", (int)-delay);
+#endif
+ err = snd_pcm_forward( this->audio_fd, -delay );
+ if(err >= 0) {
+ err = snd_pcm_delay( this->audio_fd, &delay );
+ }
+ }
+
+ /*
+ * on error or (still) negative delays ensure delay
+ * is not negative
+ */
if (err || (delay < 0))
delay = 0;