Commit 67b96a07 authored by Erwan Tulou's avatar Erwan Tulou

skins2: better input management

This patch fixes failed assertions occurring sometimes on var_DelCallback for intf-event for input objects.
parent 808e8fb5
...@@ -53,6 +53,7 @@ ...@@ -53,6 +53,7 @@
#include "../utils/var_bool.hpp" #include "../utils/var_bool.hpp"
#include <sstream> #include <sstream>
#include <assert.h>
VlcProc *VlcProc::instance( intf_thread_t *pIntf ) VlcProc *VlcProc::instance( intf_thread_t *pIntf )
{ {
...@@ -205,9 +206,6 @@ VlcProc::~VlcProc() ...@@ -205,9 +206,6 @@ VlcProc::~VlcProc()
m_pVout = NULL; m_pVout = NULL;
} }
if( getIntf()->p_sys->p_input )
reset_input();
interaction_Unregister( getIntf() ); interaction_Unregister( getIntf() );
var_DelCallback( getIntf()->p_libvlc, "volume-change", var_DelCallback( getIntf()->p_libvlc, "volume-change",
...@@ -495,17 +493,8 @@ int VlcProc::onGenericCallback( vlc_object_t *pObj, const char *pVariable, ...@@ -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 ) 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); 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 // Update the stream variable
updateStreamName(); updateStreamName();
...@@ -525,6 +514,16 @@ void VlcProc::on_intf_event_changed( vlc_object_t* p_obj, vlc_value_t newVal ) ...@@ -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; 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 ) switch( newVal.i_int )
{ {
case INPUT_EVENT_STATE: case INPUT_EVENT_STATE:
...@@ -629,6 +628,14 @@ void VlcProc::on_intf_event_changed( vlc_object_t* p_obj, vlc_value_t newVal ) ...@@ -629,6 +628,14 @@ void VlcProc::on_intf_event_changed( vlc_object_t* p_obj, vlc_value_t newVal )
break; break;
case INPUT_EVENT_DEAD: 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(); reset_input();
break; break;
...@@ -641,6 +648,8 @@ void VlcProc::on_bit_rate_changed( vlc_object_t* p_obj, vlc_value_t newVal ) ...@@ -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; 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; int bitrate = var_GetInteger( pInput, "bit-rate" ) / 1000;
SET_TEXT( m_cVarStreamBitRate, UString::fromInt( getIntf(), bitrate ) ); 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 ) ...@@ -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; 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; int sampleRate = var_GetInteger( pInput, "sample-rate" ) / 1000;
SET_TEXT( m_cVarStreamSampleRate, UString::fromInt(getIntf(),sampleRate) ); 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 ) ...@@ -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; 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" ) ); 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 ) ...@@ -710,9 +723,6 @@ void VlcProc::on_audio_filter_changed( vlc_object_t* p_obj, vlc_value_t newVal )
void VlcProc::reset_input() void VlcProc::reset_input()
{ {
input_thread_t* pInput = getIntf()->p_sys->p_input;
if( !pInput ) return;
SET_BOOL( m_cVarSeekable, false ); SET_BOOL( m_cVarSeekable, false );
SET_BOOL( m_cVarRecordable, false ); SET_BOOL( m_cVarRecordable, false );
SET_BOOL( m_cVarRecording, false ); SET_BOOL( m_cVarRecording, false );
...@@ -727,13 +737,6 @@ void VlcProc::reset_input() ...@@ -727,13 +737,6 @@ void VlcProc::reset_input()
SET_STREAMTIME( m_cVarTime, 0, false ); SET_STREAMTIME( m_cVarTime, 0, false );
SET_TEXT( m_cVarStreamBitRate, UString( getIntf(), "") ); SET_TEXT( m_cVarStreamBitRate, UString( getIntf(), "") );
SET_TEXT( m_cVarStreamSampleRate, 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() void VlcProc::init_variables()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment