Commit graph

4758 commits

Author SHA1 Message Date
Wim Taymans
060d0e1761 Revert "loop: don't call the hooks around blocking wait"
This reverts commit 46dfa69f26.

We do actually need to release the locks for now. The reason is that
pipewire core will at various points do a blocking invoke into the
thread-loop (which is the data-loop when using non-rt/async processing)
to synchronize state. Because these functions are called with the
thread-loop lock and from some other thread (like gstreamer) it causes
a deadlock because the thread-loop is locked and can't run and the
caller is waiting for the thread-loop to complete.

See #4472
2025-06-26 12:45:29 +02:00
Wim Taymans
ff60e68a23 Revert "alsa: add Teufel Cage Pro mapping"
This reverts commit 0321f543d3.
2025-06-26 11:34:20 +02:00
Wim Taymans
c644f54ea7 audioconvert: remove unused field 2025-06-25 10:46:05 +02:00
Wim Taymans
cc94909ca1 tests: set the flags on buffers correctly 2025-06-25 10:45:59 +02:00
Wim Taymans
0fa5ceba1c audioconvert: mark output as not empty when draining
When we are draining, we use an empty input buffer but then we push out the
remaining samples out of filters and we can't assume they are empty.
2025-06-25 10:44:11 +02:00
Wim Taymans
86d1233107 alsa: don't log unknown events with info
Debug is good enough
2025-06-25 10:43:18 +02:00
Harald Sitter
0321f543d3 alsa: add Teufel Cage Pro mapping 2025-06-25 10:42:03 +02:00
Wim Taymans
a53a960645 alsa-udev: support alsa.use-ucm
Make a new alsa.use-ucm option that sets api.alsa.use-ucm on the device
it creates (when set).

There is some documentation floating around (thr arch wiki) with this
property.

See #4755
2025-06-25 10:41:51 +02:00
Wim Taymans
88046b9f03 spa: add volume_ramp_scale enum type info
And link it to the SPA_PROP_volumeRampScale property
2025-06-13 11:53:42 +02:00
Wim Taymans
ecbd4f552c spa: make the wave, pattern and ditherType Int
Properties of type Id should have a type of the enum with the possible
values associated with them.

The other types that don't have a fixed enumeration but are usually
mapped to some constant/description with PropInfo should be Int.

Fixes !2399
2025-06-13 11:53:42 +02:00
Wim Taymans
e3f6a81df1 alsa: reset alsa_sync when linked
When a linked node needs to be resynced we actually never clear the
flag or reset the dll. Move the code around so that it still does
the reset of the flag and dll without actually doing the resync in
the ringbuffer when it is a linked node.
2025-06-13 11:53:42 +02:00
Wim Taymans
4cfef13042 alsa: reset dll in prepare
When we do_prepare, always reset the dll. We already set the alsa_sync
field but that is only used by followers to resync in some cases.

When reseting the dll, we also reset the next_time and base_time values,
we however need to do this before calculating the error in update_time
when we are the driver in IRQ mode or else we get some crazy error
that distorts the rate estimation.
2025-06-13 11:53:42 +02:00
Martin Geier
b5e9e59cdb alsa-pcm: enable interrupts after alsa recovery
Interrupts are disabled in alsa_irq_wakeup_event -> playback_ready method
to not produce another wakeups when waiting for a new data. Interrupts are
enabled again when a new data arrives in a method spa_alsa_write.
In rare cases, when there is multiple streams providing data and one of
them is disconnected, a new data fails to be delivered and the spa_alsa_write
is not called. Not providing data produces underrun and alsa-pcm invokes
recovery process. Recovery process starts a new playback, but without interrupts
enabled is graph not triggered and new data are not delivered (to enable
interrupts). Recovery process keeps running in loop.
Now the interrupts are enabled again after the recovery and the starvation
should not occur.

Signed-off-by: Martin Geier <martin.geier@streamunlimited.com>
2025-06-13 11:14:22 +02:00
Wim Taymans
46dfa69f26 loop: don't call the hooks around blocking wait
The blocking invoke function is not meant to be called with any of the
loop context locks acquired so that it can actually run the invoke call
while blocking. Make this (and other blocking risks) clear in the
documentation.

Because it is not supposed to be called with any of the locks, we should
also not try to call the hooks (that implement the unlock/lock).

Fixes #4472
2025-06-10 12:18:28 +02:00
Wim Taymans
1139ab5966 alsa: handle NULL io
It is possible that the port io is set to NULL when the node is
negotiating or destroying.

Fixes #4734
2025-06-10 11:01:36 +02:00
Wim Taymans
889d069b46 adapter: use the right default when filtering default
Before fixating the format, we try to add as many of the PortConfig
fields as we can as defaults. However, when we already have a property
that intersects, prefer to use the original negotiated one prefered by
the follower.

