If RFCOMM is disabled on the kernel, headset_server_probe() fails.
Relevant log messages:
audio/manager.c:headset_server_probe() path /org/bluez/499/hci0
src/adapter.c:btd_adapter_ref() 0x4bb4f78: ref=6
audio/manager.c:audio_adapter_ref() 0x4ca3010: ref=1
socket(STREAM, RFCOMM): Protocol not supported (93)
audio/manager.c:audio_adapter_unref() 0x4ca3010: ref=0
src/adapter.c:btd_adapter_unref() 0x4bb4f78: ref=5
audio-headset: Operation not permitted (1)
The powered callback should only be registered if adapter driver probe
was successful. The callback unregister was moved to the beginning of
headset_server_remove() for consistency.
This fixes this memory leak:
==499== 8 bytes in 1 blocks are definitely lost in loss record 44 of 182
==499== at 0x4826444: malloc (vg_replace_malloc.c:263)
==499== by 0x4877243: g_malloc (gmem.c:132)
==499== by 0x488D088: g_slice_alloc (gslice.c:836)
==499== by 0x488E8A5: g_slist_append (gslist.c:230)
==499== by 0x18AEEE: btd_adapter_register_powered_callback
(adapter.c:3416)
==499== by 0x11AF61: headset_server_probe (manager.c:919)
==499== by 0x18B67B: probe_driver (adapter.c:2033)
==499== by 0x1908F5: adapter_init (adapter.c:2048)
==499== by 0x189D20: btd_manager_register_adapter (manager.c:397)
==499== by 0x1649AF: mgmt_cmd_complete (mgmtops.c:1075)
==499== by 0x16665E: mgmt_event (mgmtops.c:1780)
==499== by 0x48B2EFA: g_io_unix_dispatch (giounix.c:162)
This patch fix the very first incoming connection from a GSM device
(playing the gateway role), when 'device->gateway' is NULL (when we
didn't perform a SDP browse request yet)
we add the service with 'btd_device_add_uuid(device->btd_dev,
remote_uuid)' but we provide HFP_HS_UUID as remote_uuid. Consequently,
the HFP headset service is activated instead the gateway service.
This happens in the following circumstance:
bluetoothd[30869]: audio/manager.c:hf_io_cb() Authorization denied!
(bluetoothd:30869): GLib-WARNING **: Invalid file descriptor.
Reported by Daniel Wagner <wagi@monom.org>
Make sure that state changes to disconnected on errors (authorization
refused, disconnect, sdp) This change will become necessary when
integrating the Audio interface which rely on state change to confirm
that connection has started successfully.
AVDTP_CONNECT_TIMEOUT controls the delay between HSP/HFP
connection establishment and AVDTP signal channel establishment.
The original value of 1 sec. is too short to avoid racing for AVDTP
connection establishment (eg., if the device continues to configure
the HFP service level connection with additional AT cmds).
Some devices have broken AVDTP implementations that just cannot
handle the race conditions that arise if both devices are attempting
stream establishment at the same time. However, these conditions arise
only when the remote device is the ACL initiator (and in practice, the
RFCOMM initiator as well). This fix bumps out the timeout value only
when the headset has initiated the link.
By patch b9d85c0010 the initialization
of the telephony subsystem is delayed in the bluetoothd startup
procedure. As a result the SupportedFeatures bitmap has not been set
when creating the HFP SDP record. This patch changes the order of
the telephony initialization (via the state_changed function) and
the registration of the record, so that it gets the right value.
Although the corresponding bit in +BRSF is correctly set, the
missing bit for the "Three-way calling" feature in the SDP record
causes some headsets not to send AT+CHLD=? in certain situations.
This results in failed connections since BlueZ does not enter the
"connected" state on the headset interface before that command is
received, if the feature is supported by both sides.
This changes hook telephony driver de/initialization to powered state so
telephony drivers can now free their resources when there is no adapter
active in the system.
Set fast connectable added to audio manager interface. Enables
fast connectable mode for all audio adapters or sets respective
values to default when disabled. It does not interfere with any
other audio manager's interfaces, modes, or states.
Create a interface where a Handsfree agent can register and use BlueZ to
handle the rfcomm and sco links.
Many thanks to Zhenhua Zhang <zhenhua.zhang@intel.com> for his
prototype on this code.
When manager.c (HFP/HSP), avdtp.c (A2DP) or control.c wants to cancel an
authorization request it shouldnd't affect the requests of the other
modules. So btd_cancel_authorization cannot be used. This patch adds a new
cancellation function to device.c which will remove the specific callback
from the list and only if the list is empty call btd_cancel_authorization.
Audio, AudioSink, AudioSource and Control interfaces use "connecting"
instead of "connect in progress" so make the Headset interface consistent
with that.
Some headsets (Nokia HS-12W) connects first on avrcp and only then on hfp
so in case Trusted property is not set this will cause agent_authorize to
return -EBUSY and drop hfp connection.
The proper solution would be to group all connections requests only
sending one authorization so the agent either accept them all or not, but
that would require API changes which we are avoiding right now, so the
current fix only send one connection request which the reponse is used for
the rest of the connections.