Commit graph

13220 commits

Author SHA1 Message Date
David Härdeman
f33e1bc8c3 spa: alsa: autodetect supported iec958 codecs via ELD info
The alsa/acp code already supports getting a user-friendly monitor name
using the EDID-Like Data (ELD) information available from cards that follow
the Intel HDA specification.

This patch adds support for also parsing the SAD fields of the ELD, and
exposing the results as a "iec958.codecs.detected" property on the
corresponding node, which should make it possible to provide more
user-friendly configuration UIs and defaults.

The default value will take effect if the session manager does not set a
different value.

Brief example:
test@test:~/checkouts/pipewire$ pw-dump | grep -E "(iec958.codecs.detected|iec958.codecs)\":"
        "iec958.codecs": "[\"PCM\",\"AC3\",\"EAC3\",\"TrueHD\"]",
        "iec958.codecs.detected": "[\"PCM\",\"AC3\",\"EAC3\",\"TrueHD\"]",

<after powering on my receiver>

test@test:~/checkouts/pipewire$ pw-dump | grep -E "(iec958.codecs.detected|iec958.codecs)\":"
        "iec958.codecs": "[\"PCM\",\"DTS\",\"AC3\",\"EAC3\",\"TrueHD\",\"DTS-HD\"]",
        "iec958.codecs.detected": "[\"PCM\",\"DTS\",\"AC3\",\"EAC3\",\"TrueHD\",\"DTS-HD\"]",

Big thanks to Pauli Virtanen <pav@iki.fi>, who also wrote large paths of the
code for this patch.
2024-11-28 09:18:07 +01:00
Jonas Holmberg
0570d1dd00 filter-graph: Use biquad from audioconvert
Remove the biquad-implementation in filter-graph and use the one in
audioconvert instead.
2024-11-27 18:18:10 +01:00
Jonas Holmberg
e9092d7d2f core: Remove redundant declaration
Fix problem when building with -Werror=redundant-decls:

../src/pipewire/core.h:661:7: error: redundant redeclaration of ‘pw_core_get_user_data’ [-Werror=redundant-decls]
  661 | void *pw_core_get_user_data(struct pw_core *core);
      |       ^~~~~~~~~~~~~~~~~~~~~
../src/pipewire/core.h:446:7: note: previous declaration of ‘pw_core_get_user_data’ with type ‘void *(struct pw_core *)’
  446 | void *pw_core_get_user_data(struct pw_core *object);
      |       ^~~~~~~~~~~~~~~~~~~~~
2024-11-27 17:33:11 +01:00
Wim Taymans
0a0b1d594b audioconvert: use the same biquad as filter-chain 2024-11-27 16:47:53 +01:00
Wim Taymans
98365470c7 v4l2: set a clock name 2024-11-27 15:12:10 +01:00
Arun Raghavan
45eee02a99 module-rtp: Account for in-flight samples in RTP receive
When not using PTP as the driver, it is possible that packet receive and
the process() callback are out of sync, meaning that the target buffer
fill level might be off by upto one ptime's worth of samples
occasionally. This would make the DLL hunt for the target rate, and
cause a constantly varying delay.

Accounting for the delta between the packet receive time and the
process() time allows us to eliminate this jitter, resulting in much
more consistent rate matching.
2024-11-27 11:48:50 +00:00
Michael Olbrich
e76e057038 v4l2: ensure that the default frame rate is within the min/max bounds
Without this for continuous frame intervals, the default is set to 25
fps even if that is outside the min/max bounds (e.g. defined by the
peer).
Clip the default with the min/max bound to avoid this.
2024-11-27 11:46:26 +00:00
Michael Olbrich
669f53946e v4l2: handle min/max for continuous frame interval correctly
v4l2 frame intervals instead of frame rates, which is basically the
inverse. For the most part, this is already handled correctly and
numerator and denominator are swapped accordingly.

However, the minimim frame interval is the maximum frame rate so those
need to be swapped as well.

Without this, the minimum frame rate is larger than the maximum frame
rate for v4l2 devices that define a continuous frame interval.
2024-11-27 11:46:26 +00:00
Wim Taymans
89993a3cc6 gst: enable the pipewire ticks as a clock source
Use the pipewire ticks again as the clock source.

This was disabled because the v4l2 sources created bad ticks for the
graph. Now that this is improved we can enable the ticks again.

This has the advantage that simple audio playback does not drift
anymore. The only remaining problem would be timestamp drift or
discontinuities, which we don't handle here yet.
2024-11-26 17:23:00 +01:00
Wim Taymans
41e35c7b17 v4l2: use dll to track rate difference
Track the difference between the configured and real framerate and use
that as the rate correction to adjust the next_nsec clock field.
2024-11-26 17:14:26 +01:00
Wim Taymans
043245ca11 v4l2: set the NO_RATE clock flag
These sources have very inaccurate position/duration/rate information
that is not suitable for use as a clock so set the NO_RATE flag.
2024-11-26 17:05:20 +01:00
Wim Taymans
3f0fe0032f node: add a clock flag to mark rate/duration inaccurate
Some clocks (v4l2) don't process exactly process buffers at the given
rate/duration so mark this in the clock flags.

