diff --git a/src/modules/dbus/iface-device.c b/src/modules/dbus/iface-device.c index 625f057a5..d4694839c 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; }