Commit graph

11939 commits

Author SHA1 Message Date
Dmitry Sharshakov
73cda0c152 node-driver: allow fractional resync-ms 2024-01-25 12:07:11 +01:00
Wim Taymans
c28311fc97 support: add resync.ms option to node.driver
Move some of the tracking code for the DLL to where it is used.

Add resync.ms (default 10) option at which we give up rate adjusting
and instead do a hard resync. This results in a jump in the position
of the graph clock.
2024-01-25 12:06:50 +01:00
Mersad Jelacic
5f531e7fe6 thread: Change warning to info
Change warning to info in impl_acquire_rt() and impl_drop_rt().
2024-01-25 12:03:36 +01:00
Wim Taymans
13511e9295 jack: improve running check
When we get a node info about our own state, we can use the active state
of the node to decide if we are running or not.

Otherwise, we will try to hide ports from JACK clients that suspend
(while still active).

See #3794
2024-01-25 12:02:01 +01:00
Wim Taymans
c298d7faef pulse-server: the device changed when EnumRoute changes
We use EnumRoute of the card to fill in the ports of the device so when
EnumRoute changes, the associated devices also needs a change event.
2024-01-25 12:00:35 +01:00
Wim Taymans
6ee48f0562 alsa: increase buffers when using small buffer
We can increase the MAX_LATENCY again if we increase the amount of
buffers when we are using a small buffer.

Normally we ask for 4 * quantum-limit as the buffer. This should be good
to use 1 buffer and quantum-limit as the quantum with enough headroom
to not run out of buffers.

If we are however using less buffer-frames we need to be careful and
allocate an extra buffer. Imagine using a buffer of 4096 frames, we can
support a quantum of up to 2048 frames if we use 2 buffers.

See #3744
2024-01-22 16:05:52 +01:00
Wim Taymans
7e1e05f0da alsa: improve max-latency property
Half of the buffersize is not enough to support as a max-quantum, we
need to divide by (4 * frame_scale) to allow some headroom and account
for the DSD scaling. We do the same calculation to suggest a buffer size
using the quantum-limit.

See #3744
2024-01-22 16:04:38 +01:00
Wim Taymans
7775363d8e v4l2: improve filter with missing format
When the filter has no format property, just enumerate all possible
framerates. Handle error case where the filter has the wrong type.

Makes gst-launch gstpipewiresrc ! video/x-raw ! fakesink work.

See #1793
2024-01-22 16:00:37 +01:00
Wim Taymans
ef0674751f v4l2: fix format enum with unsupported framerate
Actually count the number of frame fractions we add. If we added 0, we
don't have any supported framerate that intersects with the filter and we
try the next frame size.

See #1793
2024-01-22 16:00:30 +01:00
Pauli Virtanen
0feb68fc07 bluez5: lc3: fix wrong enum_config
The rate is not a bitmask.
2024-01-22 16:00:05 +01:00
Wim Taymans
0a11281834 stream: delay emit param changes when inside emit_param_changed
When we are notifying the application of changed params, don't emit any
changes applied to the params from within the callback with
pw_stream_update_params(). This will be done after we complete the
callback.

This also avoids reseting the change counter so that we don't
accidentally think we updated the formats param when we simply changed
some other params.
2024-01-22 15:56:34 +01:00
Wim Taymans
b63230f805 impl-port: res > 0 means the param was modified
Only log the error when the res < 0, otherwise the param was accepted bu
modified.
2024-01-22 15:56:10 +01:00
Wim Taymans
9a9be2c2ed audioconvert: remove unnecessary casts 2024-01-22 15:54:19 +01:00
Dmitry Sharshakov
524edba9dd audioconvert: fix rare unaligned load exceptions
Supposed causes described in the issue. Also improve float semantics.

Fixes #3790
2024-01-22 15:54:07 +01:00
Pauli Virtanen
bae75e0d0b bluez5: add quirk for SoundCore mini2
AVRCP volume doesn't work properly with this device.

Closes #2927
2024-01-22 15:53:52 +01:00
Pauli Virtanen
46eb11051a bluez5: more informative warning with unknown transports
Unknown transports visible in DBus usually belong to a different
sound server instance that is talking to BlueZ.

Explain this in the warning message that we log, so that people can more
easily understand why things are not working.
2024-01-22 15:53:44 +01:00
Pauli Virtanen
c0716675e8 bluez5: add quirk for Rockbox Brick 2024-01-22 15:53:25 +01:00
Wim Taymans
469b7b0148 spa: small cleanups
Initialize result variable.
Use strncpy to avoid warnings about using non-NULL terminaded strings.
2024-01-12 12:14:06 +01:00
Barnabás Pőcze
01cb3fa862 spa: libcamera: bump minimum supported version to 0.2.0 2024-01-11 13:09:40 +01:00
Barnabás Pőcze
fd33d2d3bb spa: libcamera: use CameraConfiguration::orientation
libcamera commit cc65629b68d49d ("libcamera: camera: Introduce Orientation") [0]
introduced to the `CameraConfiguration::orientation` member to describe the
orientation of the image in the received memory buffers.

