summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuiz Augusto von Dentz <luiz.dentz@openbossa.org>2007-08-13 17:16:12 +0000
committerLuiz Augusto von Dentz <luiz.dentz@openbossa.org>2007-08-13 17:16:12 +0000
commit8f0de90a8fd518bc5a1b0c63a6b9d2357375a287 (patch)
tree3d54b32f1782a845bc1fa84c24ba390acbf9eb10
parent6d48df39064d820d101653714211ea4eb2aa6282 (diff)
Fix RemoveDevice bug that prevent its removal from storage.
-rw-r--r--audio/device.c13
-rw-r--r--audio/device.h2
-rw-r--r--audio/manager.c23
3 files changed, 30 insertions, 8 deletions
diff --git a/audio/device.c b/audio/device.c
index 119a4e4f..450b2afe 100644
--- a/audio/device.c
+++ b/audio/device.c
@@ -221,6 +221,19 @@ int device_store(struct device *dev, gboolean is_default)
return textfile_put(filename, dst_addr, value);
}
+int device_remove_stored(struct device *dev)
+{
+ char filename[PATH_MAX + 1];
+ char src_addr[18], dst_addr[18];
+
+ ba2str(&dev->dst, dst_addr);
+ ba2str(&dev->src, src_addr);
+
+ create_name(filename, PATH_MAX, STORAGEDIR, src_addr, "audio");
+
+ return textfile_del(filename, dst_addr);
+}
+
void device_finish_sdp_transaction(struct device *dev)
{
char address[18], *addr_ptr = address;
diff --git a/audio/device.h b/audio/device.h
index 80a95906..d9a42ca1 100644
--- a/audio/device.h
+++ b/audio/device.h
@@ -71,6 +71,8 @@ struct device *device_register(DBusConnection *conn,
int device_store(struct device *device, gboolean is_default);
+int device_remove_stored(struct device *dev);
+
void device_finish_sdp_transaction(struct device *device);
int device_get_config(struct device *dev, int sock, struct ipc_packet *req,
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, &param,
DBUS_TYPE_INVALID);
+
+ dbus_connection_emit_signal(conn, AUDIO_MANAGER_PATH,
+ AUDIO_MANAGER_INTERFACE,
+ "DefaultDeviceChanged",
+ DBUS_TYPE_STRING, &param,
+ DBUS_TYPE_INVALID);
+
+ device_store(default_dev, TRUE);
}
dbus_connection_emit_signal(conn, AUDIO_MANAGER_PATH,