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.
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.
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.
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.
MD5 hashing will be needed during the authentication process.
Original patch by Martin Blanchard. Patch splitted by
Hajime Fujita <crisp.fujita@nifty.com>.
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>.
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.
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
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.
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
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>
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".
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>
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
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.
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.
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.
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.
* 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
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>
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>
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>
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>
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>
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.
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.
This reverts commit 74251f0786.
The reverted commit was not intended to make any behavioral changes, but
it broke at least the case where a client writes more data than the
server has requested.
BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=99211
Current pacat code reads whatever available from STDIN and writes
it directly to the playback stream. A minimal buffer is created
for each read operation; no further reads are then allowed unless
earlier read buffer has been fully consumed by a stream write.
While quite simple, this model breaks upon the new requirements of
writing only frame-aligned data to the stream (commits #1 and #2).
The kernel read syscall can return a length much smaller than the
frame-aligned size requested, leading to invalid unaligned writes.
This can easily be reproduced by choosing a starved STDIN backend:
pacat /dev/random pa_stream_write() failed: EINVAL
echo 1234 | pacat pa_stream_write() failed: EINVAL
or by playing an incomplete WAV file in raw, non-paplay, mode.
So guard against such incomplete kernel reads by writing only in
frame-aligned sizes, while caching any trailing partial frame for
subsequent writes.
Other operation modes are not affected. Non-raw paplay playback is
handled by libsndfile, ensuring complete reads, and recording mode
just writes to the STDOUT fd without any special needs.
CommitReference #1: 22827a5e1e
CommitReference #2: 150ace90f3
BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=98475
BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=77595
Suggested-by: David Henningsson <diwic@ubuntu.com>
Signed-off-by: Ahmed S. Darwish <darwish.07@gmail.com>