From a54f78686f8d800851b4ca51add91f16c71df645 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C3=ABl=20Carr=C3=A9?= <funman@videolan.org> Date: Sun, 19 Nov 2006 03:43:32 +0000 Subject: [PATCH] Adds GetPlayingItem method Fixes Quit method Fixes TogglePause method --- modules/control/dbus.c | 30 ++++++++++++++++++++++++------ modules/control/dbus.h | 3 +++ 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/modules/control/dbus.c b/modules/control/dbus.c index 57f4c8501895..aef3024e1d61 100644 --- a/modules/control/dbus.c +++ b/modules/control/dbus.c @@ -105,7 +105,7 @@ DBUS_METHOD( Quit ) playlist_t *p_playlist = pl_Yield( (vlc_object_t*) p_this ); playlist_Stop( p_playlist ); pl_Release( ((vlc_object_t*) p_this) ); - ((vlc_object_t*)p_this)->b_die = VLC_TRUE; + ((vlc_object_t*)p_this)->p_libvlc->b_die = VLC_TRUE; REPLY_SEND; } @@ -135,6 +135,20 @@ DBUS_METHOD( Stop ) pl_Release( ((vlc_object_t*) p_this) ); REPLY_SEND; } + +DBUS_METHOD( GetPlayingItem ) +{ /* return the current item */ + REPLY_INIT; + OUT_ARGUMENTS; + char psz_no_input = '\0'; + char *p_psz_no_input = &psz_no_input; + playlist_t *p_playlist = pl_Yield( ((vlc_object_t*) p_this) ); + input_thread_t *p_input = p_playlist->p_input; + ADD_STRING( ( p_input ) ? &p_input->input.p_item->psz_name : &p_psz_no_input ); + pl_Release( ((vlc_object_t*) p_this) ); + REPLY_SEND; +} + DBUS_METHOD( GetPlayStatus ) { /* return a string */ REPLY_INIT; @@ -173,23 +187,26 @@ DBUS_METHOD( TogglePause ) vlc_value_t val; playlist_t *p_playlist = pl_Yield( (vlc_object_t*) p_this ); - PL_LOCK; input_thread_t *p_input = p_playlist->p_input; - - if( p_input ) + if( p_input != NULL ) { var_Get( p_input, "state", &val ); if( val.i_int != PAUSE_S ) { val.i_int = PAUSE_S; + playlist_Pause( p_playlist ); } else { val.i_int = PLAYING_S; + playlist_Play( p_playlist ); } - var_Set( p_input, "state", val ); } - PL_UNLOCK; + else + { + val.i_int = PLAYING_S; + playlist_Play( p_playlist ); + } pl_Release( p_playlist ); dbus_bool_t pause = ( val.i_int == PLAYING_S ) ? TRUE : FALSE; @@ -272,6 +289,7 @@ DBUS_METHOD( handle_messages ) /* here D-Bus method's names are associated to an handler */ METHOD_FUNC( "GetPlayStatus", GetPlayStatus ); + METHOD_FUNC( "GetPlayingItem", GetPlayingItem ); METHOD_FUNC( "AddMRL", AddMRL ); METHOD_FUNC( "TogglePause", TogglePause ); METHOD_FUNC( "Nothing", Nothing ); diff --git a/modules/control/dbus.h b/modules/control/dbus.h index f0e5fc0ccf90..4dd8b8f56e88 100644 --- a/modules/control/dbus.h +++ b/modules/control/dbus.h @@ -89,6 +89,9 @@ const char* psz_introspection_xml_data = " <method name=\"GetPlayStatus\">\n" " <arg type=\"s\" direction=\"out\" />\n" " </method>\n" +" <method name=\"GetPlayingItem\">\n" +" <arg type=\"s\" direction=\"out\" />\n" +" </method>\n" " <method name=\"TogglePause\">\n" " <arg type=\"s\" direction=\"out\" />\n" " </method>\n" -- GitLab