Commit graph

8597 commits

Author SHA1 Message Date
Tanu Kaskinen
d16600145f build-sys: add coverity/model.c to the tarball 2017-07-25 02:27:31 +03:00
Tanu Kaskinen
fff0b34347 build-sys: bump sonames 2017-07-25 01:47:58 +03:00
Tanu Kaskinen
5de4b652cb simple: fix negative latency handling
pa_usec_t is an unsigned type, but there were calculations that used it
as if it were a signed type.

If the latency is negative, pa_simple_get_latency() now reports 0.

Added some comments too.
2017-07-20 16:56:41 +03:00
Ted Ying
b0cd94233a simple: Change latency estimation to account for already-read data in pa_simple_get_latency().
BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=81075
2017-07-20 16:50:08 +03:00
Tanu Kaskinen
e7d7b29c17 protocol-native: fix bytes-to-usec conversion of "on-the-fly" data
The on_the_fly_snapshot variable contains the amount of bytes that has
been sent from the source IO thread to the main thread, but not yet
pushed to the stream memblockq. The data is in the stream format, but
the bytes-to-usec conversion used the source format, which caused random
latency reporting errors.

BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=81075
2017-07-17 19:44:51 +03:00
Tanu Kaskinen
a448cc587c core: change configured_default_sink/source type to string
This allows us to restore the default device properly when a
hotpluggable device (e.g. a USB sound card) is set as the default, but
unplugged temporarily. Previously we would forget that the unplugged
device was ever set as the default, because we had to set
configured_default_sink to NULL to avoid having a stale pa_sink pointer,
and also because module-default-device-restore couldn't resolve the name
of a currently-unplugged device to a pa_sink pointer.

BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=89934
2017-07-17 19:41:03 +03:00
Tanu Kaskinen
abdd14d5e0 fix dbus message leaks
I reviewed all places that call
dbus_connection_send_with_reply_and_block(), and found several places
where dbus messages aren't properly unreffed.
2017-07-17 19:29:21 +03:00
David Michael
e538e19664 solaris: Support building on GNU Hurd 2017-07-14 22:01:15 +03:00
Tanu Kaskinen
0a46b437e2 man: fix typo: "the" -> "they" 2017-07-12 19:56:09 +03:00
Tanu Kaskinen
6766491d7b man: fix typos: "my" -> "may" 2017-07-12 19:44:38 +03:00
Tanu Kaskinen
4ed7c1cab8 man: fix a copy-paste error 2017-07-12 18:35:24 +03:00
Grzegorz Kolodziejczyk
8cf5e9211c bluez5-device: Log subband count instead of subband flag
As log information says, SBC log info have to have one of two subband count
values: 4 or 8, instead of subband flag.
2017-07-10 19:49:02 +03:00
Yuri Chornoivan
65dbc609dc i18n: update the Ukrainian translation 2017-06-27 16:38:05 +03:00
Tanu Kaskinen
5f29e670cb Revert "bluetooth: Auto recover if profile is 'off'"
This reverts commit 69c212f8c1.

Reasons:

The original reason for the patch was to work around some issue
regarding the profile not connecting immediately (sorry, I don't really
know the details), but that issue was fixed later by commit 998dfdf4cc,
so the original reason doesn't apply any more.

Automatically changing the profile when the transport state changes to
PLAYING has traditionally been handled by module-bluetooth-policy, and
as far as I can tell, there's no reason to change that.

The assertion is unsafe. It's not guaranteed that the profile change
will always succeed (at least pa_thread_mq_init() can fail due to
reaching the maximum file descriptor limit).
2017-06-17 17:46:49 +03:00
Milo Casagrande
bbac59b0e4 i18n: update the Italian translation
Signed-off-by: Milo Casagrande <milo@milo.name>
2017-06-09 01:01:04 +03:00
Arun Raghavan
8ce8c93cb7 padsp: Write only frame-aligned chunks to the stream
Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=101121
2017-06-05 01:26:51 +03:00
Hui Wang
e3b64d8fd3 alsa: make priority of the port headset-mic higher than headphone-mic
There are two reasons for this change:

