Commit graph

8517 commits

Author SHA1 Message Date
Tanu Kaskinen
2530eb8d1b bluetooth-policy: retain backwards compatibility
The auto_switch argument was added in PulseAudio 10.0. In that release
the argument type was boolean. The type was changed to integer in commit
3397127f00. This patch adds backwards compatibility so that old
configuration files won't break when upgrading PulseAudio to 11.0.
2017-03-17 21:57:42 +02:00
Georg Chini
e26a675263 bluez5-util: Disconnect AG devices when ofono is started and headset=auto
With headset=auto it is possible that AG devices are connected and handled
via the native backend when ofono is started. Because the HS role will then
be disabled in the native backend, AG devices must be disconnected and any
future connections will be handled by ofono.
2017-03-14 07:32:31 +01:00
Georg Chini
adc2e8cd0a bluetooth: use native and ofono backends in parallel with headset=auto
This patch changes the behavior of the headset=auto switch for module-bluez5-discover.
With headset=auto now both backends will be active at the same time for the AG role and
the switching between the backends is only done for the HS role.
headset=ofono and headset=native remain unchanged.

This allows to use old HSP only headsets while running ofono and to have headset support
via pulseaudio if ofono is started with the --noplugin=hfp_ag_bluez5 option.
2017-03-11 19:02:16 +01:00
Peter Meerwald-Stadler
d065e4d114 pulse: Explicitly ignore pa_mainloop_run() return value in thread function
Coverity ID: #1137975

Signed-off-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
2017-03-10 10:18:33 +01:00
Peter Meerwald-Stadler
fa7329a2dd oss: Fix dead code
mode cannot be 0
Coverity ID: #1137964

Signed-off-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
2017-03-10 10:18:33 +01:00
Peter Meerwald-Stadler
eab0b9d83b core: Ignore pa_shared_remove() return value
document behaviour of pa_shared_remove() in case name does not exist

Coverity ID: #1380672

thanks to Georg Chini for suggesting to swap patch title and commit message

Signed-off-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
2017-03-10 10:17:40 +01:00
Peter Meerwald-Stadler
976f7e9a61 core: Assert return value of pa_shared_set/_remove() in dbus-shared
it must succeed, or we are leaking memory

Coverity ID: #1380674, #1380673

Signed-off-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
2017-03-10 10:14:37 +01:00
Tanu Kaskinen
0ced45265c dbus: fix card profile change signals
The "profile->card != c->card" check always evaluated to false, so the
CardProfileUpdated signal was never sent. The reason: call_data was
assigned to a pa_card_profile pointer, but the correct type is a pa_card
pointer.
2017-03-10 00:34:59 +02:00
Tanu Kaskinen
6022a1ee99 udev-detect: don't use readdir_r(), it's deprecated
readdir_r() was supposed to be a thread-safe version of readdir(), but
the interface turned out to be problematic. Due to the problems and the
fact that readdir() is safe enough on modern libc implementations, glibc
deprecated readdir_r() in version 2.24.

The man page contains more information about what's wrong with
readdir_r(): http://man7.org/linux/man-pages/man3/readdir_r.3.html
2017-03-10 00:32:34 +02:00
Arun Raghavan
1992c4cce1 echo-cancel: Limit the maximum sink/source latency
On systems with constrained CPUs, we might run into a situation where
the master source/sink is configured to have too high a latency.

On the source side, this would cause us to wake up with a large chunk of
data to process, which might cause us to exhust our RT limit and thus be
killed.

So it makes sense to limit the overall latency that we request from the
source (and correspondingly, the sink, so we don't starve for playback
data on the source side).

The 10 blocks maximum is somewhat arbitrary (I'm assuming the system has
enough headroom to process 10 chunks through the canceller without
getting close to the RT limit). This might make sense to make tunable in
the future.
2017-03-09 22:17:48 +05:30
Arun Raghavan
c82e4913e8 alsa: Avoid creating tiny memchunks on write iterations
If the ALSA device supports granular pointer reporting, we end up in a
situation where we write out a bunch of data, iterate, and then find a
small amount of data available in the buffer (consumed while we were
writing data into the available buffer space). We do this 10 times
before quitting the write loop.

This is inefficient in itself, but can also have wider consequences. For
example, with module-combine-sink, this will end up pushing the same
small chunks to all other devices too.

