Commit graph

10232 commits

Author SHA1 Message Date
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
Robert Mader
353c1f709d gstpipewiresrc: make stream errors permanent
When pw_stream receives a proxy error it does not set its state to an
error state on its own, commenting:
```
we just emit the state change here to inform the application.
If this is supposed to be a permanent error, the app should
do a pw_stream_set_error()
```

Until now this was not done in the pipewiresrc, resulting in the
negotiation loop to not bail out after an error as a successive
`pw_stream_get_state()` did not return an error state.

Make the error permanent so negotiation errors make us take the
appropriate error paths.
2023-02-15 14:49:42 +01:00
Wim Taymans
965b220206 module-rtp: clear ringbuffer in resync
When we resync to the timestamp, clear the ringbuffer to avoid playing
old stale samples.
2023-02-15 11:08:08 +01:00
Wim Taymans
aa3b776f6f module-rtp: resync after paused state
After the paused state, resync to the new clock time.
2023-02-15 11:06:01 +01:00
Wim Taymans
dd0d3ac264 pw-cat: remove useless code
The data stride for encoded formats should be 1 and also placed in the
stride in the buffer (not 0). So there is really no difference with the
regular codepath.
2023-02-14 16:44:52 +01:00
Wim Taymans
b9ddd54a98 pw-cat: don't read more than the requested frames 2023-02-14 16:44:52 +01:00
Niklāvs Koļesņikovs
5e0bfa0beb
RLIMITs: add support for generating limits.d files
This commit implements generating /etc/security/limits.d/20-pw-defaults.conf and
/etc/security/limits.d/25-pw-rlimits.conf files. The numbering is arbitrary and
may very well warrant being in the reverse order, however `man 5 limits.conf`
does not appear to specify the parsing order or even say exactly how multiples
matches will resolve, so the value can be adjusted later, if required.

The actual limit values, the match rule and even whether each file is to be
installed can be changed via the build system before compilation. Likewise
the files can be modified or (re)moved during distro package building phase.

The 20-pw-defaults.conf should only be installed on legacy systems lacking both
a modern kernel and up to date systemd, because all it does is set the current
Linux default. Accordingly its not installed by default.

Signed-off-by: Niklāvs Koļesņikovs <89q1r14hd@relay.firefox.com>
2023-02-14 17:37:59 +02:00
Niklāvs Koļesņikovs
d082ec0809
src/modules/meson.build: fix indentation and remove obsolete comment
Signed-off-by: Niklāvs Koļesņikovs <89q1r14hd@relay.firefox.com>
2023-02-14 17:37:59 +02:00
Barnabás Pőcze
2b6541f503 spa: support: send TID to systemd journal
Knowing which thread posted which log message can
be useful, so send the TID to the systemd journal.

The `TID` field is explicitly listed on
https://www.freedesktop.org/software/systemd/man/systemd.journal-fields.html#TID=
2023-02-14 11:38:52 +00:00
Wim Taymans
58812103f3 test: add another channelmix test 2023-02-14 11:57:04 +01:00
Wim Taymans
2895961b48 audioconvert: improve channelmix with unknown layouts
Use a 0 mask to handle unknown layouts. When the source or destination
is an unknown layout, pair, distribute or average. When pairing, keep
track how we paired and use that to construct the matrix later.

This fixes [ UNK UNK ] -> [ FL FR ] mapping by pairing.
2023-02-14 11:57:04 +01:00
Barnabás Pőcze
e09b97edc4 pipewire: impl-core: actually return created object
Actually return the pointer to the created object
from `impl-core.c:core_create_object()` instead of
returning a NULL pointer.

This has not caused issues because the return value
is not checked anywhere.
2023-02-13 19:55:45 +01:00