Commit graph

9913 commits

Author SHA1 Message Date
Wim Taymans
9b3b6e2401 pipewire: support global log level in PIPEWIRE_DEBUG
Add support for PIPEWIRE_DEBUG=3,foo.bar:5 to set a global log level in
addition to specific topics.

Previously it would have to be done with *:3,foo.bar:5, which would not
really set a global level but all topics to the custom level of 3.
2022-12-14 18:00:54 +01:00
Wim Taymans
da3273891c tests: add another pw_split_strv test
To check if an empty string after a delimiter is counted.
2022-12-14 16:56:17 +01:00
Wim Taymans
72bee99f87 pulse-server: add category for connection debug
Use a new conn. topic to debug the messages. These are disabled by
default.
2022-12-14 16:40:58 +01:00
Wim Taymans
34973eac89 pipewire: fix pw_debug_is_category_enabled()
The function was broken since the log topics were added.

Use the logger to init a topic with the given name and check if
there was a custom level for the topic.
2022-12-14 16:20:23 +01:00
Wim Taymans
e5ac60b2b2 alsa: increase target for a52 and dca
For encoded format, we need to send bigger chunks to make the encoder
happy. Add a new min_delay variable with this info so that we never
leave less than that amount of samples in the ringbuffer.

Fixes #2650
2022-12-14 12:41:22 +01:00
Dylan Aïssi
cbc75dc98d pw-mon: recognize -N and -C as valid options 2022-12-14 11:07:42 +01:00
Wim Taymans
50dad68eb4 midi: fix midi event sorting
The high bit is always 1 so we can use only the lower 3 bits for the
priority.
2022-12-13 16:41:20 +01:00
Wim Taymans
144df8675f audioconvert: enable channelmix.mix-lfe by default
It seems OK and SDL also seems to mix LFE by default so what could
possibly go wrong.

Fixes #2425
2022-12-13 16:29:46 +01:00
Jonas Holmberg
6d6a5e2dbb alsa-pcm: avoid an expected resync warning
Log resync message as info when reassigning follower.
2022-12-13 14:47:04 +01:00
Wim Taymans
480902eb3a jack: sort midi events better
Use the same sorting as ardour for midi events with the same timestamp
so that the order is:

Controller messages > Program Change > Note Off > Note On >
    Note Pressure > Channel Pressure > Pitch Bend

Fixes #1868
2022-12-13 13:01:26 +01:00
Wim Taymans
61750813ff filter-chain: move buffer resample to separate function
Fix the error paths.
Rename some variables around to make things clearer.
2022-12-13 12:18:46 +01:00
Dmitry Sharshakov
28af79be79 filter-chain: convolver: flush, add resampler quality option
Robustness fix: don't truncate IR, free the resampler state after use.
2022-12-13 10:09:55 +00:00
Dmitry Sharshakov
7950d3ff0d filter-chain: convolver: resample IR
Ensure correct filtering when node rate does not match filter rate
2022-12-13 10:09:55 +00:00
Wim Taymans
b5c21c1fbc pipewire: use dlclose unless PIPEWIRE_DLCLOSE is set to false
Always dlclose the libraries but use PIPEWIRE_DLCLOSE to override this
behaviour.

Fixes #2786
2022-12-12 17:11:04 +01:00
Wim Taymans
b29200ee82 pulse-server: add a pulse.cmd section
Add a new config section that can contain a set of commands to run after
starting.

There is only load-module available now but it can be used to remove the
dependency on pactl when starting the server.
2022-12-12 16:46:16 +01:00
Wim Taymans
87d2719148 utils: expose pw_split_ip 2022-12-12 16:45:30 +01:00
Mersad Jelacic
72f5dbe6a6 doc: Change variable name to 'SPA_PLUGIN_DIR'
Sync with 'SPA_PLUGIN_DIR' name that is used in code.