This got changed when the default for the pod filter changed to the
filter value.

The effect is, for example, when the follower asks for FL FR FC LFE SL
SR and the sink is using FL FR SL SR FC LFE, the PortConfig (and the
default) would then be FL FR SL SR FC LFE. After negotiation, we would
get FL FR FC LFE SL SR as the format but then with the filter and the
wrong default we would fixate to FL FR SL SR FC LFE, which does not
match what the follower wanted and either results in wrong channels
or an error of the follower.

See #4722
2025-06-03 10:54:07 +02:00
Jonas Holmberg
fc9aa51619 pod: declare offset as unused in spa_pod_builder_bytes_end()
Fixes compiler warning:

/usr/include/spa-0.2/spa/pod/builder.h:357:69: error: unused parameter 'offset'
[-Werror=unused-parameter]
2025-05-29 09:08:40 +02:00
Wim Taymans
62a719d71a adapter:handle -ENOENT when enumerating buffers
When the follower has no buffer suggestion, it can return -ENOENT, which
should not generate an error but simply use the converter buffer
suggestion instead.
2025-05-27 16:14:15 +02:00
Wim Taymans
c507c4b0ff adapter: negotiate from target to follower
Since 3abda54d80 we prefer the format
of the filter. This reverses the selection of the default value when
negotiating buffers from the target to the follower.

If the follower does not select a reasonable value for the buffer size,
for example, this then results in wrongly sized buffers.

Fix this by reversing the order of allocation from target to follower
where we let the target (converter) select a default value, which is
more likely to be correct.

See #4713, #4619
2025-05-26 15:44:51 +02:00
Wim Taymans
06941f7315 alsa: remove UMP flag from control format
Don't set the UMP type flag on the format. Use the negotiated types flag
to decide what format to output. Add support for output to old style
midi.

Set the UMP type flag only on the new mixer and JACK when UMP is
enabled.

This ensures that only new (or explicitly requesting) apps get UMP and
old apps receive old midi.

This makes JACK running on 1.2 in flatpaks work with midi again.
2025-05-23 17:00:16 +02:00
Wim Taymans
76db05a0f8 Use "8 bit raw midi" for control ports again
There is no need to encode the potential format in the format.dsp of
control ports, this is just for legacy compatibility with JACK apps. The
actual format can be negotiated with the types field.

Fixes midi port visibility with apps compiled against 1.2, such as JACK
apps in flatpaks.
2025-05-23 17:00:05 +02:00
Wim Taymans
483b59a9d9 pod: add bytes start/append/end functions
Add functions to dynamically start and build a bytes pod.
2025-05-23 16:59:54 +02:00
Wim Taymans
b24ceda8b2 filter-graph: lv2 features need a NULL terminator 2025-05-21 15:37:02 +02:00
Wim Taymans
61168adb92 adapter: log command errors when no converter 2025-05-20 10:54:48 +02:00
Wim Taymans
a968027bdc adapter: handle -ENOTSUP for commands
When using custom commands, the converter might return -ENOTSUP and
we should ignore this.
2025-05-20 10:54:38 +02:00
Wim Taymans
9207fea992 libcemara: take care of index offset when enumerating controls
Add an index offset when enumerating controls. We insert 2 properties
before enumerating the controls so the index of the first control needs
to have an offset of 2.
2025-05-20 10:53:55 +02:00
Wim Taymans
a66377cf42 alsa: only use default rate and channels when valid
Check the user provided rate and channels and only use them to limit the
rate and channels when they are valid.
2025-05-19 12:12:36 +02:00
Wim Taymans
e7610de305 alsa: clamp audio.channels to MAX_CHANNELS
So that we don't end up trying to use too many channels later on.
2025-05-19 12:09:21 +02:00
Robert Mader
2a8d5c1f40 v4l2: Re-enable first buffer skip for jpeg types
The workaround is typically needed with usb-cameras using jpeg streams.
Re-enabling the skip shouldn't affect what the commit was trying to do,
i.e. fix encoded streams like h264 etc.

Fixes: bcf0c0cf8 (v4l2: only skip buffer for raw formats)
(cherry picked from commit e387772dc2)
2025-05-17 15:08:45 +02:00
Wim Taymans
6b9f340219 alsa-seq: remove leftover debug line 2025-05-13 11:20:55 +02:00
Wim Taymans
1cbe4e1782 ump: handle sysex from UMP to MIDI1 better
SysEx in UMP can span multiple packets. In MIDI1 we can't split them up
into multiple events so we need to collect the complete sysex and then
write out the event.

Fixes SysEx writes to ALSA seq by running the event encoder until a
valid packet is completed.

