diff options
-rw-r--r-- | audio/headset.c | 37 | ||||
-rw-r--r-- | audio/headset.h | 4 | ||||
-rw-r--r-- | audio/manager.c | 9 |
3 files changed, 39 insertions, 11 deletions
diff --git a/audio/headset.c b/audio/headset.c index 97419a64f..7bb1746d1 100644 --- a/audio/headset.c +++ b/audio/headset.c @@ -99,6 +99,7 @@ struct headset { int data_start; int data_length; + int enable_hfp; headset_type_t type; headset_state_t state; @@ -111,6 +112,7 @@ struct headset { }; static int rfcomm_connect(struct device *device, struct pending_connect *c); +static int get_handles(struct device *device, struct pending_connect *c); static void pending_connect_free(struct pending_connect *c) { @@ -640,11 +642,21 @@ static void get_record_reply(DBusPendingCall *call, void *data) goto failed_not_supported; } - if ((uuid.type == SDP_UUID32 && + if (hs->type == SVC_HEADSET && + ((uuid.type == SDP_UUID32 && uuid.value.uuid32 != HEADSET_SVCLASS_ID) || (uuid.type == SDP_UUID16 && - uuid.value.uuid16 != HEADSET_SVCLASS_ID)) { - error("Service classes did not contain the expected UUID"); + uuid.value.uuid16 != HEADSET_SVCLASS_ID))) { + error("Service classes did not contain the expected UUID hsp"); + goto failed_not_supported; + } + + if (hs->type == SVC_HANDSFREE && + ((uuid.type == SDP_UUID32 && + uuid.value.uuid32 != HANDSFREE_SVCLASS_ID) || + (uuid.type == SDP_UUID16 && + uuid.value.uuid16 != HANDSFREE_SVCLASS_ID))) { + error("Service classes did not contain the expected UUID hfp"); goto failed_not_supported; } @@ -750,7 +762,17 @@ static void get_handles_reply(DBusPendingCall *call, void *data) } if (array_len < 1) { - debug("No record handles found"); + + if(hs->type == SVC_HANDSFREE) { + debug("No record handles found for hfp"); + hs->type = SVC_HEADSET; + get_handles(device, c); + dbus_message_unref(reply); + return; + } + + debug("No record handles found for hsp"); + if (c->msg) error_not_supported(device->conn, c->msg); goto failed; @@ -862,7 +884,7 @@ static int rfcomm_connect(struct device *device, struct pending_connect *c) if (!g_slist_find(hs->pending, c)) hs->pending = g_slist_append(hs->pending, c); - hs->type = hs->hfp_handle ? SVC_HANDSFREE : SVC_HEADSET; + hs->type = hs->enable_hfp ? SVC_HANDSFREE : SVC_HEADSET; if (hs->state == HEADSET_STATE_DISCONNECTED) return get_handles(device, c); @@ -1368,8 +1390,8 @@ void headset_update(struct device *dev, sdp_record_t *record, uint16_t svc) headset_set_channel(headset, record); } -struct headset *headset_init(struct device *dev, sdp_record_t *record, - uint16_t svc) +struct headset *headset_init(struct device *dev, int enable_hfp, + sdp_record_t *record, uint16_t svc) { struct headset *hs; @@ -1377,6 +1399,7 @@ struct headset *headset_init(struct device *dev, sdp_record_t *record, hs->rfcomm_ch = -1; hs->sp_gain = -1; hs->mic_gain = -1; + hs->enable_hfp = enable_hfp; if (!record) goto register_iface; diff --git a/audio/headset.h b/audio/headset.h index 5e19cd9a1..b151dbd9c 100644 --- a/audio/headset.h +++ b/audio/headset.h @@ -54,8 +54,8 @@ typedef enum { typedef void (*headset_stream_cb_t) (struct device *dev, void *user_data); -struct headset *headset_init(struct device *dev, sdp_record_t *record, - uint16_t svc); +struct headset *headset_init(struct device *dev, int enable_hfp, + sdp_record_t *record, uint16_t svc); void headset_free(struct device *dev); diff --git a/audio/manager.c b/audio/manager.c index 507f60ac9..cfadec477 100644 --- a/audio/manager.c +++ b/audio/manager.c @@ -108,6 +108,7 @@ static GIOChannel *hs_server = NULL; static GIOChannel *hf_server = NULL; static const struct enabled_interfaces *enabled; +static gboolean enable_hfp = FALSE; static void get_next_record(struct audio_sdp_data *data); static DBusHandlerResult get_handles(const char *uuid, @@ -254,6 +255,7 @@ static void handle_record(sdp_record_t *record, struct device *device) headset_update(device, record, uuid16); else device->headset = headset_init(device, + enable_hfp, record, uuid16); break; case HEADSET_AGW_SVCLASS_ID: @@ -265,6 +267,7 @@ static void handle_record(sdp_record_t *record, struct device *device) headset_update(device, record, uuid16); else device->headset = headset_init(device, + enable_hfp, record, uuid16); break; case HANDSFREE_AGW_SVCLASS_ID: @@ -645,7 +648,7 @@ struct device *manager_device_connected(bdaddr_t *bda, const char *uuid) if (device->headset) return device; - device->headset = headset_init(device, NULL, 0); + device->headset = headset_init(device, enable_hfp, NULL, 0); if (!device->headset) return NULL; @@ -1070,7 +1073,7 @@ static void parse_stored_devices(char *key, char *value, void *data) bacpy(&device->store, src); if (enabled->headset && strstr(value, "headset")) - device->headset = headset_init(device, NULL, 0); + device->headset = headset_init(device, enable_hfp, NULL, 0); if (enabled->sink && strstr(value, "sink")) device->sink = sink_init(device); if (enabled->control && strstr(value, "control")) @@ -1561,6 +1564,8 @@ static int headset_server_init(DBusConnection *conn, gboolean no_hfp) if (no_hfp) return 0; + enable_hfp = TRUE; + chan = DEFAULT_HF_AG_CHANNEL; hf_server = server_socket(&chan); |