]> git.sesse.net Git - vlc/blobdiff - modules/misc/inhibit.c
ty demux: simplify and fix potential memleak (CID 214)
[vlc] / modules / misc / inhibit.c
index b88b6a314e0f6a8503974bb063b1be84d12b4748..b50d8e95acc0a744363bd9c03c81ccf4704d997b 100644 (file)
@@ -219,42 +219,34 @@ static int UnInhibit( intf_thread_t *p_intf )
  *****************************************************************************/
 static void Run( intf_thread_t *p_intf )
 {
-    vlc_object_lock( p_intf );
-    while( vlc_object_alive( p_intf ) )
+    for( ;; )
     {
         input_thread_t *p_input;
 
         /* Check playing state every 30 seconds */
-        vlc_object_timedwait( p_intf, mdate() + 30000000 );
+        msleep( 30 * CLOCK_FREQ );
 
         p_input = vlc_object_find( p_intf, VLC_OBJECT_INPUT, FIND_ANYWHERE );
         if( p_input )
         {
-            if( PLAYING_S == p_input->i_state && !p_intf->p_sys->i_cookie )
+            int i_state = p_input->i_state;
+            vlc_object_release( p_input );
+
+            if( PLAYING_S == i_state && !p_intf->p_sys->i_cookie )
             {
                 if( !Inhibit( p_intf ) )
-                {
-                    vlc_object_release( p_input );
-                    goto end;
-                }
+                    break;
             }
             else if( p_intf->p_sys->i_cookie )
             {
                 if( !UnInhibit( p_intf ) )
-                {
-                    vlc_object_release( p_input );
-                    goto end;
-                }
+                    break;
             }
-            vlc_object_release( p_input );
         }
         else if( p_intf->p_sys->i_cookie )
         {
             if( !UnInhibit( p_intf ) )
-                goto end;
+                break;
         }
     }
-
-end:
-    vlc_object_unlock( p_intf );
 }