[pulseaudio-commits] [Git][pulseaudio/pulseaudio][master] 6 commits: bluetooth: improve indentation around dbus_message_iter_open_container

PulseAudio Marge Bot gitlab at gitlab.freedesktop.org
Mon Feb 1 16:15:53 UTC 2021



PulseAudio Marge Bot pushed to branch master at PulseAudio / pulseaudio


Commits:
87f08a7b by Marijn Suijten at 2021-02-01T16:10:11+00:00
bluetooth: improve indentation around dbus_message_iter_open_container

Consistently use newlines and the same indentation style for all calls
to dbus_message_iter_open_container in Bluetooth code.

Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/477>

- - - - -
99ac831f by Marijn Suijten at 2021-02-01T16:10:11+00:00
bluetooth: Unify BlueZ macro defines shared between util and native

Define all BLUEZ_ macros once in the shared header, instead of twice in
both backend-native.c and bluez5-util.h.

Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/477>

- - - - -
670f5855 by Marijn Suijten at 2021-02-01T16:10:11+00:00
bluetooth: Consistently use BlueZ defines for strings

These errors and interface names shoudld all reuse predefined constants.

Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/477>

- - - - -
537bf3cf by Marijn Suijten at 2021-02-01T16:10:11+00:00
treewide: Use DBus defines instead of direct string literals

While cleaning up the BlueZ counterpart of strings defined in
preprocessor macros it is only consistent to take care of all DBUS_
macros as a whole.

Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/477>

- - - - -
f9bf21e0 by Marijn Suijten at 2021-02-01T16:10:12+00:00
tests: Update ladspa-dbus to Python 3

Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/477>

- - - - -
ff2f1629 by Marijn Suijten at 2021-02-01T16:10:12+00:00
bluetooth: Remove unused ts_elapsed variable

Fixes: 969951121 ("bluetooth: allow increasing output bitrate")
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/477>

- - - - -


13 changed files:

- src/modules/bluetooth/backend-native.c
- src/modules/bluetooth/backend-ofono.c
- src/modules/bluetooth/bluez5-util.c
- src/modules/bluetooth/bluez5-util.h
- src/modules/bluetooth/module-bluez5-device.c
- src/modules/dbus/module-dbus-protocol.c
- src/modules/module-rygel-media-server.c
- src/modules/module-zeroconf-publish.c
- src/modules/reserve-monitor.c
- src/modules/reserve.c
- src/pulsecore/protocol-dbus.c
- src/pulsecore/rtkit.c
- src/tests/ladspa-dbus.py


Changes:

=====================================
src/modules/bluetooth/backend-native.c
=====================================
@@ -53,14 +53,6 @@ struct transport_data {
     pa_mainloop_api *mainloop;
 };
 
-#define BLUEZ_SERVICE "org.bluez"
-#define BLUEZ_MEDIA_TRANSPORT_INTERFACE BLUEZ_SERVICE ".MediaTransport1"
-
-#define BLUEZ_ERROR_NOT_SUPPORTED "org.bluez.Error.NotSupported"
-
-#define BLUEZ_PROFILE_MANAGER_INTERFACE BLUEZ_SERVICE ".ProfileManager1"
-#define BLUEZ_PROFILE_INTERFACE BLUEZ_SERVICE ".Profile1"
-
 #define HSP_AG_PROFILE "/Profile/HSPAGProfile"
 #define HSP_HS_PROFILE "/Profile/HSPHSProfile"
 
