Bug#833950: libasound2: brltty-espeak stops working with 1.1.2-1

Samuel Thibault sthibault at debian.org
Sun Oct 2 08:54:17 UTC 2016


Control: tags -1 + fixed-upstream

Hello,

Samuel Thibault, on Fri 26 Aug 2016 20:59:28 +0200, wrote:
> Chris Brannon, on Thu 18 Aug 2016 11:32:40 -0700, wrote:
> > I'm almost certain that the problem lies with portaudio, rather than
> > libasound.  It's described in my message to the portaudio list, found
> > here:
> > 
> > https://lists.columbia.edu/pipermail/portaudio/2016-August/000599.html
> 
> And the discussion shows that the issue really does seem to lie in
> there. portaudio maintainers, could you include the upstream patch from
> 
> https://lists.columbia.edu/pipermail/portaudio/2016-August/000623.html

I have attached to this mail the upstream fix that got released
yesterday as RC. Could you please apply it?

This:

> Without it, blind users using a screen reader have their screen reader
> hang every few minutes, making the system basically unusable.

is still preventing all blind users using speech synthesis from being
able to do any kind of serious work with debian testing.

Samuel
-------------- next part --------------
diff --exclude .svn --exclude .git --exclude CVS --exclude .hg -urwB portaudio-stable/src/hostapi/alsa/pa_linux_alsa.c portaudio-test/src/hostapi/alsa/pa_linux_alsa.c
--- portaudio-stable/src/hostapi/alsa/pa_linux_alsa.c	2013-10-17 14:44:09.000000000 +0200
+++ portaudio-test/src/hostapi/alsa/pa_linux_alsa.c	2016-10-02 00:07:12.000000000 +0200
@@ -1,5 +1,5 @@
 /*
- * $Id: pa_linux_alsa.c 1911 2013-10-17 12:44:09Z gineera $
+ * $Id$
  * PortAudio Portable Real-Time Audio Library
  * Latest Version at: http://www.portaudio.com
  * ALSA implementation by Joshua Haberman and Arve Knudsen
@@ -3805,8 +3805,23 @@
             totalFds += self->playback.nfds;
         }
 
+#ifdef PTHREAD_CANCELED
+        if( self->callbackMode )
+        {
+            /* To allow 'Abort' to terminate the callback thread, enable cancelability just for poll() (& disable after) */
+            pthread_setcancelstate( PTHREAD_CANCEL_ENABLE, NULL );
+        }
+#endif
+
         pollResults = poll( self->pfds, totalFds, pollTimeout );
 
+#ifdef PTHREAD_CANCELED
+        if( self->callbackMode )
+        {
+            pthread_setcancelstate( PTHREAD_CANCEL_DISABLE, NULL );
+        }
+#endif
+
         if( pollResults < 0 )
         {
             /*  XXX: Depend on preprocessor condition? */
@@ -4175,12 +4190,18 @@
     int streamStarted = 0;
 
     assert( stream );
+    /* Not implemented */
+    assert( !stream->primeBuffers );
 
     /* Execute OnExit when exiting */
     pthread_cleanup_push( &OnExit, stream );
-
-    /* Not implemented */
-    assert( !stream->primeBuffers );
+#ifdef PTHREAD_CANCELED
+    /* 'Abort' will use thread cancellation to terminate the callback thread, but the Alsa-lib functions
+     * are NOT cancel-safe, (and can end up in an inconsistent state).  So, disable cancelability for
+     * the thread here, and just re-enable it for the poll() in PaAlsaStream_WaitForFrames(). */
+    pthread_testcancel();
+    pthread_setcancelstate( PTHREAD_CANCEL_DISABLE, NULL );
+#endif
 
     /* @concern StreamStart If the output is being primed the output pcm needs to be prepared, otherwise the
      * stream is started immediately. The latter involves signaling the waiting main thread.
@@ -4265,10 +4286,6 @@
         {
             xrun = 0;
 
-#ifdef PTHREAD_CANCELED
-           pthread_testcancel();
-#endif
-
             /** @concern Xruns Under/overflows are to be reported to the callback */
             if( stream->underrun > 0.0 )
             {


More information about the Pkg-voip-maintainers mailing list