[xiph-commits] r18778 - trunk/ao/src/plugins/alsa

xiphmont at svn.xiph.org xiphmont at svn.xiph.org
Mon Jan 21 18:35:11 PST 2013


Author: xiphmont
Date: 2013-01-21 18:35:11 -0800 (Mon, 21 Jan 2013)
New Revision: 18778

Modified:
   trunk/ao/src/plugins/alsa/ao_alsa.c
Log:
Add one last failsafe in the case where Pulse is emulating ALSA, but
the output device is disabled; it will queue as fast as it can, but
simply hold the data, meaning the close wait can be huge.

In this case, look or a close wait > 1s, and if so, drain instead of
wait.



Modified: trunk/ao/src/plugins/alsa/ao_alsa.c
===================================================================
--- trunk/ao/src/plugins/alsa/ao_alsa.c	2013-01-21 23:14:27 UTC (rev 18777)
+++ trunk/ao/src/plugins/alsa/ao_alsa.c	2013-01-22 02:35:11 UTC (rev 18778)
@@ -769,15 +769,21 @@
                 snd_pcm_drain(internal->pcm_handle);
               }else{
                 double s = (double)(sframes - internal->static_delay)/internal->sample_rate;
-                if(s>0){
-                  struct timespec sleep,wake;
-                  sleep.tv_sec = (int)s;
-                  sleep.tv_nsec = (s-sleep.tv_sec)*1000000000;
-                  while(nanosleep(&sleep,&wake)<0){
-                    if(errno==EINTR)
-                      sleep=wake;
-                    else
-                      break;
+                if(s>1){
+                  /* something went wrong; fall back */
+                  snd_pcm_drain(internal->pcm_handle);
+                }else{
+                  fprintf(stderr,"s=%f(%d)",s,(int)sframes);
+                  if(s>0){
+                    struct timespec sleep,wake;
+                    sleep.tv_sec = (int)s;
+                    sleep.tv_nsec = (s-sleep.tv_sec)*1000000000;
+                    while(nanosleep(&sleep,&wake)<0){
+                      if(errno==EINTR)
+                        sleep=wake;
+                      else
+                        break;
+                    }
                   }
                 }
               }



More information about the commits mailing list