1. If it is a Dell desktop machine with the realtek codec, and there
is no internal microphone on it, there is one physical audio jack
which can support headphone, headset and microphone, but this audio
jack does not have hardware capability to distinguish what is plugged
in, after users plug in a headphone and select headphone from UI
program, the headphone can't output any sound. There are many reasons
for this issue, one of them is the active_port of pa_source is set
to headphone-mic, that means the kernel audio driver will configure
this audio jack to be a microphone jack instead of headphone jack.
If we make the priority of headset-mic a bit higher than headphone-mic,
the headset-mic will be the active_port of pa_source unless users
select the headphone-mic on purpose, then this issue will be fixed.

2. Nowadays, the headset is more popular than traditional microphone,
It is highly possible that users plug in a headset instead of
microphone, it makes sense to make the headset-mic's priority higher
than headphone-mic's.

Signed-off-by: Hui Wang <hui.wang@canonical.com>
2017-06-01 00:53:31 +03:00
Georg Chini
73cc75dd86 stream-restore: Ignore sink-inputs/source-outputs that connect a filter to the master
module-stream-restore primarily uses the role of a stream for restoring. The sink-inputs
and source-outputs of filters all have role "filter", therefore currently all filters are
treated equally and are restored to the same device and volume.

This patch lets module-stream-restore ignore the streams that connect the filter to the
master.

Bug link: https://bugs.freedesktop.org/show_bug.cgi?id=100065
2017-05-31 20:54:43 +02:00
Tanu Kaskinen
ea506e9e23 i18n: update the French translation
These changes are from fedora.zanata.org. The authors are
Sam Friedmann <sfriedma@redhat.com>
Wim Taymans <wim.taymans@gmail.com>
Edouard Duliege <edouard.duliege@gmail.com>
2017-05-22 10:06:29 +03:00
Muhammet Kara
3c9e777770 i18n: Updated Turkish translation 2017-05-20 20:46:31 +03:00
Tanu Kaskinen
a7017b831e sink-input, source-output: don't allow moving streams that are connected to moving filter devices
When a filter sink is moving, it's not connected to any master sink, and
therefore it's not connected to any IO thread either. In this situation
trying to move a stream that is connected to the filter sink is likely
to result in crashing, because starting the move involves sending a
message to the IO thread. Sometimes this works by accident (the
asyncmsgq of the filter sink still points to the old master sink's
asyncmsgq), but we really should never attempt it. This patch blocks all
moves where the moving stream is connected to a filter sink that itself
is in the middle of a move.

BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=100277
2017-05-18 23:32:32 +03:00
Georg Chini
e08124f6ba sink/source: Don't update default sink/source before calling PA_CORE_HOOK_{SINK,SOURCE}_PUT
In sink_put() and source_put(), pa_core_update_default_{sink,source}() was called
before the PA_CORE_HOOK_{SINK,SOURCE}_PUT hook. Therefore module-switch-on-connect
could not correctly determine the old default sink/source if no user default was
set and a sink/source with higher priority than any other sink/source turned up.

This patch corrects the problem by swapping the order of the hook call and the
pa_core_update_default_sink() call.

Additionally it corrects a problem in module-switch-on-connect. If, after the
change above, the new sink/source was the first sink/source to appear, pulseaudio
would crash because module-switch-on-connect assumed that the default sink/source
was not NULL. The patch checks if the default sink/source is NULL and only sets
the new default sink/source in that case.
2017-05-18 07:47:27 +02:00
Georg Chini
edc465da77 virtual sources and sinks: Don't double attach a sink input or source output on filter load
When a filter is loaded and module-switch-on-connect is present, switch-on-connect
will make the filter the default sink or source and move streams from the old
default to the filter. This is done from the sink/source put hook, therefore streams
are moved to the filter before the module init function of the filter calls
sink_input_put() or source_output_put(). The move succeeds because the asyncmsq
already points to the queue of the master sink or source. When the master sink or
source is attached to the sink input or source output, the attach callback will call
pa_{sink,source}_attach_within_thread(). These functions assume that all streams
are detached. Because streams were already moved to the filter by switch-on-connect,
this assumption leads to an assertion in pa_{sink_input,source_output}_attach().

This patch fixes the problem by reverting the order of the pa_{sink,source}_put()
calls and the pa_{sink_input,source_output}_put calls and creating the sink input
or source output corked. The initial rewind that is done for the master sink is
moved to the sink message handler. The order of the unlink calls is swapped as well
to prevent that the filter appears to be moving during module unload.

The patch also seems to improve user experience, the move of a stream to the filter
sink is now done without any audible interruption on my system.

