Commit graph

8484 commits

Author SHA1 Message Date
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
Martin Blanchard
32a5b3047b raop: Update and standardise source file headers 2017-01-19 03:10:19 +02:00
Martin Blanchard
094906b3f9 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.
2017-01-19 03:10:19 +02:00
Martin Blanchard
8022e56581 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.
2017-01-19 03:10:19 +02:00
Martin Blanchard
5ff21c3bdd 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.
2017-01-19 03:00:45 +02:00
Martin Blanchard
a33c04c0cc 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>.
2017-01-19 03:00:45 +02:00
Martin Blanchard
bac8a2ba66 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>.
2017-01-19 03:00:45 +02:00
Martin Blanchard
31ded701b1 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.
2017-01-19 03:00:45 +02:00
Martin Blanchard
31e2bc2fcf 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.
2017-01-19 03:00:45 +02:00
Martin Blanchard
604bf450dc raop: Do not send audio before RECORD response
This patch prevents audio packets to be sent before the server
respond to the RECORD command.
2017-01-19 03:00:45 +02:00
Matthias Wabersich
29385da239 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
2017-01-19 03:00:45 +02:00
Martin Blanchard
402bb7ce48 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.
2017-01-19 03:00:45 +02:00
Hajime Fujita
1e51282621 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
2017-01-19 03:00:45 +02:00
Hajime Fujita
43bf134aa1 core-util: do in-place search in pa_str_in_list_spaces
Reviewed-by: Anton Lundin <glance@acc.umu.se>
2017-01-19 03:00:45 +02:00
Hajime Fujita
04b46803cd core-util: add pa_split_space_in_place function
Reviewed-by: Anton Lundin <glance@acc.umu.se>
2017-01-19 03:00:45 +02:00
Hajime Fujita
e2be9fca9c 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>
2017-01-19 03:00:45 +02:00
David Mandelberg
6e6f497219 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
2017-01-19 03:00:45 +02:00
David Mandelberg
6ec4ca218e remix-test: test the remixer with PA_RESAMPLER_NO_FILL_SINK set 2017-01-19 03:00:45 +02:00