Commit graph

10197 commits

Author SHA1 Message Date
Sanchayan Maity
65f3a9c481 cpu-arm: Fix incorrect free
A bug was introduced with the refactoring in da26563. In arm_init,
the buffer passed to spa_cpu_read_file is allocated and it is just
going to return that. So cpuinfo will actually point to buffer on
the stack, which need not be freed with a call to free.

The crash resulting with the incorrect free.

root@dragonboard-845c:~# pipewire --version
munmap_chunk(): invalid pointer
[  185.037284] audit: type=1701 audit(1659949975.843:14): auid=4294967295 uid=0 gid=0 ses=4294967295 pid=2243 comm="pipewire" exe="/usr/bin/pipewire" sig=6 res=1
Aborted
root@dragonboard-845c:~# wireplumber --version
munmap_chunk(): invalid pointer
[  193.453693] audit: type=1701 audit(1659949984.255:15): auid=4294967295 uid=0 gid=0 ses=4294967295 pid=2244 comm="wireplumber" exe="/usr/bin/wireplumber" sig=6 res=1
Aborted

Backtrace from the crash

(gdb) bt
!0  __pthread_kill_implementation (threadid=<optimized out>, signo=signo@entry=6, no_tid=no_tid@entry=0) at pthread_kill.c:44
!1  0x0000fffff7d8edd8 in __pthread_kill_internal (signo=6, threadid=<optimized out>) at pthread_kill.c:78
!2  0x0000fffff7d4a390 in __GI_raise (sig=sig@entry=6) at /usr/src/debug/glibc/2.36-r0/sysdeps/posix/raise.c:26
!3  0x0000fffff7d37498 in __GI_abort () at abort.c:79
!4  0x0000fffff7d83374 in __libc_message (action=action@entry=do_abort, fmt=fmt@entry=0xfffff7e5fc20 "%s\n") at /usr/src/debug/glibc/2.36-r0/sysdeps/posix/libc_fatal.c:155
!5  0x0000fffff7d988c0 in malloc_printerr (str=str@entry=0xfffff7e5a7f0 "munmap_chunk(): invalid pointer") at malloc.c:5660
!6  0x0000fffff7d98aac in munmap_chunk (p=p@entry=0xffffffffd258) at malloc.c:3054
!7  0x0000fffff7d9d068 in __GI___libc_free (mem=mem@entry=0xffffffffd268) at malloc.c:3375
!8  0x0000fffff7cd36cc in arm_init (impl=impl@entry=0xaaaaaaac8c48) at /usr/src/debug/pipewire/1.0-r0/spa/plugins/support/cpu-arm.c:97
!9  0x0000fffff7cd391c in impl_init (factory=<optimized out>, handle=0xaaaaaaac8c48, info=0xffffffffe548, support=<optimized out>, n_support=<optimized out>) at /usr/src/debug/pipewire/1.0-r0/spa/plugins/support/cpu.c:264
!10 0x0000fffff7f3a234 in load_spa_handle (lib=<optimized out>, factory_name=factory_name@entry=0xfffff7f6d768 "support.cpu", info=info@entry=0xffffffffe548, n_support=1,
    support=support@entry=0xfffff7fb0488 <global_support+88>) at /usr/src/debug/pipewire/1.0-r0/src/pipewire/pipewire.c:280
!11 0x0000fffff7f3a5b0 in add_interface (factory_name=factory_name@entry=0xfffff7f6d768 "support.cpu", type=type@entry=0xfffff7f62310 "Spa:Pointer:Interface:CPU", info=info@entry=0xffffffffe548,
    support=0xfffff7fb0430 <global_support>) at /usr/src/debug/pipewire/1.0-r0/src/pipewire/pipewire.c:358