@@ -83,7 +75,7 @@ struct transport_data {
     "   <arg name=\"opts\" direction=\"in\" type=\"a{sv}\"/>"           \
     "  </method>"                                                       \
     " </interface>"                                                     \
-    " <interface name=\"org.freedesktop.DBus.Introspectable\">"         \
+    " <interface name=\"" DBUS_INTERFACE_INTROSPECTABLE "\">"           \
     "  <method name=\"Introspect\">"                                    \
     "   <arg name=\"data\" type=\"s\" direction=\"out\"/>"              \
     "  </method>"                                                       \
@@ -334,8 +326,12 @@ static void register_profile(pa_bluetooth_backend *b, const char *profile, const
     dbus_message_iter_init_append(m, &i);
     pa_assert_se(dbus_message_iter_append_basic(&i, DBUS_TYPE_OBJECT_PATH, &profile));
     pa_assert_se(dbus_message_iter_append_basic(&i, DBUS_TYPE_STRING, &uuid));
-    dbus_message_iter_open_container(&i, DBUS_TYPE_ARRAY, DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING DBUS_TYPE_STRING_AS_STRING
-            DBUS_TYPE_VARIANT_AS_STRING DBUS_DICT_ENTRY_END_CHAR_AS_STRING, &d);
+    dbus_message_iter_open_container(&i, DBUS_TYPE_ARRAY,
+                                     DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
+                                     DBUS_TYPE_STRING_AS_STRING
+                                     DBUS_TYPE_VARIANT_AS_STRING
+                                     DBUS_DICT_ENTRY_END_CHAR_AS_STRING,
+                                     &d);
     if (pa_bluetooth_uuid_is_hsp_hs(uuid)) {
         /* In the headset role, the connection will only be initiated from the remote side */
         autoconnect = 0;
@@ -564,7 +560,7 @@ static DBusMessage *profile_new_connection(DBusConnection *conn, DBusMessage *m,
     return r;
 
 fail:
-    pa_assert_se(r = dbus_message_new_error(m, "org.bluez.Error.InvalidArguments", "Unable to handle new connection"));
+    pa_assert_se(r = dbus_message_new_error(m, BLUEZ_ERROR_INVALID_ARGUMENTS, "Unable to handle new connection"));
     return r;
 }
 
@@ -592,7 +588,7 @@ static DBusHandlerResult profile_handler(DBusConnection *c, DBusMessage *m, void
     if (!pa_streq(path, HSP_AG_PROFILE) && !pa_streq(path, HSP_HS_PROFILE))
         return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
 
-    if (dbus_message_is_method_call(m, "org.freedesktop.DBus.Introspectable", "Introspect")) {
+    if (dbus_message_is_method_call(m, DBUS_INTERFACE_INTROSPECTABLE, "Introspect")) {
         const char *xml = PROFILE_INTROSPECT_XML;
 
         pa_assert_se(r = dbus_message_new_method_return(m));


=====================================
src/modules/bluetooth/backend-ofono.c
=====================================
@@ -43,12 +43,12 @@
 #define HF_AUDIO_AGENT_XML                                          \
     DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE                       \
     "<node>"                                                        \
-    "  <interface name=\"org.freedesktop.DBus.Introspectable\">"    \
+    "  <interface name=\"" DBUS_INTERFACE_INTROSPECTABLE "\">"      \
     "    <method name=\"Introspect\">"                              \
     "      <arg direction=\"out\" type=\"s\" />"                    \
     "    </method>"                                                 \
     "  </interface>"                                                \
-    "  <interface name=\"org.ofono.HandsfreeAudioAgent\">"          \
+    "  <interface name=\"" HF_AUDIO_AGENT_INTERFACE "\">"           \
     "    <method name=\"Release\">"                                 \
     "    </method>"                                                 \
     "    <method name=\"NewConnection\">"                           \
@@ -515,12 +515,12 @@ static DBusHandlerResult filter_cb(DBusConnection *bus, DBusMessage *m, void *da
     pa_assert(backend);
 
     sender = dbus_message_get_sender(m);
-    if (!pa_safe_streq(backend->ofono_bus_id, sender) && !pa_streq("org.freedesktop.DBus", sender))
+    if (!pa_safe_streq(backend->ofono_bus_id, sender) && !pa_streq(DBUS_SERVICE_DBUS, sender))
         return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
 
     dbus_error_init(&err);
 
-    if (dbus_message_is_signal(m, "org.freedesktop.DBus", "NameOwnerChanged")) {
+    if (dbus_message_is_signal(m, DBUS_INTERFACE_DBUS, "NameOwnerChanged")) {
         const char *name, *old_owner, *new_owner;
 
         if (!dbus_message_get_args(m, &err,
@@ -528,7 +528,7 @@ static DBusHandlerResult filter_cb(DBusConnection *bus, DBusMessage *m, void *da
                                    DBUS_TYPE_STRING, &old_owner,
                                    DBUS_TYPE_STRING, &new_owner,
                                    DBUS_TYPE_INVALID)) {
-            pa_log_error("Failed to parse org.freedesktop.DBus.NameOwnerChanged: %s", err.message);
+            pa_log_error("Failed to parse " DBUS_INTERFACE_DBUS ".NameOwnerChanged: %s", err.message);
             goto fail;
         }
 
@@ -664,7 +664,7 @@ static DBusHandlerResult hf_audio_agent_handler(DBusConnection *c, DBusMessage *
 
     pa_log_debug("dbus: path=%s, interface=%s, member=%s", path, interface, member);
 
-    if (dbus_message_is_method_call(m, "org.freedesktop.DBus.Introspectable", "Introspect")) {
+    if (dbus_message_is_method_call(m, DBUS_INTERFACE_INTROSPECTABLE, "Introspect")) {
         const char *xml = HF_AUDIO_AGENT_XML;
 
         pa_assert_se(r = dbus_message_new_method_return(m));
@@ -718,7 +718,7 @@ pa_bluetooth_backend *pa_bluetooth_ofono_backend_new(pa_core *c, pa_bluetooth_di
     }
 
     if (pa_dbus_add_matches(pa_dbus_connection_get(backend->connection), &err,
-            "type='signal',sender='org.freedesktop.DBus',interface='org.freedesktop.DBus',member='NameOwnerChanged',"
+            "type='signal',sender='" DBUS_SERVICE_DBUS "',interface='" DBUS_INTERFACE_DBUS "',member='NameOwnerChanged',"
             "arg0='" OFONO_SERVICE "'",
             "type='signal',sender='" OFONO_SERVICE "',interface='" HF_AUDIO_MANAGER_INTERFACE "',member='CardAdded'",
             "type='signal',sender='" OFONO_SERVICE "',interface='" HF_AUDIO_MANAGER_INTERFACE "',member='CardRemoved'",
@@ -748,7 +748,7 @@ void pa_bluetooth_ofono_backend_free(pa_bluetooth_backend *backend) {
     dbus_connection_unregister_object_path(pa_dbus_connection_get(backend->connection), HF_AUDIO_AGENT_PATH);
 
     pa_dbus_remove_matches(pa_dbus_connection_get(backend->connection),
-            "type='signal',sender='org.freedesktop.DBus',interface='org.freedesktop.DBus',member='NameOwnerChanged',"
+            "type='signal',sender='" DBUS_SERVICE_DBUS "',interface='" DBUS_INTERFACE_DBUS "',member='NameOwnerChanged',"
             "arg0='" OFONO_SERVICE "'",
             "type='signal',sender='" OFONO_SERVICE "',interface='" HF_AUDIO_MANAGER_INTERFACE "',member='CardAdded'",
             "type='signal',sender='" OFONO_SERVICE "',interface='" HF_AUDIO_MANAGER_INTERFACE "',member='CardRemoved'",


=====================================
src/modules/bluetooth/bluez5-util.c
=====================================
@@ -42,14 +42,7 @@
 
 #define WAIT_FOR_PROFILES_TIMEOUT_USEC (3 * PA_USEC_PER_SEC)
 
-#define BLUEZ_SERVICE "org.bluez"
-#define BLUEZ_ADAPTER_INTERFACE BLUEZ_SERVICE ".Adapter1"
-#define BLUEZ_DEVICE_INTERFACE BLUEZ_SERVICE ".Device1"
-#define BLUEZ_MEDIA_INTERFACE BLUEZ_SERVICE ".Media1"
-#define BLUEZ_MEDIA_ENDPOINT_INTERFACE BLUEZ_SERVICE ".MediaEndpoint1"
-#define BLUEZ_MEDIA_TRANSPORT_INTERFACE BLUEZ_SERVICE ".MediaTransport1"
-
-#define BLUEZ_ERROR_NOT_SUPPORTED "org.bluez.Error.NotSupported"
+#define DBUS_INTERFACE_OBJECT_MANAGER DBUS_INTERFACE_DBUS ".ObjectManager"
 
 #define A2DP_OBJECT_MANAGER_PATH "/MediaEndpoint"
 #define A2DP_SOURCE_ENDPOINT A2DP_OBJECT_MANAGER_PATH "/A2DPSource"
@@ -58,7 +51,7 @@
 #define OBJECT_MANAGER_INTROSPECT_XML                                          \
     DBUS_INTROSPECT_1_0_XML_DOCTYPE_DECL_NODE                                  \
     "<node>\n"                                                                 \
-    " <interface name=\"org.freedesktop.DBus.ObjectManager\">\n"               \
+    " <interface name=\"" DBUS_INTERFACE_OBJECT_MANAGER "\">\n"                \
     "  <method name=\"GetManagedObjects\">\n"                                  \
     "   <arg name=\"objects\" direction=\"out\" type=\"a{oa{sa{sv}}}\"/>\n"    \
     "  </method>\n"                                                            \
@@ -71,7 +64,7 @@
     "   <arg name=\"interfaces\" type=\"as\"/>\n"                              \
     "  </signal>\n"                                                            \
     " </interface>\n"                                                          \
-    " <interface name=\"org.freedesktop.DBus.Introspectable\">\n"              \
+    " <interface name=\"" DBUS_INTERFACE_INTROSPECTABLE "\">\n"                \
     "  <method name=\"Introspect\">\n"                                         \
     "   <arg name=\"data\" direction=\"out\" type=\"s\"/>\n"                   \
     "  </method>\n"                                                            \
@@ -98,7 +91,7 @@
     "  <method name=\"Release\">"                                       \
     "  </method>"                                                       \
     " </interface>"                                                     \
-    " <interface name=\"org.freedesktop.DBus.Introspectable\">"         \
+    " <interface name=\"" DBUS_INTERFACE_INTROSPECTABLE "\">"           \
     "  <method name=\"Introspect\">"                                    \
     "   <arg name=\"data\" type=\"s\" direction=\"out\"/>"              \
     "  </method>"                                                       \
@@ -382,11 +375,11 @@ bool pa_bluetooth_switch_codec(pa_bluetooth_device *device, pa_bluetooth_profile
     dbus_message_iter_init_append(m, &iter);
     pa_assert_se(dbus_message_iter_append_basic(&iter, DBUS_TYPE_OBJECT_PATH, &pa_endpoint));
     dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
-            DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
-            DBUS_TYPE_STRING_AS_STRING
-            DBUS_TYPE_VARIANT_AS_STRING
-            DBUS_DICT_ENTRY_END_CHAR_AS_STRING,
-            &dict);
+                                     DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
+                                     DBUS_TYPE_STRING_AS_STRING
+                                     DBUS_TYPE_VARIANT_AS_STRING
+                                     DBUS_DICT_ENTRY_END_CHAR_AS_STRING,
+                                     &dict);
     pa_dbus_append_basic_array_variant_dict_entry(&dict, "Capabilities", DBUS_TYPE_BYTE, &config, config_size);
     dbus_message_iter_close_container(&iter, &dict);
 
@@ -513,7 +506,7 @@ static int bluez5_transport_acquire_cb(pa_bluetooth_transport *t, bool optional,
     dbus_message_unref(m);
     m = NULL;
     if (!r) {
-        if (optional && pa_streq(err.name, "org.bluez.Error.NotAvailable"))
+        if (optional && pa_streq(err.name, BLUEZ_ERROR_NOT_AVAILABLE))
             pa_log_info("Failed optional acquire of unavailable transport %s", t->path);
         else
             pa_log_error("Transport %s() failed for transport %s (%s)", method, t->path, err.message);
@@ -1109,8 +1102,12 @@ static void register_legacy_sbc_endpoint(pa_bluetooth_discovery *y, const pa_a2d
 
     dbus_message_iter_init_append(m, &i);
     pa_assert_se(dbus_message_iter_append_basic(&i, DBUS_TYPE_OBJECT_PATH, &endpoint));
-    dbus_message_iter_open_container(&i, DBUS_TYPE_ARRAY, DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING DBUS_TYPE_STRING_AS_STRING
-                                         DBUS_TYPE_VARIANT_AS_STRING DBUS_DICT_ENTRY_END_CHAR_AS_STRING, &d);
+    dbus_message_iter_open_container(&i, DBUS_TYPE_ARRAY,
+                                     DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
+                                     DBUS_TYPE_STRING_AS_STRING
+                                     DBUS_TYPE_VARIANT_AS_STRING
+                                     DBUS_DICT_ENTRY_END_CHAR_AS_STRING,
+                                     &d);
     pa_dbus_append_basic_variant_dict_entry(&d, "UUID", DBUS_TYPE_STRING, &uuid);
     pa_dbus_append_basic_variant_dict_entry(&d, "Codec", DBUS_TYPE_BYTE, &codec_id);
     pa_dbus_append_basic_array_variant_dict_entry(&d, "Capabilities", DBUS_TYPE_BYTE, &capabilities, capabilities_size);
@@ -1196,11 +1193,11 @@ static void register_application(pa_bluetooth_adapter *a) {
     dbus_message_iter_init_append(m, &i);
     pa_assert_se(dbus_message_iter_append_basic(&i, DBUS_TYPE_OBJECT_PATH, &object_manager_path));
     dbus_message_iter_open_container(&i, DBUS_TYPE_ARRAY,
-            DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
-            DBUS_TYPE_STRING_AS_STRING
-            DBUS_TYPE_VARIANT_AS_STRING
-            DBUS_DICT_ENTRY_END_CHAR_AS_STRING,
-            &d);
+                                     DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
+                                     DBUS_TYPE_STRING_AS_STRING
+                                     DBUS_TYPE_VARIANT_AS_STRING
+                                     DBUS_DICT_ENTRY_END_CHAR_AS_STRING,
+                                     &d);
     dbus_message_iter_close_container(&i, &d);
 
     send_and_add_to_pending(a->discovery, m, register_application_reply, pa_xstrdup(a->path));
@@ -1454,7 +1451,7 @@ void pa_bluetooth_discovery_set_ofono_running(pa_bluetooth_discovery *y, bool is
             if (device_supports_profile(d, PA_BLUETOOTH_PROFILE_HEADSET_AUDIO_GATEWAY)) {
                 DBusMessage *m;
 
-                pa_assert_se(m = dbus_message_new_method_call(BLUEZ_SERVICE, d->path, "org.bluez.Device1", "Disconnect"));
+                pa_assert_se(m = dbus_message_new_method_call(BLUEZ_SERVICE, d->path, BLUEZ_DEVICE_INTERFACE, "Disconnect"));
                 dbus_message_set_no_reply(m, true);
                 pa_assert_se(dbus_connection_send(pa_dbus_connection_get(y->connection), m, NULL));
                 dbus_message_unref(m);
@@ -1520,7 +1517,7 @@ static void get_managed_objects(pa_bluetooth_discovery *y) {
 
     pa_assert(y);
 
-    pa_assert_se(m = dbus_message_new_method_call(BLUEZ_SERVICE, "/", "org.freedesktop.DBus.ObjectManager",
+    pa_assert_se(m = dbus_message_new_method_call(BLUEZ_SERVICE, "/", DBUS_INTERFACE_OBJECT_MANAGER,
                                                   "GetManagedObjects"));
     send_and_add_to_pending(y, m, get_managed_objects_reply, NULL);
 }
@@ -1542,7 +1539,7 @@ static DBusHandlerResult filter_cb(DBusConnection *bus, DBusMessage *m, void *us
 
     dbus_error_init(&err);
 
-    if (dbus_message_is_signal(m, "org.freedesktop.DBus", "NameOwnerChanged")) {
+    if (dbus_message_is_signal(m, DBUS_INTERFACE_DBUS, "NameOwnerChanged")) {
         const char *name, *old_owner, *new_owner;
 
         if (!dbus_message_get_args(m, &err,
@@ -1550,7 +1547,7 @@ static DBusHandlerResult filter_cb(DBusConnection *bus, DBusMessage *m, void *us
                                    DBUS_TYPE_STRING, &old_owner,
                                    DBUS_TYPE_STRING, &new_owner,
                                    DBUS_TYPE_INVALID)) {
-            pa_log_error("Failed to parse org.freedesktop.DBus.NameOwnerChanged: %s", err.message);
+            pa_log_error("Failed to parse " DBUS_INTERFACE_DBUS ".NameOwnerChanged: %s", err.message);
             goto fail;
         }
 
@@ -1577,7 +1574,7 @@ static DBusHandlerResult filter_cb(DBusConnection *bus, DBusMessage *m, void *us
         }
 
         return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
-    } else if (dbus_message_is_signal(m, "org.freedesktop.DBus.ObjectManager", "InterfacesAdded")) {
+    } else if (dbus_message_is_signal(m, DBUS_INTERFACE_OBJECT_MANAGER, "InterfacesAdded")) {
         DBusMessageIter arg_i;
 
         if (!y->objects_listed)
@@ -1591,7 +1588,7 @@ static DBusHandlerResult filter_cb(DBusConnection *bus, DBusMessage *m, void *us
         parse_interfaces_and_properties(y, &arg_i);
 
         return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
-    } else if (dbus_message_is_signal(m, "org.freedesktop.DBus.ObjectManager", "InterfacesRemoved")) {
+    } else if (dbus_message_is_signal(m, DBUS_INTERFACE_OBJECT_MANAGER, "InterfacesRemoved")) {
         const char *p;
         DBusMessageIter arg_i;
         DBusMessageIter element_i;
@@ -1628,7 +1625,7 @@ static DBusHandlerResult filter_cb(DBusConnection *bus, DBusMessage *m, void *us
 
         return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
 
-    } else if (dbus_message_is_signal(m, "org.freedesktop.DBus.Properties", "PropertiesChanged")) {
+    } else if (dbus_message_is_signal(m, DBUS_INTERFACE_PROPERTIES, "PropertiesChanged")) {
         DBusMessageIter arg_i;
         const char *iface;
 
@@ -1863,7 +1860,7 @@ fail:
     pa_log_error("Endpoint SetConfiguration(): invalid arguments");
 
 fail2:
-    pa_assert_se(r = dbus_message_new_error(m, "org.bluez.Error.InvalidArguments", "Unable to set configuration"));
+    pa_assert_se(r = dbus_message_new_error(m, BLUEZ_ERROR_INVALID_ARGUMENTS, "Unable to set configuration"));
     return r;
 }
 
@@ -1902,7 +1899,7 @@ static DBusMessage *endpoint_select_configuration(DBusConnection *conn, DBusMess
     return r;
 
 fail:
-    pa_assert_se(r = dbus_message_new_error(m, "org.bluez.Error.InvalidArguments", "Unable to select configuration"));
+    pa_assert_se(r = dbus_message_new_error(m, BLUEZ_ERROR_INVALID_ARGUMENTS, "Unable to select configuration"));
     return r;
 }
 
@@ -1933,7 +1930,7 @@ static DBusMessage *endpoint_clear_configuration(DBusConnection *conn, DBusMessa
 
 fail:
     if (!dbus_message_get_no_reply(m))
-        pa_assert_se(r = dbus_message_new_error(m, "org.bluez.Error.InvalidArguments", "Unable to clear configuration"));
+        pa_assert_se(r = dbus_message_new_error(m, BLUEZ_ERROR_INVALID_ARGUMENTS, "Unable to clear configuration"));
     return r;
 }
 
@@ -1977,7 +1974,7 @@ static DBusHandlerResult endpoint_handler(DBusConnection *c, DBusMessage *m, voi
     if (!a2dp_endpoint_to_a2dp_codec(path))
         return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
 
-    if (dbus_message_is_method_call(m, "org.freedesktop.DBus.Introspectable", "Introspect")) {
+    if (dbus_message_is_method_call(m, DBUS_INTERFACE_INTROSPECTABLE, "Introspect")) {
         const char *xml = ENDPOINT_INTROSPECT_XML;
 
         pa_assert_se(r = dbus_message_new_method_return(m));
@@ -2073,12 +2070,12 @@ static DBusHandlerResult object_manager_handler(DBusConnection *c, DBusMessage *
 
     pa_log_debug("dbus: path=%s, interface=%s, member=%s", path, interface, member);
 
-    if (dbus_message_is_method_call(m, "org.freedesktop.DBus.Introspectable", "Introspect")) {
+    if (dbus_message_is_method_call(m, DBUS_INTERFACE_INTROSPECTABLE, "Introspect")) {
         const char *xml = OBJECT_MANAGER_INTROSPECT_XML;
 
         pa_assert_se(r = dbus_message_new_method_return(m));
         pa_assert_se(dbus_message_append_args(r, DBUS_TYPE_STRING, &xml, DBUS_TYPE_INVALID));
-    } else if (dbus_message_is_method_call(m, "org.freedesktop.DBus.ObjectManager", "GetManagedObjects")) {
+    } else if (dbus_message_is_method_call(m, DBUS_INTERFACE_OBJECT_MANAGER, "GetManagedObjects")) {
         DBusMessageIter iter, array;
         int i;
 
@@ -2198,18 +2195,18 @@ pa_bluetooth_discovery* pa_bluetooth_discovery_get(pa_core *c, int headset_backe
     y->filter_added = true;
 
     if (pa_dbus_add_matches(conn, &err,
-            "type='signal',sender='org.freedesktop.DBus',interface='org.freedesktop.DBus',member='NameOwnerChanged'"
+            "type='signal',sender='" DBUS_SERVICE_DBUS "',interface='" DBUS_INTERFACE_DBUS "',member='NameOwnerChanged'"
             ",arg0='" BLUEZ_SERVICE "'",
-            "type='signal',sender='" BLUEZ_SERVICE "',interface='org.freedesktop.DBus.ObjectManager',member='InterfacesAdded'",
-            "type='signal',sender='" BLUEZ_SERVICE "',interface='org.freedesktop.DBus.ObjectManager',"
+            "type='signal',sender='" BLUEZ_SERVICE "',interface='" DBUS_INTERFACE_OBJECT_MANAGER "',member='InterfacesAdded'",
+            "type='signal',sender='" BLUEZ_SERVICE "',interface='" DBUS_INTERFACE_OBJECT_MANAGER "',"
             "member='InterfacesRemoved'",
-            "type='signal',sender='" BLUEZ_SERVICE "',interface='org.freedesktop.DBus.Properties',member='PropertiesChanged'"
+            "type='signal',sender='" BLUEZ_SERVICE "',interface='" DBUS_INTERFACE_PROPERTIES "',member='PropertiesChanged'"
             ",arg0='" BLUEZ_ADAPTER_INTERFACE "'",
-            "type='signal',sender='" BLUEZ_SERVICE "',interface='org.freedesktop.DBus.Properties',member='PropertiesChanged'"
+            "type='signal',sender='" BLUEZ_SERVICE "',interface='" DBUS_INTERFACE_PROPERTIES "',member='PropertiesChanged'"
             ",arg0='" BLUEZ_DEVICE_INTERFACE "'",
-            "type='signal',sender='" BLUEZ_SERVICE "',interface='org.freedesktop.DBus.Properties',member='PropertiesChanged'"
+            "type='signal',sender='" BLUEZ_SERVICE "',interface='" DBUS_INTERFACE_PROPERTIES "',member='PropertiesChanged'"
             ",arg0='" BLUEZ_MEDIA_ENDPOINT_INTERFACE "'",
-            "type='signal',sender='" BLUEZ_SERVICE "',interface='org.freedesktop.DBus.Properties',member='PropertiesChanged'"
+            "type='signal',sender='" BLUEZ_SERVICE "',interface='" DBUS_INTERFACE_PROPERTIES "',member='PropertiesChanged'"
             ",arg0='" BLUEZ_MEDIA_TRANSPORT_INTERFACE "'",
             NULL) < 0) {
         pa_log_error("Failed to add D-Bus matches: %s", err.message);
@@ -2288,19 +2285,19 @@ void pa_bluetooth_discovery_unref(pa_bluetooth_discovery *y) {
 
         if (y->matches_added)
             pa_dbus_remove_matches(pa_dbus_connection_get(y->connection),
-                "type='signal',sender='org.freedesktop.DBus',interface='org.freedesktop.DBus',member='NameOwnerChanged',"
+                "type='signal',sender='" DBUS_SERVICE_DBUS "',interface='" DBUS_INTERFACE_DBUS "',member='NameOwnerChanged',"
                 "arg0='" BLUEZ_SERVICE "'",
-                "type='signal',sender='" BLUEZ_SERVICE "',interface='org.freedesktop.DBus.ObjectManager',"
+                "type='signal',sender='" BLUEZ_SERVICE "',interface='" DBUS_INTERFACE_OBJECT_MANAGER "',"
                 "member='InterfacesAdded'",
-                "type='signal',sender='" BLUEZ_SERVICE "',interface='org.freedesktop.DBus.ObjectManager',"
+                "type='signal',sender='" BLUEZ_SERVICE "',interface='" DBUS_INTERFACE_OBJECT_MANAGER "',"
                 "member='InterfacesRemoved'",
-                "type='signal',sender='" BLUEZ_SERVICE "',interface='org.freedesktop.DBus.Properties',"
+                "type='signal',sender='" BLUEZ_SERVICE "',interface='" DBUS_INTERFACE_PROPERTIES "',"
                 "member='PropertiesChanged',arg0='" BLUEZ_ADAPTER_INTERFACE "'",
-                "type='signal',sender='" BLUEZ_SERVICE "',interface='org.freedesktop.DBus.Properties',"
+                "type='signal',sender='" BLUEZ_SERVICE "',interface='" DBUS_INTERFACE_PROPERTIES "',"
                 "member='PropertiesChanged',arg0='" BLUEZ_DEVICE_INTERFACE "'",
-                "type='signal',sender='" BLUEZ_SERVICE "',interface='org.freedesktop.DBus.Properties',"
+                "type='signal',sender='" BLUEZ_SERVICE "',interface='" DBUS_INTERFACE_PROPERTIES "',"
                 "member='PropertiesChanged',arg0='" BLUEZ_MEDIA_ENDPOINT_INTERFACE "'",
-                "type='signal',sender='" BLUEZ_SERVICE "',interface='org.freedesktop.DBus.Properties',"
+                "type='signal',sender='" BLUEZ_SERVICE "',interface='" DBUS_INTERFACE_PROPERTIES "',"
                 "member='PropertiesChanged',arg0='" BLUEZ_MEDIA_TRANSPORT_INTERFACE "'",
                 NULL);
 


=====================================
src/modules/bluetooth/bluez5-util.h
=====================================
@@ -25,6 +25,19 @@
 
 #include "a2dp-codec-util.h"
 
+#define BLUEZ_SERVICE "org.bluez"
+#define BLUEZ_ADAPTER_INTERFACE BLUEZ_SERVICE ".Adapter1"
+#define BLUEZ_DEVICE_INTERFACE BLUEZ_SERVICE ".Device1"
+#define BLUEZ_MEDIA_ENDPOINT_INTERFACE BLUEZ_SERVICE ".MediaEndpoint1"
+#define BLUEZ_MEDIA_INTERFACE BLUEZ_SERVICE ".Media1"
+#define BLUEZ_MEDIA_TRANSPORT_INTERFACE BLUEZ_SERVICE ".MediaTransport1"
+#define BLUEZ_PROFILE_INTERFACE BLUEZ_SERVICE ".Profile1"
+#define BLUEZ_PROFILE_MANAGER_INTERFACE BLUEZ_SERVICE ".ProfileManager1"
+
+#define BLUEZ_ERROR_INVALID_ARGUMENTS BLUEZ_SERVICE ".Error.InvalidArguments"
+#define BLUEZ_ERROR_NOT_AVAILABLE BLUEZ_SERVICE ".Error.NotAvailable"
+#define BLUEZ_ERROR_NOT_SUPPORTED BLUEZ_SERVICE ".Error.NotSupported"
+
 #define PA_BLUETOOTH_UUID_A2DP_SOURCE "0000110a-0000-1000-8000-00805f9b34fb"
 #define PA_BLUETOOTH_UUID_A2DP_SINK   "0000110b-0000-1000-8000-00805f9b34fb"
 


=====================================
src/modules/bluetooth/module-bluez5-device.c
=====================================
@@ -1367,7 +1367,6 @@ static void thread_func(void *userdata) {
     unsigned blocks_to_write = 0;
     unsigned bytes_to_write = 0;
     struct timeval tv_last_output_rate_change;
-    pa_usec_t ts_elapsed;
 
     pa_assert(u);
     pa_assert(u->transport);


=====================================
src/modules/dbus/module-dbus-protocol.c
=====================================
@@ -158,7 +158,7 @@ static DBusHandlerResult disconnection_filter_cb(DBusConnection *connection, DBu
     pa_assert(message);
     pa_assert(c);
 
-    if (dbus_message_is_signal(message, "org.freedesktop.DBus.Local", "Disconnected")) {
+    if (dbus_message_is_signal(message, DBUS_INTERFACE_LOCAL, "Disconnected")) {
         /* The connection died. Now we want to free the connection object, but
          * let's wait until this message is fully processed, in case someone
          * else is interested in this signal too. */


=====================================
src/modules/module-rygel-media-server.c
=====================================
@@ -96,7 +96,7 @@ PA_MODULE_USAGE("display_name=<UPnP Media Server name>");
     "  <property name=\"Path\" type=\"s\" access=\"read\"/>"            \
     "  <property name=\"DisplayName\" type=\"s\" access=\"read\"/>"     \
     " </interface>"                                                     \
-    " <interface name=\"org.freedesktop.DBus.Properties\">"             \
+    " <interface name=\"" DBUS_INTERFACE_PROPERTIES "\">"               \
     "  <method name=\"Get\">"                                           \
     "   <arg name=\"interface\" direction=\"in\" type=\"s\"/>"          \
     "   <arg name=\"property\" direction=\"in\" type=\"s\"/>"           \
@@ -107,7 +107,7 @@ PA_MODULE_USAGE("display_name=<UPnP Media Server name>");
     "   <arg name=\"properties\" direction=\"out\" type=\"a{sv}\"/>"    \
     "  </method>"                                                       \
     " </interface>"                                                     \
-    " <interface name=\"org.freedesktop.DBus.Introspectable\">"         \
+    " <interface name=\"" DBUS_INTERFACE_INTROSPECTABLE "\">"           \
     "  <method name=\"Introspect\">"                                    \
     "   <arg name=\"data\" type=\"s\" direction=\"out\"/>"              \
     "  </method>"                                                       \
@@ -130,7 +130,7 @@ PA_MODULE_USAGE("display_name=<UPnP Media Server name>");
     " <interface name=\"org.gnome.UPnP.MediaItem2\">"                   \
     "  <property name=\"URLs\" type=\"as\" access=\"read\"/>"           \
     "  <property name=\"MIMEType\" type=\"s\" access=\"read\"/>"        \
-    "  <property name=\"DLNAProfile\" type=\"s\" access=\"read\"/>"        \
+    "  <property name=\"DLNAProfile\" type=\"s\" access=\"read\"/>"     \
     " </interface>"                                                     \
     " <interface name=\"org.gnome.UPnP.MediaObject2\">"                 \
     "  <property name=\"Parent\" type=\"s\" access=\"read\"/>"          \
@@ -138,7 +138,7 @@ PA_MODULE_USAGE("display_name=<UPnP Media Server name>");
     "  <property name=\"Path\" type=\"s\" access=\"read\"/>"            \
     "  <property name=\"DisplayName\" type=\"s\" access=\"read\"/>"     \
     " </interface>"                                                     \
-    " <interface name=\"org.freedesktop.DBus.Properties\">"             \
+    " <interface name=\"" DBUS_INTERFACE_PROPERTIES "\">"               \
     "  <method name=\"Get\">"                                           \
     "   <arg name=\"interface\" direction=\"in\" type=\"s\"/>"          \
     "   <arg name=\"property\" direction=\"in\" type=\"s\"/>"           \
@@ -149,7 +149,7 @@ PA_MODULE_USAGE("display_name=<UPnP Media Server name>");
     "   <arg name=\"properties\" direction=\"out\" type=\"a{sv}\"/>"    \
     "  </method>"                                                       \
     " </interface>"                                                     \
-    " <interface name=\"org.freedesktop.DBus.Introspectable\">"         \
+    " <interface name=\"" DBUS_INTERFACE_INTROSPECTABLE "\">"           \
     "  <method name=\"Introspect\">"                                    \
     "   <arg name=\"data\" type=\"s\" direction=\"out\"/>"              \
     "  </method>"                                                       \
@@ -215,7 +215,7 @@ static bool message_is_property_get(DBusMessage *m, const char *interface, const
 
     pa_assert(m);
 
-    if (!dbus_message_is_method_call(m, "org.freedesktop.DBus.Properties", "Get"))
+    if (!dbus_message_is_method_call(m, DBUS_INTERFACE_PROPERTIES, "Get"))
         return false;
 
     if (!dbus_message_get_args(m, &error, DBUS_TYPE_STRING, &i, DBUS_TYPE_STRING, &p, DBUS_TYPE_INVALID) || dbus_error_is_set(&error)) {
@@ -234,7 +234,7 @@ static bool message_is_property_get_all(DBusMessage *m, const char *interface) {
 
     pa_assert(m);
 
-    if (!dbus_message_is_method_call(m, "org.freedesktop.DBus.Properties", "GetAll"))
+    if (!dbus_message_is_method_call(m, DBUS_INTERFACE_PROPERTIES, "GetAll"))
         return false;
 
     if (!dbus_message_get_args(m, &error, DBUS_TYPE_STRING, &i, DBUS_TYPE_INVALID) || dbus_error_is_set(&error)) {
@@ -721,7 +721,7 @@ static DBusHandlerResult root_handler(DBusConnection *c, DBusMessage *m, void *u
         append_property_dict_entry_string(r, &sub, "DisplayName", u->display_name);
         pa_assert_se(dbus_message_iter_close_container(&iter, &sub));
 
-    } else if (dbus_message_is_method_call(m, "org.freedesktop.DBus.Introspectable", "Introspect")) {
+    } else if (dbus_message_is_method_call(m, DBUS_INTERFACE_INTROSPECTABLE, "Introspect")) {
         const char *xml = ROOT_INTROSPECT_XML;
 
         pa_assert_se(r = dbus_message_new_method_return(m));
@@ -913,7 +913,7 @@ static DBusHandlerResult sinks_and_sources_handler(DBusConnection *c, DBusMessag
             append_sink_or_source_container_mediaobject2_properties(r, &sub, path);
             pa_assert_se(dbus_message_iter_close_container(&iter, &sub));
 
-        } else if (dbus_message_is_method_call(m, "org.freedesktop.DBus.Introspectable", "Introspect")) {
+        } else if (dbus_message_is_method_call(m, DBUS_INTERFACE_INTROSPECTABLE, "Introspect")) {
             pa_strbuf *sb;
             char *xml;
             uint32_t idx;
@@ -1010,7 +1010,7 @@ static DBusHandlerResult sinks_and_sources_handler(DBusConnection *c, DBusMessag
 
             pa_assert_se(dbus_message_iter_close_container(&iter, &sub));
 
-        } else if (dbus_message_is_method_call(m, "org.freedesktop.DBus.Introspectable", "Introspect")) {
+        } else if (dbus_message_is_method_call(m, DBUS_INTERFACE_INTROSPECTABLE, "Introspect")) {
             const char *xml =
                 ITEM_INTROSPECT_XML;
 


=====================================
src/modules/module-zeroconf-publish.c
=====================================
@@ -689,7 +689,7 @@ static char *get_icon_name(pa_module*m) {
 
     msg = dbus_message_new_method_call(HOSTNAME_DBUS_INTERFACE,
                                        HOSTNAME_DBUS_PATH,
-                                       "org.freedesktop.DBus.Properties",
+                                       DBUS_INTERFACE_PROPERTIES,
                                        "Get");
     dbus_message_append_args(msg, DBUS_TYPE_STRING, &interface, DBUS_TYPE_STRING, &property, DBUS_TYPE_INVALID);
 


=====================================
src/modules/reserve-monitor.c
=====================================
@@ -90,7 +90,7 @@ static DBusHandlerResult filter_handler(
 	m = userdata;
 	assert(m->ref >= 1);
 
-	if (dbus_message_is_signal(s, "org.freedesktop.DBus", "NameOwnerChanged")) {
+	if (dbus_message_is_signal(s, DBUS_INTERFACE_DBUS, "NameOwnerChanged")) {
 		const char *name, *old, *new;
 
 		if (!dbus_message_get_args(


=====================================
src/modules/reserve.c
=====================================
@@ -71,14 +71,14 @@ static const char introspection[] =
 	"  <property name=\"ApplicationName\" type=\"s\" access=\"read\"/>"
 	"  <property name=\"ApplicationDeviceName\" type=\"s\" access=\"read\"/>"
 	" </interface>"
-	" <interface name=\"org.freedesktop.DBus.Properties\">"
+	" <interface name=\"" DBUS_INTERFACE_PROPERTIES "\">"
 	"  <method name=\"Get\">"
 	"   <arg name=\"interface\" direction=\"in\" type=\"s\"/>"
 	"   <arg name=\"property\" direction=\"in\" type=\"s\"/>"
 	"   <arg name=\"value\" direction=\"out\" type=\"v\"/>"
 	"  </method>"
 	" </interface>"
-	" <interface name=\"org.freedesktop.DBus.Introspectable\">"
+	" <interface name=\"" DBUS_INTERFACE_INTROSPECTABLE "\">"
 	"  <method name=\"Introspect\">"
 	"   <arg name=\"data\" type=\"s\" direction=\"out\"/>"
 	"  </method>"
@@ -170,7 +170,7 @@ static DBusHandlerResult object_handler(
 
 	} else if (dbus_message_is_method_call(
 			   m,
-			   "org.freedesktop.DBus.Properties",
+			   DBUS_INTERFACE_PROPERTIES,
 			   "Get")) {
 
 		const char *interface, *property;
@@ -234,7 +234,7 @@ static DBusHandlerResult object_handler(
 
 	} else if (dbus_message_is_method_call(
 			   m,
-			   "org.freedesktop.DBus.Introspectable",
+			   DBUS_INTERFACE_INTROSPECTABLE,
 			   "Introspect")) {
 			    const char *i = introspection;
 
@@ -300,7 +300,7 @@ static DBusHandlerResult filter_handler(
 	d = userdata;
 	assert(d->ref >= 1);
 
-	if (dbus_message_is_signal(m, "org.freedesktop.DBus", "NameLost")) {
+	if (dbus_message_is_signal(m, DBUS_INTERFACE_DBUS, "NameLost")) {
 		const char *name;
 
 		if (!dbus_message_get_args(
@@ -670,7 +670,7 @@ int rd_dbus_get_name_owner(
 			goto fail;
 		}
 
-	} else if (dbus_error_has_name(error, "org.freedesktop.DBus.Error.NameHasNoOwner"))
+	} else if (dbus_error_has_name(error, DBUS_ERROR_NAME_HAS_NO_OWNER))
 		dbus_error_free(error);
 	else {
 		r = -EIO;


=====================================
src/pulsecore/protocol-dbus.c
=====================================
@@ -515,7 +515,7 @@ static DBusHandlerResult handle_message_cb(DBusConnection *connection, DBusMessa
     pa_assert_se(call_info.method = dbus_message_get_member(message));
     pa_assert_se(call_info.method_sig = dbus_message_get_signature(message));
 
-    if (dbus_message_is_method_call(message, "org.freedesktop.DBus.Introspectable", "Introspect") ||
+    if (dbus_message_is_method_call(message, DBUS_INTERFACE_INTROSPECTABLE, "Introspect") ||
         (!dbus_message_get_interface(message) && dbus_message_has_member(message, "Introspect"))) {
         pa_dbus_send_basic_value_reply(connection, message, DBUS_TYPE_STRING, &call_info.obj_entry->introspection);
         goto finish;


=====================================
src/pulsecore/rtkit.c
=====================================
@@ -77,7 +77,7 @@ static long long rtkit_get_int_property(DBusConnection *connection, const char*
         if (!(m = dbus_message_new_method_call(
                               RTKIT_SERVICE_NAME,
                               RTKIT_OBJECT_PATH,
-                              "org.freedesktop.DBus.Properties",
+                              DBUS_INTERFACE_PROPERTIES,
                               "Get"))) {
                 ret = -ENOMEM;
                 goto finish;


=====================================
src/tests/ladspa-dbus.py
=====================================
@@ -27,7 +27,7 @@ def get_ladspa_property_interface(sinkname):
     session = dbus.SessionBus()
 
     # get the private D-Bus socket address from PulseAudio properties
-    session_property_iface = dbus.Interface(session.get_object("org.PulseAudio1", "/org/pulseaudio/server_lookup1"), "org.freedesktop.DBus.Properties")
+    session_property_iface = dbus.Interface(session.get_object("org.PulseAudio1", "/org/pulseaudio/server_lookup1"), dbus.PROPERTIES_IFACE)
     socket = session_property_iface.Get("org.PulseAudio.ServerLookup1", "Address")
 
     # connect to the private PulseAudio D-Bus socket
@@ -40,7 +40,7 @@ def get_ladspa_property_interface(sinkname):
     ladspa_sink_path = core.GetSinkByName(sinkname)
 
     # property interface proxy for the sink
-    ladspa_sink_property_iface = dbus.Interface(connection.get_object(object_path=ladspa_sink_path), "org.freedesktop.DBus.Properties")
+    ladspa_sink_property_iface = dbus.Interface(connection.get_object(object_path=ladspa_sink_path), dbus.PROPERTIES_IFACE)
 
     return ladspa_sink_property_iface
 
@@ -84,7 +84,7 @@ def print_arguments(arguments, defaults):
 sinkname, arguments, defaults = parse_arguments(sys.argv)
 
 if sinkname == None:
-    print USAGE
+    print(USAGE)
     sys.exit(1)
 
 # get the D-Bus property interface of the sink



View it on GitLab: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/compare/89bae1b3b72301e2344188d195dbbf21873f3a97...ff2f16294f23f2d7dbaef50f83d833fd9e8584da

-- 
View it on GitLab: https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/compare/89bae1b3b72301e2344188d195dbbf21873f3a97...ff2f16294f23f2d7dbaef50f83d833fd9e8584da
You're receiving this email because of your account on gitlab.freedesktop.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/pulseaudio-commits/attachments/20210201/2081bac0/attachment-0001.htm>


More information about the pulseaudio-commits mailing list