Commit graph

6735 commits

Author SHA1 Message Date
Mikel Astiz
b8fd6f869e bluetooth: Do not acquire transport during profile change
Until today, setting the card to some profile resulted in a transport
acquisition, leading to audio stream setup. This is generally not very
interesting and even undesireable for HFGW use-cases, where the
Gateway role (the remote end) would typically request the SCO link.

Nevertheless, there is no safe way to implement such check without race
conditions, since the BlueZ's state can change between the state report
and the call to Acquire(). The chances for this to reproduce are quite
low though, since interface state changes are relatively slow.

This race condition requires that BlueZ's API is extended in order to
perform the operation atomically, which has already been discussed and
ack-ed in the BlueZ mailing list.

Note that this patch does not introduce a new race condition, since it
already existed before (the PropertyChanged->Acquire race condition,
affecting HFGW use-cases). It is just more explicit now.
2012-09-26 19:27:14 +08:00
Mikel Astiz
884d1d46ca bluetooth: Set profile even if transport not acquired
If the acquisition of the transport fails, the profile should still be
set. In this case the audio is not actually streaming, so the sink and
source will be created but left suspended.

If the transport needs to be acquired later, for example because the
user wants to route the audio the remote device, the suspend flag should
have to be changed.
2012-09-26 19:27:14 +08:00
Mikel Astiz
dcc11dcbe9 bluetooth: Support port availability flag
Use the port availability flag to expose whether a certain profile is
connected and whether it's doing actual audio streaming.

The proposed mapping is the following:
- Profile disconnected: port is unavailable
- Profile is connected (but not streaming/playing): availability unknown
- Profile is streaming/playing: port is available

The availability-unknown is specially interesting: it involves that if
the sink/source exists (corresponding card profile set), it is currently
in suspended state.

For example, for SCO cases (HFGW or HSP), this means the SCO is down. A
policy module would typically not change this, unless someone is really
trying to use the sink/source. This situation would be nicely handled by
module-suspend-on-idle, which would automatically connect SCO.

On the other hand, if the user wants to control the status of the SCO,
it will still be possible by resuming the sink or source (suspend=0).
This works out-of-the-box since most UIs would show to the user ports
whose availability is unknown.
2012-09-26 19:27:14 +08:00
Mikel Astiz
4cc4c30187 bluetooth: Config MTU transport after acquire
The configuration of the transport that depends on the MTU should be
performed every time the transport has been acquired, since the
parameters depend on what the Media API provides. This requires to
update the parameters of the sinks and sources as well.

This patch moves this code into a new function that will be called
when the stream is starting (setup_stream), from the IO thread.

This makes the code more robust, since the existing multiple calls to
bt_transport_acquire() do not rely on setup_bt() being able to acquire
the transport.
2012-09-26 19:27:14 +08:00
Mikel Astiz
2a7d001c97 bluetooth: Provide dummy set_port callbacks
There should be one port per sink/source so a dummy set_port callback
will be enough.

Adding this callback avoid the "operation not implemented" error
message and additionally makes the module work nicely with
module-switch-on-port-available.
2012-09-26 19:27:14 +08:00
Mikel Astiz
f280e8b50d sink, source: Support creating suspended sinks and sources
The initial state of a sink or source might not necessarily be IDLE,
because sometimes it might be suspended from the very beginning.
2012-09-26 19:27:14 +08:00
Mikel Astiz
0ee5fa6377 bluetooth: Fix check if transport exists before acquire
The transport might have disapeared exactly before acquiring, so we
should avoid an assertion failure, in this case inside the function
pa_bluetooth_discovery_get_by_path().
2012-09-26 19:27:14 +08:00
Mikel Astiz
76248fd8f2 bluetooth: Fix using garbage memory
module-bluetooth-policy should set the allocated memory to zero, in
order to handle failure cases properly.
2012-09-26 19:27:14 +08:00
Mikel Astiz
9a5330e601 bluetooth: Fix wrongly set "phone" role for HFGW
The HFGW source should be consistent with the sink by not setting the
"phone" intended role.

Even though setting this role seems to make sense strictly speaking, the
rest of the codebase doesn't handle this well. Therefore, the audio
coming from a Bluetooth phone can be routed back to the same device.
2012-09-26 19:27:14 +08:00
Mikel Astiz
38de0af64e bluetooth: Refactor code to helper function
Make code more readable by introducing the helper function
bt_transport_is_acquired(). This also adds assertions to check whether
the internal state is consistent.
2012-09-26 19:27:14 +08:00
Mikel Astiz
431f56fd68 bluetooth: Refactor parsing of signal PropertyChanged
Wrap the code parsing the PropertyChanged signal into a helper function
that will return the new state of the interface.
2012-09-26 19:27:14 +08:00
Mikel Astiz
4d2748ef5c bluetooth: Remove return value of setup_stream()
The function setup_stream() never fails so the code can be simplified by
just removing the return value.
2012-09-26 19:27:13 +08:00
Mikel Astiz
49f5c111bd bluetooth: Remove return value of bt_transport_config()
The function bt_transport_config() never fails so the code can be
simplified by just removing the return value.
2012-09-26 19:27:13 +08:00
Matthijs Kooijman
3d2d30f688 equalizer: Don't cleanup u->sink in sink_input_kill_cb yet
Previously, sink_input_kill_cb would cleanup u->sink an then unload the
module. However, during module unload, both save_state and dbus_done
tried to use u->sink, causing a segfault or assertion failure.