The patch is only tested for module-echo-cancel.

Bug-Link: https://bugs.freedesktop.org/show_bug.cgi?id=100065
2017-05-18 07:46:46 +02:00
Georg Chini
00aeedfe98 virtual sinks and sources: Revert commits
This patch reverts commit db4fbb0121 and
3bb94c4e83. They were the wrong approach
to fix the bug (and did not fix it anyway).
2017-05-18 07:46:08 +02:00
Tanu Kaskinen
4c6843f020 sink, source: update the default sink/source on port switches
When sinks are compared during the default sink selection, the active
port's availability is inspected. Therefore, the default sink should be
updated when the active port changes, because the new port may have
different availability status than the old port.

For example, let's say that a laptop has an analog sink with a speaker
and a headphone port, and headphones are initially plugged in, so both
ports can be used[1]. The headphone port is initially the active port.
There's also a null sink in the system. When the headphones are
unplugged, the headphone port becomes unavailable, and the null sink
becomes the new default sink. Then module-switch-on-port-available
changes the analog sink port to speakers. Now the default sink should
change back to the analog sink, but that doesn't happen without this
patch.

[1] Actually we currently mark speakers as unavailable when headphones
are plugged in, but that's not strictly necessary. My example relies on
both ports being available initially, so the bug can't be reproduced
with the current mixer configuration.
2017-05-17 23:05:04 +03:00
muzena
61860e7ceb i18n: update the Croatian translation 2017-05-11 12:21:29 +03:00
Georg Chini
998dfdf4cc bluez5-device: Correctly handle suspend/resume cyle for audio gateway role of ofono backend
When the ofono backend released a tranport during suspend of sink or source, the
transport state was not changed to IDLE. Therefore pa_bluetooth_transport_set_state()
would return immediately when trying to resume. Even though the transport was acquired
correctly, setup_stream() would never be called and the resume failed.

This patch sets the transport state to IDLE when the transport is released. On resume,
the first call to transport_acquire() will be done from the message handler of the
*_SET_STATE message when source or sink are set to RUNNING. This call will only request
the setup of the connection, so setup_stream() cannot be called.
When the transport changes the state to PLAYING in hf_audio_agent_new_connection(),
handle_transport_state_change() is called. Because the sink or source state is already
RUNNING, the pa_{source,sink}_suspend() call will not lead to a state change message
and the I/O thread must be signaled explicitely to setup the stream.

The first setup of the device would also fail, which was only visible when the profile
was restored after connecting the headset. When trying to restore the headset_head_unit
profile, the profile was shortly set to off, so the headset always returned to a2dp.

This patch allows a delayed setup for the headset_head_unit profile, so that the profile
can successfully be restored.
2017-05-04 13:14:51 +02:00
Luiz Augusto von Dentz
f44f2996b4 bluetooth: ofono: Fix failing to parse valid NewConnection
When suspending due to idle timeout the transport will not change its
state, also in case the fd is closed due to POLLERR/POLLHUP events
the release shall check if the fd is still set otherwise it will fail
to be acquired again.
2017-05-04 13:14:06 +02:00
Luiz Augusto von Dentz
826bb358cc bluetooth: ofono: Close fd if cannot be accepted
Always close fd that cannot be accepted otherwise it will be left open
without being attached to any transport.
2017-05-04 13:12:08 +02:00
Luiz Augusto von Dentz
69c212f8c1 bluetooth: Auto recover if profile is 'off'
This means something went wrong, which in case of ofono backend it is
probably due to the profile not connecting immediately, but it can be
safely restored in that case the transport is playing which means the
profile has recovered connectivity.
2017-05-04 12:59:48 +02:00
Luiz Augusto von Dentz
956e72135e bluetooth: Don't default to native backend
The native backend is limited to HSP only which may not work with devices
that can only do HFP so if oFono is enabled it shall be used as default.
2017-05-04 12:58:21 +02:00
Luiz Augusto von Dentz
f45fc03e3d bluetooth: ofono: Detect if Connect has been called
This detects if profile has already been called and we are waiting
the response.
2017-05-04 12:53:06 +02:00
Luiz Augusto von Dentz
cf23f07ec7 bluetooth: ofono: Fix asserting when connecting as AG
Check the card Type property instead of assuming ofono would only be used
for HF role.
2017-05-04 12:52:00 +02:00
Luiz Augusto von Dentz
fe43e72604 bluetooth: ofono: Don't attempt to connect if fd is ready
If SCO fd is already set don't attempt to connect again.
2017-05-04 12:49:53 +02:00
Tanu Kaskinen
4e3aa53a3f jack-sink: fix latency calculation
The compiler warned about number_of_frames being possibly used
uninitialized, and on closer inspection I found that it was indeed not
initialized if saved_frame_time_valid is false.

