Commit graph

12630 commits

Author SHA1 Message Date
Robert Mader 226440382b gst: src: Reset transform on stream stop
When a stream is stopped, chances are high that downstream elements
change or get reset, i.e. don't remember a previously send rotation
event. Thus reset the transform value in order to ensure we create a new
one on the next stream start.

In order to not regress the case when downstream *does* remember the
orientation and the buffer orientation changes from e.g.
`TRANSFORMATION_90` to `TRANSFORMATION_None` between stream
stop and restart, initialize the remembered transform to an invalid
value and ensure we always send a rotation event, even for
`TRANSFORMATION_None`.
2024-07-02 15:15:05 +02:00
David Coles 015a367e30 Rename sample config that prevents checkout on Windows
`:` is a reserved character on Windows filesystems.

As far as I can tell from looking through both PulseAudio and PipeWire
commit history the files under `alsa/mixer/samples` are not used or
installed by anything.

See #2474.
2024-07-01 15:28:58 +00:00
David Coles 9ae9009edf Define setlinebuf for MSVC
According to `setbuf(3)`, `setlinebuf` is exactly equivalent to
`setvbuf(stream, NULL, _IOLBF, 0)`.
2024-07-01 15:28:58 +00:00
David Coles 5d7624001d Add spa/utils/endian.h
This provides access to GNU C library-style endian and byteswap functions.

Windows doesn't provide pre-processor defines for endianness, but
all current Windows architectures (X32, X64, ARM) are little-endian.
2024-07-01 15:28:58 +00:00
David Coles a97e8b6d1f Avoid using interface as a variable name
While not a reserved keyword, MSVC `#define interface struct`[1]
which causes a compile error when including the `spa/support/plugin.h`
header. While this can be worked around by `#undef interface`, it's
also easy to just rename the local variable.

[1]: https://stackoverflow.com/questions/25234203/what-is-the-interface-keyword-in-msvc
2024-07-01 15:28:58 +00:00
David Coles dd652d01b8 Port videotestsrc to LoopUtils
The `LoopUtils` interface can be used on platforms that don't
support the Linux-specific `timerfd` interface.

Added `local-videotestsrc` to validate the plugin still functions.

Restructured the SDL event loop as the window would not update
under WSL2, resulting in a black window being shown. All rendering
in SDL2 must happen on the same thread that originally created the
renderer.

To prevent the SDL event loop from being starved, we make sure to
poll it at least every 100 ms.
2024-07-01 15:28:14 +00:00
Wim Taymans c94d5ed215 tests: don't iterate all possible values
Or else the valgrind unit test times out.
2024-07-01 17:20:25 +02:00
Wim Taymans 29171cadb5 context: improve sync group handling some more
Keep track of the sync nodes we added to a driver and bring in the other
nodes from the same sync group, group or link groups. This makes it
possible to have disjoint sync groups each with their own driver.
2024-07-01 16:05:07 +02:00
Wim Taymans 070bcea63b context: Fix node collect with groups and sync enabled
When checking for the nodes to collect with a driver, don't just skip
checking the other nodes when the driver is not in the sync group.
Instead collect all nodes that have the same group and link group as
the driver first and then check the sync groups.

Fixes export in ardour8

Fixes #4083
2024-07-01 14:50:34 +02:00
Wim Taymans dc5f441909 module-raop: only set softVolume when valid 2024-07-01 11:42:29 +02:00
Wim Taymans b151b1f570 impl-node: fix required state for async driver nodes
When the node activation.required was incremented because it was a
driver, only decrement it in that case, regardless of the current driver
state of the node.

This fixes the case of KODI where the required field gets out of sync
and things become unschedulable.

Fixes #4087
2024-07-01 10:36:09 +02:00
Wim Taymans b1bb0ead3c alsa: remove unused variables 2024-06-30 21:23:00 +02:00
Barnabás Pőcze 04450e14a4 treewide: fix more -Wformat issues
See !2057
2024-06-30 19:22:17 +00:00
Eli Schwartz b5f031bc15 meson: fix conflicting use of feature-based dependency lookups
When spa-plugins is enabled, the gio-2.0 global dependency is
overwritten.

When bluez support is enabled, OR when gsettings is enabled, the gio-2.0
dependency is then detected as found. This means that
pipewire-module-protocol-pulse can end up enabling gsettings support
even if it has been forcibly turned off.