!12 0x0000fffff7f3b3f8 in pw_init (argc=argc@entry=0xffffffffea5c, argv=argv@entry=0xffffffffea50) at /usr/src/debug/pipewire/1.0-r0/src/pipewire/pipewire.c:661
!13 0x0000aaaaaaaa1104 in main (argc=<optimized out>, argv=<optimized out>) at /usr/src/debug/pipewire/1.0-r0/src/daemon/pipewire.c:79
(gdb) f 8
!8  0x0000fffff7cd36cc in arm_init (impl=impl@entry=0xaaaaaaac8c48) at /usr/src/debug/pipewire/1.0-r0/spa/plugins/support/cpu-arm.c:97
97      /usr/src/debug/pipewire/1.0-r0/spa/plugins/support/cpu-arm.c: No such file or directory.
(gdb) info locals
flags = 122
cpuinfo = 0xffffffffd268 "processor\t: 0\nBogoMIPS\t: 38.40\nFeatures\t: fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm lrcpc dcpop\nCPU implementer\t: 0x51\nCPU architecture: 8\nCPU variant\t.
line = 0xaaaaaaac8ce0 "\310\252\252\252\n"
buffer = "processor\t: 0\nBogoMIPS\t: 38.40\nFeatures\t: fp asimd evtstrm aes pmull sha1 sha2 crc32 atomics fphp asimdhp cpuid asimdrdm lrcpc dcpop\nCPU implementer\t: 0x51\nCPU architecture: 8\nCPU variant\t: 0x7\nCPU pa"...
arch = <optimized out>
__func__ = "arm_init"
2023-01-14 19:51:33 +00:00
Lukas Rusak
da7673ca6e
spa: fix documentation for SPA_FORMAT_AUDIO_position
spa_audio_position isn't a valid enum. The actual enum is spa_audio_channel

Signed-off-by: Lukas Rusak <lorusak@gmail.com>
2023-01-13 21:25:36 -08:00
Wim Taymans
792defde27 adapter: only add port name override when not empty
This makes it possible to add an empty string to keep the original
port name.
2023-01-13 17:52:24 +01:00
Wim Taymans
7072f2b78a spa: fix switch on media_subtype 2023-01-13 17:39:33 +01:00
Josh Lay
5b42c07b15 Add support for GSX 1000 v2 2023-01-13 12:19:30 +00:00
Wim Taymans
9a580362a7 spa: fix includes 2023-01-13 11:41:38 +01:00
Wim Taymans
00ae289a14 spa: reorganize params
Split files into separate files.
Move type annotations to a matching -types.h files.
Move helpers to matching -utils.h files.
Add helpers to parse generic audio and video info.
2023-01-13 11:02:51 +01:00
Dylan Aïssi
4e9c3b26d9 doc: remove duplicate FULL_PATH_NAMES field
FULL_PATH_NAMES is defined twice. Remove the one set to YES
since including the full path breaks reproducible builds.

See https://reproducible-builds.org/docs/build-path/
2023-01-12 18:09:54 +01:00
Dylan Aïssi
4329961a67 man: fix typo in pw-link: Whithout -> Without 2023-01-12 18:08:28 +01:00
Dylan Aïssi
d653f26343 man: fix typo in pw-cat: seperator -> separator 2023-01-12 18:07:57 +01:00
Robert Mader
6bf47e0bfa pipewiresrc: Always advertise support for DmaBuf
Quoting https://docs.pipewire.org/page_dma_buf.html section "v4l2":
```
It's the the responsibility of the producer while the add_buffer event
to choose DMA-BUF as the used buffer type even though no modifier is
present, if it can guarantee, that the used buffer is mmapable.
```

As Gstreamer internally can mmap dmabufs just fine, support this case.
This enables dmabuf support with V4L2 and libcamera.

This was also tested against Gnome-Shell, which correctly handles this
case and only chooses DmaBuf if the negotiated format has a modifier,
i.e. if the Gstreamer peer supports the format with
`GST_CAPS_FEATURE_MEMORY_DMABUF`.

Fixes 602aa7d541
2023-01-12 11:27:27 +00:00
Robert Mader
17c53577e8 gst: Log buffer memory type
This is helpful when one wants to ensure the right memory type is used,
independently from the negotiated format.
2023-01-12 11:27:27 +00:00
Robert Mader
714b438814 libcamera: Check format info for correct flags and modifier 2023-01-12 11:22:25 +00:00
Robert Mader
c61b9a09b8 video: Add SPA_VIDEO_FLAG_MODIFIER flag
The drm format modifier value `0` is actually `DRM_FORMAT_MOD_LINEAR`,
a commonly used modifier. Unfortunately there appears to be no value
that can savely used as placeholder for "no value", as e.g.
`DRM_FORMAT_MOD_INVALID` is often used to indicate an implicit modifier.

Thus add a new flag that clearly indicates whether the modifier
value is set or not, add it to `spa_video_info_raw` and the util
functions.

Closes https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/2943
2023-01-12 11:22:25 +00:00
Wim Taymans
da26563a83 cpu: clean up
Change read_file to spa_cpu_read_file and remove static because it might
not be used for some cpus.
Use spa_cpu_read_file in arm cpu detection.
2023-01-12 12:20:30 +01:00
Wim Taymans
bba452695e 0.3.64 2023-01-12 10:31:04 +01:00
Dmitry Sharshakov
09f00b5086 v4l2: support setting target source 2023-01-11 11:43:37 +00:00
Wim Taymans
afedd107a8 Revert "video: Add extra field indicating if modifier value is valid"
This reverts commit 1e6920c33b.

