From 8f0de90a8fd518bc5a1b0c63a6b9d2357375a287 Mon Sep 17 00:00:00 2001 From: Luiz Augusto von Dentz Date: Mon, 13 Aug 2007 17:16:12 +0000 Subject: Fix RemoveDevice bug that prevent its removal from storage. --- audio/manager.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) (limited to 'audio/manager.c') diff --git a/audio/manager.c b/audio/manager.c index 7a650054..231af376 100644 --- a/audio/manager.c +++ b/audio/manager.c @@ -862,20 +862,19 @@ static DBusHandlerResult am_remove_device(DBusConnection *conn, return DBUS_HANDLER_RESULT_NEED_MEMORY; device = match->data; - remove_device(device); + device_remove_stored(device); - if (default_dev == device) { + /* Fallback to a valid default */ + if (default_dev == NULL) { const char *param; GSList *l; - default_dev = NULL; - - for (l = devices; l != NULL; l = l->next) { - device = l->data; + default_dev = manager_get_connected_device(); - if (device->headset) - default_dev = device; + if (!default_dev) { + l = devices; + default_dev = (g_slist_last(l))->data; } param = default_dev ? default_dev->path : ""; @@ -885,6 +884,14 @@ static DBusHandlerResult am_remove_device(DBusConnection *conn, "DefaultHeadsetChanged", DBUS_TYPE_STRING, ¶m, DBUS_TYPE_INVALID); + + dbus_connection_emit_signal(conn, AUDIO_MANAGER_PATH, + AUDIO_MANAGER_INTERFACE, + "DefaultDeviceChanged", + DBUS_TYPE_STRING, ¶m, + DBUS_TYPE_INVALID); + + device_store(default_dev, TRUE); } dbus_connection_emit_signal(conn, AUDIO_MANAGER_PATH, -- cgit