Commit graph

2631 commits

Author SHA1 Message Date
David Henningsson
135afa28e7 bluetooth: Never allow microphone output ports
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-08 18:23:41 +01:00
Mikel Astiz
0a280ceed7 bluetooth: Use form factor to set port name and description
Use the information provided by the form factor to decide which name and
description should be used during port creation.
2013-03-08 18:22:17 +01:00
Mikel Astiz
b394743fb3 bluetooth: Add specific form factor for phones
When a phone is paired, use PA_BT_FORM_FACTOR_PHONE to properly specify
its form factor.
2013-03-08 18:22:14 +01:00
Mikel Astiz
11d7a2d197 bluetooth: Use enum to represent form factors
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-03-08 18:22:11 +01:00
Stefan Huber
278ceb453f modules: Remove obsolete may_move_to callbacks
Some modules have source_output_may_move_to_cb() and
sink_input_may_move_to_cb() implemented that duplicate the default behavior.
Remove them.
2013-03-06 16:32:12 +02:00
Stefan Huber
1489c43acc modules: remove obsolete comment on PA_SOURCE_OUTPUT_DONT_INHIBIT_AUTO_SUSPEND 2013-03-06 01:42:07 +02:00
Stefan Huber
83a64ff7b4 virtual-source: remove redundant checks and callbacks
- do not check pa_xnew0()'s return value
- remove redundant source_output_process_msg_cb()
2013-03-06 01:41:19 +02:00
Stefan Huber
b5226992d4 modules: add module-remap-source 2013-03-05 23:20:13 +02:00
David Henningsson
fd3a4e588c alsa-card: Make ELD monitor name a port property
If there is a proper monitor name, we expose this as a device.product.name
property on the port. This can be useful for UIs who might want to show
this name.

Signed-off-by: David Henningsson <david.henningsson@canonical.com>
2013-02-19 20:45:38 +02:00
David Henningsson
bf487f0ffa alsa-mixer: Add possibility to configure ELD device
The alsa mixer kcontrol has "device index" 3, 7, 8, and 9.
We need to configure this properly.

Signed-off-by: David Henningsson <david.henningsson@canonical.com>
2013-02-19 20:14:40 +02:00
David Henningsson
eaa893d7d1 alsa-util: Add a function to read ELD info
Currently, this function only reads the monitor name, but could
be extended to read e g supported formats as well.

Signed-off-by: David Henningsson <david.henningsson@canonical.com>
2013-02-19 20:10:16 +02:00
Mikel Astiz
2f0f07a755 bluetooth: Fix assertion failure if BlueZ crashes during GetProperties
If BlueZ crashes exactly while PulseAudio waits for the GetProperties reply, the
device has already been removed from the hashmap and therefore an assertion
failure is experienced.

The solution consists of ignoring the reply in these cases.

The problem can be observed in the following traces:

D: [pulseaudio] bluetooth-util.c: Bluetooth daemon appeared.
D: [pulseaudio] bluetooth-util.c: dbus: interface=org.bluez.Manager, path=/, member=AdapterAdded
D: [pulseaudio] bluetooth-util.c: Adapter /org/bluez/497/hci1 created
D: [pulseaudio] bluetooth-util.c: Registering /MediaEndpoint/HFPAG on adapter /org/bluez/497/hci1.
D: [pulseaudio] bluetooth-util.c: Registering /MediaEndpoint/HFPHS on adapter /org/bluez/497/hci1.
D: [pulseaudio] bluetooth-util.c: Registering /MediaEndpoint/A2DPSource on adapter /org/bluez/497/hci1.
D: [pulseaudio] bluetooth-util.c: Registering /MediaEndpoint/A2DPSink on adapter /org/bluez/497/hci1.
D: [pulseaudio] bluetooth-util.c: dbus: interface=org.bluez.Adapter, path=/org/bluez/497/hci1, member=DeviceCreated
D: [pulseaudio] bluetooth-util.c: Device /org/bluez/497/hci1/dev_90_84_0D_B2_C7_04 created
D: [pulseaudio] bluetooth-util.c: dbus: interface=org.freedesktop.DBus, path=/org/freedesktop/DBus, member=NameOwnerChanged
D: [pulseaudio] bluetooth-util.c: Bluetooth daemon disappeared.
E: [pulseaudio] bluetooth-util.c: Assertion 'p->call_data == d' failed at modules/bluetooth/bluetooth-util.c:685, function get_properties_reply(). Aborting.
2013-02-19 19:30:17 +02:00
Mikel Astiz
90ae777500 bluetooth: Fix possible adapter duplicates
The D-Bus signal AdapterAdded can be received during our call to
GetProperties(), before the reply is received. In this case, the adapter
will be listed twice and thus the endpoint registration will fail with
"AlreadyExists" as follows:

D: [pulseaudio] bluetooth-util.c: dbus: interface=org.bluez.Manager, path=/, member=AdapterAdded
D: [pulseaudio] bluetooth-util.c: Adapter /org/bluez/21220/hci0 created
D: [pulseaudio] bluetooth-util.c: Registering /MediaEndpoint/HFPAG on adapter /org/bluez/21220/hci0.
D: [pulseaudio] bluetooth-util.c: Registering /MediaEndpoint/HFPHS on adapter /org/bluez/21220/hci0.
D: [pulseaudio] bluetooth-util.c: Registering /MediaEndpoint/A2DPSource on adapter /org/bluez/21220/hci0.
D: [pulseaudio] bluetooth-util.c: Registering /MediaEndpoint/A2DPSink on adapter /org/bluez/21220/hci0.
D: [pulseaudio] bluetooth-util.c: Registering /MediaEndpoint/HFPAG on adapter /org/bluez/21220/hci0.
D: [pulseaudio] bluetooth-util.c: Registering /MediaEndpoint/HFPHS on adapter /org/bluez/21220/hci0.
D: [pulseaudio] bluetooth-util.c: Registering /MediaEndpoint/A2DPSource on adapter /org/bluez/21220/hci0.
D: [pulseaudio] bluetooth-util.c: Registering /MediaEndpoint/A2DPSink on adapter /org/bluez/21220/hci0.
E: [pulseaudio] bluetooth-util.c: RegisterEndpoint() failed: org.bluez.Error.AlreadyExists: Already Exists
E: [pulseaudio] bluetooth-util.c: RegisterEndpoint() failed: org.bluez.Error.AlreadyExists: Already Exists
E: [pulseaudio] bluetooth-util.c: RegisterEndpoint() failed: org.bluez.Error.AlreadyExists: Already Exists
E: [pulseaudio] bluetooth-util.c: RegisterEndpoint() failed: org.bluez.Error.AlreadyExists: Already Exists
2013-02-18 19:50:37 +02:00
Stefan Huber
163430f05b echo-cancel: Enable different sample specs for rec and out stream
Enable advanced AEC methods to use different specs (i.e., number of
channels) for rec and out stream. A typical application is beam forming
resp. multi-channel AEC, which takes multiple record channels to produce
an echo-canceled output stream.
This commit alters the EC API as follows: the EC's init() used to get
source and sink's sample spec/channel map. The new interface renamed
source to rec and sink to play and additionally passes sample spec and
channel map of the out stream. The new parameter names of init()
{rec,play,out}_{ss,map} are more intuitive and also resemble to the
parameter names known from run(). Both rec_{ss,map} and out_{ss,map} are
initialized as we knew it from source_{ss,map} before being passed to
init(). The previous EC implementations only require trivial changes,
i.e., setting rec_{ss,map} to out_{ss,map} at the end of init() in case
that out_{ss,map} is modified in init().
2013-02-18 19:16:40 +02:00
Mikel Astiz
17b3cb954b bluetooth: Merge all ports into "bluetooth-input" and "bluetooth-output"
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-18 18:39:12 +02:00
Mikel Astiz
d776416709 bluetooth: Use profile availability to auto-switch profiles
Use the card profile availability flag instead of port availability in
order to automatically switch profiles, for example when a paired phone
starts streaming A2DP audio.
2013-02-18 18:02:39 +02:00
Mikel Astiz
966a827d77 bluetooth: Expose card profile availability
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-18 17:48:43 +02:00
Mikel Astiz
8851644a3c core: Internally deprecate pa_port_available_t to use pa_available_t
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-18 17:25:53 +02:00
Stefan Huber
3aefdd995c echo-cancel: Do not bypass EC implementation when play stream is empty
When the play stream from the EC sink has not enough data available then
the EC implementation is currently bypassed by directly forwarding the
record bytes to the EC source. Since EC implementations maintain their
own buffers and cause certain latencies, a bypass leads to glitches as
the out stream stream jumps forth and back in time. Furthermore, some
EC implementations may also apply noise reduction or other sound
enhancing techniques, which are therefore bypassed, too.