In commit fe70b9e11a "source/sink: Allow pa_{source,
sink}_get_latency_within_thread() to return negative values" the
number_of_frames variable was added as an unsigned version of the l
variable, and number_of_frames partially replaced the l variable. The
replacement should have gone all the way, however. This patch removes
the remaining uses of the l variable and substitutes number_of_frames
on its place, and as a result, number_of_frames is now always
initialized.
2017-05-02 16:53:40 +03:00
Tanu Kaskinen
1c477fcb67 core, device-port: check availability when choosing the default device
It doesn't make sense to use a sink or source whose active port is
unavailable, so let's take this into account when choosing the default
sink and source.
2017-05-02 16:18:46 +03:00
Tanu Kaskinen
6b34896130 improve default sink/source handling
Currently the default sink policy is simple: either the user has
configured it explicitly, in which case we always use that as the
default, or we pick the sink with the highest priority. The sink
priorities are currently static, so there's no need to worry about
updating the default sink when sink priorities change.

I intend to make things a bit more complex: if the active port of a sink
is unavailable, the sink should not be the default sink, and I also want
to make sink priorities dependent on the active port, so changing the
port should cause re-evaluation of which sink to choose as the default.
Currently the default sink choice is done only when someone calls
pa_namereg_get_default_sink(), and change notifications are only sent
when a sink is created or destroyed. That makes it hard to add new rules
to the default sink selection policy.

This patch moves the default sink selection to
pa_core_update_default_sink(), which is called whenever something
happens that can affect the default sink choice. That function needs to
know the previous choice in order to send change notifications as
appropriate, but previously pa_core.default_sink was only set when the
user had configured it explicitly. Now pa_core.default_sink is always
set (unless there are no sinks at all), so pa_core_update_default_sink()
can use that to get the previous choice. The user configuration is saved
in a new variable, pa_core.configured_default_sink.

pa_namereg_get_default_sink() is now unnecessary, because
pa_core.default_sink can be used directly to get the
currently-considered-best sink. pa_namereg_set_default_sink() is
replaced by pa_core_set_configured_default_sink().

I haven't confirmed it, but I expect that this patch will fix problems
in the D-Bus protocol related to default sink handling. The D-Bus
protocol used to get confused when the current default sink gets
removed. It would incorrectly think that if there's no explicitly
configured default sink, then there's no default sink at all. Even
worse, when the D-Bus thinks that there's no default sink, it concludes
that there are no sinks at all, which made it impossible to configure
the default sink via the D-Bus interface. Now that pa_core.default_sink
is always set, except when there really aren't any sinks, the D-Bus
protocol should behave correctly.

BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=99425
2017-05-02 16:10:19 +03:00
Tanu Kaskinen
ea3ebd09d1 alsa: don't assume that hw:x is an analog output
Previously, if front:x didn't work, we would try to use hw:x for analog
stereo output. There's no guarantee that hw:x is an analog output,
however. For example, the Intel HDMI LPE driver uses hw:x for HDMI
output, and PulseAudio incorrectly created analog profiles for that
card, because front:x doesn't work but hw:x does.

This patch changes things so that the analog stereo mapping doesn't any
more use hw:x as a fallback. A separate "unknown stereo" fallback
mapping is added to handle the rare case where hw:x is the only PCM
device that works.

BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=100488
2017-05-02 14:23:56 +03:00
Georg Chini
68203100ff volume: Fix overflow in percent calculation of pa_*volume_snprint*()
The percent calculation could overflow in the pa_*volume_snprint*() functions.
For large volumes, volume * 100 can exceed UINT32_MAX.

This patch adds appropriate type casts.
2017-04-29 10:38:05 +02:00
Georg Chini
be1276d816 volume: Print a warning when volume is clipped in pa_sw_volume_multiply/divide()
When the volume exceeds PA_VOLUME_MAX in pa_sw_volume_multiply() or
pa_sw_volume_divide(), volume settings are insanely high and the
user should be notified about it.

