d->audio_sink_state = PA_BT_AUDIO_STATE_INVALID;
d->audio_source_state = PA_BT_AUDIO_STATE_INVALID;
d->headset_state = PA_BT_AUDIO_STATE_INVALID;
+ d->hfgw_state = PA_BT_AUDIO_STATE_INVALID;
return d;
}
pa_assert(d);
return
- d->device_info_valid &&
+ d->device_info_valid && (d->hfgw_state != PA_BT_AUDIO_STATE_INVALID ||
(d->audio_state != PA_BT_AUDIO_STATE_INVALID &&
(d->audio_sink_state != PA_BT_AUDIO_STATE_INVALID ||
d->audio_source_state != PA_BT_AUDIO_STATE_INVALID ||
- d->headset_state != PA_BT_AUDIO_STATE_INVALID));
+ d->headset_state != PA_BT_AUDIO_STATE_INVALID)));
}
static int parse_device_property(pa_bluetooth_discovery *y, pa_bluetooth_device *d, DBusMessageIter *i) {
PA_LLIST_PREPEND(pa_bluetooth_uuid, d->uuids, node);
/* Vudentz said the interfaces are here when the UUIDs are announced */
- if (strcasecmp(HSP_HS_UUID, value) == 0 || strcasecmp(HFP_HS_UUID, value) == 0) {
+ if (strcasecmp(HSP_AG_UUID, value) == 0 || strcasecmp(HFP_AG_UUID, value) == 0) {
+ pa_assert_se(m = dbus_message_new_method_call("org.bluez", d->path, "org.bluez.HandsfreeGateway", "GetProperties"));
+ send_and_add_to_pending(y, d, m, get_properties_reply);
+ } else if (strcasecmp(HSP_HS_UUID, value) == 0 || strcasecmp(HFP_HS_UUID, value) == 0) {
pa_assert_se(m = dbus_message_new_method_call("org.bluez", d->path, "org.bluez.Headset", "GetProperties"));
send_and_add_to_pending(y, d, m, get_properties_reply);
} else if (strcasecmp(A2DP_SINK_UUID, value) == 0) {
} else if (dbus_message_has_interface(p->message, "org.bluez.AudioSink")) {
if (parse_audio_property(y, &d->audio_sink_state, &dict_i) < 0)
goto finish;
+
} else if (dbus_message_has_interface(p->message, "org.bluez.AudioSource")) {
if (parse_audio_property(y, &d->audio_source_state, &dict_i) < 0)
goto finish;
+
+ } else if (dbus_message_has_interface(p->message, "org.bluez.HandsfreeGateway")) {
+ if (parse_audio_property(y, &d->hfgw_state, &arg_i) < 0)
+ goto finish;
}
}
dbus_message_is_signal(m, "org.bluez.Headset", "PropertyChanged") ||
dbus_message_is_signal(m, "org.bluez.AudioSink", "PropertyChanged") ||
dbus_message_is_signal(m, "org.bluez.AudioSource", "PropertyChanged") ||
+ dbus_message_is_signal(m, "org.bluez.HandsfreeGateway", "PropertyChanged") ||
dbus_message_is_signal(m, "org.bluez.Device", "PropertyChanged")) {
pa_bluetooth_device *d;
} else if (dbus_message_has_interface(m, "org.bluez.AudioSink")) {
if (parse_audio_property(y, &d->audio_sink_state, &arg_i) < 0)
goto fail;
+
} else if (dbus_message_has_interface(m, "org.bluez.AudioSource")) {
if (parse_audio_property(y, &d->audio_source_state, &arg_i) < 0)
goto fail;
+
+ } else if (dbus_message_has_interface(m, "org.bluez.HandsfreeGateway")) {
+ if (parse_audio_property(y, &d->hfgw_state, &arg_i) < 0)
+ goto fail;
}
run_callback(y, d, FALSE);
d->audio_sink_state = PA_BT_AUDIO_STATE_DISCONNECTED;
d->audio_source_state = PA_BT_AUDIO_STATE_DISCONNECTED;
d->headset_state = PA_BT_AUDIO_STATE_DISCONNECTED;
+ d->hfgw_state = PA_BT_AUDIO_STATE_DISCONNECTED;
run_callback(y, d, FALSE);
}
"type='signal',sender='org.bluez',interface='org.bluez.Audio',member='PropertyChanged'",
"type='signal',sender='org.bluez',interface='org.bluez.Headset',member='PropertyChanged'",
"type='signal',sender='org.bluez',interface='org.bluez.AudioSink',member='PropertyChanged'",
- "type='signal',sender='org.bluez',interface='org.bluez.AudioSource',member='PropertyChanged'", NULL) < 0) {
+ "type='signal',sender='org.bluez',interface='org.bluez.AudioSource',member='PropertyChanged'",
+ "type='signal',sender='org.bluez',interface='org.bluez.HandsfreeGateway',member='PropertyChanged'",
+ NULL) < 0) {
pa_log("Failed to add D-Bus matches: %s", err.message);
goto fail;
}
"type='signal',sender='org.bluez',interface='org.bluez.Audio',member='PropertyChanged'",
"type='signal',sender='org.bluez',interface='org.bluez.Headset',member='PropertyChanged'",
"type='signal',sender='org.bluez',interface='org.bluez.AudioSink',member='PropertyChanged'",
- "type='signal',sender='org.bluez',interface='org.bluez.AudioSource',member='PropertyChanged'", NULL);
+ "type='signal',sender='org.bluez',interface='org.bluez.AudioSource',member='PropertyChanged'",
+ "type='signal',sender='org.bluez',interface='org.bluez.HandsfreeGateway',member='PropertyChanged'",
+ NULL);
if (y->filter_added)
dbus_connection_remove_filter(pa_dbus_connection_get(y->connection), filter_cb, y);
"source_name=<name for the source> "
"source_properties=<properties for the source> "
"address=<address of the device> "
- "profile=<a2dp|hsp> "
+ "profile=<a2dp|hsp|hfgw> "
"rate=<sample rate> "
"channels=<number of channels> "
"path=<device object path> "
PROFILE_A2DP,
PROFILE_A2DP_SOURCE,
PROFILE_HSP,
+ PROFILE_HFGW,
PROFILE_OFF
};
pa_log_debug("Payload size is %lu %lu", (unsigned long) bytes_left, (unsigned long) sizeof(*codec));
if (((u->profile == PROFILE_A2DP || u->profile == PROFILE_A2DP_SOURCE) && codec->transport != BT_CAPABILITIES_TRANSPORT_A2DP) ||
- (u->profile == PROFILE_HSP && codec->transport != BT_CAPABILITIES_TRANSPORT_SCO)) {
+ ((u->profile == PROFILE_HSP || u->profile == PROFILE_HFGW) && codec->transport != BT_CAPABILITIES_TRANSPORT_SCO)) {
pa_log_error("Got capabilities for wrong codec.");
return -1;
}
- if (u->profile == PROFILE_HSP) {
+ if (u->profile == PROFILE_HSP || u->profile == PROFILE_HFGW) {
if (bytes_left <= 0 || codec->length != sizeof(u->hsp.pcm_capabilities))
return -1;
if (u->profile == PROFILE_A2DP || u->profile == PROFILE_A2DP_SOURCE)
msg.getcaps_req.transport = BT_CAPABILITIES_TRANSPORT_A2DP;
else {
- pa_assert(u->profile == PROFILE_HSP);
+ pa_assert(u->profile == PROFILE_HSP || u->profile == PROFILE_HFGW);
msg.getcaps_req.transport = BT_CAPABILITIES_TRANSPORT_SCO;
}
msg.getcaps_req.flags = u->auto_connect ? BT_FLAG_AUTOCONNECT : 0;
if (setup_a2dp(u) < 0)
return -1;
} else {
- pa_assert(u->profile == PROFILE_HSP);
+ pa_assert(u->profile == PROFILE_HSP || u->profile == PROFILE_HFGW);
u->sample_spec.format = PA_SAMPLE_S16LE;
u->sample_spec.channels = 1;
int ret = 0;
pa_assert(u);
- pa_assert(u->profile == PROFILE_HSP);
+ pa_assert(u->profile == PROFILE_HSP || u->profile == PROFILE_HFGW);
pa_assert(u->sink);
/* First, render some data */
pa_memchunk memchunk;
pa_assert(u);
- pa_assert(u->profile == PROFILE_HSP);
+ pa_assert(u->profile == PROFILE_HSP || u->profile == PROFILE_HFGW);
pa_assert(u->source);
pa_assert(u->read_smoother);
if (pollfd && (pollfd->revents & POLLIN)) {
int n_read;
- if (u->profile == PROFILE_HSP)
+ if (u->profile == PROFILE_HSP || PROFILE_HFGW)
n_read = hsp_process_push(u);
else
n_read = a2dp_process_push(u);
data.module = u->module;
pa_source_new_data_set_sample_spec(&data, &u->sample_spec);
pa_proplist_sets(data.proplist, "bluetooth.protocol", u->profile == PROFILE_A2DP_SOURCE ? "a2dp_source" : "hsp");
- if (u->profile == PROFILE_HSP)
+ if ((u->profile == PROFILE_HSP) || (u->profile == PROFILE_HFGW))
pa_proplist_sets(data.proplist, PA_PROP_DEVICE_INTENDED_ROLES, "phone");
data.card = u->card;
data.name = get_name("source", u->modargs, u->address, &b);
pa_bytes_to_usec(u->block_size, &u->sample_spec));
}
- if (u->profile == PROFILE_HSP) {
+ if (u->profile == PROFILE_HSP || u->profile == PROFILE_HFGW)
pa_proplist_sets(u->source->proplist, "bluetooth.nrec", (u->hsp.pcm_capabilities.flags & BT_PCM_FLAG_NREC) ? "1" : "0");
+
+ if (u->profile == PROFILE_HSP) {
u->source->set_volume = source_set_volume_cb;
u->source->n_volume_steps = 16;
}
return -1;
if (u->profile == PROFILE_A2DP ||
- u->profile == PROFILE_HSP)
+ u->profile == PROFILE_HSP ||
+ u->profile == PROFILE_HFGW)
if (add_sink(u) < 0)
r = -1;
if (u->profile == PROFILE_HSP ||
- u->profile == PROFILE_A2DP_SOURCE)
+ u->profile == PROFILE_A2DP_SOURCE ||
+ u->profile == PROFILE_HFGW)
if (add_source(u) < 0)
r = -1;
pa_log_warn("A2DP is not connected, refused to switch profile");
return -PA_ERR_IO;
}
+ else if (device->hfgw_state <= PA_BT_AUDIO_STATE_CONNECTED && *d == PROFILE_HFGW) {
+ pa_log_warn("HandsfreeGateway is not connected, refused to switch profile");
+ return -PA_ERR_IO;
+ }
if (u->sink) {
inputs = pa_sink_move_all_start(u->sink, NULL);
pa_hashmap_put(data.profiles, p->name, p);
}
+ if (pa_bluetooth_uuid_has(device->uuids, HFP_AG_UUID)) {
+ p = pa_card_profile_new("hfgw", _("Handsfree Gateway"), sizeof(enum profile));
+ p->priority = 20;
+ p->n_sinks = 1;
+ p->n_sources = 1;
+ p->max_sink_channels = 1;
+ p->max_source_channels = 1;
+
+ d = PA_CARD_PROFILE_DATA(p);
+ *d = PROFILE_HFGW;
+
+ pa_hashmap_put(data.profiles, p->name, p);
+ }
+
pa_assert(!pa_hashmap_isempty(data.profiles));
p = pa_card_profile_new("off", _("Off"), sizeof(enum profile));
d = PA_CARD_PROFILE_DATA(u->card->active_profile);
if ((device->headset_state < PA_BT_AUDIO_STATE_CONNECTED && *d == PROFILE_HSP) ||
- (device->audio_sink_state < PA_BT_AUDIO_STATE_CONNECTED && *d == PROFILE_A2DP)) {
+ (device->audio_sink_state < PA_BT_AUDIO_STATE_CONNECTED && *d == PROFILE_A2DP) ||
+ (device->hfgw_state < PA_BT_AUDIO_STATE_CONNECTED && *d == PROFILE_HFGW)) {
pa_log_warn("Default profile not connected, selecting off profile");
u->card->active_profile = pa_hashmap_get(u->card->profiles, "off");
u->card->save_profile = FALSE;