Fix this by passing silence bytes to the EC implementation if the play
stream runs empty. Hence, this patch keeps the EC implementation running
even if the play stream has no data available.
2013-02-18 16:26:39 +02:00
Stefan Huber
9b6dced2cb echo-cancel-test: When fopen() fails tell which file failed 2013-02-16 21:46:27 +02:00
Stefan Huber
7eff884848 echo-cancel-test: Pass aec_args with module args
The echo canceller module can pass arguments to the EC implementation
via the module parameter aec_args. However, the echo-cancel-test passes
EC arguments via a separate argv[] option, which is inconsistent. Fix
this.
2013-02-16 21:45:26 +02:00
Stefan Huber
8aa30049ec echo-cancel-test: Enable debug log level 2013-02-16 21:39:33 +02:00
Tanu Kaskinen
77b3ba514c bluetooth: Fix thread teardown code ordering
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-16 20:48:55 +02:00
Mikel Astiz
5d4b7c4a89 bluetooth: Fix premature acquire attempts
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-16 16:53:42 +02:00
Tanu Kaskinen
2c666e3e16 idxset: Add pa_idxset_remove_all()
Slightly nicer than using pa_idxset_steal_first() in a loop.
2013-02-16 01:18:59 +02:00
Tanu Kaskinen
31ee1a7d54 hashmap: Add pa_hashmap_remove_all()
Slightly nicer than using pa_hashmap_steal_first() in a loop.
2013-02-16 01:17:04 +02:00
Tanu Kaskinen
061878b5a4 idxset: Use pa_free_cb_t instead of pa_free2_cb_t
There were no users for the userdata pointer.
2013-02-16 01:15:27 +02:00
Tanu Kaskinen
43e7868008 device-port: Remove pa_device_port_hashmap_free() 2013-02-16 01:13:57 +02:00
Tanu Kaskinen
8872c238ba hashmap: Use pa_free_cb_t instead of pa_free2_cb_t
The previous patch removed module-gconf's dependency on the userdata
pointer of the free callback, and that was the only place where the
userdata pointer of pa_free2_cb_t was used, so now there's no need for
pa_free2_cb_t in pa_hashmap_free(). Using pa_free_cb_t instead allows
removing a significant amount of repetitive code.
2013-02-16 01:12:21 +02:00
Tanu Kaskinen
dcf043842e gconf: Remove needless userdata function arguments 2013-02-16 01:12:10 +02:00
Tanu Kaskinen
cfb895438a gconf: Add userdata pointer to struct module_info
This will be useful in simplifying function argument lists.
2013-02-16 01:12:01 +02:00
Peter Meerwald
95b64804ab core: Move pa_mix() into new file mix.c
idea is to allow optimized code path (similar to volume code)
and rework/specialize mixing cases to enable runtime performance improvements

no functionality changes in this patch

Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
2013-02-15 21:33:07 +02:00
Tanu Kaskinen
505a57d32d echo-cancel: Fix uninitialized variable dotp_xf_xf of AEC struct
Initialize the variable to zero by using pa_xnew0() instead of
pa_xnew(). This also allows us to remove a bunch of other zero
initialization statements.

Reported-by: Peter Meerwald <p.meerwald@bct-electronic.com>
2013-02-15 21:24:36 +02:00
Peter Meerwald
90276fe18d echo-cancel: Use proper float constants in adrian-aec
Signed-off-by: Peter Meerwald <p.meerwald@bct-electronic.com>
2013-02-15 21:18:36 +02:00
Tanu Kaskinen
8d9c41e84c echo-cancel: Fix tap weights array alignment 2013-02-15 21:16:37 +02:00
Peter Meerwald
764eabd109 echo-cancel: Fix zeroing of w in AEC_leaky()
bug probably caused by alignment requirement; sizeof(a->w) is a pointer, sizeof(a->w_arr) is an array

Signed-off-by: Peter Meerwald <p.meerwald@bct-electronic.com>
2013-02-14 16:45:54 +02:00
Peter Meerwald
bf29c8dcf7 echo-cancel: Fix memory leak / deinitialization of Adrian AEC
was simply absent

