Commit graph

104 commits

Author SHA1 Message Date
Tanu Kaskinen
d9b885e0f1 bluetooth: wait for all profiles to connect before creating card
The CONNECTION_CHANGED hook is used to notify the discovery module
about new and removed devices. When a bluetooth device connects, the
hook used to be called immediately when the first profile connected.
That meant that only one profile was marked as available during the
card creation, other profiles would get marked as available later.

That makes it hard for module-card-restore to restore the saved
profile, if the saved profile becomes available with some delay.
module-card-restore has a workaround for this problem, but that turned
out to interfere with module-bluetooth-policy, so the workaround will
be removed in the next patch.

The BlueZ 4 code doesn't need changes, because we use the
org.bluez.Audio interface to get a notification when all profiles are
connected.
2016-08-10 21:37:33 +03:00
Ondrej Holecek
5effc83479 update FSF addresses to FSF web page
FSF addresses used in PA sources are no longer valid and rpmlint
generates numerous warnings during packaging because of this.
This patch changes all FSF addresses to FSF web page according to
the GPL how-to: https://www.gnu.org/licenses/gpl-howto.en.html

Done automatically by sed-ing through sources.
2015-01-14 22:20:40 +02:00
David Henningsson
9793870b23 bluez5: Fix free order of adapters and devices
Because the adapters reference the devices hashmap on free, we mush
free the adapters hashmap first and then the devices hashmap.

Reported-by: Alexander Patrakov <patrakov@gmail.com>
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
2014-12-03 12:04:29 +01:00
David Henningsson
9ae85b1a29 bluetooth: Select headset backend through module argument
This patch adds a module argument "headset=ofono|native|auto" to
module-bluetooth-discover and module-bluez5-discover.

To make Arun's happy, the default is 'native' if compiled in, otherwise
'ofono'. 'Auto' will try to autoswitch depending on whether ofono is
running or not.

Signed-off-by: David Henningsson <david.henningsson@canonical.com>
2014-11-14 11:44:33 +01:00
David Henningsson
aea3518569 bluez 5: Load the native headset backend if the oFono one is unavailable
This implements some autodetect if both headset backends are compiled in:
First we try to contact the oFono service, if that's not working,
then we start the native backend instead.

Likewise if the oFono service is going offline/online, we load/unload
the native backend accordingly.

Signed-off-by: David Henningsson <david.henningsson@canonical.com>
2014-11-14 11:44:33 +01:00
David Henningsson
1ffede3c85 bluez 5: Build both headset backends, if available
Enable both ofono and native backends to be built into the same
libbluez5-util. Never build the null backend.

Signed-off-by: David Henningsson <david.henningsson@canonical.com>
2014-11-14 11:44:33 +01:00
Wim Taymans
d7199bafea bluez5-util: add destroy function
Add a destroy function to the transport that is called before freeing
the transport. Useful for cleaning up extra userdata.
2014-10-31 10:46:10 +05:30
Tanu Kaskinen
0df4d56cf8 bluetooth: Move stuff to pa_bluetooth_transport_put/unlink()
This should not have any effect on behaviour. The goal is to align
with the pattern that I think we should follow:

Object initialization:
 - put() is the place to create references from other objects to the
   newly created object. In this case, adding the transport to
   discovery->transports was moved from new() to put, and adding the
   transport to device->transports was moved from set_state() to
   put().

Object destruction:
 - unlink() undoes put() and removes all references from other objects
   to the object being unlinked. In this case setting the
   device->transports pointer to NULL was moved from set_state() to
   unlink(), and setting the discovery->transports pointer to NULL was
   moved from free() to unlink().
 - free() undoes new(), but also calls unlink() so that object owners
   don't need to remember to call unlink() before free().
2014-10-19 14:04:46 +03:00
Luiz Augusto von Dentz
f508b34b8b bluetooth: Add discovery to pa_bluetooth_backend_new 2014-09-10 13:25:36 +03:00
Luiz Augusto von Dentz
5c2ed8abed bluetooth: Only create backend instance once objects are listed
This makes sure the devices are discovered before the backend start
creating new transports.
2014-09-10 13:25:36 +03:00
Luiz Augusto von Dentz
19180345fa bluetooth: Add pa_bluetooth_transport_unlink 2014-09-08 13:19:59 +03:00
Luiz Augusto von Dentz
4e041f7b36 bluetooth: Add pa_bluetooth_transport_set_state 2014-09-08 13:00:54 +03:00
João Paulo Rechi Vita
dca5d07937 bluetooth: Create NULL backend 2014-08-22 12:24:39 +03:00
João Paulo Rechi Vita
1f0de01bfc bluetooth: Add basic support for HEADSET profiles
This commit adds basic support for devices implementing HSP Headset
Unit, HSP Audio Gateway, HFP Handsfree Unit, HFP Audio Gateway to the
BlueZ 5 bluetooth audio devices driver module (module-bluez5-device).
2014-08-22 12:10:12 +03:00
Tanu Kaskinen
de0d803e3c bluetooth: Refactor device validity management
There are several intertwined changes that I couldn't separate into
nicer commits. This is mostly just refactoring, but this also fixes
a bug: the old code set the device valid in parse_device_properties()
even if the device's adapter was invalid (had NULL address).