Change-Id: Ibd8f84dd2aaf4ba7f581ad44140bf7b46ae43709
2022-12-12 10:53:15 +01:00
Wim Taymans
63f279c826 audioconvert: remove default channel map
If there is no valid channel map, assume MONO channels. A valid channel
map should be assigned at the source of the data, not here.

The problem is that when a device uses AUX channels, this will be fixed
up here with a surround setup, which is not right.
2022-12-12 09:40:51 +01:00
Wim Taymans
8d4fe59764 audioconvert: improve debug
When we are mixing unnamed channels, place MONO in the debug output.
2022-12-12 09:38:51 +01:00
Sefa Eyeoglu
b927063b89
audioconvert: fix distorted audio on AVX2
Closes pipewire/pipewire#2885

Signed-off-by: Sefa Eyeoglu <contact@scrumplex.net>
2022-12-11 20:16:03 +01:00
Barnabás Pőcze
8c892443eb spa: audioadapter: fix stack-use-after-scope when configuring format
It is not enough for `buffer` to be alive in its current
scope because when execution enters that branch, `format`
will be set to `fmt`, which points inside `buffer`. And
since `format` is used outside that scope, `buffer` must
live longer.

This was detected by ASAN when Audacity was starting up.

  ==25007==ERROR: AddressSanitizer: stack-use-after-scope on address 0x7ffdbcfef560 at pc 0x7fe44ca95db3 bp 0x7ffdbcfeeda0 sp 0x7ffdbcfeed90
  READ of size 4 at 0x7ffdbcfef560 thread T0
      #0 0x7fe44ca95db2 in spa_pod_parser_pod ../spa/include/spa/pod/parser.h:67
      #1 0x7fe44ca9a805 in spa_format_parse ../spa/include/spa/param/format-utils.h:44
      #2 0x7fe44cad293a in port_set_format ../spa/plugins/audioconvert/audioconvert.c:1934
      #3 0x7fe44cadad14 in impl_node_port_set_param ../spa/plugins/audioconvert/audioconvert.c:2038
      #4 0x7fe44ca587e2 in configure_format ../spa/plugins/audioconvert/audioadapter.c:509
      #5 0x7fe44ca60dff in negotiate_format ../spa/plugins/audioconvert/audioadapter.c:822
      #6 0x7fe44ca62bbf in impl_node_send_command ../spa/plugins/audioconvert/audioadapter.c:846
      #7 0x7fe45ea1c2f1 in node_update_state ../src/pipewire/impl-node.c:407
      #8 0x7fe45ea5137e in pw_impl_node_set_state ../src/pipewire/impl-node.c:2251
      #9 0x7fe45eb3355f in pw_work_queue_destroy ../src/pipewire/work-queue.c:142
      #10 0x7fe45b2cd6f4 in source_event_func ../spa/plugins/support/loop.c:615
      #11 0x7fe45b2c634f in loop_iterate ../spa/plugins/support/loop.c:452
      #12 0x7fe45e9ebebc in spa_hook_list_clean ../spa/include/spa/utils/hook.h:395
      #13 0x5561e03dc722 in main ../src/daemon/pipewire.c:131
      #14 0x7fe45da3c28f  (/usr/lib/libc.so.6+0x2328f)
      #15 0x7fe45da3c349 in __libc_start_main (/usr/lib/libc.so.6+0x23349)
      #16 0x5561e03db2a4 in _start ../sysdeps/x86_64/start.S:115

  Address 0x7ffdbcfef560 is located in stack of thread T0 at offset 160 in frame
      #0 0x7fe44ca56fa9 in configure_format ../spa/plugins/audioconvert/audioadapter.c:475

    This frame has 4 object(s):
      [32, 36) 'state' (line 493)
      [48, 56) 'fmt' (line 494)
      [80, 128) 'b' (line 492)
      [160, 4256) 'buffer' (line 491) <== Memory access at offset 160 is inside this variable
