summaryrefslogtreecommitdiff
path: root/src/modules/bluetooth/bluez5-util.c
AgeCommit message (Collapse)AuthorFilesLines
2016-07-04pulsecore: Move pa_core structure into its own headerArun Raghavan1-0/+1
The idea is to allow some parts of the code to use pa_core as an opaque structure and access required members via API, over which we can then perform some form of access control Signed-off-by: Arun Raghavan <arun@arunraghavan.net>
2015-01-14update FSF addresses to FSF web pageOndrej Holecek1-3/+1
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.
2014-12-03bluez5: Fix free order of adapters and devicesDavid Henningsson1-3/+3
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-11-14bluetooth: Select headset backend through module argumentDavid Henningsson1-3/+8
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-14bluez 5: Load the native headset backend if the oFono one is unavailableDavid Henningsson1-0/+12
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-14bluez 5: Build both headset backends, if availableDavid Henningsson1-8/+16
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-10-31bluez5-util: add destroy functionWim Taymans1-0/+2
Add a destroy function to the transport that is called before freeing the transport. Useful for cleaning up extra userdata.
2014-10-19bluetooth: Move stuff to pa_bluetooth_transport_put/unlink()Tanu Kaskinen1-9/+10
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-09-10bluetooth: Add discovery to pa_bluetooth_backend_newLuiz Augusto von Dentz1-1/+1
2014-09-10bluetooth: Only create backend instance once objects are listedLuiz Augusto von Dentz1-1/+7
This makes sure the devices are discovered before the backend start creating new transports.
2014-09-08bluetooth: Add pa_bluetooth_transport_unlinkLuiz Augusto von Dentz1-0/+4
2014-09-08bluetooth: Add pa_bluetooth_transport_set_stateLuiz Augusto von Dentz1-6/+8
2014-08-22bluetooth: Create NULL backendJoão Paulo Rechi Vita1-0/+5
2014-08-22bluetooth: Add basic support for HEADSET profilesJoão Paulo Rechi Vita1-0/+4
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-06-06bluetooth: Refactor device validity managementTanu Kaskinen1-51/+68
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-06bluetooth: Add "valid" flag to pa_bluetooth_adapterTanu Kaskinen1-2/+3
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-05-03bluetooth: Fix a copy-paste error in log messageTanu Kaskinen1-1/+1
2014-05-03bluetooth: Remove redundant assignmentsTanu Kaskinen1-2/+0
2014-03-07Fix a few "it's -> its" typosAlexander E. Patrakov1-1/+1
2014-01-03bluez5-util: Free the adapter_path in device_free().poljar (Damir Jelić)1-0/+1
2013-11-22bluetooth: Fix crash in pa_bluetooth_discovery_get_device_by_address()João Paulo Rechi Vita1-2/+2
We need to check if the device information is valid first, so we don't pass invalid strings to pa_streq().
2013-11-22bluetooth: Check adapter address to set device_info_validJoão Paulo Rechi Vita1-2/+2
If the adapter object has no address information the device information should be marked as invalid.
2013-11-20bluetooth: Set device_info_valid to -1 when the device's adapter disappearsTanu Kaskinen1-1/+3
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-20bluetooth: Remove device_remove_all()Tanu Kaskinen1-16/+4
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-20bluetooth: Fire DEVICE_CONNECTION_CHANGED in set_device_info_valid()Tanu Kaskinen1-1/+6
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-20bluetooth: Don't mark device valid before it has an adapterTanu Kaskinen1-3/+13
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-20bluetooth: Use a helper function for setting device_info_validTanu Kaskinen1-4/+14
The helper function doesn't yet bring much benefits in this form, but I'll add more functionality later.
2013-11-15bluetooth: Remove a redundant variableTanu Kaskinen1-2/+1
2013-10-29bluetooth: Fix variable constnessTanu Kaskinen1-1/+1
The string points to memory inside a DBusMessage, so we don't own the string.
2013-10-29bluetooth: Remove adapter_remove_all()Tanu Kaskinen1-16/+4
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-09-29bluetooth: Fail to load driver if discovery module is not loadedJoão Paulo Rechi Vita1-3/+0
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-29bluetooth: Handle PropertiesChanged for org.bluez.MediaTransport1João Paulo Rechi Vita1-0/+80
2013-09-29bluetooth: Handle PropertiesChanged for org.bluez.Device1João Paulo Rechi Vita1-0/+21
2013-09-29bluetooth: Protect from a misbehaving bluetoothdJoão Paulo Rechi Vita1-2/+14
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-29bluetooth: Parse BlueZ 5 device propertiesJoão Paulo Rechi Vita1-2/+141
This code is based on previous work by Mikel Astiz.
2013-09-29bluetooth: Handle PropertiesChanged for org.bluez.Adapter1João Paulo Rechi Vita1-0/+35
2013-09-29bluetooth: Register endpoints with BlueZ 5 adapterJoão Paulo Rechi Vita1-1/+74
2013-09-29bluetooth: Parse BlueZ 5 adapter propertiesJoão Paulo Rechi Vita1-1/+72
2013-09-29bluetooth: Parse BlueZ 5 D-Bus interfacesJoão Paulo Rechi Vita1-2/+63
Parse the arguments of the InterfacesAdded signal and the GetManagedObjects() reply. This code is based on previous work by Mikel Astiz.
2013-09-29bluetooth: Handle InterfacesAdded and InterfacesRemovedJoão Paulo Rechi Vita1-0/+58
This code is based on previous work by Mikel Astiz.
2013-09-29bluetooth: Create a function to remove only one adapter objectJoão Paulo Rechi Vita1-5/+29
2013-09-29bluetooth: Get managed objectsJoão Paulo Rechi Vita1-1/+60
Get objects from the BlueZ 5 object manager. This code is based on previous work by Mikel Astiz.
2013-09-29bluetooth: Add utility function to send D-Bus messages with replyJoão Paulo Rechi Vita1-0/+22
2013-09-29bluetooth: Implement org.bluez.MediaEndpoint1.ClearConfiguration()João Paulo Rechi Vita1-2/+23
2013-09-29bluetooth: Implement org.bluez.MediaEndpoint1.SelectConfiguration()João Paulo Rechi Vita1-2/+164
2013-09-29bluetooth: Implement org.bluez.MediaEndpoint1.SetConfiguration()João Paulo Rechi Vita1-2/+174
2013-09-29bluetooth: Register MediaEndpoint1 objects with D-BusJoão Paulo Rechi Vita1-0/+150
2013-09-29bluetooth: Create pa_bluetooth_transport for BlueZ 5 supportJoão Paulo Rechi Vita1-0/+176
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-29bluetooth: Remove all devices and adapters when org.bluez goes awayJoão Paulo Rechi Vita1-1/+2
2013-09-29bluetooth: Create pa_bluetooth_device for BlueZ 5 supportJoão Paulo Rechi Vita1-0/+88
Create a structure pa_bluetooth_device to store information about the bluetooth device and utility functions to manipulate this structure.