Signed-off-by: Peter Meerwald <p.meerwald@bct-electronic.com>
2013-02-14 16:23:38 +02:00
Peter Meerwald
c43e885537 echo-cancel: Output echo canceller name if invalid
Signed-off-by: Peter Meerwald <p.meerwald@bct-electronic.com>
2013-02-14 15:25:29 +02:00
Peter Meerwald
db7415b7e9 echo-cancel: Add function pa_echo_canceller_blocksize_power2()
computes EC block size in frames (rounded down to nearest power-of-2) based
on sample rate and milliseconds

move code from speex AEC implementation to module-echo-cancel such that
functionality can be reused by other AEC implementations

Signed-off-by: Peter Meerwald <p.meerwald@bct-electronic.com>
2013-02-14 15:24:09 +02:00
Peter Meerwald
e845c86c64 build-sys: Properly check for HAVE_DBUS in module-ladspa-sink
prevents
  CC     module_ladspa_sink_la-module-ladspa-sink.lo
modules/module-ladspa-sink.c:1332:5: warning: "HAVE_DBUS" is not defined
modules/module-ladspa-sink.c:1370:5: warning: "HAVE_DBUS" is not defined
in case HAVE_DBUS is not available

Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
2013-02-14 15:06:59 +02:00
Mikel Astiz
b84c293ff3 bluetooth: Fix incorrect index check with PA_ELEMENTSOF
The equality case should also be considered an index-out-of-range case.
2013-02-14 14:41:10 +02:00
Tanu Kaskinen
4963db8dc0 udev: Add use_ucm module argument 2013-02-06 14:11:40 +02:00
David Henningsson
83d44139d3 alsa-ucm: Fallback to stereo duplex
If 'PlaybackChannels' and 'CaptureChannels' are absent in the UCM
file for a device, assume the device is stereo duplex.

Reported-by: Luke Yelavich <luke.yelavich@canonical.com>
Signed-off-by: David Henningsson <david.henningsson@canonical.com>
2013-02-06 13:49:57 +02:00
Tanu Kaskinen
10262197d0 dbus: Fix connection cleanup when killing clients 2013-02-06 12:31:33 +02:00
Jyri Sarha
a3b8b6a07e combine: Stop rate adjustments if sink is supended 2013-02-06 12:22:16 +02:00
David Henningsson
163a7dbe8b alsa-sink/source: Better thread names
Now you can actually see *which* sink/source that sends a specific
message to the log, which is quite useful if you have more than
one sound card.

Signed-off-by: David Henningsson <david.henningsson@canonical.com>
2013-02-05 08:40:40 +02:00
Mikel Astiz
58def1fd1d reserve: Fix leaking NameLost signals after release+acquire
The use of the pseudo-blocking D-Bus calls leads to the problem that
NameLost signals are received after the reply to ReleaseName().

The problem with this is that a later acquisition of the same audio
device can potentially receive the NameLost signal corresponding to
the previous instance, due to the fact that the signal hasn't been
popped from the D-Bus message queue.

The simplest approach to solve this problem is to poll the actual name
owner from the D-Bus daemon, in order to make sure that we did really
lose the name.

The proposal uses a blocking call to GetNameOwner to avoid incosistent
states in the internal APIs: it would otherwise be possible to have a
"busy" device before the reservation has been lost, in the unlikely
case if some other process acquires the name before we got the
confirmation that the NameLost was actually true.
2013-01-31 14:04:45 +02:00
Mikel Astiz
cb0f3d2878 reserve: Move get_name_owner() to the public rd_device API
The function is interesting for both rd_device and rd_monitor so make
it part of the rd_device public API to avoid duplicated code.

The decision to move the function to reserve.c is motivated by the fact
that other projects (i.e. jack) use reserve.c only. Therefore, adding a
reserve->reserve-monitor dependency should be avoided.
2013-01-31 13:56:25 +02:00
Tanu Kaskinen
849161f086 bluetooth: Fail if BlueZ tries to give duplicate device addresses. 2013-01-31 09:38:40 +02:00
Mikel Astiz
cd23fbf947 bluetooth: Detect changes in constant properties
The D-Bus API should guarantee that some properties remain constant and
therefore treat changes in such properties as errors.
2013-01-31 09:31:59 +02:00