Commit graph

8601 commits

Author SHA1 Message Date
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
Hajime Fujita
ab7b7ee249 raop: Fix memory leaks
This patch fixes several memory leaks, and thereby fixes Issue #35.
(https://github.com/hfujita/pulseaudio-raop2/issues/35)
2017-01-19 03:10:19 +02:00
Hajime Fujita
d7721032ea raop: Discard data upon getting EAGAIN on a socket
This patch discards audio data when a socket returns EAGAIN.
This was made based on a suggestion by karlstav
(https://github.com/karlstav), and is supposed to solve Issue #32.
(https://github.com/hfujita/pulseaudio-raop2/issues/32)
2017-01-19 03:10:19 +02:00
Hajime Fujita
3e26f2d15e raop: Disable is_recording flag when tearing down the connection
This patch is based on a similar idea as the previous one -- disabling
the flag right after the session is getting closed, rather than waiting
for a response from the server.
2017-01-19 03:10:19 +02:00
Hajime Fujita
f3aa588a61 raop: Stop recording when RTSP FLUSH is issued
This patch fixes the issue #31.
https://github.com/hfujita/pulseaudio-raop2/issues/31

This patch sets c->is_recording = false when the RTSP FLUSH command
is issued. This avoids a race between the server response and
the record activation in some cases.
2017-01-19 03:10:19 +02:00
Martin Blanchard
cd09b88691 raop: Add back initial volume RTSP SET_PARAMETER request on connect
Regression introduced in commit 8c6407f:
raop: Merge TCP and UDP code paths + refactoring

Anyway, we need to determine if initial volume has to be setup before
sending RECORD or after:

- Setting it up *before* shouldn't be a problem: sink.c waits for
CONNECT state, set the volume and client.c triggers RECORD only once
he's got the SET_PARAMETER reply from server.

- Setting it up *after* seems to be more difficult if we try not to
send any audio before receiving the SET_PARAMETER reply form server. A
solution may be to send SET_PARAMETER just after the RECORD server
response is received and hope that it get processed by server during the
2sec latency/buffering time...

Attached patch implement that last solution. Works for me, but I cannot
guaranty it will with your hardware...
2017-01-19 03:10:19 +02:00
Hajime Fujita
b81ceb6707 raop: Silently drop out-of-history retransmission request 2017-01-19 03:10:19 +02:00
Martin Blanchard
516906aef9 raop: Correctly wrap RTP packet sequence number 2017-01-19 03:10:19 +02:00
Hajime Fujita
3de65e61e4 raop: Add IPv6 support 2017-01-19 03:10:19 +02:00
Hajime Fujita
3e53f47c8d raop: Add address to RAOP device description
Some time one device announces multiple addresses (e.g. IPv4 one
and IPv6 one). Or some user may own multiple RAOP devices with
the same model name.
This patch adds device port to device description so that users
can distinguish appropriate RAOP sink by its address.
2017-01-19 03:10:19 +02:00
Stephen Paul Weber
751d88717e raop: Do not flush when RTSP object is not ready
This patch fixes a crash issue reported at
https://github.com/hfujita/pulseaudio-raop2/issues/9
2017-01-19 03:10:19 +02:00
Colin Leroy
f4bd06bfa5 raop: Fix packet retransmission
Fix UDP header decoding (sequence number and number of packets);
Fix missing pa_memblock_release() causing assertions after retransmission.
2017-01-19 03:10:19 +02:00
Colin Leroy
4d16369707 raop: fix typos 2017-01-19 03:10:19 +02:00
Colin Leroy
b95aebdb2d raop: fix sequence number overflow
Wrap sequence number when we reach uint16_t's max 0xFFFF.
2017-01-19 03:10:19 +02:00
Colin Leroy
81fa11e3a9 raop: Fix sink getting destroyed after one use
It is expected to get disconnected after switching back to a
different sink.
2017-01-19 03:10:19 +02:00
Martin Blanchard
1c56b86926 raop: Remove unimplemented code (PCM and AAC) 2017-01-19 03:10:19 +02:00
Martin Blanchard
750a677b43 raop: Rework packet's store memory management
This patch switch the packet-buffer to use core memory pool instead of
manually allocating the room required for storing TCP/UDP packets. Packets
are now stored using pa_memchunk instead of internal struct. Quite a few
malloc saved compare to previous design.
2017-01-19 03:10:19 +02:00