changeset 3252:eddeaebaf1c7

- fixed ugly race condition in new threading model; mutexes are also probably required to handle shared access to ip_data
author Giacomo Lozito <james@develia.org>
date Mon, 06 Aug 2007 01:32:41 +0200
parents f02623377013
children 6374d66ee623
files src/audacious/playback.c
diffstat 1 files changed, 10 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/src/audacious/playback.c	Sun Aug 05 16:43:53 2007 +0200
+++ b/src/audacious/playback.c	Mon Aug 06 01:32:41 2007 +0200
@@ -180,8 +180,17 @@
 playback_stop(void)
 {
     InputPlayback *playback;
+    
+    /* this is not very nice, but stop MUST NOT be called until
+       a playback item is created in playback_monitor_thread;
+       we need one to call plugin->stop , otherwise plugins will
+       handle multiple resources for each plugin->play_file without
+       disposing of the previous; this leads to segfault and ui freezes
+       -- giacomo */
+    while ((playback = get_current_input_playback()) == NULL)
+      g_usleep( 20000 );
 
-    if (ip_data.playing && (playback = get_current_input_playback()) != NULL)
+    if (ip_data.playing)
     {
         if (playback_get_paused() == TRUE)
         {