To improve the clarity of the code, I split the device_info_valid
variable into two booleans: properties_received and valid.

I added function device_update_valid() that checks all conditions that
affect the device validity. The function can then be called from any
place where something changes that potentially affects the device
validity. However, currently the only validity-affecting thing that
can change is the device adapter, so device_update_valid() is only
called from set_device_adapter().

I added the aforementioned set_device_adapter() function so that
whenever the adapter is set, the device validity gets updated
automatically.

The new properties_received variable allowed me to remove the
is_property_update function parameters.
2014-06-06 15:05:45 +03:00
Tanu Kaskinen
a61d065dcc bluetooth: Add "valid" flag to pa_bluetooth_adapter
This is a cosmetic change. There are a couple of places where we check
whether the adapter object is valid, and while checking whether the
address property is set works just fine, I find it nicer to have a
dedicated flag for the object validity. This improves maintainability
too, because if there will ever be more adapter properties that affect
the adapter validity, the places that check if the adapter is valid
don't need to be updated.
2014-06-06 15:05:25 +03:00
Tanu Kaskinen
3af39c648f bluetooth: Fix a copy-paste error in log message 2014-05-03 14:21:31 +03:00
Tanu Kaskinen
be9672b8c1 bluetooth: Remove redundant assignments 2014-05-03 14:10:52 +03:00
Alexander E. Patrakov
305409cfcf Fix a few "it's -> its" typos 2014-03-07 18:04:02 +02:00
poljar (Damir Jelić)
f7afaa2644 bluez5-util: Free the adapter_path in device_free(). 2014-01-03 13:16:07 +02:00
João Paulo Rechi Vita
b705e38a79 bluetooth: Fix crash in pa_bluetooth_discovery_get_device_by_address()
We need to check if the device information is valid first, so we don't
pass invalid strings to pa_streq().
2013-11-22 18:40:07 +02:00
João Paulo Rechi Vita
d8fb09b567 bluetooth: Check adapter address to set device_info_valid
If the adapter object has no address information the device information
should be marked as invalid.
2013-11-22 18:39:36 +02:00
Tanu Kaskinen
e9d760b555 bluetooth: Set device_info_valid to -1 when the device's adapter disappears
When parsing device properties, missing adapter will result in
device_info_valid being set to -1. It is then logical that if the
adapter goes missing at a later point, device_info_valid gets set to
-1 also in that situation.
2013-11-20 15:49:10 +02:00
Tanu Kaskinen
e2dea40f4a bluetooth: Remove device_remove_all()
The function did two things: set device_info_valid to -1 and called
device_free() for each device in the hashmap. Setting
device_info_valid to -1 was unnecessary. The main purpose of that was
to fire DEVICE_CONNECTION_CHANGED as a side effect, but that hook is
fired anyway in device_free(), as a side effect of removing all
transports. Calling device_free() can be delegated to pa_hashmap, when
freeing or emptying it.
2013-11-20 15:49:06 +02:00
Tanu Kaskinen
454ca62b23 bluetooth: Fire DEVICE_CONNECTION_CHANGED in set_device_info_valid()
Normally DEVICE_CONNECTION_CHANGED is fired when the first transport
becomes connected, but it may happen that the first transport becomes
connected already before the device properties have been received. In
that case the hook should be fired at the time the device properties
are received. This patch makes the hook to be fired at the right time.
2013-11-20 15:49:01 +02:00
Tanu Kaskinen
6633c1f9ff bluetooth: Don't mark device valid before it has an adapter
At this point this doesn't make any other practical difference than
making the code more logical, but in the next patch I'll fire the
DEVICE_CONNECTION_CHANGED hook in set_device_info_valid(), and at that
point it's important that the device isn't marked valid too early,
because otherwise external code would see "valid" devices that however
don't have the adapter set.
2013-11-20 15:48:56 +02:00
Tanu Kaskinen
f4f4c42fc6 bluetooth: Use a helper function for setting device_info_valid
The helper function doesn't yet bring much benefits in this form, but
I'll add more functionality later.
2013-11-20 15:48:53 +02:00
Tanu Kaskinen
12b7a600d8 bluetooth: Remove a redundant variable 2013-11-15 14:50:46 +02:00
Tanu Kaskinen
38b8c42b35 bluetooth: Fix variable constness
The string points to memory inside a DBusMessage, so we don't own the string.
2013-10-29 20:46:47 +02:00
Tanu Kaskinen
c922dce784 bluetooth: Remove adapter_remove_all()
The function was redundant, because all it did was call adapter_free()
for each adapter in the hashmap, and that can be delegated to
pa_hashmap when freeing or emptying it.
2013-10-29 20:44:14 +02:00
João Paulo Rechi Vita
dc4be17e07 bluetooth: Fail to load driver if discovery module is not loaded
For quite some time now the device driver module doesn't work well
without the discovery module, so for the BlueZ 5 support we'll prevent
the device driver module to be loaded if the discovery module is not
loaded.
2013-09-29 16:54:38 +03:00
João Paulo Rechi Vita
e352da60a7 bluetooth: Handle PropertiesChanged for org.bluez.MediaTransport1 2013-09-29 16:54:37 +03:00
João Paulo Rechi Vita
f65cafe64d bluetooth: Handle PropertiesChanged for org.bluez.Device1 2013-09-29 16:54:37 +03:00
João Paulo Rechi Vita
82fd8cc845 bluetooth: Protect from a misbehaving bluetoothd
bluetoothd always send the GetManagedObjects() reply messages with the
objects array argument following an in-depth order starting from the
root. That means parents will always be known at the time their children
objects are parsed, if clients parse the objects in the same order they
appear in the array, as we do in PulseAudio.

