Changeset 16364fa65c37326f7b99bb42b899a63b4a5ddbb5
- Timestamp:
- 25/03/08 02:25:24 (8 months ago)
- git-parent:
- Files:
-
- modules/control/dbus.c (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
modules/control/dbus.c
r67bda23 r16364fa 79 79 static int GetInputMeta ( input_item_t *, DBusMessageIter * ); 80 80 static int MarshalStatus ( intf_thread_t *, DBusMessageIter *, vlc_bool_t ); 81 static int UpdateCaps( intf_thread_t* ); 81 82 82 83 /* GetCaps() capabilities */ … … 307 308 REPLY_INIT; 308 309 OUT_ARGUMENTS; 309 playlist_t* p_playlist = pl_Yield( (vlc_object_t*) p_this ); 310 PL_LOCK; 311 312 dbus_int32_t i_caps = CAPS_NONE; 313 314 /* FIXME: 315 * Every capability should be checked in a callback, modifying p_sys->i_caps 316 * so we can send a signal whenever it changes. 317 * When it is done, GetCaps method will just return p_sys->i_caps 318 */ 319 320 if( p_playlist->items.i_size > 0 ) 321 i_caps |= CAPS_CAN_PLAY | CAPS_CAN_GO_PREV | CAPS_CAN_GO_NEXT; 322 323 if( p_playlist->p_input ) 324 { 325 access_t *p_access = (access_t*)vlc_object_find( p_playlist->p_input, 326 VLC_OBJECT_ACCESS, FIND_CHILD ); 327 if( p_access ) 328 { 329 vlc_bool_t b_can_pause; 330 if( !access2_Control( p_access, ACCESS_CAN_PAUSE, &b_can_pause ) && 331 b_can_pause ) 332 i_caps |= CAPS_CAN_PAUSE; 333 vlc_object_release( p_access ); 334 } 335 demux_t *p_demux = (demux_t*)vlc_object_find( p_playlist->p_input, 336 VLC_OBJECT_DEMUX, FIND_CHILD ); 337 if( p_demux ) 338 { /* XXX: is: demux can seek and access can not a possibility ? */ 339 vlc_bool_t b_can_seek; 340 if( !stream_Control( p_demux->s, STREAM_CAN_SEEK, &b_can_seek ) && 341 b_can_seek ) 342 i_caps |= CAPS_CAN_SEEK; 343 vlc_object_release( p_demux ); 344 } 345 } 346 347 if( ((intf_thread_t*)p_this)->p_sys->b_meta_read ) 348 i_caps |= CAPS_CAN_PROVIDE_METADATA; 349 350 PL_UNLOCK; 351 352 ADD_INT32( &i_caps ); 310 311 UpdateCaps( (intf_thread_t*)p_this ); 312 ADD_INT32( &((intf_thread_t*)p_this)->p_sys->i_caps ); 353 313 354 314 REPLY_SEND; … … 766 726 p_sys->p_conn = p_conn; 767 727 728 UpdateCaps( p_intf ); 729 768 730 return VLC_SUCCESS; 769 731 } … … 817 779 dbus_connection_read_write_dispatch( p_intf->p_sys->p_conn, 0 ); 818 780 } 781 } 782 783 /****************************************************************************** 784 * CapsChange: player capabilities change signal 785 *****************************************************************************/ 786 DBUS_SIGNAL( CapsChangeSignal ) 787 { 788 SIGNAL_INIT( "CapsChange" ); 789 OUT_ARGUMENTS; 790 791 ADD_INT32( &((intf_thread_t*)p_data)->p_sys->i_caps ); 792 SIGNAL_SEND; 819 793 } 820 794 … … 862 836 return VLC_SUCCESS; 863 837 838 /* We're called from the playlist, so that would cause locking issues */ 839 /* UpdateCaps( p_intf ); */ 864 840 TrackListChangeSignal( p_intf->p_sys->p_conn, p_data ); 865 841 return VLC_SUCCESS; … … 925 901 } 926 902 903 927 904 return VLC_SUCCESS; 928 905 } … … 941 918 return VLC_SUCCESS; 942 919 920 UpdateCaps( p_intf ); 943 921 StatusChangeSignal( p_intf->p_sys->p_conn, p_data ); 944 922 return VLC_SUCCESS; … … 992 970 } 993 971 972 UpdateCaps( p_intf ); 973 974 var_AddCallback( p_input, "state", StateChange, p_intf ); 975 976 vlc_object_release( p_input ); 977 return VLC_SUCCESS; 978 } 979 980 /***************************************************************************** 981 * UpdateCaps: update p_sys->i_caps 982 ****************************************************************************/ 983 static int UpdateCaps( intf_thread_t* p_intf ) 984 { 994 985 dbus_int32_t i_caps = CAPS_NONE; 995 986 playlist_t* p_playlist = pl_Yield( (vlc_object_t*)p_intf ); 987 PL_LOCK; 988 996 989 if( p_playlist->items.i_size > 0 ) 997 990 i_caps |= CAPS_CAN_PLAY | CAPS_CAN_GO_PREV | CAPS_CAN_GO_NEXT; … … 1021 1014 } 1022 1015 1023 if( ((intf_thread_t*)p_this)->p_sys->b_meta_read ) 1016 PL_UNLOCK; 1017 pl_Release( p_playlist ); 1018 1019 if( p_intf->p_sys->b_meta_read ) 1024 1020 i_caps |= CAPS_CAN_PROVIDE_METADATA; 1025 1021 1026 1027 var_AddCallback( p_input, "state", StateChange, p_intf ); 1028 1029 vlc_object_release( p_input ); 1022 if( i_caps != p_intf->p_sys->i_caps ) 1023 { 1024 p_intf->p_sys->i_caps = i_caps; 1025 CapsChangeSignal( p_intf->p_sys->p_conn, (vlc_object_t*)p_intf ); 1026 } 1027 1030 1028 return VLC_SUCCESS; 1031 1029 }
