platform/upstream/pulseaudio.git
7 years agoraop: Error out on parsing server port component
Peter Meerwald-Stadler [Wed, 8 Mar 2017 14:57:22 +0000 (15:57 +0100)]
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>
7 years agoraop: Log if pa_atoi() fails, latency is not used anyway
Peter Meerwald-Stadler [Tue, 7 Mar 2017 14:44:06 +0000 (15:44 +0100)]
raop: Log if pa_atoi() fails, latency is not used anyway

Coverity ID: #1398152

Signed-off-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
7 years agoraop: Fix potential NULL dereference
Peter Meerwald-Stadler [Tue, 7 Mar 2017 14:16:54 +0000 (15:16 +0100)]
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>
7 years agoraop: Fix potential dereference after NULL check
Peter Meerwald-Stadler [Tue, 7 Mar 2017 13:43:48 +0000 (14:43 +0100)]
raop: Fix potential dereference after NULL check

Coverity ID: #1398157

Signed-off-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
7 years agocombine-sink: Use PA_MAX instead of ternary operator for clarity
Arun Raghavan [Thu, 9 Mar 2017 04:33:06 +0000 (10:03 +0530)]
combine-sink: Use PA_MAX instead of ternary operator for clarity

7 years agoraop: Fix check for invalid file descriptor
Peter Meerwald-Stadler [Tue, 7 Mar 2017 13:29:12 +0000 (14:29 +0100)]
raop: Fix check for invalid file descriptor

file descriptor 0 is valid

Signed-off-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
7 years agocore-util: Fix description of pa_split()
Peter Meerwald-Stadler [Tue, 7 Mar 2017 13:53:13 +0000 (14:53 +0100)]
core-util: Fix description of pa_split()

Signed-off-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
7 years agobuild: Use #ifdef to check for #defines
Peter Meerwald-Stadler [Tue, 7 Mar 2017 15:29:30 +0000 (16:29 +0100)]
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>
7 years agowaveout: add argument deprecation error
Moritz Bruder [Wed, 1 Mar 2017 18:29:53 +0000 (19:29 +0100)]
waveout: add argument deprecation error

7 years agowaveout: fix wrong input device
Moritz Bruder [Wed, 1 Mar 2017 18:29:52 +0000 (19:29 +0100)]
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.

7 years agobackend-native: add support for the HSP Headset role
Wim Taymans [Tue, 7 Mar 2017 12:44:54 +0000 (13:44 +0100)]
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.

7 years agoiochannel: don't use variable length array in union
Tanu Kaskinen [Sat, 4 Feb 2017 12:19:01 +0000 (14:19 +0200)]
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
7 years agoraop: Fix potential NULL dereference
Peter Meerwald-Stadler [Wed, 1 Mar 2017 19:37:06 +0000 (20:37 +0100)]
raop: Fix potential NULL dereference

'realm' is mandatory

Signed-off-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
7 years agoraop: Fix potential resource leaks
Peter Meerwald-Stadler [Tue, 28 Feb 2017 07:01:20 +0000 (08:01 +0100)]
raop: Fix potential resource leaks

Coverity ID: #1410204, #1410203, #1410202, #1410201, #1410200, #1410199

Signed-off-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
7 years agoraop: Silence unchecked return value warnings
Peter Meerwald-Stadler [Mon, 27 Feb 2017 22:43:49 +0000 (23:43 +0100)]
raop: Silence unchecked return value warnings

Signed-off-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
7 years agoraop: Fix indentation
Peter Meerwald-Stadler [Mon, 27 Feb 2017 22:39:38 +0000 (23:39 +0100)]
raop: Fix indentation

Signed-off-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
7 years agoraop: Fix potential memory leak
Peter Meerwald-Stadler [Mon, 27 Feb 2017 22:23:04 +0000 (23:23 +0100)]
raop: Fix potential memory leak

Coverity ID: #1410204

Signed-off-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
7 years agoraop: Fix resource leaks
Peter Meerwald-Stadler [Wed, 22 Feb 2017 14:21:00 +0000 (15:21 +0100)]
raop: Fix resource leaks

Coverity ID: #1398158, #1398159

