Commit graph

3402 commits

Author SHA1 Message Date
Wim Taymans f62c40c205 acp: also add the Pro profile for UCM devices 2023-01-03 13:17:10 +01:00
Wim Taymans 3595e31124 acp: add ports only when there are ucm devices 2023-01-03 13:16:06 +01:00
Wim Taymans 2eaac9b67a acp: mark the Pro profile with a flag 2023-01-03 13:13:03 +01:00
Pauli Virtanen b0853ad34a bluez5: media-sink: set initial latency after getting transport
The call to set_latency doesn't do anything, before transport has been
set.
2022-12-21 16:42:04 +02:00
Pauli Virtanen c7b3ef0d9f bluez5: backend-native: fix missing brace in CIND reply
It should look like ...,("battchg,(0-5)) not ...,"battchg",(0-5))
2022-12-21 12:55:20 +02:00
Wim Taymans 9c2b2a64f0 audioconvert: improve debug output
Print channelmix matrix when there is something to print. Avoids
skipping zero matrix lines in some cases.
2022-12-16 19:50:45 +01:00
Wim Taymans 6a69152185 acp: add api.acp.probe-rate option
Add an option to configure the samplerate used for probing because the
default 48KHz might not work for everyone.

See also #1599
2022-12-16 12:57:17 +01:00
Wim Taymans 7758240c79 bluez: fix compilation without ldac_abr
The define for this constant was removed but it was LDACBT_EQMID_MQ
before.
2022-12-15 12:20:40 +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
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 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
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
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 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 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
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
Wim Taymans 80cb1d2566 acp: ignore_dB should be passed around to device
Don't only use the ignore_dB property for the profile sets but also when
setting up the mixer of a device, like pulseaudio does.
2022-12-06 13:39:45 +01:00
Robert Mader fa799aac86 libcamera: Implement SPA_META_VideoTransform support
libcamera can detect camera transforms/rotation, e.g. from the device
tree, and makes that information usable for clients via
`CameraConfiguration::transform`.
Advertise this information via the VideoTransform meta so Pipewire
clients can adjust their output accordingly.

Rotated cameras are common in mobile devices such as the Pinephone Pro,
which was used to test this feature.
2022-12-05 18:25:36 +01:00
Wim Taymans bc2cf226d7 aec-webrtc: clarify comment
drift-compensation is not needed because PipeWire already does drift
compensation between all sinks and sources linked to the resampler.

See #2692
2022-12-05 12:01:23 +01:00
Wim Taymans 03f9466c5d audioadapter: improve PortConfig enumeration
When in passthrough mode and there is no converter, simply return
our own PortConfig parameter with our direction and passthrough mode.

Otherwise, use the PortConfig from the converter but filter out only the
PortConfig that matches our direction.

This fixes enumeration of PortConfig on the adapter.
2022-12-05 11:45:44 +01:00
Wim Taymans 5bda4b6a57 audioadapter: only accept PortConfig for the adapter direction 2022-12-05 11:45:10 +01:00
Wim Taymans 177479dfd1 audioconvert: improve some more AVX2 code 2022-12-05 09:37:29 +01:00
Wim Taymans d6101d73e7 audioconvert: fix PortConfig enumeration
Enumerate what we can support in EnumPortConfig.
Enumerate what is configured in PortConfig.
2022-12-05 09:15:48 +01:00
Wim Taymans 4e4d76ccd0 audioconvert: use gather in AVX2 code 2022-12-04 20:38:35 +01:00
Frédéric Danis 90d00551b7 bluez5: sco-sink: Remove unused variable 2022-12-02 11:11:47 +01:00
Pauli Virtanen 9496078be5 bluez5: add bluetoothOffloadActive device prop for acquiring transports
Add a device prop that causes transports to be acquired.
2022-12-02 11:11:47 +01:00
Wim Taymans 61e600970b loop: improve error handling from fds
When we try to read one of the events and there was an error, don't
signal the callback. If the error is something else than EAGAIN log
a warning.

Especially for timerfd, EAGAIN can happen when the timer changed
while polling. This can happen when running the profiler because it
polls and updates the timer from different threads.
2022-12-01 20:03:06 +01:00
Robert Mader 75007ae94f libcamera: Fix build error
This is backward compatible and will be needed for libcamera 0.0.3
2022-11-30 09:53:17 +00:00
Robert Mader b952d52b59 libcamera: Handle missing control info default values
Libcamera does not always provide default values for all control infos, see
https://git.libcamera.org/libcamera/libcamera.git/tree/src/ipa/rkisp1/rkisp1.cpp?h=v0.0.2#n98

Sanitize those values, avoiding crashes.
2022-11-30 09:53:17 +00:00
columbarius 01b2552b71 spa: Add buffer meta information VideoTransform
This metadata can be used to signal that a buffer is transformed.
The values are intentionally choosen to coincide with
wl_output::transform from the wayland windowsystem.
2022-11-24 10:28:01 +00:00
Bart Ribbers c939a9edf7
spa/bluez: remove unused import fixing Musl builds with lc3
The include defines things like __uint16_t but these are unused here and glibc-specific anyway
2022-11-23 13:47:14 +01:00
Wim Taymans 4c3f56fca1 resample: cleanup the resampler core functions
Move the increment function to a macro.
Don't use extra local variables, we can just as well call the resample
functipon with them.
2022-11-20 16:19:24 +01:00
Wim Taymans bb558b7d95 audioconvert: don't overwrite port
Make a new variable to iterate the other ports so that we can use the
original port to emit notifications.

Fixes Latency and other params set on DSP ports.
2022-11-18 13:21:14 +01:00
Wim Taymans 43d02410e6 audioconvert: don't handle params when just enumerating
When we are simply enumerating the params, just collect the info
but don't act on them, like clearing the format or recalculating
the latency.

This avoids some useless work when enumerating params.

Use the more complete configure_format function to clear the format
and buffers when the EnumFormat param changed.
2022-11-18 09:34:37 +01:00
Wim Taymans 82f7ed419c audioconvert: shortcut configure_format
When we don't have a format and can't to clear it, we can return
immediately.
2022-11-18 09:29:23 +01:00
Wim Taymans bc66060b7d audioconvert: also clear buffer when new EnumFormat
Fixes #2832
2022-11-17 19:41:12 +01:00
Wim Taymans 90f5b4a4bf audioconvert: improve renegotiation
When the follower updates EnumFormat, it probably wants to renegotiate
to a new format, so clear the current format so that we do that when
starting the next time.

EnumFormat should also not only return the current format in case we
are negotiated but it should return all possible formats.

See #2832
2022-11-17 19:26:46 +01:00