Rename the meson variables to ensure they are looked up separately.
2024-06-30 18:39:38 +00:00
David Coles 2770e96e08 loop: fix update_timer handling of solo repeat argument
I believe the intent here is that if a `interval` is provided
but `value` is unset, then `value` should default to `period`
so the timer first fires after one `interval`.

Since `interval` is always a relative duration, `value` should
be interpreted as a relative duration, not an absolute one.
2024-06-30 18:37:49 +00:00
Stefan Ursella 0b39c4ec68 alsa-pcm: add basic bind-ctl write functionality 2024-06-28 12:00:16 +02:00
Barnabás Pőcze ec521ca870 meson.build: enable -Werror=format 2024-06-27 21:18:06 +00:00
Barnabás Pőcze 17fcc9fc51 pw-container: use smaller path for temporary file
The automatically deduced size is sufficient. This
prevents a -Wformat-overflow warning.
2024-06-27 21:18:06 +00:00
Barnabás Pőcze adc60af45b spa: utils: use SPA_N_ELEMENTS in for-each macros
This way the compiler is able to detect cases when
a pointer is specified instead of an array.

Furthermore, incompatible pointer types can also
be diagnosed in `SPA_FOR_EACH_ELEMENT()`.
2024-06-27 21:18:06 +00:00
Roman Lebedev 7c40cafa7c
audioconvert: avoid even more precision loss in F32 to S32 conversion
This is somewhat similar to the S32->F32 conversion improvements,
but here things a bit more tricky...

The main consideration is that the limits to which we clamp
must be valid 32-bit signed integers, but not all such integers
are exactly losslessly representable in `float32_t`.

For example it we'd clamp to `2147483647`,
that is actually a `2147483648.0f`,
and `2147483648` is not a valid 32-bit signed integer,
so the post-clamp conversion would basically be UB.
We don't have this problem for negative bound, though.

But as we know, any 25-bit signed integer is losslessly
round-trippable through float32_t, and since multiplying by 2
only changes the float's exponent, we can clamp to `2147483520`!
The algorithm of selection of the pre-clamping scale is unaffected.

This additionally avoids right-shift, and thus is even faster.

As `test_lossless_s32_lossless_subset` shows,
if the integer is in the form of s25+shift,
the maximal absolute error is finally zero.

Without going through `float`->`double`->`int`,
i'm not sure if the `float`->`int` conversion
can be improved further.
2024-06-27 19:41:20 +03:00
Roman Lebedev f4c89b1b40
audioconvert: avoid even more precision loss in S32 to F32 conversion
There's really no point in doing that s25_32 intermediate step,
to be honest i don't have a clue why the original implementation
did that \_(ツ)_/¯.

Both `S25_SCALE` and `S32_SCALE` are powers of two,
and thus are both exactly representable as floats,
and reprocial of power-of-two is also exactly representable,
so it's not like that rescaling results in precision loss.

This additionally avoids right-shift, and thus is even faster.

As `test_lossless_s32_lossless_subset` shows,
if the integer is in the form of s25+shift,
the maximal absolute error became even lower,
but not zero, because F32->S32 still goes through S25 intermediate.
I think we could theoretically do better,
but then the clamping becomes pretty finicky,
so i don't feel like touching that here.
2024-06-27 19:41:20 +03:00
Roman Lebedev c517865864
audioconvert: somewhat avoid precision loss in S32 to F32 conversion
At the very least, we should go through s25_32 intermediate
instead of s24_32, to avoid needlessly loosing 1 LSB precision bit.

That being said, i suspect it's still not doing the right thing.
Why are we silently dropping those 7 LSB bits?
Is that really the way to do it?
2024-06-27 19:41:20 +03:00
Roman Lebedev 175d533b56
audioconvert: somewhat avoid precision loss in F32 to S32 conversion
At the very least, we should go through s25_32 intermediate
instead of s24_32, to avoid needlessly loosing 1 LSB precision bit.

FIXME: the noise codepath is not covered with tests.
2024-06-27 19:41:20 +03:00
Roman Lebedev 2a035ac49e
audioconvert: introduce s25_32 type, f32<->s25 cast is lossless
The largest integer that 32-bit floating point can exactly represent
is actually `(2^24)-1`, not`(2^23)-1` like the code assumes.
This means, whenever we use s24 as an intermediate step
to go between f32 and s32, we lose a bit of precision.