Then c65e40b8480ffb ("libcamera: Use CameraConfiguration::orientation") [1]
removed `CameraConfiguration::transform`, which broke the libcamera plugin.

Fix that by using the new `orientation` member.

[0]: https://git.linuxtv.org/libcamera.git/commit/?id=cc65629b68d49d5f2a4d61537584c56ba510a335
[1]: https://git.linuxtv.org/libcamera.git/commit/?id=c65e40b8480ffb5f50e01a4e6713164c7194a937
2024-01-11 13:09:32 +01:00
Wim Taymans
79b98884af 1.0.1 2024-01-10 13:30:27 +01:00
Wim Taymans
1733cc7fea support: fix freewheel timeout in node-driver
When freewheeling we will immediately schedule a new graph cycle when we
get a process call because the graph completed.

When the process call is not done, because of some xrun or
because some node was removed that causes the graph to fail completion,
The next cycle will happen after a timeout.

This timeout was calculated as the ideal wakeup time (after a quantum of
time) and would accumulate for each timeout. The result is that the
timeout ended up far in the future and would stall the freewheel driver
for a long time.

Fix this by always setting the next timeout to wakeup time + freewheel.timeout
seconds. Also add a config property for the timeout (10 seconds, like
jack2 by default).
2024-01-10 13:25:41 +01:00
Wim Taymans
5a596edd53 spa: small cleanups
Use snprint to ensure null terminated strings.
Initialize res, it would be uninitialized when setting a NULL Latency
param.
2024-01-10 13:25:35 +01:00
Wim Taymans
50096e2c76 doc: clarify rlimits conf file
Fixes #3760
2024-01-09 09:20:40 +01:00
Wim Taymans
2b7fa2ff5a spa: remove some references to unimplemented items
Fixes #3763
2024-01-09 09:20:16 +01:00
Barnabás Pőcze
beee7d1ce2 meson_options: pass proper boolean values to boolean options
Passing strings has been deprecated:
https://mesonbuild.com/Release-notes-for-1-1-0.html#coercing-values-in-the-option-function-is-deprecated
2024-01-09 09:19:58 +01:00
Mauro Carvalho Chehab
4dfd8b4497 bluez5: update bluez-hardware.conf to ignore sbc-mq on Primark earbud
Primark True Wireless earbud doesn't support sbc-xq. Having it
enabled causes bluez to enter into a loop enabling/disabling
the device dozens of times per minute, making it unusable.
2024-01-09 09:10:53 +01:00
Michael Tretter
16964b323f gst/pipewiresink: fix dts_offset
GStreamer uses a time stamp for the decoding time, but PipeWire uses an
offset to the presentation time. Thus, the pipewiresink must not use the
DTS as dts_offset, but has to calculate the offset.

If the buffer's DTS is invalid, assume that dts is pts.
2024-01-04 17:55:14 +01:00
Wim Taymans
917c6419b1 pulse-server: call update_object_info in manager_added
get_device_info() requires us to call update_object_info() in the added
and updated events.

Fixes a bug where the properties were invalid in the avahi txt record.
2024-01-04 17:54:23 +01:00
Wim Taymans
591330ab74 protocol: don't allow NULL event or command
If causes crashes when the handlers try to get the ID.
2024-01-04 17:54:14 +01:00
Barnabás Pőcze
4fd1f88a99 pipewire: module-loopback: fix delay buffer memory leak 2024-01-04 17:53:44 +01:00
George Kiagiadakis
0c99d37db2 gstpipewiresrc: break out of wait_started() also on STATE_UNCONNECTED
When the session manager sends an error to the client, it typically
also destroys the node after the error, which causes the stream to go
to STATE_UNCONNECTED via proxy_removed(). In that case, make sure
we exit the loop early, otherwise it will take 30 seconds to unblock
gst_element_set_state()

This is a revised version of the fix that was commited via !1763
and then reverted, as it was problematic. Now the code ensures
that it breaks out only if the state was previously CONNECTING
or higher.
2024-01-04 17:53:25 +01:00
Duncan Overbruck
c199611c89 pulse-server: fill in active port for monitors
The monitor sources also list the port of the sink and so the active
port needs to be collected as well so it doesn't fall back to the first
port (which might not be available).
2023-12-20 10:16:56 +01:00
Wim Taymans
67fde171a2 gst: keep track of node ports
Keep a list of ports for the node. When the node goes away, clear the
port links to the node. Handle the case where the port no longer has a
node.

This avoids a crash when, for example, the node permission is removed
and the port points to the now freed node_data.

