Commit graph

10443 commits

Author SHA1 Message Date
Barnabás Pőcze
39ce32985b spa: support single argument static assertions in older standards
Single argument static_assert() is only available since
C++17 and C23. Some compilers accept it even in earlier language
versions, but some do not.

Single argument static assertions can be supported by using
a GCC extensions, namely that `, ## __VA_ARGS__` removes the
comma if the variadic argument list is empty. This enables a
construction which passes a pre-determined string as the second
argument of the underlying static_assert() when only a single
argument is used in the `SPA_STATIC_ASSERT()` macro.

Fixes #3050
2023-03-04 11:57:51 +00:00
Robert Rosengren
57a89e5723 module-rtp: Add configurable DSCP support
Add configurable DSCP support with the net.dscp option. Applying only on
RTP, not on SAP discovery.
2023-03-03 15:13:37 +00:00
Wim Taymans
a7322d5043 alsa: improve target delay in ALSA
Don't just limit the max delay of samples we keep in the ALSA ringbuffer
to the buffer_size but to half of it. Make this into a max_delay
variable.

If we have a buffer size of 8192 samples and a headroom of 8192 samples,
when capturing, we would wait for the ringbuffer to contain at least
8192 samples, which would always xrun. When we limit the size to
half, we can still read the data without xruns.

Fixes #2972
2023-03-03 14:59:38 +01:00
Anders Jonsson
8030a9f360 po: Update Swedish translation 2023-03-03 08:17:09 +00:00
Pauli Virtanen
34d8466c8c bluez5: sources should produce full buffer every cycle
On underflow in sources, pad with explicit silence.  This avoids the
audioadapter from getting off sync from the cycle. That causes problems
as driver when we want to produce a buffer only a the start of the
cycle.

In some cases, it's also possible that the io already has buffer at the
start of the cycle when rate matching as driver. Currently, we don't
produce buffer in this case, but we should.  Fix that by doing things in
the exact same way as ALSA sources do.
2023-03-02 16:18:27 +00:00
Wim Taymans
5ab1d898ca impl-port: improve port properties
Move the port property logic from the adapter to the port itself.

The port was already doing some of the same work as a fallback but can
just as well do everything. This also makes things more unified when
there is no adapter used.
2023-03-02 12:35:11 +01:00
Wim Taymans
5c180a57a5 audioconvert: copy follower port flags
Copy the follower port flags to the adapter ports. This is mostly
interesting to mark the ports of a device as physical and terminal.
2023-03-02 12:35:06 +01:00
Wim Taymans
ab94a71e3c pulse-server: improve channel_map parsing
Add some more common channel name shortcuts supported by pulseaudio.
Make sure we match the full channel-name, not just the prefix.
Generate an invalid channel map when an invalid channel name was
given instead of a partial channel map.
2023-03-01 13:44:24 +01:00
Wim Taymans
8a24f58cd1 pulse-server: improve format parsing
The pulseaudio format should be parsed case insensitive.
Add some more pulseaudio supported formats.
2023-03-01 13:44:24 +01:00
Wim Taymans
03abce72e5 pulse-server: error on invalid format
When an invalid format is given as a module argument, generate an error.
2023-03-01 13:44:24 +01:00
Barnabás Pőcze
7aae9a3e8b pipewire-jack: indent with tabs to avoid clang-tidy warnings 2023-02-25 20:48:45 +01:00
Barnabás Pőcze
0e0a2627aa treewide: print pthread_t as a pointer
On glibc, `pthread_t` is `unsigned long int` while on musl
it has a pointer type. To avoid format string warnings,
cast it to `void *` and use the `%p` format specifier.
2023-02-25 20:45:28 +01:00
Barnabás Pőcze
d776d378cd pipewire: module-protocol-simple: cast argument of accept4()
With glibc omitting the cast does not trigger a warning because
glibc uses GCC's `transparent_union` attribute. musl does not
do that, so to avoid getting warnings there, add the cast.

https://gcc.gnu.org/onlinedocs/gcc/Common-Type-Attributes.html#index-transparent_005funion-type-attribute
2023-02-25 20:21:45 +01:00
Barnabás Pőcze
7b3ef1ac4e spa: alsa: fix spa_log_trace_fp() args
Less arguments were passed than required by the format string.
2023-02-25 20:17:51 +01:00
Pauli Virtanen
99d5436f15 bluez5: media-sink: write packets exactly on time
Delay output by one packet, so that we never need to wait for
node_process to supply more data when a packet is due out, and can write
audio packets at exactly equal intervals (up to timer/io accuracy).

