Commit graph

9690 commits

Author SHA1 Message Date
Martin Geier
422c2ad726 alsa-plugin: prevent deadlock when update_active is called from two threads
When there is not enough room for next data to write, alsa calls
snd_pcm_pipewire_poll_descriptors to setup file descriptor. This function
clears io->poll_fd by calling spa_system_eventfd_read and next time the
quantum is processed, update_active sets value in io->poll_fd,
alsa is notified and can continue to push data.

In bad case scenario, update_active is called simultaneously from
both - alsa thread and pw thread. In alsa thread, the check_active(io)
returns false, pw->active is set to false, but spa_system_eventfd_read
isn't called yet as Alsa thread is rescheduled. Pw thread starts to execute
the same code, however this time, check_active(io) returns true, pw->active
is set to true and spa_system_eventfd_write is called. When alsa thread
starts to run again, spa_system_eventfd_read is called and clears any
events from io->poll_fd.
Alsa starts to poll for events, io->poll_fd is clear, pw->active is set
to true and therefore spa_system_eventfd_write is not called ever again.

To fix this deadlock, write to io->poll_fd every time there is some
room for new data. Doing this is safe, as write only increases internal
counter and next read clears the counter.
This code can lead to opposite behavior - spa_system_eventfd_write is
called right after spa_system_eventfd_read, however there is no room for
new data. This would lead to busy loop in alsa thread. To prevent this
scenario, call update_active alsa in snd_pcm_pipewire_poll_revents.

Signed-off-by: Martin Geier <martin.geier@streamunlimited.com>
2022-10-25 11:26:20 +00:00
Wim Taymans
7182145435 libcamera: pick better default format
Pick the first format in the list of supported as something closest
to 640x480 instead of the lowest possible resolution.

Applications that don't suggest a default size will then get something
more sensible than a poster frame.
2022-10-25 12:10:42 +02:00
Christoffer Gydenius
b35983eb7e module-echo-cancel: aec-plugin parameters
Make it possible for a aec-plugin to provide props/params
through module-echo-cancel and make it possible for a
aec-plugin to listen and react to these props/params getting updated.

Add method enum_props() that is used under setup_streams() to
get props from aec_plugin.
Add get_params() and set_params() for updating and getting
aec-plugin params under the input/output_param_changed calls
and getting params under setup_streams().
2022-10-24 16:58:00 +02:00
Wim Taymans
2086fa5ad2 libcamera: recycle buffers when no io area 2022-10-24 15:40:13 +02:00
Wim Taymans
1d0adba0f6 impl-node: remove nodes from graph after Pause completes
While we process the Pause, the node might sill emit some events or do
processing, which would give an error because we already removed the
node from the graph.

Instead, remove the node from the graph when the node state is updated
to the new state.
2022-10-24 15:24:47 +02:00
Wim Taymans
8fcfa154eb impl-link: don't activate links with inactive input
Also check the active state of the input node, not just if the node
was added to the graph because a node can become inactive and only
later be removed from the graph.
2022-10-24 15:18:03 +02:00
Wim Taymans
df094b3649 v4l2: recycle buffers when no io area
When there is no io area to place our buffers, recycle them immediately.
Otherwise we would run out of buffers and stall.
2022-10-24 13:16:08 +02:00
Wim Taymans
a57602cc4d v4l2: remove unused forward declaration 2022-10-24 13:15:42 +02:00
Wim Taymans
2c4e1b8537 node: check if active when ready event is emited
Add a check that the node is actually started when we get the ready
callback.
2022-10-24 12:33:56 +02:00
Oğuz Ersen
3d3851e5a3
po: Update Turkish translation 2022-10-23 10:42:14 +03:00
Pauli Virtanen
2fa3120486 bluez5: driver should produce buffers before ready
The graph cycle goes: driver timeout -> process output nodes -> process
driver node.  Hence, driver should produce buffers in the timeout,
otherwise there's one quantum extra latency.