This commit tries to protect PulseAudio in the case bluetoothd changes
that behavior for some reason. It hasn't been tested, since this
situation never occurs.
2013-09-29 16:54:37 +03:00
João Paulo Rechi Vita
89e97215c7 bluetooth: Parse BlueZ 5 device properties
This code is based on previous work by Mikel Astiz.
2013-09-29 16:54:37 +03:00
João Paulo Rechi Vita
877f0a7d54 bluetooth: Handle PropertiesChanged for org.bluez.Adapter1 2013-09-29 16:54:37 +03:00
João Paulo Rechi Vita
a59177e666 bluetooth: Register endpoints with BlueZ 5 adapter 2013-09-29 16:54:37 +03:00
João Paulo Rechi Vita
42dccb6b37 bluetooth: Parse BlueZ 5 adapter properties 2013-09-29 16:54:37 +03:00
João Paulo Rechi Vita
f1d8958fb6 bluetooth: Parse BlueZ 5 D-Bus interfaces
Parse the arguments of the InterfacesAdded signal and the
GetManagedObjects() reply.

This code is based on previous work by Mikel Astiz.
2013-09-29 16:54:37 +03:00
João Paulo Rechi Vita
878eccb680 bluetooth: Handle InterfacesAdded and InterfacesRemoved
This code is based on previous work by Mikel Astiz.
2013-09-29 16:54:37 +03:00
João Paulo Rechi Vita
1e58120a5c bluetooth: Create a function to remove only one adapter object 2013-09-29 16:54:37 +03:00
João Paulo Rechi Vita
b8edddddd3 bluetooth: Get managed objects
Get objects from the BlueZ 5 object manager. This code is based on
previous work by Mikel Astiz.
2013-09-29 16:54:37 +03:00
João Paulo Rechi Vita
d186d0f105 bluetooth: Add utility function to send D-Bus messages with reply 2013-09-29 16:54:37 +03:00
João Paulo Rechi Vita
63108c5cc8 bluetooth: Implement org.bluez.MediaEndpoint1.ClearConfiguration() 2013-09-29 16:54:37 +03:00
João Paulo Rechi Vita
2594909338 bluetooth: Implement org.bluez.MediaEndpoint1.SelectConfiguration() 2013-09-29 16:54:37 +03:00
João Paulo Rechi Vita
449d6cb1e2 bluetooth: Implement org.bluez.MediaEndpoint1.SetConfiguration() 2013-09-29 16:54:37 +03:00
João Paulo Rechi Vita
aff6fa79ba bluetooth: Register MediaEndpoint1 objects with D-Bus 2013-09-29 16:54:37 +03:00
João Paulo Rechi Vita
e78e7e698c bluetooth: Create pa_bluetooth_transport for BlueZ 5 support
Create the pa_bluetooth_transport structure to store information about
the bluetooth transport and utility functions to manipulate this
structure. The acquire() and release() operations are function pointers
in the pa_bluetooth_transport structure to make possible for different
transport backends to provide different implementations of these
operations. Thre is also a userdata field for the transport backend
provide data for the acquire/release functions.

This commit also creates a new function
pa_bluetooth_device_any_transport_connected() to check if there is any
audio connection between the host and a remote device.
2013-09-29 16:54:37 +03:00
João Paulo Rechi Vita
c3efb24aa7 bluetooth: Remove all devices and adapters when org.bluez goes away 2013-09-29 16:54:36 +03:00
João Paulo Rechi Vita
9be71b5838 bluetooth: Create pa_bluetooth_device for BlueZ 5 support
Create a structure pa_bluetooth_device to store information about the
bluetooth device and utility functions to manipulate this structure.
2013-09-29 16:54:36 +03:00