[vlc-commits] skins2: factorize some code

Erwan Tulou git at videolan.org
Mon Jan 28 15:19:25 CET 2013


vlc | branch: master | Erwan Tulou <erwan10 at videolan.org> | Mon Jan 28 12:35:00 2013 +0100| [d5d09d94ccfa4516e3b6abab6e2afaf12ea10406] | committer: Erwan Tulou

skins2: factorize some code

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

 modules/gui/skins2/src/vlcproc.cpp |   52 +++++++++++++++++++++---------------
 modules/gui/skins2/src/vlcproc.hpp |    3 +++
 2 files changed, 34 insertions(+), 21 deletions(-)

diff --git a/modules/gui/skins2/src/vlcproc.cpp b/modules/gui/skins2/src/vlcproc.cpp
index c7a8a3d..80b1395 100644
--- a/modules/gui/skins2/src/vlcproc.cpp
+++ b/modules/gui/skins2/src/vlcproc.cpp
@@ -453,27 +453,7 @@ void VlcProc::on_intf_event_changed( vlc_object_t* p_obj, vlc_value_t newVal )
         getIntf()->p_sys->p_input = pInput;
         vlc_object_hold( pInput );
 
-        input_item_t *p_item = input_GetItem( pInput );
-        if( p_item )
-        {
-            // Update short name
-            char *psz_name = input_item_GetName( p_item );
-            SET_TEXT( m_cVarStreamName, UString( getIntf(), psz_name ) );
-            free( psz_name );
-
-            // Update local path (if possible) or full uri
-            char *psz_uri = input_item_GetURI( p_item );
-            char *psz_path = make_path( psz_uri );
-            char *psz_save = psz_path ? psz_path : psz_uri;
-            SET_TEXT( m_cVarStreamURI, UString( getIntf(), psz_save ) );
-            free( psz_path );
-            free( psz_uri );
-
-            // Update art uri
-            char *psz_art = input_item_GetArtURL( p_item );
-            SET_STRING( m_cVarStreamArt, string( psz_art ? psz_art : "" ) );
-            free( psz_art );
-        }
+        update_current_input();
     }
 
     switch( newVal.i_int )
@@ -794,6 +774,36 @@ void VlcProc::init_variables()
     update_equalizer();
 }
 
+
+void VlcProc::update_current_input()
+{
+    input_thread_t* pInput = getIntf()->p_sys->p_input;
+    if( !pInput )
+        return;
+
+    input_item_t *p_item = input_GetItem( pInput );
+    if( p_item )
+    {
+        // Update short name
+        char *psz_name = input_item_GetName( p_item );
+        SET_TEXT( m_cVarStreamName, UString( getIntf(), psz_name ) );
+        free( psz_name );
+
+        // Update local path (if possible) or full uri
+        char *psz_uri = input_item_GetURI( p_item );
+        char *psz_path = make_path( psz_uri );
+        char *psz_save = psz_path ? psz_path : psz_uri;
+        SET_TEXT( m_cVarStreamURI, UString( getIntf(), psz_save ) );
+        free( psz_path );
+        free( psz_uri );
+
+        // Update art uri
+        char *psz_art = input_item_GetArtURL( p_item );
+        SET_STRING( m_cVarStreamArt, string( psz_art ? psz_art : "" ) );
+        free( psz_art );
+    }
+}
+
 void VlcProc::update_equalizer()
 {
 
diff --git a/modules/gui/skins2/src/vlcproc.hpp b/modules/gui/skins2/src/vlcproc.hpp
index ff397ef..6373102 100644
--- a/modules/gui/skins2/src/vlcproc.hpp
+++ b/modules/gui/skins2/src/vlcproc.hpp
@@ -98,6 +98,9 @@ public:
     /// update equalizer
     void update_equalizer( );
 
+    /// update global variables for the current input
+    void update_current_input( );
+
     void on_intf_event_changed( vlc_object_t* p_obj, vlc_value_t newVal );
     void on_bit_rate_changed( vlc_object_t* p_obj, vlc_value_t newVal );
     void on_sample_rate_changed( vlc_object_t* p_obj, vlc_value_t newVal );



More information about the vlc-commits mailing list