]> git.sesse.net Git - vlc/blobdiff - src/interface/interaction.c
libvlccore: push threads cancellation down vlc_thread_create
[vlc] / src / interface / interaction.c
index e0920eaf50d62a70f0ff56f8e635f728233f828e..4b0f0b79e7ce58653900b9ee28792de4b0a7c718 100644 (file)
@@ -48,7 +48,7 @@
  *****************************************************************************/
 static interaction_t *          InteractionGet( vlc_object_t * );
 static void                     InteractionSearchInterface( interaction_t * );
-static void                     InteractionLoop( vlc_object_t * );
+static void*                    InteractionLoop( vlc_object_t * );
 static void                     InteractionManage( interaction_t * );
 
 static interaction_dialog_t    *DialogGetById( interaction_t* , int );
@@ -343,7 +343,10 @@ void __intf_UserHide( vlc_object_t *p_this, int i_id )
     p_dialog = DialogGetById( p_interaction, i_id );
 
     if( p_dialog )
+    {
         p_dialog->i_status = ANSWERED_DIALOG;
+        vlc_object_signal_unlocked( p_interaction );
+    }
 
     vlc_object_unlock( p_interaction );
     vlc_object_release( p_interaction );
@@ -470,9 +473,14 @@ static int DialogSend( vlc_object_t *p_this, interaction_dialog_t *p_dialog )
 {
     interaction_t *p_interaction = InteractionGet( p_this );
 
+    if( !p_interaction )
+        return VLC_EGENERIC;
+
     /* Get an id, if we don't already have one */
+    vlc_object_lock( p_interaction );
     if( p_dialog->i_id == 0 )
         p_dialog->i_id = ++p_interaction->i_last_id;
+    vlc_object_unlock( p_interaction );
 
     if( p_this->i_flags & OBJECT_FLAGS_NOINTERACT )
     {
@@ -548,10 +556,10 @@ static int DialogSend( vlc_object_t *p_this, interaction_dialog_t *p_dialog )
     }
 }
 
-static void InteractionLoop( vlc_object_t *p_this )
+static void* InteractionLoop( vlc_object_t *p_this )
 {
-    int i;
     interaction_t *p_interaction = (interaction_t*) p_this;
+    int canc = vlc_savecancel ();
 
     vlc_object_lock( p_this );
     while( vlc_object_alive( p_this ) )
@@ -562,12 +570,14 @@ static void InteractionLoop( vlc_object_t *p_this )
     vlc_object_unlock( p_this );
 
     /* Remove all dialogs - Interfaces must be able to clean up their data */
-    for( i = p_interaction->i_dialogs -1 ; i >= 0; i-- )
+    for( int i = p_interaction->i_dialogs -1 ; i >= 0; i-- )
     {
         interaction_dialog_t * p_dialog = p_interaction->pp_dialogs[i];
         DialogDestroy( p_dialog );
         REMOVE_ELEM( p_interaction->pp_dialogs, p_interaction->i_dialogs, i );
     }
+    vlc_restorecancel (canc);
+    return NULL;
 }
 
 /**