[vlc-devel] [PATCH] dbus: Fix the instance identifier part of the MPRIS bus name

Mirsal Ennaime mirsal at videolan.org
Mon Apr 16 14:07:24 CEST 2012


The D-Bus specification forbids parts of well-known bus names to begin
with a digit. This patch changes the instance-specific part of the bus
name to .instance<pid> instead of -<pid> in order to comply with the
MPRIS v2.2

see: http://specifications.freedesktop.org/mpris-spec/2.2/#Bus-Name-Policy
---
 modules/control/dbus/dbus.c |   15 +++++++++++----
 modules/control/dbus/dbus.h |    5 +++--
 2 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/modules/control/dbus/dbus.c b/modules/control/dbus/dbus.c
index be9f0bd..c663d85 100644
--- a/modules/control/dbus/dbus.c
+++ b/modules/control/dbus/dbus.c
@@ -2,8 +2,8 @@
  * dbus.c : D-Bus control interface
  *****************************************************************************
  * Copyright © 2006-2008 Rafaël Carré
- * Copyright © 2007-2010 Mirsal Ennaime
- * Copyright © 2009-2010 The VideoLAN team
+ * Copyright © 2007-2012 Mirsal Ennaime
+ * Copyright © 2009-2012 The VideoLAN team
  * $Id$
  *
  * Authors:    Rafaël Carré <funman at videolanorg>
@@ -185,10 +185,17 @@ static int Open( vlc_object_t *p_this )
     dbus_connection_set_exit_on_disconnect( p_conn, FALSE );
 
     /* register a well-known name on the bus */
-    char unique_service[sizeof (DBUS_MPRIS_BUS_NAME) + 10];
+    size_t i_length = sizeof( DBUS_MPRIS_BUS_NAME ) +
+        sizeof( DBUS_INSTANCE_ID_PREFIX ) + 10;
+
+    char unique_service[i_length];
+
     snprintf( unique_service, sizeof (unique_service),
-              DBUS_MPRIS_BUS_NAME"-%"PRIu32, (uint32_t)getpid() );
+            DBUS_MPRIS_BUS_NAME"."DBUS_INSTANCE_ID_PREFIX"%"PRIu32,
+            (uint32_t)getpid() );
+
     dbus_bus_request_name( p_conn, unique_service, 0, &error );
+
     if( dbus_error_is_set( &error ) )
     {
         msg_Err( p_this, "Error requesting service name %s: %s",
diff --git a/modules/control/dbus/dbus.h b/modules/control/dbus/dbus.h
index 1230f41..12e66a1 100644
--- a/modules/control/dbus/dbus.h
+++ b/modules/control/dbus/dbus.h
@@ -2,8 +2,8 @@
  * dbus.h : D-Bus control interface
  *****************************************************************************
  * Copyright © 2006-2008 Rafaël Carré
- * Copyright © 2007-2010 Mirsal Ennaime
- * Copyright © 2009-2010 The VideoLAN team
+ * Copyright © 2007-2012 Mirsal Ennaime
+ * Copyright © 2009-2012 The VideoLAN team
  * $Id$
  *
  * Authors:    Rafaël Carré <funman at videolanorg>
@@ -28,6 +28,7 @@
 #define _VLC_DBUS_H
 
 #define DBUS_MPRIS_BUS_NAME "org.mpris.MediaPlayer2.vlc"
+#define DBUS_INSTANCE_ID_PREFIX "instance"
 
 static DBusHandlerResult
 MPRISEntryPoint ( DBusConnection *p_conn, DBusMessage *p_from, void *p_this );
-- 
1.7.9.5




More information about the vlc-devel mailing list