]> git.sesse.net Git - vlc/blobdiff - modules/control/dbus.c
Use pl_Locked and pl_Unlocked.
[vlc] / modules / control / dbus.c
index 06f716b47c27113b0e33b4d7473f43423f22c7d5..bd998d5d1159c353b060d88699976583920d76f0 100644 (file)
@@ -47,7 +47,7 @@
 # include "config.h"
 #endif
 
-#include <vlc/vlc.h>
+#include <vlc_common.h>
 #include <vlc_plugin.h>
 #include <vlc_aout.h>
 #include <vlc_interface.h>
@@ -57,6 +57,8 @@
 
 #include <math.h>
 
+#include <assert.h>
+
 /*****************************************************************************
  * Local prototypes.
  *****************************************************************************/
@@ -106,10 +108,10 @@ struct intf_sys_t
  *****************************************************************************/
 
 vlc_module_begin();
-    set_shortname( _("dbus"));
+    set_shortname( N_("dbus"));
     set_category( CAT_INTERFACE );
     set_subcategory( SUBCAT_INTERFACE_CONTROL );
-    set_description( _("D-Bus control interface") );
+    set_description( N_("D-Bus control interface") );
     set_capability( "interface", 0 );
     set_callbacks( Open, Close );
 vlc_module_end();
@@ -315,7 +317,22 @@ DBUS_METHOD( Play )
 {
     REPLY_INIT;
     playlist_t *p_playlist = pl_Yield( (vlc_object_t*) p_this );
-    playlist_Play( p_playlist );
+
+    PL_LOCK;
+    input_thread_t *p_input = p_playlist->p_input;
+    if( p_input )
+        vlc_object_yield( p_input );
+    PL_UNLOCK;
+
+    if( p_input )
+    {
+        double i_pos = 0;
+        input_Control( p_input, INPUT_SET_POSITION, i_pos );
+        vlc_object_release( p_input );
+    }
+    else
+        playlist_Play( p_playlist );
+
     pl_Release( p_playlist );
     REPLY_SEND;
 }
@@ -367,6 +384,7 @@ DBUS_METHOD( Identity )
 DBUS_METHOD( AddTrack )
 { /* add the string to the playlist, and play it if the boolean is true */
     REPLY_INIT;
+    OUT_ARGUMENTS;
 
     DBusError error;
     dbus_error_init( &error );
@@ -394,6 +412,9 @@ DBUS_METHOD( AddTrack )
             PLAYLIST_END, true, false );
     pl_Release( p_playlist );
 
+    dbus_int32_t i_success = 0;
+    ADD_INT32( &i_success );
+
     REPLY_SEND;
 }
 
@@ -486,7 +507,7 @@ DBUS_METHOD( DelTrack )
     {
         playlist_DeleteFromInput( p_playlist,
             p_playlist->current.p_elems[i_position]->p_input->i_id,
-            true );
+            pl_Locked );
     }
     PL_UNLOCK;
 
@@ -856,7 +877,7 @@ static int TrackListChangeEmit( vlc_object_t *p_this, const char *psz_var,
         playlist_t *p_playlist = (playlist_t*)p_this;
         playlist_add_t *p_add = newval.p_address;
         playlist_item_t *p_item;
-        p_item = playlist_ItemGetById( p_playlist, p_add->i_node, true );
+        p_item = playlist_ItemGetById( p_playlist, p_add->i_node, false );
         assert( p_item );
         while( p_item->p_parent )
             p_item = p_item->p_parent;
@@ -928,7 +949,7 @@ static int StateChange( vlc_object_t *p_this, const char* psz_var,
     }
 
     if( newval.i_int == PLAYING_S || newval.i_int == PAUSE_S ||
-        newval.i_int == END_S )
+        newval.i_int == STOP_S ||  newval.i_int == END_S )
     {
         StatusChangeSignal( p_sys->p_conn, (void*) p_intf );
     }