This patch adds volume clamping to pa_sw_volume_divide() and prints
a warning when the volume is clipped in both functions.
2017-04-29 10:12:01 +02:00
Georg Chini
d985276c8b source/sink: Fix wrong calculation of thread_info.current_hw_volume
In pa_{source,sink}_new() and pa_{source,sink}_put() the current hardware
volume was miscalculated:

hw volume (dB) = real volume (dB) + soft volume (dB)
was used instead of
hw volume (dB) = real volume (dB) - soft volume (dB)

This lead to a crash in pa_alsa_path_set_volume() if high volumes were
set and the port was changed.

This patch fixes the calculation. Thanks to Tanu for pointing out
the correct solution.

Bug link: https://bugs.freedesktop.org/show_bug.cgi?id=65520
2017-04-29 10:07:01 +02:00
Rafael Fontenelle
2417305ae7 i18n: update the Brazilian Portuguese translation 2017-04-25 10:20:58 +03:00
Georg Chini
db4fbb0121 virtual sources and sinks: Fix possible segfault
Several virtual sources and sinks apart from module-echo-cancel also query the master
sink or source to estimate the current latency. Those modules might potentially show
the bug that is described for module-echo-cancel in bug 100277.

This patch checks in the message handlers for the PA_{SINK,SOURCE}_MESSAGE_GET_LATENCY
if the master sink or source is valid and returns 0 as latency if not. This is however
not yet sufficient to solve the issue. Additional patches will follow.
2017-04-24 20:31:54 +02:00
Georg Chini
3bb94c4e83 echo-cancel: Fix segfault during profile switch
When module-echo-cancel is loaded and there is only one sound card, then during a
profile switch, all sinks and sources can become temporarily unavailable. If
module-always sink is loaded, it will load a null-sink in that situation. If
also module-switch-on-connect is loaded, it will try to move the sink-inputs to
the new null-sink. If a sink-input was connected to the echo-cancel sink,
pa_sink_input_start_move() will send a PA_SINK_GET_LATENCY message to the
echo-cancel sink. The message handler will then in turn call
pa_sink_get_latency_within_thread() for the invalid master sink of module-echo-cancel.
This lead to a segfault.

This patch checks in the message handler if the master sink (or source) is valid and
returns 0 if not.
2017-04-24 20:30:48 +02:00
KimJeongYeon
15b0b60aae i18n: Update the Korean translation
Translate filter modules and fixed wrong c-format.

Signed-off-by: KimJeongYeon <jeongyeon.kim@samsung.com>
2017-04-24 14:50:10 +03:00
muzena
a6837ed1d5 i18n: add Croatian translation 2017-04-24 14:40:42 +03:00
Georg Chini
ce9ea846e9 bluez5-util: Fix segfault during shutdown of daemon
If a HFP audio gateway was connected via the ofono backend, pulse would
segfault during shutdown of the daemon. pa_bluetooth_discovery_unref()
removed the devices and transports before the ofono backend was freed.
Because the ofono backend keeps its own list of transports, transport_free()
was then called during termination of the ofono backend with an invalid
transport. Bug reported by Andrew Hlynskyi.

This patch moves the termination of the ofono and native backends before
freeing the devices.
2017-04-21 21:49:58 +02:00
Corentin Noël
92a6fe7453 echo-cancel: Change the DEVICE_MASTER_DEVICE property when changing device 2017-04-20 15:58:45 +05:30
Christian Kellner
9418807c92 sink: Add missing 'hifi' form factor to priorities
Assign it a propriety of 600, therefore ranking higher then speaker,
but below headphone.

https://bugs.freedesktop.org/show_bug.cgi?id=100579
2017-04-19 17:04:35 +03:00
Christian Kellner
6f4d303b6a sink: Add portable form factor priority (450)
The 'portable' form factor was currently missing meaning it is not
getting any form-factor priority at all and it would therefore always
be ranked lower then internal devices (which receive 400 form factor
priority). The priority 450 is smaller then 'speaker', based on the
idea that a portable device might have less quality then a dedicated
'speaker' device (some Yamaha amplifiers announce themselves as such).

https://bugs.freedesktop.org/show_bug.cgi?id=100579
2017-04-19 17:00:02 +03:00