We need to use the nsec field in the clock to derive ticks in pw-stream
in that case to get a good clock.
2024-11-26 17:02:02 +01:00
Wim Taymans
ef8d2ab125 gst: mark the pipewiresink as EARLY_PROCESS
We want to receive process callbacks as soon as a buffer is ready for
reuse because we dequeue it for use in our buffer pool.
2024-11-26 16:57:14 +01:00
Wim Taymans
25e06e5912 spa: remove some old includes 2024-11-26 13:30:58 +01:00
Wim Taymans
4d4607e62a doc: copy docs from the _methods struct 2024-11-26 13:21:04 +01:00
Wim Taymans
853c4783bc spa: inline some metadata functions 2024-11-26 12:46:58 +01:00
Wim Taymans
9fc33a6142 spa: add some more functions 2024-11-26 12:21:05 +01:00
Wim Taymans
d966a36fdd spa: compile all function into libspa.so 2024-11-26 11:58:51 +01:00
Wim Taymans
31802d4994 add per type API defines 2024-11-26 11:58:51 +01:00
Wim Taymans
b03f2f7afa make per object IMPL 2024-11-26 11:35:50 +01:00
Wim Taymans
999b26c590 static inline more macros 2024-11-26 11:35:49 +01:00
Wim Taymans
90b0e45037 make static inline -> SPA_API_IMPL
So that we can export the symbols as well.
2024-11-26 11:35:49 +01:00
Wim Taymans
84bd4b7ea9 spa: use static inline for interfaces instead of macro
It gives better typechecking and a path to make a library of functions.
2024-11-26 11:35:49 +01:00
Wim Taymans
5e0e1204d7 impl-node: remove old check
Remove the check for the target rate and duration. The drivers are
supposed to update that now.

The check is a little racy because a new target could have been
configured right after the driver emitted the ready signal. In that
case we should not update the clock values but let the driver run with
the old values and let the new values become active in the next cycle.
2024-11-26 10:59:54 +01:00
Pauli Virtanen
e74e7b938e bluez5: don't re-emit nodes on device set events if unchanged
Only re-emit nodes on BAP device set changes, if our configuration
actually needs to be changed.
2024-11-25 21:26:13 +02:00
Pauli Virtanen
656ebcfcbb bluez5: fix handling of multiple transports for same profile
Don't mark a profile disconnected, if it still has active transports.

For BAP, emit device set changed events when transports come and go, so
that the SPA device can reconfigure accordingly.
2024-11-25 21:26:13 +02:00
Pauli Virtanen
e08846dc9c alsa-card-profiles: move HDMI/AC3 profiles to separate profile set
These shouldn't be enabled by default, because they cannot be
autodetected, and if the configuration is not a supported one, they
produce loud BRRRT at 100% volume and ALSA errors.
2024-11-23 14:58:17 +02:00
Pauli Virtanen
c36c028dd2 pw-dump: don't emit remove events when not monitoring
When pw-dump is called without --monitor, it should output exactly one
JSON array, and no remove event indicators.
2024-11-23 12:11:33 +00:00
Pauli Virtanen
603c67628e bluez5: fix BAP route non-deviceset availability
Fix issue where BAP routes are marked unavailable for devices not in a
device set.

Fixes: a154169942
2024-11-23 11:25:46 +02:00
Philip Withnall
88873e295b build: Explicitly disable -Werror=strict-aliasing
Pipewire is designed to be built without strict aliasing enabled (as
evidenced by already hard-coding `-fno-strict-aliasing`). In case people
have strict aliasing warnings enabled by default in their build
environment, explicitly disable errors from those.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-11-22 16:24:51 +00:00
Philip Withnall
89a605b7a2 filter-graph: Remove duplicate install keyword from meson.build
This fixes building with `--fatal-meson-warnings`.

Signed-off-by: Philip Withnall <pwithnall@gnome.org>
2024-11-22 16:24:51 +00:00
Arun Raghavan
90075b838c spa: alsa: Try to initialise card_index from path if needed
If the PCM is loaded directly using only api.alsa.path,
state->card_index may never be initialised, and then we end up opening
the wrong ctl device. Let's try a fallback for this case.
2024-11-22 10:36:26 -05:00
Wim Taymans
ae37dd7773 doc: fix the SPA POD enum docs
The first argument should be the element count.
Fix the format for float, it should be with captial F.
2024-11-22 14:58:16 +01:00
Wim Taymans
ae465ccbfc stream: fix EARLY_PROCESS again
It got removed with the async improvements. We shouñd simply ask more
buffers whenever we push one to be dequeued.

