From 249b0fc3d311cd35fe3ca886c757d50fa25794cd Mon Sep 17 00:00:00 2001 From: Tanu Kaskinen Date: Sun, 2 Nov 2014 20:43:06 +0200 Subject: [PATCH] dbus: Fix Device.SetActivePort() handler The old code tried to look up the port object by using an object path, but the ports hashmap uses port names as keys, so the method failed always. BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=85369 --- src/modules/dbus/iface-device.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/modules/dbus/iface-device.c b/src/modules/dbus/iface-device.c index 625f057..d469483 100644 --- a/src/modules/dbus/iface-device.c +++ b/src/modules/dbus/iface-device.c @@ -725,6 +725,8 @@ static void handle_get_active_port(DBusConnection *conn, DBusMessage *msg, void static void handle_set_active_port(DBusConnection *conn, DBusMessage *msg, DBusMessageIter *iter, void *userdata) { pa_dbusiface_device *d = userdata; const char *new_active_path; + pa_dbusiface_device_port *port; + void *state; pa_dbusiface_device_port *new_active; int r; @@ -747,7 +749,14 @@ static void handle_set_active_port(DBusConnection *conn, DBusMessage *msg, DBusM dbus_message_iter_get_basic(iter, &new_active_path); - if (!(new_active = pa_hashmap_get(d->ports, new_active_path))) { + PA_HASHMAP_FOREACH(port, d->ports, state) { + if (pa_streq(pa_dbusiface_device_port_get_path(port), new_active_path)) { + new_active = port; + break; + } + } + + if (!new_active) { pa_dbus_send_error(conn, msg, PA_DBUS_ERROR_NOT_FOUND, "No such port: %s", new_active_path); return; } -- 1.9.3