Also fixes split MIDI1 packets in the JACK API when going through the
tunnel or via netjack.
2025-05-13 10:48:39 +02:00
Wim Taymans
750b88c3ca control: only convert midi/UMP, pass other control types
We should only try to convert MIDI/UMP when the port doesn't support it
but let all the other control types pass through.

Fixes #4692
2025-05-09 12:01:24 +02:00
Wim Taymans
37dbf93cc4 filter-graph: remove useless check 2025-05-09 11:59:31 +02:00
Guido Günther
2d4af3ced5 spa: Add default: statements
This allows to use the library in projects that use `-Wswitch-default`
without any

 #pragma GCC diagnostic push
 #pragma GCC diagnostic ignored "-Wswitch-default"
 #pragma GCC diagnostic pop

This is useful as as the header is being pulled in via
pipewire/wireplumber headers into projects that might have this warning
enabled and would otherwise fail to build with -Werror.

Signed-off-by: Guido Günther <agx@sigxcpu.org>
2025-05-09 11:58:55 +02:00
Wim Taymans
7d27668fb2 ebur128: fix port name
Fixes #4667
2025-05-09 11:53:37 +02:00
Wim Taymans
0135baa60f alsa-seq: add the source only on success
Otherwise if we have an error with the timerfd, we have the source fd
added and we close the device.
2025-05-09 11:53:07 +02:00
Wim Taymans
49c4c44dce videoconvert: consume input buffer in all cases
Return the input buffer when we get some error so that the other side
can send new data.
2025-05-09 11:52:04 +02:00
Wim Taymans
957bde02cd v4l2: only skip buffer for raw formats
We don't want to skip the first buffer for encoded formats because it
can contain the encoding parameters, in the h264 case, for example.
2025-05-09 11:51:45 +02:00
Wim Taymans
f857a50734 ump: fix program change 2.0 to 1.0 conversion
The program change byte should not be shifted an extra bit, unlike all
the other messages.

Fixes #4664
2025-05-09 11:51:20 +02:00
Wim Taymans
3abda54d80 pod: use default value of filter
When using a filter, it makes more sense to use the default value
of the filter as a first attempt.

One case is in adapter when we try to find a passthrough format first. The
audioconverter suggests a default rate of the graph rate but the follower
filters this out for another unrelated default value and passthrough is not
possible (altough it would be because the default value of the filter is
in the supported follower range).

Fixes #4619
2025-05-09 11:49:08 +02:00
Wim Taymans
ac42f55916 ebur128: work around libebur128 bug
Versions 1.2.5 and 1.2.6 don't scale the window in ms correctly, leading
to excessive memory allocation, so work around this here.
See https://github.com/jiixyj/libebur128/pull/132

Fixes #4646
2025-04-14 11:19:44 +02:00
Kenny Levinsen
a0be431c7f audioconvert: Increase param length limit to 4096
Parameter values read into a 512 byte long buffer, which is insufficient
for medium to long filter-graph parameters.

Increase the buffer to 4096 bytes to give some wiggle-room.
2025-04-14 09:41:47 +02:00
Wim Taymans
1388f16c47 adapter: handle builder overflow 2025-04-02 15:33:54 +02:00
Wim Taymans
ce6d2fce9a audioadapter: init the builder for each param
Or else we keep on adding items until we overflow.
2025-04-02 15:33:54 +02:00
Wim Taymans
a9eba98e8e pod: handle builder overflows
When the builder is overflowed, we might get a NULL pod. This is a valid
situation that we need to handle because it can be used to get the
required builder buffer size.
2025-04-02 15:33:54 +02:00
Wim Taymans
2d26fbcddf v4l2: handle nearest set_format
The set_format function can return 1 when the format was adjusted to the
nearest supported format so return this from the port_set_param
function.

This instructs the adapter to recheck the configured format so that it
can store the adjuted format on the converter.
2025-04-02 15:33:54 +02:00
Wim Taymans
8d7175a1e7 adapter: add Header metadata by default
Firefox needs this but we should eventually check the Meta Params to
decide on this.
2025-04-02 15:33:54 +02:00
Pauli Virtanen
4176caca30 alsa: seq: double-check midi client version
Check midi client version after setting it, to see if it was really
successfully set.  Old kernels without UMP don't know about the midi
version fields, so snd_seq_set_client_midi_version() appears to fail
silently there.
2025-04-02 15:33:54 +02:00
Wim Taymans
fb43eb8ee2 audioconvert: fix the filter-graph samplerate
The filter graph runs before or after the resampler depending on the
direction of the conversion.
2025-03-14 10:16:15 +01:00
Pauli Virtanen
d58d2a2375 spa: acp: indicate ALSA UCM profile errors in UIs
Add "[ALSA UCM error]" to the end of card description, to indicate
something is wrong.
2025-03-14 10:16:08 +01:00