Make the bluez5 media/sco sources as drivers put a buffer to io before
indicating ready, and as follower do it in process. Also make checks if
io == NULL, and don't set io->status to HAVE_DATA unless there really is
a buffer ready.
2022-10-22 15:23:06 +03:00
Jonas Holmberg
facf73b01c module-echo-cancel: Correct offset
Correct the offset of first delayed data to run the canceller on.
2022-10-21 16:25:57 +00:00
Wim Taymans
7a0058ffb6 pw-top: do refresh after sync
So that we also draw the screen quickly when there is no profiler
running.
2022-10-21 18:25:33 +02:00
AsciiWolf
977713a2e1 Update Czech translation 2022-10-21 14:48:05 +00:00
Wim Taymans
6e88c30080 pw-top: do initial refresh after first data 2022-10-21 16:44:59 +02:00
Barnabás Pőcze
95eeb7c2ec spa: bluez: dbus: add endpoint (un)registration helpers
Introduce `unregister_media_endpoint()` to unregister the specified
media endpoint object from dbus. Moreover, move the logic that decides
whether or not a particular codec should be registered for a given
direction into `endpoint_should_be_registered()` and use that in
both `(un)register_media_endpoint()`.
2022-10-21 13:39:31 +00:00
Jonas Holmberg
8092a0a637 module-echo-cancel: Run canceller on first frames
Run canceller on the first frames when play delay is not a multiple of
the chunk size.
2022-10-21 14:53:26 +02:00
Wim Taymans
71879961db alsa-seq: avoid division by 0
Make sure the rate in the state is updated in all cases and make sure
that it never has anything with a 0 in it to avoid division by zero.
2022-10-21 13:15:36 +02:00
Jonas Holmberg
0e066e44fe module-echo-cancel: Don't use old delayed play data
Do not use old delayed data in play_buffer when a new stream is started.
Copy silence to output until play_buffer has been filled with new data
instead.
2022-10-21 11:42:41 +02:00
Wim Taymans
ec90b575d7 pw-top: also show IEC958 passthrough formats 2022-10-21 10:23:34 +02:00
Pauli Virtanen
d388c206ef bluez5: reset timers when reassigning followers
Driver timeouts need to be started/stopped when we switch from follower
to driver or vice versa.

The BT sources fail to do this, so fix it. Sinks already do it right.
2022-10-21 07:09:36 +00:00
Wim Taymans
c0fc29494f bluez5: stop before freeing things
Make sure all timers are stopped before we clear our state.

See #2764
2022-10-20 21:52:49 +02:00
Wim Taymans
643d95f515 jack: set port valid state safely
When unregistering a port, set the port to invalid first and sync the
data loop so that it will not be used anymore from the data loop.

See #2652
2022-10-20 21:34:01 +02:00
Wim Taymans
4c1115cf1d alsa-seq: attempt to get more data in timeout
Also emit the NEED_DATA status so that the graph will pull in new
midi data even when we don't output anything.

Fixes #2775
2022-10-20 17:44:42 +02:00
Wim Taymans
f7c4909243 udev: use devpath for the sysfs.path property
So that it matches what pulseaudio does.

Fixes #2779
2022-10-20 16:44:37 +02:00
Wim Taymans
1aef910dcc jack: make jack_bufsize adjust the global quantum
Bind to the settings metadata.
Add a property to control if a client will set a temporary or global
quantum whith jack_bufsize.
Make a match rule for jack_bufsize and force a global quantum change.

Fixes #1273
2022-10-20 16:34:47 +02:00
Wim Taymans
24b113e2d3 module-loopback: add target.delay.sec property
Add a target.delay.sec property to module-loopback that uses a
ringbuffer to further delay the signal to the requested value. This
also takes into account the graph delay to get an end-to-end delay.

Add a -d property to pw-loopback to control this.

Implement latency_msec on the pulse module with this new property so
that it behaves similar to pulseaudio.
2022-10-20 16:02:28 +02:00
Wim Taymans
35c9650e0e pulse-server: do chmod of the socket like pulseaudio
Pulseaudio sets the socket permissions to 0777 with chmod when the
socket was not from systemd. Do the same.

Fixes #1729
2022-10-20 11:49:52 +02:00
Wim Taymans
e5881e9afb module-pulse-tunnel: rate limit some messages 2022-10-20 09:24:54 +02:00
George Kiagiadakis
500a5a689e gitlab-ci: disable building session managers
...except in the build_session_managers job.

This decouples pipewire's CI from wireplumber's dependencies
and potential failures. The build_session_managers job is supposed
to catch session manager integration errors, not any other job.
2022-10-18 14:51:56 +00:00
George Kiagiadakis
33e8667cfc meson_options: change default session manager to wireplumber 2022-10-18 14:51:56 +00:00
Pauli Virtanen
9c4aab7508 bluez5: sco-sink: implement flushing the same way as in a2dp-sink
Use separate timers for driving graph and for flushing, since they don't
have the same period.