In principle, this should not be necessary. However, enable it for now,
in case this improves the various stutter/etc. bug reports.
2023-02-25 01:10:20 +00:00
Pauli Virtanen
f05e68e4d4 bluez5: media-sink: encode next packet as soon as possible
After flushing a packet, encode the next one immediately if we already
have the data.  This makes the flush timing more accurate (std ~4x
smaller) as we don't need to wait for the encode.
2023-02-25 01:10:20 +00:00
Carlos Rafael Giani
031f992981 alsa-compress-offload-sink: major sink rework
* Add support for running the sink as a driver
* Detect which compressed formats are actually supported
* Correctly open/close/start/stop device according to the node commands
* Shift away from tinycompress and use Compress-Offload ioctls directly
  to be able to access various caps information (including fragment sizes)
  which are unavailable in the tinycompress API
* Implement SPA_PARAM_PropInfo and SPA_PARAM_Props support
2023-02-24 14:15:13 +01:00
Carlos Rafael Giani
f03c606ad9 pw-cat: Keep track of excess playtime when playing encoded audio 2023-02-24 14:15:13 +01:00
Carlos Rafael Giani
dc161fc6af pw-cat: Rework encoded audio support to use libavformat to parse frames 2023-02-24 14:15:13 +01:00
Carlos Rafael Giani
580a3d9872 pw-cat: Enable libavutil logs
This is useful for debugging pw-cat encoded audio playback errors.
2023-02-24 14:15:13 +01:00
Pauli Virtanen
da21cfa93c bluez5: backend-native: implement AT+BCC
Implement HF-initiated connection establishment command AT+BCC
for HFP AG.
2023-02-23 18:42:53 +02:00
Robert Mader
06bad5523d gstpipewiresrc: Set stream error on caps negotiation failure
In order to make `wait_started()` error out accordingly, which otherwise
blocks `change_state()` until the timeout is over.
2023-02-23 11:58:52 +00:00
Wim Taymans
eb797cac48 pulse-server: improve FIX_ flag handling
When a stream uses the FIX_ flags it should negotiate to the format of
the sink or source it connects to. To do this, look up the sink or
source and look at the format, use this as the allowed format for the
stream when the FIX flags are set.

Make it still possible to override with with properties. Use
audio.position to make it possible to set a channelmap override.
2023-02-23 12:53:58 +01:00
Wim Taymans
ad6ab7e0b7 pulse-server: refactor channel position parsing 2023-02-23 12:39:36 +01:00
Wim Taymans
eca4049a38 null-sink: accept our custom format as well 2023-02-23 12:04:13 +01:00
Wim Taymans
8aefdd8a6a audioconvert: log params to error as well 2023-02-23 12:03:40 +01:00
Wim Taymans
c74efea51e pulse-server: pass format to the null-sink
The effect is that the null-sink will report the given format in the
Sample Specification, which is what some applications might expect when
they pass a format parameter.
2023-02-23 10:34:07 +01:00
Wim Taymans
a9756def46 spa: allow passing audio.format to null-sink
So that the EnumFormat returns the given format instead of the default
float ones.
2023-02-23 10:31:51 +01:00
Wim Taymans
d11f8d5dea pulse-server: move fix function to format functions 2023-02-23 09:23:32 +01:00
Wim Taymans
4163991a97 pulse-server: use pulse.fix.* keys
Use a different key than the usual one to select an audio format when we
are fixating a stream format to avoid confusion.

So pulse.fix.rate, pulse.fix.format, pulse.fix.channels are now used to
force a specific format when the stream has the FIX_ stream flags.
2023-02-23 09:23:32 +01:00
Pauli Virtanen
15e4b3d500 bluez5: media-source: allow using bigger A2DP receive buffers
The maximum receive buffer target of 6 packets may be too small when
there's huge jitter in reception.  Increase it so that we may use all
buffer available if needed (2*quantum_limit = 370 ms @ 44100).

For SCO, explicitly set maximum buffer to 40 ms, so that latency cannot
grow too large there.  For A2DP duplex, set it to 80 ms for same reason.
These are close to the old 6*packet limit.
2023-02-22 20:20:07 +02:00
Wim Taymans
d28990af34 pulse-server: add support for overriding fix format
Add support for using custom format, rate or channels when the streams
asks to fix those parameters for us.

