]> git.sesse.net Git - vlc/blobdiff - modules/misc/screensaver.c
Fix race condition in screensaver exit
[vlc] / modules / misc / screensaver.c
index 95ab05d266138394b42c64b01e4c0be8411a881e..14efcbffe25087cee7e1b78cabb2888f4dda19cc 100644 (file)
@@ -138,9 +138,16 @@ static void Run( intf_thread_t *p_intf )
     p_intf->p_sys->p_connection = dbus_init( p_intf );
 #endif
 
-    do
+    vlc_object_lock( p_intf );
+    for(;;)
     {
         vlc_object_t *p_vout;
+        vlc_bool_t b_quit;
+
+        /* Check screensaver every 30 seconds */
+        if( vlc_object_timedwait( p_intf, mdate() + 30000000 ) < 0 )
+            break;
+
         p_vout = vlc_object_find( p_intf, VLC_OBJECT_VOUT, FIND_ANYWHERE );
 
         /* If there is a video output, disable xscreensaver */
@@ -169,15 +176,8 @@ static void Run( intf_thread_t *p_intf )
                 vlc_object_release( p_input );
             }
         }
-
-        /* Check screensaver every 30 seconds */
-        vlc_mutex_lock( &p_intf->object_lock );
-        vlc_cond_timedwait( &p_intf->object_wait, &p_intf->object_lock,
-                            mdate() + 30000000 );
     }
-    while( !p_intf->b_die );
-
-    vlc_mutex_unlock( &p_intf->object_lock );
+    vlc_object_unlock( p_intf );
 }
 
 #ifdef HAVE_DBUS