Fixes #3708
2023-12-14 13:13:56 +01:00
Wim Taymans
705c977e9e gst: remove unused pending list 2023-12-14 13:13:51 +01:00
Wim Taymans
8d5e7749c2 jack: handle -ENOENT from the core
This means that we tried to do something on a proxy that was destroyed
on the server and we should just ignore the error.
2023-12-14 13:12:44 +01:00
Dimitrios Katsaros
4331779e4d ALSA: Remove alsa timer from IRQ scheduling
As part of the setup for IRQ based scheduling, a period event
was installed. Not only is a timer based polling unecessary for
IRQ scheduling, depending on the state of the system, the timer
could fire far enough from the IRQ, causing alsa wakeup events
with no data in the ring buffer. Pipewire would identify these
events as an "early wakeup", adding an extra quantum of time
to the next_time estimate, skewing the clock and causing issues
with apps that depend on precise timing.
2023-12-14 13:12:38 +01:00
Wim Taymans
bbb3b5d8b1 module-pipe-tunnel: avoid bitfield data race
Move the have_sync bitfield away from the other bitfields because they
are written from different threads and might cause a data race.

Fixes #3706
2023-12-14 13:12:29 +01:00
Wim Taymans
c07bef13be audioadapter: improve state check
Update the started and ready state after we suspend/pause the node so
that we don't complain if scheduling happens between setting the fields
and actually stopping the follower.

Also only complain when the scheduling happens when the node is not
ready. It is possible that the node is scheduled before we manage to set
the started field.
2023-12-14 13:12:23 +01:00
Wim Taymans
41e88b1267 audioconvert: avoid bitfield data races
Move the driver and warned bits after the int field in the struct so
that they are placed in separate memory.

Otherwise, a write from the data thread might race with a write from the
main thread and leave the bits in the wrong state.
2023-12-14 13:12:14 +01:00
Barnabás Pőcze
32ee81d977 pipewire: data-loop: set thread name
Set the name of the thread running the data loop to "pw-data-loop"
for easier identification in debuggers, htop, etc.
2023-12-14 13:09:39 +01:00
Wim Taymans
0c1ee5f01d Revert "alsa: also use interpolated time as nsec in IRQ mode"
This reverts commit 49cdb468c2.

We should not do this, the nsec field should be relatable to the clock
monotonic time. If we use the estimated time, without actually using it
as a timer, we might end up with a wakeup time in the future compared to
the MONOTONIC clock time.

Instead, you can use the estimated current time simply by subtracting
the rate corrected duration from the next_nsec. This is really only
useful for some selected use cases (like in the JACK library).

This fixes some issues where in pro-audio mode, a client would try to
compare the current MONOTONIC time to nsec and find that it is in the
past.

This commit was done in an attempt to fix #3657 but it turned out the
real problem was something else.
2023-12-14 13:09:21 +01:00
Wim Taymans
2a29581b2a jack: improve current_usec calculation
We should not use nsec from the clock as the current_usec because
current_usec is supposed to be an idealized time when the wakeup would
have happened and nsec is when it actually happened.

Instead use next_nsec and subtract the rate corrected period from it to
get the idealized current_usec.

We can still use nsec to calculate the elapsed time since the wakeup and
be sure that it is always in the past.
2023-12-14 13:09:10 +01:00
Wim Taymans
8079194952 raop: use default 1500ms latency again
Use 1500ms as the default latency and use the raop.latency.ms to
configure a smaller value.

Fixes #3605
2023-12-11 16:38:36 +01:00
Wim Taymans
ca011af2cd raop: use 1500ms of latency as fallback
The Pro Link 1 replies with Audio-latency=0, patch that up to
1500ms to make it work again.

Previously it configured 1500ms as the default latency but that seems
unnecessary in the usual case.

Fixes #3698
2023-12-11 16:11:00 +01:00
Pauli Virtanen
00d1b85eea pulse-server: update all params only after enumeration complete
For params that don't emit change events, the param enumeration does not
start core sync, and its enumeration may be incomplete if a previous
core sync completes first.

Fix by always starting a core sync if we are updating params.

This fixes dev_info.active_port being sporadically SPA_ID_INVALID if
there is event pressure, which causes do_set_volume randomly set the
volume on the node instead of setting it on the device.  This can be
triggered e.g. by shaking the volume slider in Pavucontrol with mouse.
2023-12-09 13:05:54 +01:00
Wim Taymans
0f58b9162b conf: fix comment node.always-driver -> node.always-process
Fixes #3696
2023-12-09 13:05:19 +01:00
Wim Taymans
8ecc61e117 module-x11-bell: force pulse backend
The libcanberra ALSA backend has some races and causes crashes, we
should try to not use that one.

Fixes #3688
2023-12-05 16:24:37 +01:00
Wim Taymans
22db59d8a3 alsa: fix rate matching in the sequencer
The alsa sequencer rate matching was not actually working correctly.
It would compare the previous queue time with the current time and
compare that to the quantum. This would include uncorrected errors from
jitter and would result in the timeouts being scaled in the wrong
direction forever.

Instead, calculate an ideal queue time and compare our current queue
time against that. We then use the correction to scale the timeout or
the next queue time prediction.

Also use the predicted time as the base time for the event timestamps.
this results in less jitter.

Fixes #3657
2023-12-05 15:37:02 +01:00
Wim Taymans
4e6b629ae2 alsa: reset dll when we reprogram the timers 2023-12-05 15:36:58 +01:00