Signed-off-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
7 years agoraop: Fix memleak
Peter Meerwald-Stadler [Wed, 22 Feb 2017 14:09:02 +0000 (15:09 +0100)]
raop: Fix memleak

use local scope for trs variable simplifying cleanup
Coverity ID: #1398160

Signed-off-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
7 years agoraop: Fail after search for port number
Peter Meerwald-Stadler [Tue, 7 Mar 2017 07:22:25 +0000 (08:22 +0100)]
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>
7 years agoraop: Fix loop searching for port number
Peter Meerwald-Stadler [Wed, 22 Feb 2017 14:02:43 +0000 (15:02 +0100)]
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>
7 years agoraop: Fix double free
Peter Meerwald-Stadler [Wed, 22 Feb 2017 13:49:48 +0000 (14:49 +0100)]
raop: Fix double free

make nick variable local, fix double free
Coverity CID: #1398162

Signed-off-by: Peter Meerwald-Stadler <pmeerw@pmeerw.net>
7 years agobuild: Add Coverity scan model
Peter Meerwald-Stadler [Mon, 6 Mar 2017 07:15:29 +0000 (08:15 +0100)]
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>
7 years agoloopback: fix up the previous commit
Georg Chini [Mon, 27 Feb 2017 12:54:50 +0000 (13:54 +0100)]
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.

7 years agoloopback: Initialize latency at startup and during source/sink changes
Georg Chini [Sun, 19 Feb 2017 16:15:10 +0000 (17:15 +0100)]
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.

7 years agocoreaudio-device: fix improper memory handling leading to crashes.
Mihai Moldovan [Sat, 25 Feb 2017 09:38:24 +0000 (10:38 +0100)]
coreaudio-device: fix improper memory handling leading to crashes.

Make sure that we NULL pointers after freeing them. Otherwise bad things
happen.

7 years agobuild-sys: FlatCarbon is dead. Good riddance.
Mihai Moldovan [Sat, 25 Feb 2017 09:35:06 +0000 (10:35 +0100)]
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.

7 years agoloopback: correct comments about the thread calling a function
Georg Chini [Sun, 19 Feb 2017 16:15:09 +0000 (17:15 +0100)]
loopback: correct comments about the thread calling a function

The comments were wrong and confusing.

7 years agoloopback: Rename sink_input_buffer to loopback_memblockq_length
Georg Chini [Mon, 13 Feb 2017 12:01:58 +0000 (13:01 +0100)]
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.

7 years agobluez5-device: Use correct constants for fixed latency in PA_{SINK, SOURCE}_MESSAGE_G...
Georg Chini [Wed, 15 Feb 2017 10:32:26 +0000 (11:32 +0100)]
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.

7 years agobluetooth: Make use of getsockopt() to determine MTU configurable
Georg Chini [Sat, 4 Feb 2017 19:32:15 +0000 (20:32 +0100)]
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.

7 years agoalsa-util: don't crash on devices with more than 32 channels
Tanu Kaskinen [Sat, 28 Jan 2017 16:08:24 +0000 (18:08 +0200)]
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>
7 years agosink, source: Make rate selection more explicit
Arun Raghavan [Mon, 30 Jan 2017 08:37:37 +0000 (14:07 +0530)]
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.

7 years agosink, source: Add a mode to avoid resampling if possible
Arun Raghavan [Sat, 28 Jan 2017 07:49:08 +0000 (13:19 +0530)]
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.

7 years agothread-test: fix deadlock
Tanu Kaskinen [Mon, 23 Jan 2017 08:38:59 +0000 (10:38 +0200)]
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

7 years agobuild-sys: Enable clang-based builds on Travis
Arun Raghavan [Tue, 24 Jan 2017 11:47:59 +0000 (17:17 +0530)]
build-sys: Enable clang-based builds on Travis

7 years agosuspend-on-idle: resume on unload
Wim Taymans [Wed, 11 Jan 2017 11:50:13 +0000 (12:50 +0100)]
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.

7 years agoraop: Fix #37: OOB access in rtsp_auth_cb
ced2c [Sun, 6 Nov 2016 18:54:27 +0000 (12:54 -0600)]
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

7 years agoraop: Fix #36: invalid access to freed object
ced2c [Sun, 6 Nov 2016 18:54:26 +0000 (12:54 -0600)]
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