See #3480
2024-11-22 12:22:14 +01:00
Wim Taymans
e1fc3de595 modules: use pw_stream_set_rate() some more 2024-11-22 09:55:36 +01:00
Wim Taymans
804df3389a modules: use pw_stream_set_rate() when we can 2024-11-22 09:49:27 +01:00
Wim Taymans
433afeaa1e stream: add function to set adaptive resampler rate
Make a function to set the adaptive resampler.
2024-11-22 09:29:53 +01:00
Wim Taymans
188d920733 pass the right types to the methods
This currently works because we accept void* for these functions but it
will fail when we will use the real types.
2024-11-20 10:17:37 +01:00
Pauli Virtanen
e393e57a26 pulse-server: ensure positive stream delay in GET_PLAYBACK/RECORD_LATENCY
Pulseaudio protocol requires stream latency is uint64. Clamp the
Pipewire signed latency to the range, better than wrapping around.
2024-11-19 22:07:09 +02:00
Wim Taymans
a997627906 impl-node: save all previous timestamps on start
When the driver starts, save all previous node timestamps, not just the
previous signal time.

For async nodes, uses the previous timestamps in the profiler messages
so that we get stats with 1 cycle of delay instead of bogus values
because the node is still processing.

Fixes pw-top for async nodes.
2024-11-15 18:06:12 +01:00
Wim Taymans
1084cc24b6 alsa: handle the case where the driver is destroyed
When the driver node is destroyed (like when unplugging the cable) it
will drop/pause all of the follower ALSA nodes. This is something that
happens internally because of how the ALSA nodes work together, on the
PipeWire level, the nodes are still running and they will just be moved to
another driver.

The problem is that nothing will then start the nodes again after moving
it to the new driver. Fix this by keeping track of the desired target
state of the ALSA node and restoring that state when we detect that we are
paused when moved to a new driver.

Fixes #4401
2024-11-15 16:09:36 +01:00
Wim Taymans
3b51dbba1c filter-graph: improve output port number calculations
When no output ports are given, use the number of graph outputs, which
needs to take into account the number of times we duplicated the graph.
2024-11-15 12:21:49 +01:00
Wim Taymans
3b27ff0c71 doc: fix spa_pod_parser_get_object example 2024-11-15 12:09:19 +01:00
Wim Taymans
f261b2f96f filter-chain: update channels from filter-graph
Add a filter-graph info structure with the number of inputs and outputs
in the graph definition.

Use the input/outputs to update the number of channels on the capture and
playback streams when not explicitly given. Also copy over the positions
when they match the other stream and were not explicitly specified.

Fixes #4404
2024-11-15 10:53:45 +01:00
Wim Taymans
8c59fae42d loop: add overflow queues again
Add the overflow queues again. We can easily iterate atomically over the
overflow queues and flush them.

Overflowing a queue is quite common when heavy swapping is done and
should never cause a lockup, so allocate new queues as we need them. We
can share the eventfd with the main queue to avoid wastings fds.

The limit on the number of queues is then only for when concurrent
threads want to invoke things, so 128 is plenty enough.
2024-11-14 17:38:43 +01:00
Michael Olbrich
687075f2bd gst: handle interlace mode
If the peer announces an interlace mode then use it. Otherwise assume
that the video is not interlaced.

This also fixes a problem with caps negotiation:
If downstream reports caps with not fixated interlace mode, e.g.
"interlace-mode=(string){ progressive, interleaved, mixed }"
then without this, the caps handle_format_change() (in the pipewiresrc)
are not fixed and the source waits forever for the negotiation to
finish.
2024-11-14 17:18:28 +01:00
Wim Taymans
6cf320e387 loop: handle queue overflow better
When a queue overflows we place the queue back in the stack and try
again. Because it's at the top of the stack we take exactly the same
queue and keep on looping forever if the other thread is blocked for
some reason.

Instead, mark the queue as overflowed and only place it back in the
stack when we have flushed it.

This avoids a deadlock when the main-thread invokes on the data loop
and blocks and when the data loop invokes on the main-thread and
overflows the queue.
2024-11-14 15:58:09 +01:00
Wim Taymans
bb2d848bf6 impl-node: don't remove from graph when creating
When we were in the CREATING state, don't remove ourselves from the
graph because we were not added yet.
2024-11-14 15:56:57 +01:00
Wim Taymans
d32ab4d8ea alsa: remove unused variable 2024-11-14 12:03:55 +01:00
Wim Taymans
0833b19a75 module-vban: fill some default channel layouts
VBAN does not really transmit any channel layouts so make some
assumptions about the layout when not explicitly specified.
2024-11-14 11:07:05 +01:00