Flushing is done based on the time positions of the next sample to be
written, so it will stay in sync with the graph.  Because writing too
much data to SCO sockets generally only causes the device to skip ahead,
we don't need to handle the case where the writing has been lagging.

This fixes simultaneous playback to both ALSA and SCO sinks from the
same graph, with SCO as driver, which previously produces broken sound
(e.g. with pw-play --latency 512, linked to the two sinks) ALSA nodes
require regular driver intervals, which was not true previously.
2022-10-18 14:42:14 +00:00
Pauli Virtanen
9cfa66baa2 bluez5: media-sink: flush packets at time of first sample
Send encoded data packets at the time corresponding to their first
sample. This is simpler than what we did previously.

Use this scheme also for BAP.
2022-10-18 14:42:14 +00:00
Pauli Virtanen
d231e2a1b1 bluez5: media-sink: bigger socket buffer
Bigger buffer allows for more fluctuation in transmission rate without
sound glitches.

It doesn't matter much for latency, as under normal conditions we are
not producing data faster than the BT adapter can transmit, so the
buffer generally is almost always empty or full, and in the latter case
we have to reduce the bitrate.
2022-10-18 14:42:14 +00:00
George Kiagiadakis
8a3c1bedde gitlab-ci: move check_missing_headers into its own job and hide the script 2022-10-18 17:19:28 +03:00
Wim Taymans
88785c42e5 modules: avoid partial writes to pulseaudio
Pulseaudio requires that we call pa_stream_write with a multiple
of frame_size bytes. Because our ringbuffer is a power of two, this
might cause problems at the edge of ringbuffer where a sample is
split between the end and beginning of the ringbuffer.

Avoid this by letting pulse allocate a buffer instead and memcpy
the requires samples into it.

Fixes multichannel output on module-pulse-tunnel.
2022-10-18 13:14:32 +02:00
Wim Taymans
e6356f7415 module: pass a channel map in pa_stream_new
Convert the PipeWire channelmap to pulseaudio and pass it in
pw_stream_new().
2022-10-17 18:58:15 +02:00
Jonas Holmberg
22a1e5b848 alsa-pcm: Start playback when there is data
Do not start the playback device until there is data to play. Otherwise
time consuming configuration of other nodes (such as setting hw params
of a capture device) may be done after playback has been started, which
may cause xrun.
2022-10-17 15:21:49 +02:00
Wim Taymans
e2638b4b68 modules: use resample.prefill for echo cancel streams 2022-10-17 15:09:46 +02:00
Wim Taymans
3e9b4657cb modules: add since tag 2022-10-13 13:16:33 +02:00
Wim Taymans
f0753ffdf9 jack: improve acquire/drop_rt methods
Instead of calling the default implementation that does not implement
these methods, keep the last thread-utils around in a global and use
that instead.
2022-10-13 12:09:36 +02:00
Wim Taymans
38e3c2be6c jack: client_thread_id() returns NULL
client_thread_id() returns NULL on jack1 and jack2 when the client is
not activated yet, so do the same here.
2022-10-13 12:08:27 +02:00
Wim Taymans
25f40e4c2a thread: emit a warning when calling unimplemented functions
These are fallback functions that are not implemented. It is expected
that the thread-utils is used from the context, which is a complete
implementation provided by module-rt.
2022-10-13 11:57:04 +02:00
Wim Taymans
b178d222d5 jack: also implement drop_rt in our custom thread utils 2022-10-13 11:56:28 +02:00
Wim Taymans
3a7d6b74f2 audioconvert: only reinit channelmix when params change
Don't reinitialize the channel mixer when only the volume changes.
2022-10-13 10:31:09 +02:00
Wim Taymans
9efb2e3463 audioconvert: optimize upmix functions with SSE 2022-10-13 10:19:04 +02:00
Wim Taymans
0adc351d36 audioconvert: use spa_dtoa to format floats and doubles
The parsing functions expect float values in the default locale so use
the spa_dtoa function to generate such a float.

Fixes setting params with floating point values when the locale is not
the default locale.
2022-10-13 10:15:52 +02:00
Wim Taymans
59e49d31eb raop: add error from reply
Return an error from the reply callback and log some generic message
in case there is an error value returned.
2022-10-12 17:51:35 +02:00
Tycho Haemers
e168af8804 Update src/modules/module-raop-sink.c 2022-10-12 13:41:07 +00:00
Tycho Haemers
09a62514e3 Update src/modules/module-raop-sink.c 2022-10-12 13:28:14 +00:00