7 years agoraop: Fix memory leaks
Hajime Fujita [Sun, 6 Nov 2016 18:54:25 +0000 (12:54 -0600)]
raop: Fix memory leaks

This patch fixes several memory leaks, and thereby fixes Issue #35.
(https://github.com/hfujita/pulseaudio-raop2/issues/35)

7 years agoraop: Discard data upon getting EAGAIN on a socket
Hajime Fujita [Sun, 6 Nov 2016 18:54:24 +0000 (12:54 -0600)]
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)

7 years agoraop: Disable is_recording flag when tearing down the connection
Hajime Fujita [Sun, 6 Nov 2016 18:54:23 +0000 (12:54 -0600)]
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.

7 years agoraop: Stop recording when RTSP FLUSH is issued
Hajime Fujita [Sun, 6 Nov 2016 18:54:22 +0000 (12:54 -0600)]
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.

7 years agoraop: Add back initial volume RTSP SET_PARAMETER request on connect
Martin Blanchard [Sun, 6 Nov 2016 18:54:21 +0000 (12:54 -0600)]
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...

7 years agoraop: Silently drop out-of-history retransmission request
Hajime Fujita [Sun, 6 Nov 2016 18:54:20 +0000 (12:54 -0600)]
raop: Silently drop out-of-history retransmission request

7 years agoraop: Correctly wrap RTP packet sequence number
Martin Blanchard [Sun, 6 Nov 2016 18:54:19 +0000 (12:54 -0600)]
raop: Correctly wrap RTP packet sequence number

7 years agoraop: Add IPv6 support
Hajime Fujita [Sun, 6 Nov 2016 18:54:18 +0000 (12:54 -0600)]
raop: Add IPv6 support

7 years agoraop: Add address to RAOP device description
Hajime Fujita [Sun, 6 Nov 2016 18:54:17 +0000 (12:54 -0600)]
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.

7 years agoraop: Do not flush when RTSP object is not ready
Stephen Paul Weber [Sun, 6 Nov 2016 18:54:16 +0000 (12:54 -0600)]
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

7 years agoraop: Fix packet retransmission
Colin Leroy [Sun, 6 Nov 2016 18:54:15 +0000 (12:54 -0600)]
raop: Fix packet retransmission

Fix UDP header decoding (sequence number and number of packets);
Fix missing pa_memblock_release() causing assertions after retransmission.

7 years agoraop: fix typos
Colin Leroy [Sun, 6 Nov 2016 18:54:14 +0000 (12:54 -0600)]
raop: fix typos

7 years agoraop: fix sequence number overflow
Colin Leroy [Sun, 6 Nov 2016 18:54:13 +0000 (12:54 -0600)]
raop: fix sequence number overflow

Wrap sequence number when we reach uint16_t's max 0xFFFF.

7 years agoraop: Fix sink getting destroyed after one use
Colin Leroy [Sun, 6 Nov 2016 18:54:12 +0000 (12:54 -0600)]
raop: Fix sink getting destroyed after one use

It is expected to get disconnected after switching back to a
different sink.

7 years agoraop: Remove unimplemented code (PCM and AAC)
Martin Blanchard [Sun, 6 Nov 2016 18:54:11 +0000 (12:54 -0600)]
raop: Remove unimplemented code (PCM and AAC)

7 years agoraop: Rework packet's store memory management
Martin Blanchard [Sun, 6 Nov 2016 18:54:10 +0000 (12:54 -0600)]
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.

7 years agoraop: Update and standardise source file headers
Martin Blanchard [Sun, 6 Nov 2016 18:54:09 +0000 (12:54 -0600)]
raop: Update and standardise source file headers

7 years agoraop: Prefer ALAC encoding to raw PCM if supported by server
Martin Blanchard [Sun, 6 Nov 2016 18:54:08 +0000 (12:54 -0600)]
raop: Prefer ALAC encoding to raw PCM if supported by server

ALAC encoding is to be prefered simply because ALAC audio packet reverse-
engineering and implementation is in better shape than raw PCM. Sending ALAC
audio does not mean compressing audio and thus linking an external library to
do so. ALAC packets has the ability to carry uncompressed PCM frames, and
that's what is implemented at the time.

