]> git.sesse.net Git - vlc/commitdiff
Convert hotkeys to using cond_wait/cond_signal
authorClément Stenac <zorglub@videolan.org>
Sun, 24 Sep 2006 10:40:00 +0000 (10:40 +0000)
committerClément Stenac <zorglub@videolan.org>
Sun, 24 Sep 2006 10:40:00 +0000 (10:40 +0000)
This removes useless wakeups and improves hotkeys reactivity

modules/control/hotkeys.c
src/interface/interface.c

index fe0c9b6dc5192e59377e7f1540827cf96f6d6c77..8c339bc5211dace30803f59c26ea3a5d2d578c48 100644 (file)
@@ -170,7 +170,7 @@ static void Run( intf_thread_t *p_intf )
         int i_times = 0;
 
         /* Sleep a bit */
-        msleep( INTF_IDLE_SLEEP );
+//        msleep( INTF_IDLE_SLEEP );
 
         /* Update the input */
         if( p_intf->p_sys->p_input == NULL )
@@ -228,8 +228,11 @@ static void Run( intf_thread_t *p_intf )
 
         if( !i_action )
         {
+            vlc_mutex_lock( &p_intf->object_lock );
+            vlc_cond_wait( &p_intf->object_wait, &p_intf->object_lock );
+            vlc_mutex_unlock( &p_intf->object_lock );
             /* No key pressed, sleep a bit more */
-            msleep( INTF_IDLE_SLEEP );
+//            msleep( INTF_IDLE_SLEEP );
             continue;
         }
 
@@ -746,6 +749,9 @@ static int KeyEvent( vlc_object_t *p_this, char const *psz_var,
         p_intf->p_sys->p_keys[ p_intf->p_sys->i_size ] = newval.i_int;
         p_intf->p_sys->i_size++;
     }
+    vlc_mutex_lock( &p_intf->object_lock );
+    vlc_cond_signal( &p_intf->object_wait );
+    vlc_mutex_unlock( &p_intf->object_lock );
     vlc_mutex_unlock( &p_intf->p_sys->change_lock );
 
     return VLC_SUCCESS;
index 6216136fc5b521520815e30f779faffaa1d9552f..958c26d8c4deb9223e137847e1acfca19cd860e5 100644 (file)
@@ -261,7 +261,10 @@ void intf_StopThread( intf_thread_t *p_intf )
     {
         p_intf->b_die = VLC_TRUE;
         if( p_intf->pf_run )
+        {
+            vlc_cond_signal( &p_intf->object_wait );
             vlc_thread_join( p_intf );
+        }
     }
 }