[vlc-devel] commit: Interaction: avoid thread if there is no provider ( Rémi Denis-Courmont )

git version control git at videolan.org
Sun Feb 1 11:57:19 CET 2009


vlc | branch: master | Rémi Denis-Courmont <rdenis at simphalempin.com> | Sun Feb  1 12:56:47 2009 +0200| [c00b6cab199aced4b4b748591e18cd70be10f6e8] | committer: Rémi Denis-Courmont 

Interaction: avoid thread if there is no provider

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=c00b6cab199aced4b4b748591e18cd70be10f6e8
---

 include/vlc_interface.h     |    1 +
 src/interface/interaction.c |   52 +++++++++++++++----------------------------
 2 files changed, 19 insertions(+), 34 deletions(-)

diff --git a/include/vlc_interface.h b/include/vlc_interface.h
index f3813d2..d4ea0df 100644
--- a/include/vlc_interface.h
+++ b/include/vlc_interface.h
@@ -224,6 +224,7 @@ struct interaction_dialog_t
     interaction_t  *p_interaction;      ///< Parent interaction object
     vlc_object_t   *p_parent;           ///< The vlc object that asked
                                         //for interaction
+    intf_thread_t  *p_interface;
 };
 
 /**
diff --git a/src/interface/interaction.c b/src/interface/interaction.c
index c3322c1..f041878 100644
--- a/src/interface/interaction.c
+++ b/src/interface/interaction.c
@@ -476,16 +476,27 @@ static void DialogDestroy( interaction_dialog_t *p_dialog )
  * if required */
 static int DialogSend( vlc_object_t *p_this, interaction_dialog_t *p_dialog )
 {
-    interaction_t *p_interaction = InteractionGet( p_dialog->p_parent );
+    interaction_t *p_interaction;
+    intf_thread_t *p_intf;
+
+    if( p_this->i_flags & OBJECT_FLAGS_NOINTERACT )
+        return VLC_EGENERIC;
 
+    p_interaction = InteractionGet( p_dialog->p_parent );
     if( !p_interaction )
         return VLC_EGENERIC;
 
-    if( p_this->i_flags & OBJECT_FLAGS_NOINTERACT )
+    p_intf = SearchInterface( p_interaction );
+    if( p_intf == NULL )
     {
+        p_dialog->i_return = DIALOG_DEFAULT; /* Give default answer */
+
+        /* Pretend we have hidden and destroyed it */
+        p_dialog->i_status = HIDING_DIALOG;
         vlc_object_release( p_interaction );
-        return VLC_EGENERIC;
+        return VLC_SUCCESS;
     }
+    p_dialog->p_interface = p_intf;
 
     if( config_GetInt( p_this, "interact" ) ||
         p_dialog->i_flags & DIALOG_BLOCKING_ERROR ||
@@ -585,26 +596,6 @@ static void InteractionManage( interaction_t *p_interaction )
     vlc_value_t val;
     int i_index;
 
-    /* Nothing to do */
-    if( p_interaction->i_dialogs == 0 ) return;
-
-    p_interaction->p_intf = SearchInterface( p_interaction );
-    if( !p_interaction->p_intf )
-    {
-        /* We mark all dialogs as answered with their "default" answer */
-        for( i_index = 0 ; i_index < p_interaction->i_dialogs; i_index ++ )
-        {
-            interaction_dialog_t *p_dialog = p_interaction->pp_dialogs[i_index];
-            p_dialog->i_return = DIALOG_DEFAULT; /* Give default answer */
-
-            /* Pretend we have hidden and destroyed it */
-            if( p_dialog->i_status == HIDDEN_DIALOG )
-                p_dialog->i_status = DESTROYED_DIALOG;
-            else
-                p_dialog->i_status = HIDING_DIALOG;
-        }
-    }
-
     for( i_index = 0 ; i_index < p_interaction->i_dialogs; i_index ++ )
     {
         interaction_dialog_t *p_dialog = p_interaction->pp_dialogs[i_index];
@@ -614,23 +605,20 @@ static void InteractionManage( interaction_t *p_interaction )
             /* Ask interface to hide it */
             p_dialog->i_action = INTERACT_HIDE;
             val.p_address = p_dialog;
-            if( p_interaction->p_intf )
-                var_Set( p_interaction->p_intf, "interaction", val );
+            var_Set( p_dialog->p_interface, "interaction", val );
             p_dialog->i_status = HIDING_DIALOG;
             break;
         case UPDATED_DIALOG:
             p_dialog->i_action = INTERACT_UPDATE;
             val.p_address = p_dialog;
-            if( p_interaction->p_intf )
-                var_Set( p_interaction->p_intf, "interaction", val );
+            var_Set( p_dialog->p_interface, "interaction", val );
             p_dialog->i_status = SENT_DIALOG;
             break;
         case HIDDEN_DIALOG:
             if( !(p_dialog->i_flags & DIALOG_GOT_ANSWER) ) break;
             p_dialog->i_action = INTERACT_DESTROY;
             val.p_address = p_dialog;
-            if( p_interaction->p_intf )
-                var_Set( p_interaction->p_intf, "interaction", val );
+            var_Set( p_dialog->p_interface, "interaction", val );
             break;
         case DESTROYED_DIALOG:
             /* Interface has now destroyed it, remove it */
@@ -644,13 +632,9 @@ static void InteractionManage( interaction_t *p_interaction )
 
             p_dialog->i_action = INTERACT_NEW;
             val.p_address = p_dialog;
-            if( p_interaction->p_intf )
-                var_Set( p_interaction->p_intf, "interaction", val );
+            var_Set( p_dialog->p_interface, "interaction", val );
             p_dialog->i_status = SENT_DIALOG;
             break;
         }
     }
-
-    if( p_interaction->p_intf )
-        vlc_object_release( p_interaction->p_intf );
 }




More information about the vlc-devel mailing list