7 years agoraop: Merge TCP and UDP code paths + refactoring
Martin Blanchard [Sun, 6 Nov 2016 18:54:07 +0000 (12:54 -0600)]
raop: Merge TCP and UDP code paths + refactoring

TCP and UDP implementation are following two diffrent code path while code
logic is quite the same. This patch merges both code path into a unique one
and, thus, leads to a big refactoring. Major changes include:
  - moving sink implementation to a separate file (raop-sink.c)
  - move raop-sink.c protocol specific code to raop-client.c
  - modernise RTSP session handling in TCP mode
  - reduce code duplications between TCP and UDP modes
  - introduce authentication support
  - TCP mode does not constantly send silent audio anymore

About authentication: OPTIONS is now issued when the sink is preliminary
loaded. Client authentication appends at that time and credential is kept
for the whole sink lifetime. Later RTSP connection will thus look like this:
ANNOUNCE > 200 OK > SETUP > 200 OK > RECORD > 200 OK (no more OPTIONS). This
behaviour is similar to iTunes one.

Also this patch includes file name changes to match Pulseaudio naming
rules, as most of pulseaudio source code files seem to be using '-'
instead of '_' as a word separator.

7 years agoraop: Add BA (Basic) and DA (Digest) HTTP authentication helpers
Martin Blanchard [Sun, 6 Nov 2016 18:54:06 +0000 (12:54 -0600)]
raop: Add BA (Basic) and DA (Digest) HTTP authentication helpers

RAOP authentication is using standard HTTP challenge-response authentication
scheme. This patch adds two helper functions that generate the proper hash
(for both techniques) given a username, a password and session related tokens.

7 years agoraop: Add a MD5 hashing fuction
Martin Blanchard [Sun, 6 Nov 2016 18:54:05 +0000 (12:54 -0600)]
raop: Add a MD5 hashing fuction

MD5 hashing will be needed during the authentication process.

Original patch by Martin Blanchard. Patch splitted by
Hajime Fujita <crisp.fujita@nifty.com>.

7 years agoraop: Move base64 implementation to a util file
Martin Blanchard [Sun, 6 Nov 2016 18:54:04 +0000 (12:54 -0600)]
raop: Move base64 implementation to a util file

Base64 implementation is now in a common file called raop_util.c.
Old Base64 files are removed but copyright is preserved.

Original patch by Martin Blanchard, patch splitted by
Hajime Fujita <crisp.fujita@nifty.com>.

7 years agoraop: Extract encryption related code into a separate file
Martin Blanchard [Sun, 6 Nov 2016 18:54:03 +0000 (12:54 -0600)]
raop: Extract encryption related code into a separate file

That makes the raop_client.c code smaller/cleaner and will simplify
addition of more crypto related stuffs like authentication.

7 years agoraop: Better playback resume handling
Martin Blanchard [Sun, 6 Nov 2016 18:54:02 +0000 (12:54 -0600)]
raop: Better playback resume handling

When playback stops, a FLUSH command is send to the server and the sink
goes to IDLE. If playback resumes quickly, sink goes back to RUNNING
(without being SUSPENDED) and the sink should just start streaming again.
This patch implements this behaviour.

7 years agoraop: Do not send audio before RECORD response
Martin Blanchard [Sun, 6 Nov 2016 18:54:01 +0000 (12:54 -0600)]
raop: Do not send audio before RECORD response

This patch prevents audio packets to be sent before the server
respond to the RECORD command.

7 years agoraop: Packet retransmission support for UDP
Matthias Wabersich [Sun, 6 Nov 2016 18:54:00 +0000 (12:54 -0600)]
raop: Packet retransmission support for UDP

This patch adds an RTP audio packet retransmission support and a
circular buffer implementation for it.

This patch was originally written by Matthias Wabersich [1] and
later debugged and integrated into the latest tree by Hajime Fujita

[1]: https://bugs.freedesktop.org/show_bug.cgi?id=42804#c44

7 years agoraop: Parse server capabilities on discovery
Martin Blanchard [Sun, 6 Nov 2016 18:53:59 +0000 (12:53 -0600)]
raop: Parse server capabilities on discovery

During the discovery phase, raop servers send their capabilities
(supported encryption, audio codec...). These should be passed to the
raop sink via module's arguments.

