Commit 96067e49 authored by Rafaël Carré's avatar Rafaël Carré

dbus: monitor input state change through "intf-event"

End of playlist is still not notified
parent a34ed254
...@@ -67,7 +67,7 @@ static int Open ( vlc_object_t * ); ...@@ -67,7 +67,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( intf_thread_t *, int ); static int StateChange( intf_thread_t * );
static int TrackChange( intf_thread_t * ); static int TrackChange( intf_thread_t * );
static int AllCallback( vlc_object_t*, const char*, vlc_value_t, vlc_value_t, void* ); static int AllCallback( vlc_object_t*, const char*, vlc_value_t, vlc_value_t, void* );
...@@ -75,7 +75,6 @@ typedef struct ...@@ -75,7 +75,6 @@ typedef struct
{ {
int signal; int signal;
int i_node; int i_node;
int i_input_state;
} callback_info_t; } callback_info_t;
/***************************************************************************** /*****************************************************************************
...@@ -117,6 +116,7 @@ static int Open( vlc_object_t *p_this ) ...@@ -117,6 +116,7 @@ static int Open( vlc_object_t *p_this )
p_sys->i_caps = CAPS_NONE; p_sys->i_caps = CAPS_NONE;
p_sys->b_dead = false; p_sys->b_dead = false;
p_sys->p_input = NULL; p_sys->p_input = NULL;
p_sys->i_playing_state = -1;
p_sys->b_unique = var_CreateGetBool( p_intf, "dbus-unique-service-id" ); p_sys->b_unique = var_CreateGetBool( p_intf, "dbus-unique-service-id" );
if( p_sys->b_unique ) if( p_sys->b_unique )
...@@ -212,7 +212,7 @@ static void Close ( vlc_object_t *p_this ) ...@@ -212,7 +212,7 @@ static void Close ( vlc_object_t *p_this )
if( p_sys->p_input ) if( p_sys->p_input )
{ {
var_DelCallback( p_sys->p_input, "state", AllCallback, p_intf ); var_DelCallback( p_sys->p_input, "intf-event", AllCallback, p_intf );
vlc_object_release( p_sys->p_input ); vlc_object_release( p_sys->p_input );
} }
...@@ -280,7 +280,7 @@ static void Run ( intf_thread_t *p_intf ) ...@@ -280,7 +280,7 @@ static void Run ( intf_thread_t *p_intf )
StatusChangeEmit( p_intf ); StatusChangeEmit( p_intf );
break; break;
case SIGNAL_STATE: case SIGNAL_STATE:
StateChange( p_intf, info[i]->i_input_state ); StateChange( p_intf );
break; break;
default: default:
assert(0); assert(0);
...@@ -342,6 +342,8 @@ static int AllCallback( vlc_object_t *p_this, const char *psz_var, ...@@ -342,6 +342,8 @@ static int AllCallback( vlc_object_t *p_this, const char *psz_var,
if( !info ) if( !info )
return VLC_ENOMEM; return VLC_ENOMEM;
vlc_mutex_lock( &p_intf->p_sys->lock );
// Wich event is it ? // Wich event is it ?
if( !strcmp( "item-current", psz_var ) ) if( !strcmp( "item-current", psz_var ) )
info->signal = SIGNAL_ITEM_CURRENT; info->signal = SIGNAL_ITEM_CURRENT;
...@@ -360,17 +362,24 @@ static int AllCallback( vlc_object_t *p_this, const char *psz_var, ...@@ -360,17 +362,24 @@ 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 ) ) else if( !strcmp( "intf-event", psz_var ) )
{ {
dbus_int32_t state;
state = (var_GetInteger(p_this, "state") == PAUSE_S) ? 1 : 0;
if( state == p_intf->p_sys->i_playing_state )
goto end;
p_intf->p_sys->i_playing_state = state;
info->signal = SIGNAL_STATE; info->signal = SIGNAL_STATE;
info->i_input_state = newval.i_int;
} }
else else
assert(0); assert(0);
// Append the event // Append the event
vlc_mutex_lock( &p_intf->p_sys->lock );
vlc_array_append( p_intf->p_sys->p_events, info ); vlc_array_append( p_intf->p_sys->p_events, info );
end:
vlc_mutex_unlock( &p_intf->p_sys->lock ); vlc_mutex_unlock( &p_intf->p_sys->lock );
return VLC_SUCCESS; return VLC_SUCCESS;
} }
...@@ -378,9 +387,7 @@ static int AllCallback( vlc_object_t *p_this, const char *psz_var, ...@@ -378,9 +387,7 @@ static int AllCallback( vlc_object_t *p_this, const char *psz_var,
/***************************************************************************** /*****************************************************************************
* 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( intf_thread_t *p_intf )
// vlc_value_t oldval, vlc_value_t newval, void *p_data )
static int StateChange( intf_thread_t *p_intf, int i_input_state )
{ {
intf_sys_t *p_sys = p_intf->p_sys; intf_sys_t *p_sys = p_intf->p_sys;
playlist_t *p_playlist = p_sys->p_playlist; playlist_t *p_playlist = p_sys->p_playlist;
...@@ -392,7 +399,7 @@ static int StateChange( intf_thread_t *p_intf, int i_input_state ) ...@@ -392,7 +399,7 @@ static int StateChange( intf_thread_t *p_intf, int i_input_state )
UpdateCaps( p_intf ); UpdateCaps( p_intf );
if( !p_sys->b_meta_read && i_input_state == PLAYING_S ) if( !p_sys->b_meta_read && p_sys->i_playing_state == 0)
{ {
p_input = playlist_CurrentInput( p_playlist ); p_input = playlist_CurrentInput( p_playlist );
if( p_input ) if( p_input )
...@@ -407,11 +414,7 @@ static int StateChange( intf_thread_t *p_intf, int i_input_state ) ...@@ -407,11 +414,7 @@ static int StateChange( intf_thread_t *p_intf, int i_input_state )
} }
} }
if( i_input_state == PLAYING_S || i_input_state == PAUSE_S || StatusChangeEmit( p_intf );
i_input_state == END_S )
{
StatusChangeEmit( p_intf );
}
return VLC_SUCCESS; return VLC_SUCCESS;
} }
...@@ -431,7 +434,7 @@ static int TrackChange( intf_thread_t *p_intf ) ...@@ -431,7 +434,7 @@ static int TrackChange( intf_thread_t *p_intf )
if( p_sys->p_input ) if( p_sys->p_input )
{ {
var_DelCallback( p_sys->p_input, "state", AllCallback, p_intf ); var_DelCallback( p_sys->p_input, "intf-event", AllCallback, p_intf );
vlc_object_release( p_sys->p_input ); vlc_object_release( p_sys->p_input );
p_sys->p_input = NULL; p_sys->p_input = NULL;
} }
...@@ -458,7 +461,7 @@ static int TrackChange( intf_thread_t *p_intf ) ...@@ -458,7 +461,7 @@ static int TrackChange( intf_thread_t *p_intf )
} }
p_sys->p_input = p_input; p_sys->p_input = p_input;
var_AddCallback( p_input, "state", AllCallback, p_intf ); var_AddCallback( p_input, "intf-event", AllCallback, p_intf );
return VLC_SUCCESS; return VLC_SUCCESS;
} }
......
...@@ -85,6 +85,7 @@ struct intf_sys_t ...@@ -85,6 +85,7 @@ struct intf_sys_t
playlist_t *p_playlist; playlist_t *p_playlist;
bool b_meta_read; bool b_meta_read;
dbus_int32_t i_caps; dbus_int32_t i_caps;
dbus_int32_t i_playing_state;
bool b_dead; bool b_dead;
vlc_array_t *p_events; vlc_array_t *p_events;
vlc_mutex_t lock; vlc_mutex_t lock;
......
...@@ -446,24 +446,11 @@ static int MarshalStatus( intf_thread_t* p_intf, DBusMessageIter* args ) ...@@ -446,24 +446,11 @@ static int MarshalStatus( intf_thread_t* p_intf, DBusMessageIter* args )
DBusMessageIter status; DBusMessageIter status;
dbus_int32_t i_state, i_random, i_repeat, i_loop; dbus_int32_t i_state, i_random, i_repeat, i_loop;
int i_val;
playlist_t* p_playlist = p_intf->p_sys->p_playlist; playlist_t* p_playlist = p_intf->p_sys->p_playlist;
input_thread_t* p_input = NULL;
i_state = 2; vlc_mutex_lock( &p_intf->p_sys->lock );
i_state = p_intf->p_sys->i_playing_state;
p_input = playlist_CurrentInput( p_playlist ); vlc_mutex_unlock( &p_intf->p_sys->lock );
if( p_input )
{
i_val = var_GetInteger( p_input, "state" );
if( i_val >= END_S )
i_state = 2;
else if( i_val == PAUSE_S )
i_state = 1;
else if( i_val <= PLAYING_S )
i_state = 0;
vlc_object_release( p_input );
}
i_random = var_CreateGetBool( p_playlist, "random" ); i_random = var_CreateGetBool( p_playlist, "random" );
......
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