Commit cccd154d authored by Rémi Duraffort's avatar Rémi Duraffort

dbus: fix another locking problem.

parent f1238847
...@@ -65,9 +65,7 @@ static int Open ( vlc_object_t * ); ...@@ -65,9 +65,7 @@ static int Open ( vlc_object_t * );
static void Close ( vlc_object_t * ); static void Close ( vlc_object_t * );
static void Run ( intf_thread_t * ); static void Run ( intf_thread_t * );
static int StateChange( vlc_object_t *, const char *, vlc_value_t, static int StateChange( intf_thread_t *, int );
vlc_value_t, void * );
static int TrackChange( intf_thread_t * ); static int TrackChange( intf_thread_t * );
static int StatusChangeEmit( intf_thread_t *); static int StatusChangeEmit( intf_thread_t *);
static int TrackListChangeEmit( intf_thread_t *, int, int ); static int TrackListChangeEmit( intf_thread_t *, int, int );
...@@ -118,6 +116,7 @@ typedef struct ...@@ -118,6 +116,7 @@ typedef struct
{ {
int signal; int signal;
int i_node; int i_node;
int i_input_state;
} callback_info_t; } callback_info_t;
...@@ -808,7 +807,7 @@ static void Close ( vlc_object_t *p_this ) ...@@ -808,7 +807,7 @@ static void Close ( vlc_object_t *p_this )
p_input = playlist_CurrentInput( p_playlist ); p_input = playlist_CurrentInput( p_playlist );
if ( p_input ) if ( p_input )
{ {
var_DelCallback( p_input, "state", StateChange, p_intf ); var_DelCallback( p_input, "state", AllCallback, p_intf );
vlc_object_release( p_input ); vlc_object_release( p_input );
} }
...@@ -853,6 +852,9 @@ static void Run ( intf_thread_t *p_intf ) ...@@ -853,6 +852,9 @@ static void Run ( intf_thread_t *p_intf )
case SIGNAL_LOOP: case SIGNAL_LOOP:
StatusChangeEmit( p_intf ); StatusChangeEmit( p_intf );
break; break;
case SIGNAL_STATE:
StateChange( p_intf, info->i_input_state );
break;
default: default:
assert(0); assert(0);
} }
...@@ -895,6 +897,11 @@ static int AllCallback( vlc_object_t *p_this, const char *psz_var, ...@@ -895,6 +897,11 @@ static int AllCallback( vlc_object_t *p_this, const char *psz_var,
info->signal = SIGNAL_REPEAT; info->signal = SIGNAL_REPEAT;
else if( !strcmp( "loop", psz_var ) ) else if( !strcmp( "loop", psz_var ) )
info->signal = SIGNAL_LOOP; info->signal = SIGNAL_LOOP;
else if( !strcmp( "state", psz_var ) )
{
info->signal = SIGNAL_STATE;
info->i_input_state = newval.i_int;
}
else else
assert(0); assert(0);
...@@ -1000,32 +1007,41 @@ DBUS_SIGNAL( StatusChangeSignal ) ...@@ -1000,32 +1007,41 @@ DBUS_SIGNAL( StatusChangeSignal )
/***************************************************************************** /*****************************************************************************
* StateChange: callback on input "state" * StateChange: callback on input "state"
*****************************************************************************/ *****************************************************************************/
static int StateChange( vlc_object_t *p_this, const char* psz_var, //static int StateChange( vlc_object_t *p_this, const char* psz_var,
vlc_value_t oldval, vlc_value_t newval, void *p_data ) // vlc_value_t oldval, vlc_value_t newval, void *p_data )
static int StateChange( intf_thread_t *p_intf, int i_input_state )
{ {
VLC_UNUSED(psz_var); VLC_UNUSED(oldval);
intf_thread_t *p_intf = ( intf_thread_t* ) p_data;
intf_sys_t *p_sys = p_intf->p_sys; intf_sys_t *p_sys = p_intf->p_sys;
playlist_t *p_playlist;
input_thread_t *p_input;
input_item_t *p_item;
if( p_intf->p_sys->b_dead ) if( p_intf->p_sys->b_dead )
return VLC_SUCCESS; return VLC_SUCCESS;
UpdateCaps( p_intf, true ); UpdateCaps( p_intf, pl_Unlocked );
if( !p_sys->b_meta_read && newval.i_int == PLAYING_S ) if( !p_sys->b_meta_read && i_input_state == PLAYING_S )
{ {
input_item_t *p_item = input_GetItem( (input_thread_t*)p_this ); p_playlist = pl_Hold( p_intf );
if( p_item ) p_input = playlist_CurrentInput( p_playlist );
if( p_input )
{ {
p_sys->b_meta_read = true; p_item = input_GetItem( p_input );
TrackChangeSignal( p_sys->p_conn, p_item ); if( p_item )
{
p_sys->b_meta_read = true;
TrackChangeSignal( p_sys->p_conn, p_item );
}
vlc_object_release( p_input );
} }
pl_Release( p_intf );
} }
if( newval.i_int == PLAYING_S || newval.i_int == PAUSE_S || if( i_input_state == PLAYING_S || i_input_state == PAUSE_S ||
newval.i_int == END_S ) i_input_state == END_S )
{ {
StatusChangeSignal( p_sys->p_conn, (void*) p_intf ); StatusChangeSignal( p_sys->p_conn, p_intf );
} }
return VLC_SUCCESS; return VLC_SUCCESS;
...@@ -1082,7 +1098,7 @@ static int TrackChange( intf_thread_t *p_intf ) ...@@ -1082,7 +1098,7 @@ static int TrackChange( intf_thread_t *p_intf )
TrackChangeSignal( p_sys->p_conn, p_item ); TrackChangeSignal( p_sys->p_conn, p_item );
} }
var_AddCallback( p_input, "state", StateChange, p_intf ); var_AddCallback( p_input, "state", AllCallback, p_intf );
vlc_object_release( p_input ); vlc_object_release( p_input );
return VLC_SUCCESS; return VLC_SUCCESS;
......
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