Bug 214697 - games-emulation/zsnes-1.51-r1 problem with libao/alsa
Bug#: 214697 Product:  Gentoo Linux Version: 2006.1 Platform: x86
OS/Version: Linux Status: RESOLVED Severity: normal Priority: P2
Resolution: FIXED Assigned To: drizzt@gentoo.org Reported By: jlhamm@acm.org
Component: Games
URL: 
Summary: games-emulation/zsnes-1.51-r1 problem with libao/alsa
Keywords:  
Status Whiteboard: 
Opened: 2008-03-25 14:28 0000
Description:   Opened: 2008-03-25 14:28 0000
For libao to work properly the audio thread has to be created *after* the mutex
and condition is created otherwise the sound thread has a chance to deadlock
(as it was wont to do on my machine before I applied this patch :).

I can't take credit for this fix as it was posted on one of the zsnes dev
sites. As such, it's probably already upstream. But in lieu of an upstream
version bump any time soon, I think this patch should be rolled in here as -r2.

Patch below comes from
http://board.zsnes.com/phpBB2/viewtopic.php?p=157699&sid=4ead2f9a94c153be8e85916ad6ac2f8b

--------------------------------------------------------------------------

diff -ur zsnes-1.510/src/linux/audio.c zsnes-1.510-new/src/linux/audio.c 
--- zsnes-1.510/src/linux/audio.c   2007-01-09 20:19:12.000000000 -0500 
+++ zsnes-1.510-new/src/linux/audio.c   2007-12-30 20:33:07.000000000 -0500 
@@ -177,11 +177,7 @@ 
   } 
   else 
   { 
-    if (pthread_create(&audio_thread, 0, SoundThread_ao, 0)) 
-    { 
-      puts("pthread_create() failed."); 
-    } 
-    else if (pthread_mutex_init(&audio_mutex, 0)) 
+    if (pthread_mutex_init(&audio_mutex, 0)) 
     { 
       puts("pthread_mutex_init() failed."); 
     } 
@@ -189,6 +185,10 @@ 
     { 
       puts("pthread_cond_init() failed."); 
     } 
+    else if (pthread_create(&audio_thread, 0, SoundThread_ao, 0)) 
+    { 
+      puts("pthread_create() failed."); 
+    } 
     InitSampleControl(); 
   }

------- Comment #1 From James L. Hammons 2008-04-02 12:55:50 0000 -------
Created an attachment (id=148077) [details]
Tested ebuild with new patch included

------- Comment #2 From James L. Hammons 2008-04-02 12:57:08 0000 -------
Created an attachment (id=148078) [details]
The patch

------- Comment #3 From Timothy Redaelli 2008-05-09 19:15:11 0000 -------
Fixed, thanks