Causes an ABI break.
2023-01-11 12:21:42 +01:00
Wim Taymans
bdc0720bcb Revert "libcamera: Implement proper dmabuf negotiation support"
This reverts commit 950b62a8d8.

It depends on ABI break
2023-01-11 12:21:32 +01:00
Robert Mader
950b62a8d8 libcamera: Implement proper dmabuf negotiation support
According to https://docs.pipewire.org/page_dma_buf.html, i.e. announce
each format once with, once without `SPA_FORMAT_VIDEO_modifier`
property.

Note: currently libcamera always uses `DRM_FORMAT_MOD_LINEAR` (`== 0`),
so `pix.modifier()` returning `0` does not mean that no modifier is
supported.

This is needed for clients using the new DMABuf negotiation pattern,
such as gstpipewiresrc after 602aa7d5.
2023-01-11 01:39:42 +01:00
Robert Mader
1e6920c33b video: Add extra field indicating if modifier value is valid
The drm format modifier value `0` is actually `DRM_FORMAT_MOD_LINEAR`,
a commonly used modifier. Unfortunately there appears to be no value
that can savely used as placeholder for "no value", as e.g.
`DRM_FORMAT_MOD_INVALID` is often used to indicate an implicit modifier.

Thus add an extra field that clearly indicates whether the modifier
value is set or not, add it to the util fuctions and use it for the
current only user, the libcamera backend.

Fixes 5a6da7d5e1

Closes https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/2943
2023-01-10 22:01:31 +01:00
Wim Taymans
cab3e3c1ce clarify deprecated use of NODE_TARGET 2023-01-10 17:21:02 +01:00
Wim Taymans
c3032c70b6 keys: move NODE_TARGET to deprecated properties
Add PW_ENABLE_DEPRECATED to some places where we can not yet
avoid removing support.
2023-01-10 17:17:34 +01:00
Wim Taymans
95f87301c7 clarify PIPEWIRE_NODE
PIPEWIRE_NODE is mapped to TARGET_OBJECT so it contains the serial or
the node name.
Make sure pw-stream maps this to TARGET_OBJECT.
Make JACK use the PIPEWIRE_NODE for serial or node.name.
2023-01-10 17:11:43 +01:00
Wim Taymans
2254c74fb9 use TARGET_OBJECT instead of the deprecated NODE_TARGET
Clarify the docs.
2023-01-10 16:51:47 +01:00
Wim Taymans
a7df07c449 gst: don't set the deprecated path anymore
Just use the target_object property instead which uses the object.serial
is is less prone to races when the object id is recycled.
2023-01-10 16:47:47 +01:00
Wim Taymans
1beddd78d2 tools: clarify the target param
The target param is an object.serial or node.name.
Use TARGET_OBJECT instead of NODE_TARGET.
2023-01-10 16:45:50 +01:00
Wim Taymans
8767e8ed97 pulse-server: handle .monitor master source 2023-01-10 16:22:39 +01:00
Wim Taymans
ff69454eb4 pulse-server: use TARGET_OBJECT
The pulse API uses either the node.name or object.serials so pass this
along in the TARGET_OBJECT instead of the NODE_TARGET now that
wireplumber handles this.
2023-01-10 16:05:55 +01:00
Wim Taymans
624e265fd6 pulse-server: clear the drained state correctly
When we start the drain, we unpause the stream. When we conplete the
drain, we unpause again, which does nothing when the stream was already
unpaused. However, this leaves the drained state on the stream and so
the stream will never be able to play new data.

Trigger a new pw_stream_set_active() with the current stream state to
clear the drained state.

Fixes #2928
2023-01-10 12:49:22 +01:00
Wim Taymans
97aafe2234 fix use_buffers checks
We can set 0 buffers even if there is no format.
Return -ENOSPC when too many buffers are set.
2023-01-10 12:30:25 +01:00
Wim Taymans
9f3237b74e context: keep per node quantum and rate settings
Copy the global quantum and rate limits before applying node specific
settings. Otherwise one node settings will propagate to the defaults
of the next nodes, which can result in impossible or wrong settings.

See #2925
2023-01-09 17:56:04 +01:00
Dmitry Sharshakov
395749fea9 v4l2: cleanup and simplify
Co-authored-by: Barnabás Pőcze <pobrn@protonmail.com>
2023-01-09 12:27:17 +00:00
Dmitry Sharshakov
996f8a5832 v4l2: ignore symlinks in case of openat passthrough 2023-01-09 12:27:17 +00:00
Wim Taymans
ba374a7b47 impl-node: restore running state after reconfigure
Add a reconfigure state on the node that is set when the node was IDLE
or RUNNING when reconfigured.

