Commit graph

576 commits

Author SHA1 Message Date
João Paulo Rechi Vita
6d88a139fc bluetooth: Create oFono backend 2014-08-22 12:26:18 +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
2198048e5d bluetooth: Add BlueZ 5 headset profile names in policy module 2014-08-22 12:24:39 +03:00
Luiz Augusto von Dentz
bdef2dbd0a bluetooth: Assert transport has a matching profile
It is a bug if a transport has no matching profile.
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
15ae55ed9b bluetooth: Refactor POLLHUP handling
The code in the "io_fail" section was only used for HUP handling, but
there were jumps to there also from places where reading or writing
failed, because the read/write failure could have been caused by HUP.
This patch simplifies things by checking for HUP condition before
trying to read or write. Now if reading or writing fails, we will
jump to "fail" directly instead of going via the "io_fail" label. As
a result, the "io_fail" label isn't needed any more.
2014-06-24 13:29:39 +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
João Paulo Rechi Vita
5881368bf4 bluetooth: Notify the main thread of a stream fd HUP 2014-06-01 14:45:31 +03:00
João Paulo Rechi Vita
01feb3c162 bluetooth: Rename variable to improve code readability
The label 'u' is used throughout the code to name pointers to the struct
userdata.
2014-06-01 13:37:23 +03:00
João Paulo Rechi Vita
09933e582b bluetooth: Change BlueZ 5 card profile name from a2dp to a2dp_sink
This name is more acurate with regards of what role we're currently
playing and we've already been using it in
pa_bluetooth_profile_to_string() since 449d6cb.
2014-05-25 12:24:17 +03:00
João Paulo Rechi Vita
7fe34cff61 bluetooth: Fix lines going over column 128 2014-05-25 12:24:03 +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
James Bunton
3f21c21628 bluetooth: Fix timing to count based on decoded data
Currently the latency information is being updated based on the encoded
SBC data instead of the decoded PCM data. Fixing this required moving
the timing update to be after the packet has been decoded.
2014-03-03 18:06:21 +02:00
James Bunton
4a5f48e7a4 bluetooth: Don't abort on SBC decoding error
The Nokia E7 running Symbian Belle Refresh seems to generate invalid SBC
packets every few minutes. This causes pulseaudio to disconnect the
stream and log "SBC decoding error (-3)".

If a single packet is bad, pulseaudio should keep playing the stream.
2014-03-03 18:06:21 +02:00
poljar (Damir Jelić)
f7afaa2644 bluez5-util: Free the adapter_path in device_free(). 2014-01-03 13:16:07 +02:00
Tanu Kaskinen
2747c96101 Add pa_channels_valid()
I think this makes the code a bit nicer to read and write. This also
reduces the chances of off-by-one errors when checking the bounds of
channel count values.
2013-12-15 11:44:35 +01:00
Tanu Kaskinen
643eb5bae2 bluetooth: Fix profile priority comparison
BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=72414
2013-12-14 09:34:21 +02:00
Peter Meerwald
e74d4244a2 modules: Make use of new function pa_modargs_get_sample_rate()
by using pa_modargs_get_sample_rate() we avoid inconsistant validity
checking of the sample rate in various places

Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
2013-12-05 10:54:12 +02:00
Tanu Kaskinen
ce304d6208 Pass the profile object instead of the profile name to pa_card_set_profile()
When setting attribute foo, or in this case the card profile, in my
opinion the thing passed to the set_foo() function should be of the
type of foo, not a string identifier that can be used to search for
the actual foo in set_foo().

This is mostly a question of taste, but there's at least some small
benefit from passing the actual object: often the profile object is
already available when calling pa_card_set_profile(), so passing the
card name would cause unnecessary searching when pa_card_set_profile()
needs to look up the profile from the hashmap.
2013-11-29 07:25:13 +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
9490a067bb bluetooth: Track discovery modules by index
Previously module-bluez5-discover and module-bluez4-discover were being
tracked using their pa_module pointer. But during daemon shutdown these
modules are unloaded before module-bluetooth-discover, leaving stale
pointers in module-bluetooth-discover's userdata. To avoid this problem
this commit makes module-bluetooth-discover keep track of
module-bluez5-discover and module-bluez4-discovery by their indexes.
2013-10-15 10:42:25 +03:00
Tanu Kaskinen
189708a597 bluetooth: Add a comment about messing with the IDLE suspend cause 2013-09-29 19:47:16 +03:00
João Paulo Rechi Vita
8753b8c147 bluetooth: Revive module-bluetooth-discover
Create a wrapper module called module-bluetooth-discover to avoid
breaking backward-compatibility of default.pa. This wrapper may
eventually be dropped altoghether with BlueZ 4 support.
2013-09-29 16:54:38 +03: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
774c73309d bluetooth: Implement get_n_used() for module-bluez5-device 2013-09-29 16:54:38 +03:00
João Paulo Rechi Vita
ef24f7f3aa bluetooth: Handle changes to BlueZ 5 transports state 2013-09-29 16:54:38 +03:00
João Paulo Rechi Vita
8d303f0bd1 bluetooth: Process source messages for BlueZ 5 cards 2013-09-29 16:54:38 +03:00
João Paulo Rechi Vita
05366fdc22 bluetooth: Process sink messages for BlueZ 5 cards 2013-09-29 16:54:38 +03:00
João Paulo Rechi Vita
eb9813c833 bluetooth: Create I/O thread function for BlueZ 5 cards
Create the thread function, the render and push functions for A2DP, the
process message function for communication between the I/O thread and
the main thread, and other helper functions related to them.
2013-09-29 16:54:38 +03:00
João Paulo Rechi Vita
44462904df bluetooth: Set card profile for BlueZ 5 cards 2013-09-29 16:54:38 +03:00
João Paulo Rechi Vita
d243fdd07b bluetooth: Start / stop I/O thread for BlueZ 5 cards 2013-09-29 16:54:38 +03:00
João Paulo Rechi Vita
8d1decffd7 bluetooth: Create source for BlueZ 5 cards 2013-09-29 16:54:38 +03:00
João Paulo Rechi Vita
0274032141 bluetooth: Create sink for BlueZ 5 cards 2013-09-29 16:54:38 +03:00
João Paulo Rechi Vita
7e80678cc5 bluetooth: Initialize profiles for BlueZ 5 cards
Initialized the currently active profile, configure and acquire the
transport.
2013-09-29 16:54:38 +03:00
João Paulo Rechi Vita
a0ed6d7970 bluetooth: Create BlueZ 5 card profile for each audio UUID 2013-09-29 16:54:38 +03:00
João Paulo Rechi Vita
5a9007338b bluetooth: Create BlueZ 5 card ports 2013-09-29 16:54:38 +03:00
João Paulo Rechi Vita
501f5e2898 bluetooth: Create BlueZ 5 card 2013-09-29 16:54:38 +03:00
João Paulo Rechi Vita
6ba1610b6f bluetooth: Unload module-bluez5-device on device's disconnection 2013-09-29 16:54:38 +03:00