Commit Graph

221 Commits

Author SHA1 Message Date
Mikel Astiz
ee14d62aba audio: Add multiple device search to manager
This method is useful to search for more than one device fulfulling
certain criteria.
2012-05-07 07:05:39 -07:00
Chan-yeol Park
8a3f778658 audio: Add missing debug message in authorization 2012-04-16 22:54:27 +03:00
Anderson Lizardo
cb40056ccd audio: Fix memory leak when headset server probe() fails
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)
2012-04-12 14:36:34 +03:00
Arnaud Mouiche
4fd2d5ae38 HFP gateway: fix failure on very first GSM connection
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.
2012-03-15 08:22:10 +00:00
Mikel Astiz
817b2577f8 audio: fix io channel shutdown on error
In the unlikely case of service record allocation error, the io channel
should be properly shut down.
2012-03-13 15:53:34 +02:00
Mikel Astiz
8e6f1054e8 audio: fix missing io channel shutdown
Channel must be explicitly shut down because otherwise the reference
counter never reaches zero, due to the server installed by bt_io_listen.
2012-03-13 15:53:17 +02:00
Mikel Astiz
f732bbf978 audio: fix missing unref in case of error
audio_adapter_get() increases the reference counter of the adapter, so
it's necessary to decrement it in case of error.
2012-03-13 15:53:07 +02:00
Johan Hedberg
c2ecc3efc7 audio: Remove redundant state_changed() call in headset_server_probe() 2012-03-02 01:39:14 +02:00
Johan Hedberg
b06899eace Fix device address type tracking 2011-12-23 13:00:55 +02:00
Luiz Augusto von Dentz
6b1be64e10 audio: enable Media API by default
This replaces unix socket IPC which is considered deprecated and will
eventually be removed.
2011-11-21 11:50:16 +02:00
Dmitriy Paliy
a267bc2dcd Fix enable fast connectable when connection allowed 2011-11-14 14:09:00 +02:00
Luiz Augusto von Dentz
6d130cd512 Fix calling g_io_channel_shutdown twice for a gateway connection
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>
2011-10-25 10:40:01 +02:00
Luiz Augusto von Dentz
14ae307458 AVRCP: move MediaPlayer to adapter object
This move the MediaPlayer registration to adapter object on Media
interface so we can track players properly.
2011-10-06 11:13:28 +03:00
Frédéric Dalleau
9344ad5be8 Check all states before allowing gw connection 2011-09-24 13:12:00 +03:00
Frédéric Dalleau
dfea776a9c Set state to "connecting" on connection requested
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.
2011-09-22 20:10:17 +09:00
Luiz Augusto von Dentz
99f32ae9ac AVRCP: move handling of vendor dependent PDU from control.c to avrcp.c
This helps to isolate AVRCP PDU handling and MediaPlayer interface.
2011-09-13 10:44:56 +03:00
Peter Hurley
84f4d71d7d Fix get/set_hfp_active to match name conventions
These two functions are defined exclusively for headsets, so
follow established name conventions.
2011-08-22 11:04:24 +03:00
Peter Hurley
f9dddf3f41 Increase timeout before initiating AVDTP connection
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.
2011-08-22 10:49:02 +03:00
Lucas De Marchi
8c8eaec49b avrcp: add skeleton of MediaPlayer interface 2011-08-12 11:04:29 +03:00
Claudio Takahasi
9c0c6b6b33 Remove unneeded textfile header includes 2011-08-02 10:53:38 +03:00
Daniel Orstadius
3b7e90d9db Init telephony before adding the HFP SDP record
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.
2011-06-01 11:15:33 +03:00
Szymon Janc
51d73841d4 Remove unused variable svclass from hf_io_cb 2011-05-15 01:47:10 +03:00
Szymon Janc
24c6dee3b3 Remove redundant local copy of GSlist* from functions
Those functions already get copy of pointer to list so local copy is
not needed.
2011-05-15 01:47:05 +03:00
Szymon Janc
f8937ef155 Fix possible NULL pointer dereference in headset_server_init 2011-05-15 01:47:05 +03:00
Johan Hedberg
4efb97bdae Add manager_foreach_adapter()
Ultimately manager_get_adapters shouldn't be needed at all. By
introducing manager_foreach_adapter most instances can be removed.
2010-12-19 13:25:51 +02:00
Johan Hedberg
d9998b7216 Fix invalid g_io_channel_unref call in hf_io_cb 2010-12-15 19:51:11 +02:00
Luiz Augusto von Dentz
3dc2fef459 Fix deinitializing telephony backend when it wasn't initialized
Telephony driver is now deinitialized on headset adapter driver remove so
telephony_exit should not be called on plugin exit anymore.
2010-12-02 11:03:23 +02:00
Johan Hedberg
20ccc578c8 Remove unused includes 2010-11-28 13:41:35 +02:00
Luiz Augusto von Dentz
b9d85c0010 Fix not deinitializing telephony driver when there is no adapter powered
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.
2010-11-25 22:00:00 +02:00
Luiz Augusto von Dentz
f87e1bed13 Add initial implementation of org.bluez.Media spec 2010-09-15 15:21:53 +03:00
Luiz Augusto Von Dentz
c1d7443db5 Add option to enable/disable unix ipc via audio.conf 2010-09-15 15:05:44 +03:00
Dmitriy Paliy
7c073172d0 Add set fast connectable to audio manager
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.
2010-08-18 13:46:01 +03:00
Luiz Augusto von Dentz
0f775bfff6 Remove redundant information that is already present in DBG 2010-06-29 10:29:10 +03:00
Johan Hedberg
b336e93a47 Fix memory leak 2010-06-17 09:40:56 +03:00
Zhu Yanhai
a4cb490fe2 Fix adapter reference counting in gateway_server_remove
gateway_server_remove should unref the adapter, not ref it.
2010-06-04 11:24:42 +03:00
Johan Hedberg
bac81ba536 Coding style cleanup 2010-05-26 13:14:25 +03:00
Gustavo F. Padovan
8e58667ef0 Move debug() to DBG()
Use the new dynamic debug feature
2010-05-21 18:21:48 +02:00
Gustavo F. Padovan
e891f7df62 Move logging.{c,h} to log.{c,h}
Try to make log stuff more similar to ConnMan and oFono.
2010-05-21 14:40:36 +02:00
Gustavo F. Padovan
a2b958337f Implement HandsfreeGateway Interface
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.
2010-02-04 10:54:45 -08:00
Johan Hedberg
5592142cb9 Update Nokia copyrights 2010-01-07 01:11:05 -08:00
Marcel Holtmann
9184e2eeb7 Update copyright information 2010-01-01 17:08:17 -08:00
Johan Hedberg
4d72fa6203 Fix HFP HF-role SDP record profile version 2009-10-05 22:44:03 +02:00
Johan Hedberg
88d7897d4c Fix audio connection authorization handling with timeouts
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.
2009-09-04 18:50:56 +03:00
Johan Hedberg
9c3f955375 Rename audio_device_is_connected more appropriately 2009-09-03 19:55:23 +03:00
Johan Hedberg
9722cf5f77 Make headset connecting state consistent with the rest of the interfaces
Audio, AudioSink, AudioSource and Control interfaces use "connecting"
instead of "connect in progress" so make the Headset interface consistent
with that.
2009-09-02 12:24:23 +03:00
Johan Hedberg
cd66784046 Don't enable the SCO server socket when not necessary
The SCO server socket shouldn't be enabled when neither Gateway nor
Headset support is enabled.
2009-08-11 10:32:53 +03:00
João Paulo Rechi Vita
f79bab5a11 Create A2DP Source interface. 2009-07-13 22:16:26 +03:00
Forrest Zhao
9a6d297c34 Misc fixes for HFP HF role 2009-06-30 12:36:54 +03:00
João Paulo Rechi Vita
99e1a2f757 Fix small typo 2009-06-19 23:05:40 +03:00
Luiz Augusto von Dentz
e7e1be5d17 Fix bug which cause authorization to be denied in certain headsets.
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.
2009-06-15 18:10:39 +03:00