The segfault is easy to reproduce: Load module-equalizer-sink and then
press ctrl-C to terminate pulseaudio.

This commit removes the u->sink cleanup in sink_input_kill_cb, since
u->sink will be cleaned up by the module's pa__done as well (after it
has been used).

Signed-off-by: Matthijs Kooijman <matthijs@stdin.nl>
2012-09-25 20:39:15 +03:00
Andika Triwidada
626085ed9c i18n: Add Indonesian translation. 2012-09-23 20:19:45 +03:00
David Henningsson
24034ed715 flist: Increase default list size to 256
Nowadays, we are using more hashmaps and other things, than we did
before. Therefore, I often get the "flist is full (don't worry)"
message. This change should avoid that message. I was unable to find
any significance in increase of memory footprint from this change.

Signed-off-by: David Henningsson <david.henningsson@canonical.com>
2012-09-23 13:12:54 +03:00
David Henningsson
6174c207d2 alsa-mixer: Add "iec958-stereo-input" to well known path names
Interestingly, the name is properly matched even though there
is no paths/iec958-stereo-input.conf file.

Signed-off-by: David Henningsson <david.henningsson@canonical.com>
2012-09-21 12:06:56 +02:00
Arun Raghavan
f72a32151c stream: Allow record streams to start muted
This check was valid before we introduced per-source-output volumes, so
dropping it now. Thanks to Alban Browaeys <prahal@yahoo.com> for
catching this.
2012-09-21 15:42:37 +08:00
Mikel Astiz
5412a69cac loopback: Disable adjust timer when suspended
Stop the rate adjustment timer when no audio is flowing.
2012-09-21 10:38:15 +03:00
Frédéric Dalleau
6c916697bc loopback: Cork source-output if sink is suspended
During initialization, the approach avoids having a needless short
period of corked state in case the sink is suspended, by always creating
the source-output corked and uncorking it immediately afterwards when
the sink is not suspended.
2012-09-21 10:32:32 +03:00
Frédéric Dalleau
e90e19f457 loopback: Cork sink-input if source is suspended
During initialization, the approach avoids having a needless short
period of corked state in case the source is suspended, by always
creating the sink-input corked and uncorking it immediately afterwards
when the source is not suspended.
2012-09-21 10:25:13 +03:00
Flavio Ceolin
2c8aa18b1d sink-input: Remove redundant check in pa_sink_input_request_rewind().
This bug is part of the problems spotted by Tanu.

BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=53923
2012-09-16 09:47:43 +03:00
Arun Raghavan
3e3c9ef67b Revert "build: Merge bluez pkg-config checks into one"
Keeping the SBC check separate means we can keep the SBC_LIBS/CFLAGS
separate, which is cleaner. Thanks to Jan Steffens for pointing out that
this was broken (SBC_* wasn't actually changed to match the configure
change).

This reverts commit da5078e5c7.
2012-09-07 23:45:12 +05:30
Tanu Kaskinen
6b52b47856 .gitignore: Add cpu-test. 2012-09-07 17:22:10 +03:00
Arun Raghavan
da5078e5c7 build: Merge bluez pkg-config checks into one 2012-09-06 09:07:34 -07:00
Tanu Kaskinen
1f1db97b65 bluetooth: Remove commented out code. 2012-09-06 15:59:34 +03:00
Luiz Augusto von Dentz
75df8714d7 bluetooth: Don't force any profile on discovery module
Let device module figure out the priority based on the state of the
profiles.

Note that most likely all profiles will be in PA_BT_AUDIO_STATE_CONNECTED
state so 'Off' will be the initial profile then it is up to the policy
module to switch to the most suitable profile.
2012-09-06 15:59:34 +03:00
Luiz Augusto von Dentz
8228db051e bluetooth: Remove built-in/static SBC codec
SBC shared library is now available at:

http://git.kernel.org/?p=bluetooth/sbc.git;a=summary
2012-09-06 15:59:24 +03:00
Uoti Urpala
6031546f66 sink-input: Fix underrun_for calculation when resampling.
pa_sink_input_seek() calculates output lenth (slength) and
corresponding input length (ilength). During an underrun, the function
generates slength bytes of silence and adds ilength to the
underrun_for value. However, the ilength value may be shortened to
match resampler limits, and there's no corresponding adjustment to
slength. Thus, the length of the generated silence is longer than
resampler output would have been, and underrun_for should be increased
by more than the limited ilength. This error makes the user-visible
since_underrun field in struct pa_timing_info too small. Fix by using
the original value calculated before limiting in this case.
2012-08-30 12:00:35 +03:00
Tanu Kaskinen
34ab73b9ac sink: Remove an incorrect FIXME comment.
The problem that the comment mentions doesn't actually
exist, because when the sink latency is changed to a smaller
value, the sink implementor will request the required
rewind.
2012-08-30 11:54:54 +03:00
Tanu Kaskinen
352130f850 sink-input: Add a comment in pa_sink_input_request_rewind(). 2012-08-29 08:25:15 +03:00
Tanu Kaskinen
056bb3a39c sink-input: Fix comment: s/push/peek/ 2012-08-29 08:25:15 +03:00
Mikel Astiz
9f924a9dda bluetooth: Support HFGW in module-bluetooth-policy
Add support for hfgw card profile in module-bluetooth-policy, just like
a2dp_source is handled.

