Commit graph

9748 commits

Author SHA1 Message Date
Pauli Virtanen 99406aefea bluez5: deal with missing endpoint path in selectproperties 2022-10-26 18:59:26 +03:00
Anders Jonsson f20636f659 po: Update Swedish translation 2022-10-26 13:10:05 +00:00
Wim Taymans 431176c618 alsa: avoid division by 0
Use the wanted amount of samples to determine the buffered data.
Also make sure we don't divide by 0.
2022-10-26 13:22:38 +02:00
Wim Taymans 0396ca4931 libcamera: let the session manager set pause-on-idle 2022-10-25 20:27:14 +02:00
Wim Taymans 9d0be53be9 alsa: fix some signedness warnings 2022-10-25 16:27:46 +02:00
Wim Taymans d247db8d26 pw-top: improve output
Show the node state in the S column
Use the node state to show or hide info, this will only show info for
active nodes.
Do redraw updates when something important changes
Update man page
2022-10-25 16:24:03 +02:00
Martin Geier f5f4be5109 alsa-plugin: improve alsa plugin delay precision if alsa period is not align with the quantum
Method on_stream_process can be called multiple times with the same
pwt.delay and pwt.now values. Its a case, when snd_pcm_pipewire_process
returns less then b->requested frames. For example, if requested is 2048
and alsa period size is 512, then on_stream_process is called 4 times
in a row with the same pwt.delay and pwt.now values.
Store number of transferred frames for this "session" in separate variable
so its incremented each time the on_stream_process is called. Number
of transferred frames is cleared when a new "session" starts.

Introduce also number of buffered frames, which is number of frames
read from alsa but not sent to pipewire yet. This is the case
when period is not align with the quantum size. For example alsa period is
480, but quantum is 512. on_stream_process is called 2 times for the first
quantum, 512 frames is sent to pipewire and 448 frames are cached for the
next round. These 448 frames needs to be included in delay computation
in the next on_stream_process.

Signed-off-by: Martin Geier <martin.geier@streamunlimited.com>
2022-10-25 11:32:00 +00:00
Martin Geier 1a4c2ce624 alsa-plugin: unblock alsa poll when there is pw error
When there is a core error, update_active method is called from
on_core_error. update_active is supposed to unblock alsa thread,
in case the alsa is waiting for more some room for data.

Checking for active state is not sufficient and spa_system_eventfd_write
needs to be called also in case of error.

Signed-off-by: Martin Geier <martin.geier@streamunlimited.com>
2022-10-25 11:26:20 +00:00
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