/** * PropertiesChangedSignal() synthetizes and sends the * org.freedesktop.DBus.Properties.PropertiesChanged signal */ static DBusHandlerResult PropertiesChangedSignal( intf_thread_t *p_intf, vlc_dictionary_t *p_changed_properties ) { DBusConnection *p_conn = p_intf->p_sys->p_conn; DBusMessageIter changed_properties, invalidated_properties; const char *psz_interface_name = DBUS_MPRIS_ROOT_INTERFACE; SIGNAL_INIT( DBUS_INTERFACE_PROPERTIES, DBUS_MPRIS_OBJECT_PATH, "PropertiesChanged" ); OUT_ARGUMENTS; ADD_STRING( &psz_interface_name ); if( !dbus_message_iter_open_container( &args, DBUS_TYPE_ARRAY, "{sv}", &changed_properties ) ) return DBUS_HANDLER_RESULT_NEED_MEMORY; if( vlc_dictionary_has_key( p_changed_properties, "Fullscreen" ) ) { if( AddProperty( p_intf, &changed_properties, "Fullscreen", "b", MarshalFullscreen ) != VLC_SUCCESS ) { dbus_message_iter_abandon_container( &args, &changed_properties ); return DBUS_HANDLER_RESULT_NEED_MEMORY; } } if( !dbus_message_iter_close_container( &args, &changed_properties ) ) return DBUS_HANDLER_RESULT_NEED_MEMORY; if( !dbus_message_iter_open_container( &args, DBUS_TYPE_ARRAY, "s", &invalidated_properties ) ) return DBUS_HANDLER_RESULT_NEED_MEMORY; if( !dbus_message_iter_close_container( &args, &invalidated_properties ) ) return DBUS_HANDLER_RESULT_NEED_MEMORY; SIGNAL_SEND; }
/** * ProcessEvents() reacts to a list of events originating from other VLC threads * * This function must be called with p_sys->lock unlocked * * @param intf_thread_t *p_intf This interface thread state * @param callback_info_t *p_events the list of events to process */ static void ProcessEvents( intf_thread_t *p_intf, callback_info_t **p_events, int i_events ) { playlist_t *p_playlist = p_intf->p_sys->p_playlist; bool b_can_play = p_intf->p_sys->b_can_play; vlc_dictionary_t player_properties, tracklist_properties; vlc_dictionary_init( &player_properties, 0 ); vlc_dictionary_init( &tracklist_properties, 0 ); for( int i = 0; i < i_events; i++ ) { switch( p_events[i]->signal ) { case SIGNAL_ITEM_CURRENT: TrackChange( p_intf ); vlc_dictionary_insert( &player_properties, "Metadata", NULL ); break; case SIGNAL_INTF_CHANGE: case SIGNAL_PLAYLIST_ITEM_APPEND: case SIGNAL_PLAYLIST_ITEM_DELETED: PL_LOCK; b_can_play = playlist_CurrentSize( p_playlist ) > 0; PL_UNLOCK; if( b_can_play != p_intf->p_sys->b_can_play ) { p_intf->p_sys->b_can_play = b_can_play; vlc_dictionary_insert( &player_properties, "CanPlay", NULL ); } if( !vlc_dictionary_has_key( &tracklist_properties, "Tracks" ) ) vlc_dictionary_insert( &tracklist_properties, "Tracks", NULL ); break; case SIGNAL_VOLUME_MUTED: case SIGNAL_VOLUME_CHANGE: vlc_dictionary_insert( &player_properties, "Volume", NULL ); break; case SIGNAL_RANDOM: vlc_dictionary_insert( &player_properties, "Shuffle", NULL ); break; case SIGNAL_REPEAT: case SIGNAL_LOOP: vlc_dictionary_insert( &player_properties, "LoopStatus", NULL ); break; case SIGNAL_STATE: vlc_dictionary_insert( &player_properties, "PlaybackStatus", NULL ); break; case SIGNAL_RATE: vlc_dictionary_insert( &player_properties, "Rate", NULL ); break; case SIGNAL_INPUT_METADATA: { input_thread_t *p_input = playlist_CurrentInput( p_playlist ); input_item_t *p_item; if( p_input ) { p_item = input_GetItem( p_input ); vlc_object_release( p_input ); if( p_item ) vlc_dictionary_insert( &player_properties, "Metadata", NULL ); } break; } case SIGNAL_CAN_SEEK: vlc_dictionary_insert( &player_properties, "CanSeek", NULL ); break; case SIGNAL_CAN_PAUSE: vlc_dictionary_insert( &player_properties, "CanPause", NULL ); break; case SIGNAL_SEEK: { input_thread_t *p_input; input_item_t *p_item; p_input = playlist_CurrentInput( p_intf->p_sys->p_playlist ); if( p_input ) { p_item = input_GetItem( p_input ); vlc_object_release( p_input ); if( p_item && ( p_item->i_id == p_events[i]->i_item ) ) SeekedEmit( p_intf ); } break; } default: assert(0); } free( p_events[i] ); } if( vlc_dictionary_keys_count( &player_properties ) ) PlayerPropertiesChangedEmit( p_intf, &player_properties ); if( vlc_dictionary_keys_count( &tracklist_properties ) ) TrackListPropertiesChangedEmit( p_intf, &tracklist_properties ); vlc_dictionary_clear( &player_properties, NULL, NULL ); vlc_dictionary_clear( &tracklist_properties, NULL, NULL ); }