2022-12-10 09:59:08 +00:00
Barnabás Pőcze
3bdd2e01c5 pipewire: store SPA handles in a global list by age
Operating on the assumption that every SPA handle
can reference any other older SPA handle, the only
safe destruction order is from youngest to oldest.

To achieve this, store all handles across all plugins
sorted by age (youngest first), and use that as the
order of destruction in `pw_deinit()`.

This line of thinking does not account for what happens
when a handle that is referenced by others is unloaded,
but it does not make that case worse either.

See #2881
2022-12-10 00:46:37 +01:00
Wim Taymans
d4eff5b058 fix build some more. 2022-12-09 18:10:15 +01:00
Wim Taymans
a52ecd02df fix build some more... 2022-12-09 18:05:01 +01:00
Wim Taymans
61951dd327 fix build 2022-12-09 17:43:34 +01:00
Wim Taymans
f44d55f6c2 handle read from timerfd correctly
When reading the timerfd gives an error, we should return right away
because the timeout did not happen.

If we change the timerfd timeout before reading it, we can get -EAGAIN.
Don't log an error in that case but wait for the new timeout.
2022-12-09 17:30:31 +01:00
Wim Taymans
3a443b4e1c 0.3.62 2022-12-09 11:28:24 +01:00
Jonas Holmberg
4e3103f566 audioconvert: change warning to info
Change log level to info when stopped node gets ready callback since it
can happen and it is not a problem.
2022-12-09 11:20:20 +01:00
Wim Taymans
bccd33c4ab Revert "audioadapter: only accept PortConfig for the adapter direction"
This reverts commit 5bda4b6a57.

The reason is that when you use a null-audio-sink as a source, the
adapter will think it's a sink while wireplumber will try to use it as a
source.

There is no quick solution for this so revert this check for now.
2022-12-09 10:51:05 +01:00
Wim Taymans
45235172c8 pulse-server: disable idle.timeout by default
Only enable pulse.idle.timeout for selected applications
(speech-dispatcher) and let other applications be. We can also
lower the minreq and min-quantum of speech-dispatcher now.

Fixes #2880
2022-12-09 10:00:32 +01:00
Wim Taymans
a6f8790ece pw-top: log core errors, silence other errors with info 2022-12-08 17:29:19 +01:00
Wim Taymans
ced0f853a1 impl-node: improve state change when driver changes
Imagine this case with pw-loopback:
 - the output stream is created and connected
 - the input stream is created and connected
 - the output stream is linked first and input+output move to the
   sink as the driver. Start is sent to input+output but delayed
   for the driver until all is complete.
 - the input stream is linked to a source. The source becomes the
   new driver and input+output+sink is moved to the source.
 - all completes, the source is sent the Start command because it is
   a driver. The sink also completes but is not sent a Start Command
   because it is no longer a driver.
   -> sink is scheduled but not started and gives errors

This patch clears the pending state of a driver when it is no longer
a driver. This makes the new driver set a new state (and cancel the
old state) and all followers will start correctly.
2022-12-08 16:24:52 +01:00
Wim Taymans
638de5a3b7 gst: set stride to 0
We don't really know any better yet.
2022-12-08 13:39:58 +01:00
Wim Taymans
8db85cf198 examples: handle 0 stride better
Assume the stride is size/height in case someone doesn't set the stride
correctly.
2022-12-08 13:39:58 +01:00
Jonas Holmberg
83f1de95c0 module-loopback: connect playback before capture
Connect the playback stream before the capture stream since the capture
stream can otherwise trigger playback_process() before the playback node
has been activated.
2022-12-08 13:31:45 +01:00
Wim Taymans
dee2a51eb0 impl-node: don't pass the -EBUSY to the caller
Let the caller receive EBUSY from the _set_state method instead of
an error code to make sure it doesn't go into error.
2022-12-08 12:38:36 +01:00
Wim Taymans
9bf6fa05d1 module-rtp-sink: silence some messages 2022-12-08 12:10:22 +01:00
Wim Taymans
2f397035b8 modules: don't call pw_stream_set_control in process
pw_stream_set_control can only be used from the pipewire main_loop, not
the process callback. Instead, use the rate_match field directly.

