]> git.sesse.net Git - vlc/blobdiff - modules/control/dbus/dbus_player.c
playlist: rename playlist_Pause() to playlist_TogglePause()
[vlc] / modules / control / dbus / dbus_player.c
index e2332a9caa15277c893e1aa0279a2576aba21744..d55824906106c0c22571b17d5893eb7df03c806f 100644 (file)
@@ -32,6 +32,7 @@
 
 #include <vlc_common.h>
 #include <vlc_playlist.h>
+#include <vlc_input.h>
 #include <vlc_interface.h>
 
 #include <math.h>
@@ -44,8 +45,7 @@ MarshalPosition( intf_thread_t *p_intf, DBusMessageIter *container )
 {
     /* returns position in microseconds */
     dbus_int64_t i_pos;
-    input_thread_t *p_input;
-    p_input = playlist_CurrentInput( p_intf->p_sys->p_playlist );
+    input_thread_t *p_input = pl_CurrentInput( p_intf );
 
     if( !p_input )
         i_pos = 0;
@@ -87,7 +87,7 @@ DBUS_METHOD( SetPosition )
         return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
     }
 
-    input_thread_t *p_input = playlist_CurrentInput( PL );
+    input_thread_t *p_input = pl_CurrentInput( p_this );
 
     if( p_input )
     {
@@ -138,7 +138,7 @@ DBUS_METHOD( Seek )
         return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
     }
 
-    input_thread_t *p_input = playlist_CurrentInput( PL );
+    input_thread_t *p_input = pl_CurrentInput( p_this );
     if( p_input && var_GetBool( p_input, "can-seek" ) )
     {
         i_pos = var_GetTime( p_input, "time" );
@@ -208,7 +208,7 @@ DBUS_METHOD( Stop )
 DBUS_METHOD( Play )
 {
     REPLY_INIT;
-    input_thread_t *p_input =  playlist_CurrentInput( PL );
+    input_thread_t *p_input =  pl_CurrentInput( p_this );
 
     if( !p_input || var_GetInteger( p_input, "state" ) != PLAYING_S )
         playlist_Play( PL );
@@ -222,10 +222,10 @@ DBUS_METHOD( Play )
 DBUS_METHOD( Pause )
 {
     REPLY_INIT;
-    input_thread_t *p_input = playlist_CurrentInput( PL );
+    input_thread_t *p_input = pl_CurrentInput( p_this );
 
     if( p_input && var_GetInteger(p_input, "state") == PLAYING_S )
-        playlist_Pause( PL );
+        playlist_TogglePause( PL );
 
     if( p_input )
         vlc_object_release( p_input );
@@ -236,10 +236,10 @@ DBUS_METHOD( Pause )
 DBUS_METHOD( PlayPause )
 {
     REPLY_INIT;
-    input_thread_t *p_input = playlist_CurrentInput( PL );
+    input_thread_t *p_input = pl_CurrentInput( p_this );
 
     if( p_input && var_GetInteger(p_input, "state") == PLAYING_S )
-        playlist_Pause( PL );
+        playlist_TogglePause( PL );
     else
         playlist_Play( PL );
 
@@ -324,8 +324,7 @@ static int
 MarshalCanPause( intf_thread_t *p_intf, DBusMessageIter *container )
 {
     dbus_bool_t b_can_pause = FALSE;
-    input_thread_t *p_input;
-    p_input = playlist_CurrentInput( p_intf->p_sys->p_playlist );
+    input_thread_t *p_input = pl_CurrentInput( p_intf );
 
     if( p_input )
     {
@@ -357,8 +356,7 @@ static int
 MarshalCanSeek( intf_thread_t *p_intf, DBusMessageIter *container )
 {
     dbus_bool_t b_can_seek = FALSE;
-    input_thread_t *p_input;
-    p_input = playlist_CurrentInput( p_intf->p_sys->p_playlist );
+    input_thread_t *p_input = pl_CurrentInput( p_intf );
 
     if( p_input )
     {
@@ -401,10 +399,10 @@ DBUS_METHOD( ShuffleSet )
 static int
 MarshalPlaybackStatus( intf_thread_t *p_intf, DBusMessageIter *container )
 {
-    input_thread_t *p_input;
+    input_thread_t *p_input = pl_CurrentInput( p_intf );
     const char *psz_playback_status;
 
-    if( ( p_input = playlist_CurrentInput( p_intf->p_sys->p_playlist ) ) )
+    if( p_input != NULL )
     {
         switch( var_GetInteger( p_input, "state" ) )
         {
@@ -435,9 +433,9 @@ static int
 MarshalRate( intf_thread_t *p_intf, DBusMessageIter *container )
 {
     double d_rate;
-    input_thread_t *p_input;
+    input_thread_t *p_input = pl_CurrentInput( p_intf );
 
-    if( ( p_input = playlist_CurrentInput( p_intf->p_sys->p_playlist ) ) )
+    if( p_input != NULL )
     {
         d_rate = var_GetFloat( p_input, "rate" );
         vlc_object_release( (vlc_object_t*) p_input );
@@ -461,8 +459,8 @@ DBUS_METHOD( RateSet )
     if( VLC_SUCCESS != DemarshalSetPropertyValue( p_from, &d_rate ) )
         return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
 
-    input_thread_t *p_input;
-    if( ( p_input = playlist_CurrentInput( PL ) ) )
+    input_thread_t *p_input = pl_CurrentInput( p_this );
+    if( p_input != NULL )
     {
         var_SetFloat( p_input, "rate", (float) d_rate );
         vlc_object_release( (vlc_object_t*) p_input );
@@ -551,10 +549,10 @@ static int
 MarshalMetadata( intf_thread_t *p_intf, DBusMessageIter *container )
 {
     DBusMessageIter a;
-    input_thread_t *p_input = NULL;
+    input_thread_t *p_input = pl_CurrentInput( p_intf );
     input_item_t   *p_item  = NULL;
 
-    if( ( p_input = playlist_CurrentInput( p_intf->p_sys->p_playlist ) ) )
+    if( p_input != NULL )
     {
         p_item = input_GetItem( p_input );
 
@@ -597,7 +595,7 @@ DBUS_SIGNAL( SeekedSignal )
 
     dbus_int64_t i_pos = 0;
     intf_thread_t *p_intf = (intf_thread_t*) p_data;
-    input_thread_t *p_input = playlist_CurrentInput( p_intf->p_sys->p_playlist );
+    input_thread_t *p_input = pl_CurrentInput( p_intf );
 
     if( p_input )
     {
@@ -875,6 +873,8 @@ PropertiesChangedSignal( intf_thread_t    *p_intf,
         free( ppsz_properties[i] );
     }
 
+    free( ppsz_properties );
+
     if( !dbus_message_iter_close_container( &args, &changed_properties ) )
         return DBUS_HANDLER_RESULT_NEED_MEMORY;
 
@@ -885,8 +885,6 @@ PropertiesChangedSignal( intf_thread_t    *p_intf,
     if( !dbus_message_iter_close_container( &args, &invalidated_properties ) )
         return DBUS_HANDLER_RESULT_NEED_MEMORY;
 
-    free( ppsz_properties );
-
     SIGNAL_SEND;
 }