Original patch written by Martin Blanchard, then modified by Hajime
Fujita <crisp.fujita@nifty.com> based on review comments by
Anton Lundin <glance@acc.umu.se>.
Now resolver_cb always dtrdup()s string blocks given by Avahi,
to make the code easier to maintain.

7 years agoraop: Add UDP protocol handling
Hajime Fujita [Sun, 6 Nov 2016 18:53:58 +0000 (12:53 -0600)]
raop: Add UDP protocol handling

There are two versions in the RAOP protocol; one uses TCP and the
other uses UDP. Current raop implementation only supports TCP
version.

This patch adds an initial UDP protocol support for RAOP.
It is based on Martin Blanchard's work
(http://repo.or.cz/w/pulseaudio-raopUDP.git/shortlog/refs/heads/raop)
which is inspired by Christophe Fergeau's work
(https://github.com/zx2c4/pulseaudio-raop2).

Matrin's modifications were edited by Hajime Fujita, so that it
would support both TCP and UDP protocol in a single module.

Also this patch includes a fix that was found thanks to Matthias,
who reported that his ALAC
codec support fixed the issue.
https://bugs.freedesktop.org/show_bug.cgi?id=42804#c30

7 years agocore-util: do in-place search in pa_str_in_list_spaces
Hajime Fujita [Sun, 6 Nov 2016 18:53:57 +0000 (12:53 -0600)]
core-util: do in-place search in pa_str_in_list_spaces

Reviewed-by: Anton Lundin <glance@acc.umu.se>
7 years agocore-util: add pa_split_space_in_place function
Hajime Fujita [Sun, 6 Nov 2016 18:53:56 +0000 (12:53 -0600)]
core-util: add pa_split_space_in_place function

Reviewed-by: Anton Lundin <glance@acc.umu.se>
7 years agocore-util: add pa_strneq macro
Hajime Fujita [Sun, 6 Nov 2016 18:53:55 +0000 (12:53 -0600)]
core-util: add pa_strneq macro

This macro compares if the given two strings, with the maximum length
of n, are equal. Useful for strings that are not NULL-terminated.

Reviewed-by: Anton Lundin <glance@acc.umu.se>
7 years agodaemon-conf: add remixing-use-all-sink-channels option
David Mandelberg [Wed, 4 Jan 2017 16:55:49 +0000 (11:55 -0500)]
daemon-conf: add remixing-use-all-sink-channels option

This option controls the PA_RESAMPLER_NO_FILL_SINK flag added in a
previous commit.

BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=62588
BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=94563
7 years agoremix-test: test the remixer with PA_RESAMPLER_NO_FILL_SINK set
David Mandelberg [Wed, 4 Jan 2017 16:55:48 +0000 (11:55 -0500)]
remix-test: test the remixer with PA_RESAMPLER_NO_FILL_SINK set

7 years agoresampler: Flag for remixing to all sink channels.
David Mandelberg [Wed, 4 Jan 2017 16:55:47 +0000 (11:55 -0500)]
resampler: Flag for remixing to all sink channels.

Add a flag PA_RESAMPLER_NO_FILL_SINK, which controls whether remixing
should attempt to use all sink channels, versus only the ones needed
to reproduce the source audio.

BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=62588
BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=94563
Suggested-by: Alexander E. Patrakov <patrakov@gmail.com>
7 years agoremix-test: test the remixer using different flags
David Mandelberg [Wed, 4 Jan 2017 16:55:46 +0000 (11:55 -0500)]
remix-test: test the remixer using different flags

This will make it easier to see how the following commit affects the
remixer.

7 years agovala: use the correct syntax
Corentin Noël [Mon, 26 Dec 2016 10:52:06 +0000 (11:52 +0100)]
vala: use the correct syntax

Constants should be declared simply with "const". With struct members,
"static" means that all struct instances share the same variable, i.e.
all instances always see the same value. That's of course already
implied in the concept of "constant". Newer Vala versions don't allow
mixing "const" and "static".

7 years agoalsa: remove double calls of snd_pcm_prepare()
Takashi Sakamoto [Fri, 30 Dec 2016 03:05:20 +0000 (12:05 +0900)]
alsa: remove double calls of snd_pcm_prepare()

In alsa-lib, snd_pcm_hw_params() internally calls snd_pcm_prepare(), thus
user space applications have no need to call snd_pcm_prepare() after calls
of snd_pcm_hw_params(). An explicit calls of snd_pcm_prepare() is expected
in a case to recover PCM substreams.

Current implementation of PulseAudio modules for ALSA playbacking/capturing
results in double calls of snd_pcm_prepare(). The second call for hw plugin
of alsa-lib executes ioctl(2) with SNDRV_PCM_IOCTL_PREPARE command in state
of SNDRV_PCM_STATE_PREPARED for the PCM substream. This has no effects to
the PCM substream as long as corresponding drivers are implemented
correctly.

This commit removes the second call for the reason.

Signed-off-by: Takashi Sakamoto <o-takashi@sakamocchi.jp>
7 years agobluetooth: fix distorted audio during Bluetooth SCO HFP/HSP playback
Renjith Thomas [Thu, 15 Dec 2016 07:04:14 +0000 (12:34 +0530)]
bluetooth: fix distorted audio during Bluetooth SCO HFP/HSP playback

Issue: When HFP/HSP profile is used with certain BT chipsets, the
audio sounds heavily distorted, with very slow playback full of noise.
During recording, the samples are dropped and it distorts the recorded
audio samples.

The root cause of both the issues are related to the fixed MTU sizes
in the PA stack, which is 48 bytes. Here, the BT chipset CC256x had
180 bytes MTU and it was being under-utilized and the rate at which
the samples were being accepted where not matching the expected rate,
and hence the distortion.

Solution: The appropriate solution to this problem is by reading the
MTU size of the SCO socket using getsockopts dynamically.

BugLink: http://bit.ly/2gDpGPv
BugLink: http://bit.ly/2hQsARK
7 years agopadsp: allow overriding library install location
Felipe Sateler [Mon, 28 Nov 2016 17:49:06 +0000 (14:49 -0300)]
padsp: allow overriding library install location

The current build script hardcodes the $pkglibdir in the padsp command.
This works and is a reasonable default. However, distributions that
know where they install, can override this path and thus make padsp
work for any architecture that has the library installed by using the
following configure argument:

   --with-pulsedsp-location='/usr/\\$$LIB/pulseaudio'

This works because ld.so considers $LIB a variable that will expand to
several location paths, depending on the architecture of the binary
being executed.

In debian, for example, this would work for libpulsedsp.so installed in
/usr/lib/x86_64-linux-gnu/ for amd64 and /usr/lib/i386-linux-gnu/ for
i386, with a single padsp command.

7 years agobuild-sys: Don't override libtoolize
Philip Chimento [Sat, 12 Nov 2016 20:48:44 +0000 (12:48 -0800)]
build-sys: Don't override libtoolize

The autoreconf invocation below will already pick up any overrides the
user might have made to their LIBTOOLIZE variable. Overriding it here
will break on Darwin systems where libtoolize is not called glibtoolize,
and is not necessary, so just remove it.

7 years agox11-bell: ignore volume from X11
Tanu Kaskinen [Thu, 10 Nov 2016 11:22:04 +0000 (13:22 +0200)]
x11-bell: ignore volume from X11

X11 has its own bell volume setting, controlled with the "xset b"
command. If we use that volume, then the "System Sounds" slider in
pavucontrol doesn't affect the x11-bell sample volume, which in my
opinion is a bad thing. Ignoring the volume suggestion from X11 allows
module-stream-restore to apply the "event" role volume.

7 years agobuild-sys: Move TLS check after flags additions
Philip Chimento [Thu, 10 Nov 2016 05:22:53 +0000 (21:22 -0800)]
build-sys: Move TLS check after flags additions

Any compiler flags should be set before asking the compiler to check for
thread-local storage with AX_TLS, since compiler flags (in this case
-mmacosx-version-min=10.5) can influence the outcome of that check.

7 years agoshell-completion: update zsh completion for pasuspender
Paul Seyfert [Tue, 8 Nov 2016 11:28:55 +0000 (12:28 +0100)]
shell-completion: update zsh completion for pasuspender

 * remove suggestion of '-C' due to incorrect ordering of options for
   _arguments
 * avoid suggesting multiple options
 * add suggestion of "--", followed by executable programs
 * after "--server=<hostname>" or "-s <hostname>" suggest "--"
 * after "-- <program>" continue standard tab completion

BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=98639
7 years agobluetooth: Add optional heuristic for switching between hsp and a2dp profiles
Pali Rohár [Sun, 11 Sep 2016 14:41:02 +0000 (16:41 +0200)]
bluetooth: Add optional heuristic for switching between hsp and a2dp profiles

Not all VOIP applications (specially those which use alsa) set media.role to
phone. This means we need some heuristic to determinate if we want to switch
from a2dp to hsp profile based on number and types of source output (recording)
streams.

And also some people want to use their bluetooth headset (with microphone) as
their default recording device but some do not want to because of low quality.

This patch implements optional heuristic which is disabled by default. It is
disabled by default to not break experience of current pulseaudio users because
heuristic cannot be optimal. Heuristic is implemented in module-bluetooth-policy
module and decide if pulseaudio should switch to a hsp profile or not. It checks
if there is some source output with pass all these conditions:

* does not have set media.role
* does not use peak resample method (which is used by desktop volume programs)
* has assigned client/application (non virtual stream)
* does not record from monitor of sink

And if yes it switch to hsp profile.

By default this heuristic is disabled and can be enabled when loading module
module-bluetooth-policy with specifying parameter auto_switch=2

Because it is disabled by default nobody will be affected by this change unless
manually change auto_switch parameter.

Signed-off-by: Pali Rohár <pali.rohar@gmail.com>
7 years agortp: Introduce pa_rtsp_exec_ready()
Hajime Fujita [Mon, 1 Feb 2016 04:16:05 +0000 (22:16 -0600)]
rtp: Introduce pa_rtsp_exec_ready()

In the current RTSP implementation, there is a vulnerable window
between the RTSP object creation and the URL initialization.
If any RTSP command is issued during this period, it will lead to
crash by assertion violation.

This patch introduces pa_rtsp_exec_ready(), which returns if it is
safe to issue RTSP commands.

Reviewed-by: Anton Lundin <glance@acc.umu.se>
7 years agortp: Random seq number at the beginning of the session
Martin Blanchard [Mon, 1 Feb 2016 04:16:04 +0000 (22:16 -0600)]
rtp: Random seq number at the beginning of the session

Reviewed-by: Anton Lundin <glance@acc.umu.se>
7 years agortp: New pa_rtsp_options function
Colin Leroy [Mon, 1 Feb 2016 04:16:03 +0000 (22:16 -0600)]
rtp: New pa_rtsp_options function

Add a function performing a call to the OPTIONS request; also,
in some special cases, tuning transport parameters is required (default:
"RTP/AVP/TCP;unicast;interleaved=0-1;mode=record") ! The RAOP client for
example needs to overwrite them.

Reviewed-by: Anton Lundin <glance@acc.umu.se>
7 years agoraop: Add pulsecore/core-utils a pa_str_in_list function
Martin Blanchard [Mon, 1 Feb 2016 04:16:01 +0000 (22:16 -0600)]
raop: Add pulsecore/core-utils a pa_str_in_list function

Reviewed-by: Anton Lundin <glance@acc.umu.se>
7 years agoraop: Cosmetic fixes / Match coding style
Martin Blanchard [Mon, 1 Feb 2016 04:16:00 +0000 (22:16 -0600)]
raop: Cosmetic fixes / Match coding style

Reviewed-by: Anton Lundin <glance@acc.umu.se>
7 years agortp: Freeing ioline when disconnecting
Hajime Fujita [Mon, 1 Feb 2016 04:15:59 +0000 (22:15 -0600)]
rtp: Freeing ioline when disconnecting

pa_ioline_close does not free the ioline structure itself, so we
have to unref the structure if we want to free it.

Reviewed-by: Anton Lundin <glance@acc.umu.se>
7 years agoSupport IPv6 address in pa_socket_client_new_string()
Hajime Fujita [Mon, 1 Feb 2016 04:15:58 +0000 (22:15 -0600)]
Support IPv6 address in pa_socket_client_new_string()

pa_socket_client_new_string() did not work as expected when an IPv6
address string like "2001:db8::1" is passed as the "name" parameter.
This is because the name parameter is then passed to pa_parse_address(),
which thinks the last colon as a separator between hostname (or address)
and a port number. To prevent pa_parse_address() from doing this, an IPv6
address must be bracketed with "[]" (e.g. "[2001:db8::1]"). [1]

This patch fixes pa_socket_client_new_string() so that it internally
adds brackets to an IPv6 address. This decision is based on a
discussion at [2].

[1]: http://lists.freedesktop.org/archives/pulseaudio-discuss/2014-October/022010.html
[2]: http://lists.freedesktop.org/archives/pulseaudio-discuss/2014-November/022401.html

Reviewed-by: Anton Lundin <glance@acc.umu.se>
7 years agobuild-sys: add the AGPL license file to tarballs v10.0
Tanu Kaskinen [Thu, 12 Jan 2017 04:31:03 +0000 (06:31 +0200)]
build-sys: add the AGPL license file to tarballs

7 years agoupdate NEWS
Tanu Kaskinen [Wed, 18 Jan 2017 03:43:37 +0000 (05:43 +0200)]
update NEWS

7 years agodaemon-conf: changed 'not' to 'note'
Rikard Söderström [Thu, 12 Jan 2017 21:41:52 +0000 (22:41 +0100)]
daemon-conf: changed 'not' to 'note'

7 years agozeroconf-publish: fix unitialized DBusError
Tanu Kaskinen [Thu, 12 Jan 2017 04:45:20 +0000 (06:45 +0200)]
zeroconf-publish: fix unitialized DBusError

BugLink: https://bugs.archlinux.org/task/52484
7 years agoi18n: add Lithuanian translation
Moo [Fri, 6 Jan 2017 19:01:25 +0000 (21:01 +0200)]
i18n: add Lithuanian translation

7 years agobuild-sys: bump sonames v9.99.1
Tanu Kaskinen [Thu, 29 Dec 2016 13:46:53 +0000 (15:46 +0200)]
build-sys: bump sonames

There are no changes in the ABI. libpulse has received bug fixes,
libpulse-simple and libpulse-mainloop-glib have no changes at all.

7 years agomemblockq-test: fix incorrect assumption of pa_memblockq_pop_missing() behaviour
Tanu Kaskinen [Fri, 30 Dec 2016 15:52:36 +0000 (17:52 +0200)]
memblockq-test: fix incorrect assumption of pa_memblockq_pop_missing() behaviour

The intuitive meaning of "missing" would be the difference between
tlength and the current queue length, and that's how memblockq-test
assumed pa_memblockq_pop_missing() to define the term "missing", but
that was an incorrect assumption, causing the last
pa_memblockq_pop_missing() return value assertion to fail.

This patch fixes the failing assertion and adds some comments about how
the "missing" and "requested" variables in memblockq work.

7 years agomemblockq: remove pa_memblockq_missing()
Tanu Kaskinen [Fri, 30 Dec 2016 15:52:35 +0000 (17:52 +0200)]
memblockq: remove pa_memblockq_missing()

The function isn't used anywhere else than memblockq-test. Also, the
function is confusing, because it defines "missing" differently than
pa_memblockq_pop_missing(). pa_memblockq_missing() calculated the
missing amount like this:

    missing = tlength - length,

where "length" is the current queue length. pa_memblockq_pop_missing(),
on the other hand, calculates the missing amount like this:

    missing = tlength - length - requested,

where "requested" is an internal variable that keeps track of how much
the server has requested data from the client and how much of the
requests are yet to be fulfilled by the client.

memblockq-test is broken at the moment, because it assumes that
pa_memblockq_pop_missing() calculates "missing" the same way that
pa_memblockq_missing() used to calculate it. A patch for fixing that
will follow.

7 years agoLICENSE: add a note about qpaeq being licensed under AGPL
Tanu Kaskinen [Wed, 28 Dec 2016 21:35:15 +0000 (23:35 +0200)]
LICENSE: add a note about qpaeq being licensed under AGPL

7 years agoLICENSE: add a clarification
Tanu Kaskinen [Wed, 28 Dec 2016 21:35:14 +0000 (23:35 +0200)]
LICENSE: add a clarification