Commit graph

9728 commits

Author SHA1 Message Date
Wim Taymans a6e3ac68d2 v4l2: use the node description as the card name 2022-11-03 13:23:26 +01:00
Wim Taymans cd9dc974f5 v4l2: improve error debugging 2022-11-03 13:22:38 +01:00
Wim Taymans 44d743ed95 spa: make all format parsing fields optional
Just like the optional build, make all field parsing optional. This
will leave the fields with their default values if they are not parsed
from the param.

We can then remove our custom functions and use the generic ones in
various places.
2022-11-03 13:13:07 +01:00
Wim Taymans 74447acedb Add some more format checks
The format parse functions don't really check if the parsed values
make any sense so we need to to this ourselves.
2022-11-03 13:10:32 +01:00
Wim Taymans c30d743198 pw-top: initialize info struct with 0
So that we don't accidentally print uninitialized values.
2022-11-03 13:08:48 +01:00
Wim Taymans e3a4797063 pw-top: support MJPG and H264 formats 2022-11-02 17:14:40 +01:00
Wim Taymans e0c0d9806f libcamera: clear format info
Or else we end up with invalid data for the fields that did not get
initialized when parsing the format param.
2022-11-02 17:14:01 +01:00
Wim Taymans 3e4da8e8e4 filter-chain: emit en error when graph fails 2022-11-02 12:58:37 +01:00
Wim Taymans f6e76f8356 filter-chain: add more default LADSPA search paths
Add /usr/lib/ladspa and LIBDIR to the default search path as well.
2022-11-02 12:57:16 +01:00
Wim Taymans 8ab70d02dc stream: guard against node destroy 2022-11-02 12:56:45 +01:00
Wim Taymans ef8114ff0c filter-chain: improve some error messages 2022-11-02 12:42:31 +01:00
Wim Taymans 6bb73124aa filter-chain: improve some float handling
Avoid some double to float conversions.
Use fmin and fmax.
2022-11-02 12:41:20 +01:00
Wim Taymans f801dc0886 pulse-server: keep read index in sync
Keep the ringbuffer and read_index variable in sync or else we might ask
for more data than maxlength and cause an overflow.

Fixes #2799
2022-11-02 11:43:30 +01:00
Wim Taymans 51e8ff7d8e libcamera: add EnumFormat param to the node 2022-11-02 10:35:48 +01:00
Wim Taymans ef4b9745b2 libcamera: handle canceled requests
When a request is canceled, recycle it so we don't run out of buffers.
Implement getting and setting controls.
2022-10-31 19:03:55 +01:00
Wim Taymans 71d58e6445 v4l2: implement setting controls 2022-10-31 11:33:45 +01:00
Wim Taymans c5f7d3a728 param: improve pw_param
Add a sequence number to pw_param.
Add param_info to param_update to filter out the params of the latest
sequence number.

This can be used to track params from a certain sequence number. Update
node, port and device.
2022-10-30 14:57:04 +01:00
Jaroslav Kysela a2278a5f70 spa: support the speakers (output) only case in report_jack_state()
The Realtek ALC4080 USB audio device (integrated in the
motherboards) can detect the presence on all I/O jacks.

If user connects only speakers, it's a valid case.

BugLink: https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/2744
2022-10-29 20:22:06 +02:00
Ashok Sidipotu f383956b7b module-pipe-tunnel: Update the description of the module. 2022-10-28 07:07:43 +00:00
Ashok Sidipotu 315b2d1ad5 module-pipe-tunnel: Initialize the target.node property
Initialize the PW_KEY_TARGET_OBJECT property on the stream node based on the
user config.
2022-10-28 07:07:43 +00:00
Wim Taymans e6fd5888ee param: add a new user seq field in the param-info
Add a new seq field in the param-info struct. Users can use this
field to keep track of pending param updates.

Store the latest seq number of the param update in the seq field. Remove
all params that don't match the sequence number because they are too
old. This avoids duplicate old params in pw-dump output.

Rework the pulseaudio manager with this same method.
2022-10-27 20:10:33 +02:00
Wim Taymans a989230cb5 introspect: update the info more carefully
Only change the fields we care about and leave the other ones
untouched in the created info.
2022-10-27 20:09:25 +02:00
Wim Taymans d2aa240767 introspect: handle NULL result from info updates 2022-10-27 20:06:54 +02:00
Wim Taymans 552d4516b6 params: count params per id from 0
Only increment the index when we find the requirested param, this
makes the params go from index 0 to the last instead of starting at some
random index. The random index is not really a problem but it is also
no so nice.
2022-10-27 19:20:40 +02:00
Wim Taymans f0328a1f8d protocol-native: improve logging
Add an end marker in the log for the message.
Log the output messages with the right log topic.
2022-10-27 18:04:14 +02:00
Wim Taymans 855bebf0ea audioconvert: update started field better
Set up the adapter and then set the started field to true before we
Start the follower and converter. It is possible that the follower will
start processing immediately so the started state needs to be set
correctly.

Similarly, first perform the Pause and Suspend calls on the follower
and converter before clearing our buffers and format so that things
are stopped properly.

See #2764
2022-10-27 10:29:15 +02:00
Wim Taymans 122252ce52 alsa: add brackets for clarity 2022-10-27 09:12:06 +02:00
Pauli Virtanen cc4e5a89b4 bluez5: fix BAP codec sink flag usage
MEDIA_CODEC_FLAG_SINK means the local endpoint is sink. Have this the
same way for BAP, no need to invert it.
2022-10-26 20:14:34 +03:00
Pauli Virtanen d0d783541d bluez5: reduce the number of registered Opus endpoints
The different source modes can share the same endpoint.
2022-10-26 18:59:26 +03:00
Pauli Virtanen d94832942e bluez5: allow codecs to share endpoints
AVDTP in principle allows 62 endpoints, but in practice it appears some
devices (Samsung Galaxy Buds2 Pro, Redmi Buds 3 Lite, probably others)
fail to connect A2DP when the number is somewhere above 24.  A2DP
connection works when initiated from the Central, but not when the
device itself does it, so these devices are not fully broken.  We should
reduce the number of registered A2DP endpoints to avoid running into
problems with such broken devices.

Some of our source codecs are the same actual codec with the same
configuration, and don't need separate source endpoints.

Allow codecs to not have a registered endpoint (fill_caps == NULL), and
tolerate codecs with the same endpoint name.  In codec switch, keep
track separately which of the codecs with the same endpoint name the
local endpoint is currently associated with.
2022-10-26 18:59:26 +03:00
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