Given both of these, it just makes sense to not try to write out data
unless a minimum threshold is available. This could potentially be a
fragment, but it's likely most robust to just work with a fraction of
the total available buffer size.
2017-03-09 22:17:48 +05:30
Peter Meerwald-Stadler
2898a5188c raop: Error out on parsing server port component
don't ignore server port parsing errors as suggested by Hajime Fujita

Signed-off-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
Cc: Hajime Fujita <crisp.fujita@nifty.com>
2017-03-09 13:51:51 +01:00
Peter Meerwald-Stadler
add5a175b6 raop: Log if pa_atoi() fails, latency is not used anyway
Coverity ID: #1398152

Signed-off-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
2017-03-09 13:51:51 +01:00
Peter Meerwald-Stadler
4cfd544f21 raop: Fix potential NULL dereference
wath may be NULL, as suggested by Hajime Fujita
Coverity ID: #1398156

setting val = NULL is not needed

Signed-off-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
Cc: Hajime Fujita <crisp.fujita@nifty.com>
2017-03-09 13:51:51 +01:00
Peter Meerwald-Stadler
a8ce3ef844 raop: Fix potential dereference after NULL check
Coverity ID: #1398157

Signed-off-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
2017-03-09 13:51:51 +01:00
Arun Raghavan
bfe0e6366d combine-sink: Use PA_MAX instead of ternary operator for clarity 2017-03-09 12:18:06 +05:30
Peter Meerwald-Stadler
74abce331b raop: Fix check for invalid file descriptor
file descriptor 0 is valid

Signed-off-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
2017-03-08 14:31:29 +01:00
Peter Meerwald-Stadler
6b7b70c472 core-util: Fix description of pa_split()
Signed-off-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
2017-03-08 14:31:29 +01:00
Peter Meerwald-Stadler
a199b9045e build: Use #ifdef to check for #defines
for example, in case HAVE_MEMFD is #undef, checking with #if HAVE_MEMFD
gives a warning (gcc 5.4.1, Ubuntu)

pulsecore/shm.c: In function 'sharedmem_create':
pulsecore/shm.c:208:5: warning: "HAVE_MEMFD" is not defined [-Wundef]
 #if HAVE_MEMFD

use #ifdef or #if defined() to check for presence of a #define

Signed-off-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
2017-03-08 14:31:29 +01:00
Moritz Bruder
48ba5e4957 waveout: add argument deprecation error 2017-03-07 18:15:17 +02:00
Moritz Bruder
7259df9590 waveout: fix wrong input device
Both input and output device were chosen with the same device number.
This is problematic as those numbers don't have to correspond.
Additionally the input device was named after the output device. This
commit adresses both issues by providing specific parameters for each
type.
2017-03-07 18:15:08 +02:00
Wim Taymans
e1dc75da99 backend-native: add support for the HSP Headset role
This is a rebase of Wim Taymans patch to support the HSP headset role that has
somehow been forgotten. Original patch can be found at
https://lists.freedesktop.org/archives/pulseaudio-discuss/2015-February/023242.html
Rebase and minor changes by Georg Chini.

In addition to the HSP Audio Gateway, also add support for the headset
role in the native bluetooth backend. In this role, pulseaudio is used as
headset.

In the headset role, we create source and sink to receive and send the samples
from the gateway, respectively. Module-bluetooth-policy will automatically load
loopback modules to link these to a sink and source for playback. Because this
makes the source the speaker and the sink the microphone, we need to reverse the
roles of source and sink compared to the gateway role.

In the gateway role, adjusting the sink volume generates a +VGS command to set
the volume on the headset. Likewise, receiving AT+VGS updates the sink volume.

In the headset role, receiving a +VGS should set the source volume and any
source volume changes should be reported back to the gateway with AT+VGS.
2017-03-07 15:17:43 +02:00
Tanu Kaskinen
18ec0fe53e iochannel: don't use variable length array in union
Clang didn't like the variable length array:

pulsecore/iochannel.c:358:17: error: fields must have a constant size:
'variable length array in structure' extension will never be supported
        uint8_t data[CMSG_SPACE(sizeof(int) * nfd)];
                ^