The node state will be set to the running state as long as the
reconfigure state is active. When the node is running, the reconfigure
state is unset again and the node is allowed to IDLE as usual.

This fixes the case where an IDLE (but not paused node) will be
suspended when a rate change happens but will then not resume
afterwards.

This causes problems with rate changes and nodes that have the suspend
disabled by the session manager. They will be suspened anyway and this
can cause problems for devices that need to keep running to keep the
amplifiers active.

Fixes #2929
2023-01-09 11:49:10 +01:00
Wim Taymans
07633f2146 context: rename a method
Rename suspend_driver -> reconfigure_driver because that is more like
what it does.
2023-01-09 11:49:10 +01:00
Wim Taymans
e099f0598a pw-reserver: improve output a little 2023-01-09 11:49:10 +01:00
Wim Taymans
26496724c6 impl-node: move 2 state variables to private
So that they can be used when making scheduler decisions.
2023-01-09 11:49:10 +01:00
Wim Taymans
0ddf80d470 midifile: error won invalid track size
When the track data would exceed the file size, return an error.
2023-01-09 11:49:10 +01:00
Wim Taymans
6a516b9505 context: fix typo in comment 2023-01-09 11:49:10 +01:00
Robert Mader
602aa7d541 pipewiresrc: Reenable DMABuf support
This was disabled in 15b4c58e as under various circumstances Gstreamer
pipelines would mmap the DMABufs, which can be very slow in various cases.
One typical example of that is screen casting using a dedicated graphics card.

Thus we only want to use DMABufs if the peer element advertises support for
`GST_CAPS_FEATURE_MEMORY_DMABUF`, ensuring no mapping will happen if we
set the format accordingly.

This allows pipewiresrc to be used with DMABufs for fully accelerated
pipelines or in combination with a download element such as `gldownload`[1]
without regressing the commit above. The `gldownload` approach mirrors
what webrtc (Chromium/Firefox) does, but without duplicating the
functionality into pipewiresrc.

While on it, also implement dmabuf negotiation according to
https://docs.pipewire.org/page_dma_buf.html with the modifiers
`DRM_FORMAT_MOD_INVALID` and `DRM_FORMAT_MOD_LINEAR` in order to allow
dmabuf negotiation with more modern clients, including Gnome-Shell.

1: for now use something like `glupload ! glcolorconvert ! gldownload` -
   `gldownload` does not support importing DMABufs yet but `glupload` does.
2023-01-08 09:17:19 +00:00
Dmitry Sharshakov
549e543444 v4l2: report framerate using VIDIOC_G_PARM 2023-01-08 09:12:33 +00:00
Jan Beich
6d58c73937 module-rt: fix warning when xdg-desktop-portal isn't running
$ pipewire
...
[W][1234.001] mod.rt       | [     module-rt.c:  278 pw_rtkit_check_xdg_portal()] Can't find xdg-portal: (null)
...
2023-01-08 07:29:42 +00:00
Wim Taymans
b2f43e7bad pulse-server: fix echo-cancel _master args
The sink_master and source_master should be set on the capture and
playback streams so use the new properties on module-echo-cancel to do
this.
2023-01-07 15:00:40 +01:00
Wim Taymans
feac9f1c70 module-echo-cancel: add capture and playback props
Add a capture.props and playback.props config section to set properties
for the capture and playback stream.

Fixes #2939
2023-01-07 13:58:30 +01:00
Dmitry Sharshakov
6fb543a514 adapter: support node.channel-names
Allow customizing channel names for nodes
2023-01-06 23:17:33 +03:00
Wim Taymans
4f458b5d9a filter-chain: dynamically allocate the params
Dynamically allocate the offsets and params arrays so that it can
support more than 512 params.

Fixes #2933
2023-01-06 12:41:06 +01:00
Robert Mader
be2757c121 gstpipewireformat: Fully handle SPA_CHOICE_Step
The step value was not used.
2023-01-06 11:16:52 +00:00
Robert Mader
0f4fcd63ac filter: Better SPA_CHOICE_Step support
Allow comparing single values with step-ranges. An example where this
can be useful is when trying to encode a screencast with a hardware
encoder.
2023-01-06 11:16:52 +00:00
Thomas Weißschuh
d4db7e1d9b pw-dump: sort dictionaries
Dictionaries are by default printed in their insertion order.
This is unergonimic when comparing properties created by different
clients, as they may insert them in different orders.
2023-01-06 11:15:17 +00:00