[vlc-devel] commit: skins2: better input management (Erwan Tulou )

git version control git at videolan.org
Thu Dec 10 23:28:28 CET 2009


vlc | branch: master | Erwan Tulou <erwan10 at videolan.org> | Thu Dec 10 22:05:29 2009 +0100| [67b96a07c561ad10581549f45e49ad4dd962ba27] | committer: Erwan Tulou 

skins2: better input management

This patch fixes failed assertions occurring sometimes on var_DelCallback for intf-event for input objects.

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

 modules/gui/skins2/src/vlcproc.cpp |   47 +++++++++++++++++++----------------
 1 files changed, 25 insertions(+), 22 deletions(-)

diff --git a/modules/gui/skins2/src/vlcproc.cpp b/modules/gui/skins2/src/vlcproc.cpp
index 846c815..c8dacf7 100644
--- a/modules/gui/skins2/src/vlcproc.cpp
+++ b/modules/gui/skins2/src/vlcproc.cpp
@@ -53,6 +53,7 @@
 #include "../utils/var_bool.hpp"
 #include <sstream>
 
+#include <assert.h>
 
 VlcProc *VlcProc::instance( intf_thread_t *pIntf )
 {
@@ -205,9 +206,6 @@ VlcProc::~VlcProc()
         m_pVout = NULL;
     }
 
-    if( getIntf()->p_sys->p_input )
-        reset_input();
-
     interaction_Unregister( getIntf() );
 
     var_DelCallback( getIntf()->p_libvlc, "volume-change",
@@ -495,17 +493,8 @@ int VlcProc::onGenericCallback( vlc_object_t *pObj, const char *pVariable,
 
 void VlcProc::on_item_current_changed( vlc_object_t* p_obj, vlc_value_t newVal )
 {
-    playlist_t * pPlaylist = getIntf()->p_sys->p_playlist;
-    input_thread_t* pInput = getIntf()->p_sys->p_input;
     input_item_t *p_item = static_cast<input_item_t*>(newVal.p_address);
 
-    if( pInput )
-        reset_input();
-
-    pInput = playlist_CurrentInput( pPlaylist );
-    if( pInput )
-        getIntf()->p_sys->p_input = pInput;
-
     // Update the stream variable
     updateStreamName();
 
@@ -525,6 +514,16 @@ void VlcProc::on_intf_event_changed( vlc_object_t* p_obj, vlc_value_t newVal )
 {
     input_thread_t* pInput = (input_thread_t*) p_obj;
 
+    assert( getIntf()->p_sys->p_input == NULL || getIntf()->p_sys->p_input == pInput );
+
+    if( !getIntf()->p_sys->p_input )
+    {
+        msg_Dbg( getIntf(), "new input %p detected", pInput );
+
+        getIntf()->p_sys->p_input = pInput;
+        vlc_object_hold( pInput );
+    }
+
     switch( newVal.i_int )
     {
         case INPUT_EVENT_STATE:
@@ -629,6 +628,14 @@ void VlcProc::on_intf_event_changed( vlc_object_t* p_obj, vlc_value_t newVal )
             break;
 
         case INPUT_EVENT_DEAD:
+            msg_Dbg( getIntf(), "end of input detected for %p", pInput );
+
+            var_DelCallback( pInput, "intf-event", onGenericCallback, this );
+            var_DelCallback( pInput, "bit-rate", onGenericCallback, this );
+            var_DelCallback( pInput, "sample-rate", onGenericCallback, this );
+            var_DelCallback( pInput, "can-record" , onGenericCallback, this );
+            vlc_object_release( pInput );
+            getIntf()->p_sys->p_input = NULL;
             reset_input();
             break;
 
@@ -641,6 +648,8 @@ void VlcProc::on_bit_rate_changed( vlc_object_t* p_obj, vlc_value_t newVal )
 {
     input_thread_t* pInput = (input_thread_t*) p_obj;
 
+    assert( getIntf()->p_sys->p_input == NULL || getIntf()->p_sys->p_input == pInput );
+
     int bitrate = var_GetInteger( pInput, "bit-rate" ) / 1000;
     SET_TEXT( m_cVarStreamBitRate, UString::fromInt( getIntf(), bitrate ) );
 }
@@ -649,6 +658,8 @@ void VlcProc::on_sample_rate_changed( vlc_object_t* p_obj, vlc_value_t newVal )
 {
     input_thread_t* pInput = (input_thread_t*) p_obj;
 
+    assert( getIntf()->p_sys->p_input == NULL || getIntf()->p_sys->p_input == pInput );
+
     int sampleRate = var_GetInteger( pInput, "sample-rate" ) / 1000;
     SET_TEXT( m_cVarStreamSampleRate, UString::fromInt(getIntf(),sampleRate) );
 }
@@ -657,6 +668,8 @@ void VlcProc::on_can_record_changed( vlc_object_t* p_obj, vlc_value_t newVal )
 {
     input_thread_t* pInput = (input_thread_t*) p_obj;
 
+    assert( getIntf()->p_sys->p_input == NULL || getIntf()->p_sys->p_input == pInput );
+
     SET_BOOL( m_cVarRecordable, var_GetBool(  pInput, "can-record" ) );
 }
 
@@ -710,9 +723,6 @@ void VlcProc::on_audio_filter_changed( vlc_object_t* p_obj, vlc_value_t newVal )
 
 void VlcProc::reset_input()
 {
-    input_thread_t* pInput = getIntf()->p_sys->p_input;
-    if( !pInput ) return;
-
     SET_BOOL( m_cVarSeekable, false );
     SET_BOOL( m_cVarRecordable, false );
     SET_BOOL( m_cVarRecording, false );
@@ -727,13 +737,6 @@ void VlcProc::reset_input()
     SET_STREAMTIME( m_cVarTime, 0, false );
     SET_TEXT( m_cVarStreamBitRate, UString( getIntf(), "") );
     SET_TEXT( m_cVarStreamSampleRate, UString( getIntf(), "") );
-
-    var_DelCallback( pInput, "intf-event", onGenericCallback, this );
-    var_DelCallback( pInput, "bit-rate", onGenericCallback, this );
-    var_DelCallback( pInput, "sample-rate", onGenericCallback, this );
-    var_DelCallback( pInput, "can-record" , onGenericCallback, this );
-    vlc_object_release( pInput );
-    getIntf()->p_sys->p_input = NULL;
 }
 
 void VlcProc::init_variables()




More information about the vlc-devel mailing list