s25_32 is really a i32 with highest byte always being a sign byte.

Printing was done by adding
```
for(int e = 0; e != 13; ++e)
fprintf(stderr, "%16.32e,", ((float*)m1)[e]);
```
to `compare_mem`. I don't like how these tests work.

https://godbolt.org/z/abe94sedT
2024-06-27 19:41:20 +03:00
Wim Taymans 7b4c0dd5ec 1.2 2024-06-27 15:31:45 +02:00
Wim Taymans 1e5d9cc635 impl-node: increment async driver nodes required field
A driver can't be async, we always need to be able to trigger it
to start it so increment the required field.

Fixes an issue with asunc drivers such as the video-src example or gnome
screen sharing.
2024-06-27 13:22:52 +02:00
Barnabás Pőcze 7732d0e3e5 pipewire: module-raop-sink: use uint32_t for sample rate
32 bits are enough, and additionally this also fixes an incorrect
format string, which caused the default `audio.rate` to be
incorrectly set on some platforms, such as 32-bit arm ones.

Fixes #4080
2024-06-27 09:46:45 +02:00
Christian Glombek 4067b3a985 module-rtp/stream: Fix setting marker_on_first prop for RAOP 2024-06-27 06:04:56 +02:00
Christian Glombek 34ae5ce649 module-raop-sink: Fix setting sess.ts-direct prop 2024-06-27 05:44:50 +02:00
Arun Raghavan 3f35b80402 spa: aec: webrtc: Fix multichannel processing
Missed this parameter while porting to webrtc-audio-processing 1.0.
2024-06-25 15:34:30 -04:00
Barnabás Pőcze 7674b15fab pipewire-v4l2: move open*() flag check into function
This commit moves the check that determines whether the mode
argument of `open*()` exists into a separate function.

With that, the check is fixed because previously it failed to
account for the fact that `O_TMPFILE` is not a power of two.

Furthermore, add `assert()`s in the fortified variants that
ensure that no mode is required by the specified flags.
2024-06-25 19:10:13 +02:00
Wim Taymans 9d1d1fcbef impl-port: add port.group property
Can be used to group ports together. Mostly because they are all from
the same stream and split into multiple ports by audioconvert/adapter.

Also useful for the alsa sequence to group client ports together.

Also interesting when pw-filter would be able to handle streams in the
future to find out what ports belong to what streams.
2024-06-24 13:38:09 +02:00
Quentin 54c3fa06ed Update oc.po 2024-06-24 09:53:51 +00:00
Arun Raghavan 92c9b27c94 pw-cli: Dump object info on events
This prints changed state, props and params when run with -m and running
the `info` command. We try to print only things that have changed. It
would probably be good to make the props (and params) print a diff of
what's changed as well.
2024-06-21 16:08:24 -04:00
Arun Raghavan 8cd857733b module-rtp: Check if packet receive works to track receiving state
If the sender is reset, the RTP stream may return, but may no longer
correspond to the stream for which we loaded this instance of
module-rtp-source. A power cycle or network reset on Dante devices
causes a new SDP and SSRC to be selected, for example.

So let's make sure we don't consider invalid receives while tracking our
"receiving" state. Arguable, we should bail entirely if this happens.
2024-06-21 15:39:47 -04:00
Pauli Virtanen 6b6e9c4ea9 bluez5: make node.group valid JSON
The node.group property is parsed as JSON, and as it here contains ":"
it needs to be quoted accordingly. Fixes pw_strv_parse errors in logs.
2024-06-21 13:29:30 +03:00
Vlad Pruteanu 88d9d58333 bluez5: bap: Rework broadcast code length check
Co-authored-by: P V <pav@iki.fi>
2024-06-20 21:06:32 +00:00
Vlad Pruteanu 4c1271805e bluez5: bap: Fix parsing of broadcast code
This fixes the endianness of the parsed broadcast code. It also
fixes pontetial out-of-bouns write by using a bigger, temporary
bcode string, then, after checking it's length, copying it's content
to big_entry->broadcast_code.
2024-06-20 21:06:32 +00:00
Michael Tretter 1b7cf61632 gst: pipewiresink: wait for activated buffer pool before updating buffers
PipeWire expects the SPA_TYPE_OBJECT_ParamBuffers to be valid after
setting SPA_PARAM_Format. The pipewiresink knows the final buffer size
only after the pipewirepool has been activated.