Fixes #2633
2022-12-08 11:01:24 +01:00
Wim Taymans
ddf6e7ae91 loop: don't write from multiple threads
We can only write from one thread to the ringbuffer so bypass the
ringbuffer when doing in-thread invoke. Only flush the current
items so that out-of-thread items don't get inserted.
2022-12-08 08:01:40 +01:00
Wim Taymans
8ecfcbf884 loop: support recursive loop flush
Always append the item to the ringbuffer, even if we are invoking from
the thread itself. This ensure all items are always invoked in the
right order.

If we invoke from the thread, flush all items of the ringbuffer and
return.

Make sure to set the callback to NULL before invoking so that recursive
invoke doesn't call it again.

When while flushing the items we get a recursive invoke, detect this
with a counter and return immediately.
2022-12-07 22:00:58 +01:00
Wim Taymans
40f58f43fb impl-link: small cleanups
Use inode and onode for input and output nodes when deactivating, like
we do for activate.
2022-12-07 21:56:24 +01:00
Wim Taymans
19964963d3 impl-node: don't do IPC from data-loop 2022-12-07 21:19:57 +01:00
Wim Taymans
97f95f51c5 loop: only flush pending items
Mostly useful for when invoking from the thread itself so that the new
invoke item is executed before new items are added.

Imagine this case with module-loopback:
     - data-loop goes into the capture process function
          - mainloop invokes node remove of capture and waits
     - data-loop invokes trigger -> node remove is first executed, mainloop
                                    is woken up
          - mainloop continues
    	  - mainloop invokes remove of playback and waits
     - data-loop continues flushing the ringbuffer -> playback remove is
                                 executed, mainloop wakes up
    	  - mainloop continues destroying items, frees playback
    	    and capture streams
     - data-loop finaly gets to flush the trigger and crashes because
            streams are gone.
2022-12-07 19:52:13 +01:00
Wim Taymans
7b61bf8c8a improve debug 2022-12-07 16:01:16 +01:00
Robert Mader
59d393bd30 libcamera: Fix 90/270 degree transforms
`Transform::Rot90` means the client should rotate 90 deg. clockwise,
which matches `SPA_META_TRANSFORMATION_90`, i.e. the buffer was
rotated 90 deg. anti-clockwise. The flipped cases should be correct
though.

Also add the source value to the debug print for easier future
debugging.

Fixes fa799aac86
2022-12-07 14:15:59 +01:00
Wim Taymans
cf3d4c3b5d audioadapter: clear started flag earlier
First clear the started flag so that we ignore scheduling from the
follower. Then stop the follower and the converter.

This is the sequence we follow when deactivating a node, so do the
same here.

it is important that the node is not scheduled anymore when we clear
the format in suspend or else we might crash.

See #2877
2022-12-07 13:12:18 +01:00
Wim Taymans
3e000c11c4 acp: do probing in 48000 Hz again
And... we're back to 48Khz probing. Some devices fail to probe with
44.1KHz so when we need to choose between 2 bad things we choose to
do the right thing, which is probe in 48KHz.

Fixes #2857
2022-12-07 12:21:32 +01:00
Torkel Niklasson
126bcd200b modules: Change some core errors to info
Modules echo-cancel, filter-chain and loopback may print errors if no
applicable target nodes exist when they start up. For our products this
is not considered error/warning worthy, since the issue will resolve
itself once the target nodes exist.
2022-12-07 11:36:30 +01:00
Wim Taymans
37439d2b73 pulse-server: add gsettings module
Uses a thread to monitor gsettings data. Loads and unload modules
based on gsettings.

This makes paprefs work.
2022-12-07 09:45:43 +01:00
Wim Taymans
89d4cafec4 pulse-server: fix module args 2022-12-06 19:02:02 +01:00