Some streams might expect to see S16LE when they connect to a sink in
S16LE when the FIX_FORMAT flag is set but this is not the case in
PipeWire because the audio DSP pipeline works in F32, and so F32 is
choosen. Make it possible to use a pulse.rule with a audio.format
property to control this.
2023-02-22 18:11:52 +01:00
Wim Taymans
84eafcd12f pulse-server: fix return value 2023-02-22 18:03:07 +01:00
Wim Taymans
78e5c2f3e6 utils: handle random_r fallback
musl does not seem to have it so fall back to rand() and srand().
2023-02-22 16:48:04 +01:00
Wim Taymans
4e298f2fe7 pipewire: add pw_random()
Make pw_getrandom() more usable by handling the EINTR case and returning
< 0 when there was an error or not enough random data was available.

Make a new pw_random() function that uses pw_getrandom() but falls back
to a pseudo random number generator otherwise. This pseudo random number
generator is seeded with either data from the urandom source or from the
current time when pipewire is initialized.

In most cases where crytographic security is not required pw_random()
should be easier to use.
2023-02-22 15:27:27 +01:00
Robert Mader
0b69f37a7c gstpipewiresrc: Do not alter meta plane count
Shared memory buffers may contain multiple planes.
Thus we need to keep the meta plane number as derived from the format.

Closes https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/3045
2023-02-21 08:17:26 +00:00
Mike Playle
23b86761a5 Add autoconnect parameter to pipewiresrc element 2023-02-21 08:16:44 +00:00
Thomas Weißschuh
2d5e0ef47b context: free properties on allocation failure 2023-02-20 12:12:00 +00:00
Pauli Virtanen
b9d7ecb5b2 bluez5: handle BAP presentation delay and transport latency
For BAP server audio sink, set buffering target so that we try to match
the target presentation delay.  Also adjust requested node latency to be
smaller than the delay.

Also fix BAP transport presentation delay value parsing, and parse also
the other BAP transport properties. Of these, transport latency value
needs to be taken into account in the total sink latency.
2023-02-19 22:44:23 +02:00
Pauli Virtanen
192044f1d9 bluez5: dup transport fd, in case media-sink is using it
For bidirectional links, both media-sink and media-source are polling
the same fd.  This won't work, so dup the fd in media-source to avoid
problems.
2023-02-17 20:40:46 +02:00
Wim Taymans
1c9ffef813 module-rtp: reset ringbuffer on resync 2023-02-17 15:38:11 +01:00
Wim Taymans
8eaf46a678 module-rtp: add rate matching for the source
correlate the timestamps against the graph clock and calculate a rate
correction. this smooths out the timestamps.
2023-02-17 11:23:51 +01:00
Barnabás Pőcze
aca5755c91 meson.build: promote two warnings to errors
Promote the following warnings to errors:
  * implicit-function-declaration
  * int-conversion
because the code very likely will not work
correctly if any of these two trigger.
2023-02-16 20:55:55 +01:00
Barnabás Pőcze
d77ef4b05e spa: bluez: include gio/gunixfdlist.h
Apparently before glib 2.73 including only gio/gio.h
does not include gio/gunixfdlist.h. So do that explicitly.
2023-02-16 20:55:55 +01:00
Barnabás Pőcze
c8260e16d2 ci: install libbluetooth-dev on ubuntu
Test building the bluez5 SPA plugin on ubuntu as well
since it is an important plugin.
2023-02-16 20:55:55 +01:00
Wim Taymans
fbd068977c module-rtp: Add rtp-midi support
Add rtp-midi support with the media.type = midi option
2023-02-16 16:47:29 +01:00
Barnabás Pőcze
934ab3036e treewide: use SPDX tags to specify copyright information
SPDX tags make the licensing information easy to understand and clear,
and they are machine parseable.

See https://spdx.dev for more information.
2023-02-16 10:54:48 +00:00
Wim Taymans
3601ecc9dd Improve NEWS 2023-02-16 11:45:28 +01:00
Wim Taymans
08b0ed6576 0.3.66 2023-02-16 10:18:28 +01:00
Wim Taymans
0511970537 jack: use 32 bits for frame times
JACK uses 32 bits for frame times so truncate our 64 bits position
to get the wraparounds right.
2023-02-16 10:16:36 +01:00