summaryrefslogtreecommitdiffstats
path: root/audio/device.c
diff options
context:
space:
mode:
authorJohan Hedberg <johan.hedberg@nokia.com>2009-02-04 09:39:57 -0800
committerJohan Hedberg <johan.hedberg@nokia.com>2009-02-04 09:39:57 -0800
commit8569aed5570e415a2d4361c521c0b511684e3b7e (patch)
tree878d2839e2c280dc4e4fd06a1f108ca43514c3f8 /audio/device.c
parent584fe1b71eca9a98b5a0a75e08aaa4fafc4e8d83 (diff)
Delay AVRCP connection when remote device connects A2DP
The audio profile coexistence whitepaper recommends that the initiator of the A2DP connection also initiates the AVRCP connection. This patch adds a two second delay before we attempt connecting AVRCP after the remote device has connected A2DP to us.
Diffstat (limited to 'audio/device.c')
-rw-r--r--audio/device.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/audio/device.c b/audio/device.c
index 6f59746d..a5cfc880 100644
--- a/audio/device.c
+++ b/audio/device.c
@@ -54,15 +54,54 @@
#include "headset.h"
#include "sink.h"
+#define CONTROL_CONNECT_TIMEOUT 2
+
static void device_free(struct audio_device *dev)
{
if (dev->conn)
dbus_connection_unref(dev->conn);
+ if (dev->control_timer)
+ g_source_remove(dev->control_timer);
+
g_free(dev->path);
g_free(dev);
}
+static gboolean control_connect_timeout(gpointer user_data)
+{
+ struct audio_device *dev = user_data;
+
+ dev->control_timer = 0;
+
+ if (dev->control)
+ avrcp_connect(dev);
+
+ return FALSE;
+}
+
+gboolean device_set_control_timer(struct audio_device *dev)
+{
+ if (!dev->control)
+ return FALSE;
+
+ if (dev->control_timer)
+ return FALSE;
+
+ dev->control_timer = g_timeout_add_seconds(CONTROL_CONNECT_TIMEOUT,
+ control_connect_timeout,
+ dev);
+
+ return TRUE;
+}
+
+void device_remove_control_timer(struct audio_device *dev)
+{
+ if (dev->control_timer)
+ g_source_remove(dev->control_timer);
+ dev->control_timer = 0;
+}
+
struct audio_device *audio_device_register(DBusConnection *conn,
const char *path, const bdaddr_t *src,
const bdaddr_t *dst)