Commit 451d1d6762 introduced the variable length array in order to have
the correct value in msg_controllen. This patch reverts that commit and
uses a different way to achieve the same goal.

BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=99458
2017-03-07 15:17:27 +02:00
Peter Meerwald-Stadler
0cb72beace raop: Fix potential NULL dereference
'realm' is mandatory

Signed-off-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
2017-03-07 09:47:46 +01:00
Peter Meerwald-Stadler
233cb4516a raop: Fix potential resource leaks
Coverity ID: #1410204, #1410203, #1410202, #1410201, #1410200, #1410199

Signed-off-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
2017-03-07 09:47:46 +01:00
Peter Meerwald-Stadler
6c35ac7c8f raop: Silence unchecked return value warnings
Signed-off-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
2017-03-07 09:47:46 +01:00
Peter Meerwald-Stadler
20960e7cc6 raop: Fix indentation
Signed-off-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
2017-03-07 09:47:46 +01:00
Peter Meerwald-Stadler
94fc8c9ee2 raop: Fix potential memory leak
Coverity ID: #1410204

Signed-off-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
2017-03-07 09:47:46 +01:00
Peter Meerwald-Stadler
4d7922d091 raop: Fix resource leaks
Coverity ID: #1398158, #1398159

Signed-off-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
2017-03-07 09:47:46 +01:00
Peter Meerwald-Stadler
4bb25292f8 raop: Fix memleak
use local scope for trs variable simplifying cleanup
Coverity ID: #1398160

Signed-off-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
2017-03-07 09:47:46 +01:00
Peter Meerwald-Stadler
95d850a5ad raop: Fail after search for port number
should also fail if port is 0 after the loop, as suggested by Georg Chini

Signed-off-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
2017-03-07 09:47:46 +01:00
Peter Meerwald-Stadler
df9cda67d2 raop: Fix loop searching for port number
do...while not reachable, loop should try different ports in case EADDRINUSE is returned
Coverity ID: #1398161

Signed-off-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
2017-03-06 08:22:33 +01:00
Peter Meerwald-Stadler
ad9c8603b0 raop: Fix double free
make nick variable local, fix double free
Coverity CID: #1398162

Signed-off-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
2017-03-06 08:22:33 +01:00
Peter Meerwald-Stadler
424e97a5fa build: Add Coverity scan model
the modeling file help to avoid false positives and increase scanning
accuracy by explaining code Coverity can't see (out of tree libraries);
the model file must be uploaded by an admin to:
https://scan.coverity.com/projects/pulseaudio?tab=analysis_settings

the pa_assert_se() macro needs to be rewritten for Coverity so that
the assignment is not declared a side-effect

Signed-off-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
2017-03-06 08:22:33 +01:00
Georg Chini
e368ee4875 loopback: fix up the previous commit
The previous commit, "loopback: Initialize latency at startup and during
source/sink changes", was an old version of the patch that got
accidentally pushed instead of the last version. This commit does the
changes that were omitted when applying the old patch.
2017-03-06 00:45:19 +02:00
Georg Chini
f8e7354fac loopback: Initialize latency at startup and during source/sink changes
The current code does not make any attempt to initialize the end-to-end latency
to a value near the desired latency. This leads to underruns at startup because
the memblockq is initially empty and to very long adjustment times for long
latencies because the end-to-end latency at startup is significantly shorter
than the desired value.
This patch initializes the memblockq at startup and during source or sink changes
so that the end-to-end latency will be near the configured value. It also ensures
that there are no underruns if the source is slow to start and that the latency
does not grow too much when the sink is slow to start by adjusting the length of
the memblockq until the source has called push for the first time and the sink
has called pop for the second time. Waiting for the second pop is necessary
because the sink has not been started when the first pop is called.
For clarity, variables have been separated into input, output and main thread
variables.
2017-02-28 18:04:22 +02:00
Mihai Moldovan
c7d8085acb coreaudio-device: fix improper memory handling leading to crashes.
Make sure that we NULL pointers after freeing them. Otherwise bad things
happen.
2017-02-27 16:45:51 +02:00
Mihai Moldovan
b282f3bb96 build-sys: FlatCarbon is dead. Good riddance.
FlatCarbon was the flattened Carbon version used in Mac OS Classic
(i.e., pre Mac OS X.)

