summaryrefslogtreecommitdiff
path: root/src/modules/bluetooth/module-bluetooth-device.c
AgeCommit message (Collapse)AuthorFilesLines
2013-09-29bluetooth: Rename bluetooth modules to BlueZ 4João Paulo Rechi Vita1-2623/+0
2013-09-29bluetooth: Update modules description and copyrightJoão Paulo Rechi Vita1-4/+4
The current set of bluetooth modules only support up to BlueZ 4. Since the BlueZ API when through a big change with the release of BlueZ 5 the modules will be forked into a new set for BlueZ 5. This commit also fixes the spelling of Bluetooth (it's a trademark which should always be spelled with capital B) and the spelling of my name, and also update the copyright note dates throughout the Bluetooth modules.
2013-09-29Revert "bluetooth: Update to new BlueZ 5 transport acquire/release API"João Paulo Rechi Vita1-1/+7
This reverts commit 9615def4b96f0bab365ddc03f6c003f382a54752. This is part of the reversion of BlueZ 5 support so it can be added back in a separate set of modules. This makes the code easier to maintain and decrease PulseAudio's binary size.
2013-07-15bluetooth: Fix coding styleJoão Paulo Rechi Vita1-1/+1
2013-06-24Style fix: Remove new lines from opening bracketspoljar (Damir Jelić)1-4/+2
This patch replaces every occurrence of ')\n{' with ') {'. Command used for this: find . -type d \( -name ffmpeg \) -prune -o \ -regex '\(.*\.[hc]\|.*\.cc\)' \ -a -not -name core-util.c -a -not \ -name adrian-aec.c -a -not -name g711.c \ -exec sed -i -e '/)$/{N;s/)\n{$/) {/}' {} \; The excluded files are mirrored files from external sources.
2013-06-19bluetooth: Fix too late assertionTanu Kaskinen1-2/+4
u was dereferenced before the assertion that checks that u isn't NULL.
2013-06-04bluetooth: Fix input port descriptionTanu Kaskinen1-1/+1
2013-06-04bluetooth: Update to new BlueZ 5 transport acquire/release APIMikel Astiz1-7/+1
The new D-Bus API doesn't support access rights, which weren't used by PulseAudio anyway, but it does solve a race condition: now optional acquires can be implemented by bluetooth-util atomically using the D-Bus TryAcquire() method.
2013-06-04bluetooth: Remove the 'bluez.name' propertyJoão Paulo Rechi Vita1-1/+0
The 'Name' property of the Device interface became optional in BlueZ 5 and may not be present anymore (that happens when testing against the PTS 4.7.0), so it's better not to expose it to clients so they don't rely on its existence.
2013-06-04bluetooth: Use 'Alias' value as the device descriptionJoão Paulo Rechi Vita1-1/+1
The 'Alias' property should be preffered over the 'Name' property, according to the BlueZ API documentation.
2013-06-04bluetooth: Add 'bluez.alias' propertyJoão Paulo Rechi Vita1-0/+1
2013-06-04device-port: Introduce pa_device_port_new_datapoljar (Damir Jelić)1-5/+17
Port creation is now slightly different. It is now similar to how other objects are created (e.g. sinks/sources/cards). This should become more useful in the future when we move more stuff to the ports. Functionally nothing has changed.
2013-06-04device-port: Make it impossible to have dual-direction portsTanu Kaskinen1-6/+2
2013-05-21bluetooth: Fix missing port->profile associationMikel Astiz1-3/+15
Commit 17b3cb954b179392e80b0a46d8f2ba4693aec386 merged Bluetooth ports into two ports (one for input, one for output) but the association between ports and profiles was lost. BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=64713
2013-05-21bluetooth: Create ports before card profilesMikel Astiz1-2/+2
Both operations are currently independent and their order can therefore be swapped.
2013-03-08bluetooth: Never allow microphone output portsDavid Henningsson1-3/+3
If we find a microphone output port, it is probably something else than a microphone. Therefore label it "Bluetooth output" instead of "Microphone". Same goes for Headphones and Speakers, but in the other direction. Signed-off-by: David Henningsson <david.henningsson@canonical.com>
2013-03-08bluetooth: Use form factor to set port name and descriptionMikel Astiz1-6/+78
Use the information provided by the form factor to decide which name and description should be used during port creation.
2013-03-08bluetooth: Use enum to represent form factorsMikel Astiz1-3/+5
Avoid using strings only to represent form factors in the bluetooth-util API and instead use a new dedicated enum type: pa_bt_form_factor_t.
2013-02-18bluetooth: Merge all ports into "bluetooth-input" and "bluetooth-output"Mikel Astiz1-227/+81
The card profile availability flag already provides all the necessary information and therefore all Bluetooth ports can be merged, leaving the two generic ones only: "bluetooth-input" and "bluetooth-output". The availability of these port now represents whether the device is streaming audio, with the following mapping: - PA_AVAILABLE_UNKNOWN: some profile connected but not streaming - PA_AVAILABLE_NO: no profiles connected - PA_AVAILABLE_YES: some profile streaming (regardless of which) Each port's flag represents the profiles with the corresponding I/O capabilities (pa_direction_t).
2013-02-18bluetooth: Expose card profile availabilityMikel Astiz1-1/+15
Use the transport's state to not only update the ports availability, but also to update the card profile availability flag. The interpretation is as follows: - PA_AVAILABLE_UNKNOWN: BT profile is connected but no audio streaming - PA_AVAILABLE_NO: BT profile disconnected - PA_AVAILABLE_YES: BT profile connected and audio streaming
2013-02-18core: Internally deprecate pa_port_available_t to use pa_available_tMikel Astiz1-20/+20
Generalize the availability flag in order to be used beyond the scope of ports. However, pa_port_availability_t is left unchanged to avoid modifying the protocol and the client API. This should be replaced by pa_available_t after a validation phase of this new generic enum type.
2013-02-16bluetooth: Fix thread teardown code orderingTanu Kaskinen1-7/+7
thread_mq.outq may contain some unprocessed messages, which should be dispatched before unreffing the sink and source. If the sink and source are unreffed before all messages to them have been dispatched, the unreffing won't free the sink and source, and that in turn will likely cause problems with things getting freed in a wrong order.
2013-02-16bluetooth: Fix premature acquire attemptsMikel Astiz1-3/+4
A transport should be considered connected only after the connection procedure is complete, as expressed in audio_state_to_transport_state(). module-bluetooth-device should be loaded only after at least one transport is not only created (during configuration), but also connected. This fixes the issue of premature acquire attempts sometimes experienced when a headset is connected (issue not present in v3.0 though).
2013-02-16device-port: Remove pa_device_port_hashmap_free()Tanu Kaskinen1-1/+1
2013-01-29bluetooth: Fix potential assertion failure due to unaligned packet sizeMikel Astiz1-0/+11
While reading from the SCO socket, there is no guarantee regarding the resulting packet size. In some rare cases, it might not even match the alignment expected in pa_source_post(), resulting in an assertion failure inside pa_volume_memchunk(): I: [alsa-sink] module-loopback.c: Could not peek into queue I: [alsa-sink] module-loopback.c: Could not peek into queue I: [alsa-sink] module-loopback.c: Could not peek into queue E: [bluetooth] sample-util.c: Assertion 'pa_frame_aligned(c->length, spec)' failed at pulsecore/sample-util.c:725, function pa_volume_memchunk(). Aborting. Program received signal SIGABRT, Aborted. [Switching to Thread 0x7fffda98f700 (LWP 8058)] 0x00007ffff6177935 in raise () from /lib64/libc.so.6 Missing separate debuginfos, use: debuginfo-install alsa-lib-1.0.26-1.fc17.x86_64 dbus-libs-1.4.10-7.fc17.x86_64 flac-1.2.1-9.fc17.x86_64 glibc-2.15-58.fc17.x86_64 gsm-1.0.13-6.fc17.x86_64 json-c-0.10-2.fc17.x86_64 libICE-1.0.8-1.fc17.x86_64 libSM-1.2.1-1.fc17.x86_64 libX11-1.5.0-2.fc17.x86_64 libXau-1.0.6-3.fc17.x86_64 libXext-1.3.1-1.fc17.x86_64 libXi-1.6.1-1.fc17.x86_64 libXtst-1.2.0-3.fc17.x86_64 libogg-1.3.0-1.fc17.x86_64 libsndfile-1.0.25-2.fc17.x86_64 libtool-ltdl-2.4.2-3.1.fc17.x86_64 libudev-182-3.fc17.x86_64 libuuid-2.21.2-3.fc17.x86_64 libvorbis-1.3.3-1.fc17.x86_64 libxcb-1.9-1.fc17.x86_64 speex-1.2-0.14.rc1.fc17.x86_64
2013-01-24bluetooth: Fix potential assertion failure if MTU changesMikel Astiz1-0/+5
The assertion in hsp_process_render() assumes that, if a memory block is already set by the time the function is reached, its size matches write_block_size. This can however fail if a transport has been released and acquired back, in the unlikely case where the MTU has changed in the meantime, assuming the memory block wasn't released.
2013-01-11bluetooth: Convert booleans to stdbool.Tanu Kaskinen1-16/+16
2013-01-11bluetooth: Use stdbool for pa_bool_tMikel Astiz1-35/+35
Use lowercase true/false instead of TRUE/FALSE for pa_bool_t.
2012-12-19bluetooth: Don't free read_smoother in pa__done().Tanu Kaskinen1-3/+0
pa__done() calls stop_thread(), and stop_thread() already frees the smoother. The duplicate freeing is not strictly a bug, but static analyzers (in this case Coverity) may complain about double-freeing, because when pa__done() "frees" the smoother (which doesn't actually ever happen), the pointer is not nulled. pa__done() then calls bt_transport_release(), which will also free the smoother if it's not NULL. The analyzer complaint could be silenced also by nulling the pointer in pa__done(), but since this is clearly redundant code, I chose to remove it.
2012-12-19bluetooth: Replace acquire param 'start' with 'optional'Mikel Astiz1-9/+9
Make the internal function bt_transport_acquire() consistent with the API in bluetooth-util by replacing the old 'start' parameter with exactly the opposite: 'optional'. Therefore, all calls to the function need to negate the second parameter. Note also that the name is more accurate now that setup_stream() is not called inside bt_transport_acquire().
2012-12-19bluetooth: Call setup_stream() manuallyMikel Astiz1-15/+11
Do not call setup_stream() automatically inside bt_transport_acquire(). Instead, the caller is responsible to use both functions as necessary. As a first trivial step, setup_stream() is now called manually after all calls to bt_transport_acquire(u, TRUE), with the exception of setup_transport() where the thread is still about to start and thus setup_stream() will be called later on from thread_func().
2012-12-19bluetooth: Remove D-Bus dependency in module-bluetooth-deviceMikel Astiz1-101/+2
All D-Bus infrastructure is now unused after bluetooth-util has covered the pieces that were pending. Therefore, all D-Bus related code in module-bluetooth-device can be safely removed.
2012-12-19bluetooth: Use transport state instead of profile statesMikel Astiz1-2/+2
The transport state also reflects the state of the audio interface. The state redundancy can thus be minimized by always using the first one, and avoiding the use of profile-specific states with the exception of finding out the initial state of a transport.
2012-12-19bluetooth: Trivially remove bt_transport_is_acquired()Mikel Astiz1-16/+6
The function body is now trivial and can thus be inlined.
2012-12-19bluetooth: Abstract transport access types inside bluetooth-utilMikel Astiz1-23/+6
Transports can be acquired with different access rights, but in practice "rw" was always used inside module-bluetooth-device. In addition, this feature is removed in BlueZ 5.0 and therefore it is convenient to abstract all this inside bluetooth-util.
2012-12-19bluetooth: Use transport state to update port availabilityMikel Astiz1-93/+48
Use transport state to calculate the corresponding port availability, and while doing so use bluetooth-util to receive profile state updates instead of directly parsing D-Bus PropertyChanged signals.
2012-12-19bluetooth: Refactor parsing of profile state changesMikel Astiz1-30/+55
Split filter_cb() to separate the parsing of the D-Bus message from the internal logic handling the new state.
2012-12-19bluetooth: Move profile_to_string() to bluetooth-utilMikel Astiz1-19/+4
Move the function to the utility library where the enum is defined. At same time avoid using the default clause in order to make sure the compiler will complain if the enum type gets extended.
2012-12-19bluetooth: Use bluetooth-util for mic/speaker gain controlMikel Astiz1-36/+58
Use the new abstraction in bluetooth-util to both receive volume updates and request them.
2012-12-19bluetooth: Abstract microphone gain in transportMikel Astiz1-1/+0
The microphone gain represents the volume of the incoming audio stream from the headset. This can be nicely abstracted inside the transport object in bluetooth-util, so the modules don't have to take care about the D-Bus details.
2012-12-19bluetooth: Connect all hooks during module load/unloadMikel Astiz1-25/+21
Move the connection of sink/source-related hooks to module initialization and shutdown, to group all of them together. There is no need to connect them every time the card profile is changed.
2012-12-19bluetooth: Avoid PA_BLUETOOTH_TRANSPORT_HOOK_NREC_CHANGEDMikel Astiz1-10/+12
The hook has been recently moved to pa_bluetooth_hook_t, so make use of the new version.
2012-12-19bluetooth: Avoid PA_BLUETOOTH_TRANSPORT_HOOK_REMOVEDMikel Astiz1-11/+11
The hook is now deprecated so avoid using it and instead use the recently introduced PA_BLUETOOTH_HOOK_TRANSPORT_STATE_CHANGED which also reports the disconnection event.
2012-12-19bluetooth: Use array to store profile statesMikel Astiz1-43/+16
Refactor the code to use an array of states instead of independent member fields, avoiding duplicated code and improving readability.
2012-12-19bluetooth: Move device hooks into pa_bluetooth_hook_tMikel Astiz1-6/+12
Centralize the Bluetooth hooks in one single place, starting with the device hooks, while removing the duplicated ones (in this case PA_BLUETOOTH_DEVICE_HOOK_REMOVED).
2012-12-19bluetooth: Extend discovery to support multiple hooksMikel Astiz1-3/+4
Add the infrastructure to support several hooks inside pa_bluetooth_discovery, while using hook names that describe more accurately their purpose.
2012-12-19bluetooth: Avoid PA_BLUETOOTH_DEVICE_HOOK_REMOVEDMikel Astiz1-20/+5
The hook PA_BLUETOOTH_HOOK_DEVICE_CONNECTION_CHANGED gets fired also when a device is being removed, so there is actually no need to have this duplicated hook.
2012-12-19bluetooth: Remove pa_bluetooth_device_get_transport()Mikel Astiz1-1/+2
With the use of an array to represent a device's transpors, the function becomes trivial and thus can be removed.
2012-12-19bluetooth: Use round() to convert PA<->BT volumesMikel Astiz1-30/+7
The code can be simplified since it's just trying to round the result of the division. Note that the resulting behavior is slightly different, specially when the volume is 0. In this case, it will remain at 0, instead of being set to 1.
2012-12-19Log the reason for every suspend/resume.Tanu Kaskinen1-4/+12
I was looking at a log that showed that a suspend happened (at a strange time), but the log didn't tell me why the suspend was done. This patch tries to make sure that that won't happen again.