There is a race between PipeWire asking the pipewiresink for the buffers
and GStreamer activating the buffer pool. If GStreamer has not activated
the buffer pool before PipeWire asks for the Buffer params, PipeWire
won't allocate buffers with the correct type and size.

The chance of hitting this window increases, if the upstream GStreamer
element doesn't use the buffer pool. In this case the buffer pool is
activated by the first buffer that arrives at the pipewiresink, which
may take some time.

Instead of not updating the Buffer params when the buffer pool is not
active, wait for the buffer pool to become active.
2024-06-20 21:05:45 +00:00
Michael Tretter 21358526d5 gst: pipewiresink: extract gst_pipewire_sink_update_params
Add a helper function for updating the params instead of handling it in
the pool_activated callback. This allows to explicitly set the params
from the element.
2024-06-20 21:05:45 +00:00
Michael Tretter 6468e5338f gst: pipewirepool: print buffer type with numeric value
If the buffer type is invalid, the short_name will be (null). Printing
the numeric value helps the reader to understand the (null) type.
2024-06-20 21:05:45 +00:00
Barnabás Pőcze 6acfb53884 pipewire: module-roc-sink: explicity specify sender packet encoding
roc-toolkit commit 03d29eb97211ca87593566998c5087590c1bae38 [0]
("Add sample_format() and pcm_format() to SampleSpec") made
a change in how the packet encoding is determined. Specifically:

  This commit introduces small breaking change in C API:
  when we search for packet_encoding compatible with
  frame_encoding, we now take into account format too.

  It means that if you use ROC_FORMAT_PCM_FLOAT32 in frame_encoding,
  ROC_PACKET_ENCODING_AVP_L16_STEREO will not be selected automatically
  anymore, and you need to specify it manually via packet_encoding.

This causes module-roc-sink to fail to set up the ROC sender:

  roc_api: bad configuration: failed to select packet_encoding matching frame_encoding, set roc_sender_config.packet_encoding manually

So specify `ROC_PACKET_ENCODING_AVP_L16_STEREO` explicitly
as the packet encoding. This seems to work with roc-toolkit 0.3,
so the required version is not changed.

Fixes #4070

[0]: 03d29eb972
2024-06-20 21:04:40 +00:00
Wim Taymans ea7e0e9152 spa: revert peer_enum_params node event again
It's not used anymore because it does work so well.

The problem is that while it transparently proxies param enums on
ports to peers, it fails to emit events when those peer
params change in a way that would make the enum result change as well.
This makes it quite hard to use this correctly.
2024-06-20 10:22:45 +02:00
Michael Tretter 7b8b6d92d9 gst: pipewiresink: decrease log level of on_process to LOG
on_process is called whenever a buffer may be queued. This happens for
every buffer. The correct log level is LOG.
2024-06-19 15:43:06 +00:00
Michael Tretter 3b581b2417 gst: pipewiresink: print stream state as string
Print the state of the stream not only as the numeric value, but also
print the name of the state to help the reader.

While at it, add the sink element to the log output to be able to
identify the sink that received the state change.
2024-06-19 15:43:06 +00:00
Arun Raghavan 4d14531444 module-rtp: Drop redundant include 2024-06-19 11:16:09 -04:00
Arun Raghavan 9559b9382b module-rtp: Propagate cleanup.sec to module-rtp-source
This might be specified on a `create-stream`, but then not actually
applied as a module argument, and thus be ignored.
2024-06-19 11:15:17 -04:00
Arun Raghavan 2c7272a13a module-rtp: Set receiving state on stream as a property
There isn't a good way to surface this information to the module owner
yet, so let's publish the information on the stream so we can try to
manage things in policy.
2024-06-19 10:49:51 -04:00
Wim Taymans 41691f8bc9 module-vban: fix some implicit float conversions 2024-06-18 16:05:36 +02:00
Wim Taymans 51bf143a77 module-rtp: fix fmodf usage 2024-06-18 16:01:41 +02:00