It was shipped as legacy software until 10.8, then dropped completely.

Using CoreServices is good enough, manually including FlatCarbon headers
only lead to build failures for users who had old versions of Xcode
lingering around their machines.

v2: don't accidentally drop the OS X semaphore implementation.
2017-02-27 16:45:49 +02:00
Georg Chini
a8e0556120 loopback: correct comments about the thread calling a function
The comments were wrong and confusing.
2017-02-20 16:39:36 +02:00
Georg Chini
a0241c892f loopback: Rename sink_input_buffer to loopback_memblockq_length
The variable does no longer represent the length of the whole sink input buffer,
therefore it has been renamed.
2017-02-18 17:34:59 +02:00
Georg Chini
066d4c2c23 bluez5-device: Use correct constants for fixed latency in PA_{SINK, SOURCE}_MESSAGE_GET_LATENCY
The PA_{SINK,SOURCE}_GET_LATENCY message handlers falsely always added the A2DP latency as fixed
latency instead of the profile specific constant.
2017-02-16 13:20:13 +02:00
Georg Chini
1c80af147d bluetooth: Make use of getsockopt() to determine MTU configurable
A recent patch changed the MTU size from the default value of 48 to the value
returned by getsockopt(). This breaks HSP for some setups. To circumvent the
problem, this patch introduces a boolean parameter "autodetect_mtu" for
module-bluetooth-discover, module-bluez5-discover and module-bluez5-device to
make this use of getsockopt() configurable.
2017-02-14 11:48:10 +02:00
Tanu Kaskinen
ca6c3f80f5 alsa-util: don't crash on devices with more than 32 channels
The pa_channel_map_init_extend() call later in the function crashes if
if ss->channels is greater than PA_CHANNELS_MAX.

Reported here:
https://lists.freedesktop.org/archives/pulseaudio-discuss/2017-January/027404.html

Reviewed-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Tested-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
2017-01-31 15:59:14 +02:00
Arun Raghavan
539371b3f7 sink, source: Make rate selection more explicit
This serves to explicitly document the various cases we deal with in
pa_sink_update_rate()/pa_source_update_rate() rather than have some of
them hidden behind the initialisation of desired_rate.
2017-01-30 14:07:37 +05:30
Arun Raghavan
cc021c7330 sink, source: Add a mode to avoid resampling if possible
This adds an "avoid-resampling" option to daemon.conf that makes the
daemon try to use the stream sample rate if possible (the device needs
to support it, which currently only ALSA does), and there should not be
any other stream connected).

This should enable some of the "audiophile" use-cases where users wish
to play high sample rate audio files without resampling.

We still will do conversion if sample formats don't match, though. This
means that if you want to play 96 kHz/24 bit audio without any
modification the default format will need to be set to be 24-bit as
well. This will force all streams to be upconverted, which, other than
the wasted resources, should be relatively harmless.
2017-01-30 13:54:43 +05:30
Tanu Kaskinen
5e1bb023a2 thread-test: fix deadlock
If we set magic_number to zero, the code will deadlock, because the
thread that is waiting for us to set magic_number to non-zero will
never progress.

The problem was reported here:
https://lists.freedesktop.org/archives/pulseaudio-discuss/2017-January/027368.html
2017-01-26 07:56:54 +02:00
Arun Raghavan
a50030b697 build-sys: Enable clang-based builds on Travis 2017-01-24 17:17:59 +05:30
Wim Taymans
d442da3a09 suspend-on-idle: resume on unload
We need to resume all sinks we know about when unloading the module or
else they will stay suspended forever.
2017-01-20 12:04:56 +02:00
ced2c
b365d7e60c raop: Fix #37: OOB access in rtsp_auth_cb
Allocation for Apple-Challenge key is now defined to 16 bytes
(instead of 16 bits)

This patch fixes Issue #37
https://github.com/hfujita/pulseaudio-raop2/issues/37
2017-01-19 03:10:19 +02:00
ced2c
6aaf2b0a1f raop: Fix #36: invalid access to freed object
The RTSP client is not waiting anymore a new header after the
previous one (which can never occurs if RAOP is disconnected)
but after sending a command.

This patch fixes Issue #36.
https://github.com/hfujita/pulseaudio-raop2/issues/36
2017-01-19 03:10:19 +02:00