In this case also the sink needs to be connected using module-loopback.
2012-08-22 10:19:20 +03:00
Mikel Astiz
2d6db0335f bluetooth: Generalize module-bluetooth-policy
Instead of focusing on a2dp_source only, prepare the module to support
several profiles. It will be possible to enable/disable each of them
using module arguments.
2012-08-22 10:18:22 +03:00
Mikel Astiz
69f4d4af16 bluetooth: Trivial style fix
Use consistent style for pointer types in module-bluetooth-policy.
2012-08-22 10:17:48 +03:00
Mikel Astiz
2ef75a07b5 bluetooth: Fix bluetooth.protocol property
Property bluetooth.protocol did make a distinction between A2DP sink and
source roles but on the contrary did not separate HFP roles (headset vs
gateway). For consistency, they should both behave similarly.

This automatically fixes another incosistency: the HFGW (or HSP) sink
was set to bluetooth.protocol="sco", while the source was set to "hsp".
There is no use for this distinction, since the protocol (including the
role) is the same.
2012-08-22 10:12:45 +03:00
Tanu Kaskinen
0359f6c624 object: Get rid of "warning: cast increases required alignment of target type"
On ARM, pa_object has less strict alignment requirements
than e.g. pa_sink and pa_source, so when pa_object is cast
to pa_sink, the compiler thinks that it's unsafe. In this
case, however, the pointer given to pa_sink_ref() was a
pa_sink pointer to begin with, so casting it first to
pa_object and then back to pa_sink is entirely safe.

This particular source of warnings is extremely annoying,
because this message is printed for any compilation unit
that includes sink.h, source.h or any other header that
defines a class, and the message tends to get printed
multiple times for one compilation unit:

In file included from ./pulsecore/source-output.h:37:0,
                 from ./pulsecore/source.h:49,
                 from ./pulsecore/sink.h:40,
                 from ./pulsecore/core.h:50,
                 from daemon/daemon-conf.h:31,
                 from daemon/cmdline.h:25,
                 from daemon/cmdline.c:38:
./pulsecore/sink-input.h: In function 'pa_sink_input_ref':
./pulsecore/sink-input.h:245:1: warning: cast increases required alignment of target type [-Wcast-align]
2012-08-22 10:01:52 +03:00
Tanu Kaskinen
3d6092bb0f memblock: Add pa_memblock_acquire_chunk().
Besides making the code a bit cleaner, this also gets rid of
a few "cast increases required alignment of target type"
warnings.
2012-08-22 09:47:03 +03:00
Mikel Astiz
33e5802df2 bluetooth: Fix missing state checks for a2dp_source
Profile a2dp_source, just like any other card profile, should have
state guards when the profile is being changed. If the BlueZ interface
is not connected, the profile should be set to "off".
2012-08-21 19:50:29 +03:00
Mikel Astiz
d59275599a bluetooth: Minor style fix
Else clause should be in the same line as the closing brace.
2012-08-21 19:24:06 +03:00
Martin-Éric Racine
333696ff60 manpage, finnish translation: fix spelling errors 2012-08-21 16:27:37 +02:00
Deng Zhengrong
8e0f50c176 tests: fix the wrong library path in check-daemon 2012-08-20 07:27:43 +05:30
Deng Zhengrong
70acd7bf66 tests: modify ipacl-test to use 'check' framework 2012-08-20 07:06:00 +05:30
Deng Zhengrong
deeb0f05b3 tests: modify once-test to use 'check' framework 2012-08-20 07:06:00 +05:30
Deng Zhengrong
b095ebd502 tests: modify lock-autospawn-test to use 'check' framework 2012-08-20 07:06:00 +05:30
Deng Zhengrong
d9841a9431 tests: modify rtpoll-test to use 'check' framework 2012-08-20 07:06:00 +05:30
Deng Zhengrong
c02214dac5 tests: modify sig2str-test to use 'check' framework 2012-08-20 07:05:59 +05:30
Deng Zhengrong
f4dd422c75 tests: modify sigbus-test to use 'check' framework 2012-08-20 07:05:59 +05:30
Deng Zhengrong
034807d6d3 tests: modify interpol-test to use 'check' framework 2012-08-20 07:05:59 +05:30
Deng Zhengrong
23fac14278 tests: modify smoother-test to use 'check' framework 2012-08-20 07:05:59 +05:30