diff --git a/audio/device.c b/audio/device.c
index 18e873e..1d76a3f 100644
--- a/audio/device.c
+++ b/audio/device.c
#define CONTROL_CONNECT_TIMEOUT 2
#define AVDTP_CONNECT_TIMEOUT 1
+#define AVDTP_CONNECT_TIMEOUT_BOOST 1
#define HEADSET_CONNECT_TIMEOUT 1
typedef enum {
static gboolean device_set_avdtp_timer(struct audio_device *dev)
{
struct dev_priv *priv = dev->priv;
+ guint timeout = AVDTP_CONNECT_TIMEOUT;
if (!dev->sink)
return FALSE;
if (priv->avdtp_timer)
return FALSE;
- priv->avdtp_timer = g_timeout_add_seconds(AVDTP_CONNECT_TIMEOUT,
+ /* If the headset is the HSP/HFP RFCOMM initiator, give the headset
+ * time to initiate AVDTP signalling (and avoid further racing) */
+ if (dev->headset && headset_get_rfcomm_initiator(dev))
+ timeout += AVDTP_CONNECT_TIMEOUT_BOOST;
+
+ priv->avdtp_timer = g_timeout_add_seconds(timeout,
avdtp_connect_timeout,
dev);
diff --git a/audio/headset.c b/audio/headset.c
index 8e63afc..b7ad052 100644
--- a/audio/headset.c
+++ b/audio/headset.c
gboolean hfp_active;
gboolean search_hfp;
+ gboolean rfcomm_initiator;
headset_state_t state;
struct pending_connect *pending;
}
hs->hfp_active = hs->hfp_handle != 0 ? TRUE : FALSE;
+ hs->rfcomm_initiator = FALSE;
headset_set_state(dev, HEADSET_STATE_CONNECTING);
hs->hfp_active = active;
}
+gboolean headset_get_rfcomm_initiator(struct audio_device *dev)
+{
+ struct headset *hs = dev->headset;
+
+ return hs->rfcomm_initiator;
+}
+
+void headset_set_rfcomm_initiator(struct audio_device *dev,
+ gboolean initiator)
+{
+ struct headset *hs = dev->headset;
+
+ hs->rfcomm_initiator = initiator;
+}
+
GIOChannel *headset_get_rfcomm(struct audio_device *dev)
{
struct headset *hs = dev->headset;
diff --git a/audio/headset.h b/audio/headset.h
index 7ce88c8..8180d69 100644
--- a/audio/headset.h
+++ b/audio/headset.h
gboolean get_hfp_active(struct audio_device *dev);
void set_hfp_active(struct audio_device *dev, gboolean active);
+gboolean headset_get_rfcomm_initiator(struct audio_device *dev);
+void headset_set_rfcomm_initiator(struct audio_device *dev,
+ gboolean initiator);
+
void headset_set_authorized(struct audio_device *dev);
int headset_connect_rfcomm(struct audio_device *dev, GIOChannel *chan);
int headset_connect_sco(struct audio_device *dev, GIOChannel *io);
diff --git a/audio/manager.c b/audio/manager.c
index 6e583cf..4f654cf 100644
--- a/audio/manager.c
+++ b/audio/manager.c
}
set_hfp_active(device, hfp_active);
+ headset_set_rfcomm_initiator(device, TRUE);
if (headset_connect_rfcomm(device, chan) < 0) {
error("headset_connect_rfcomm failed");