Commit graph

3448 commits

Author SHA1 Message Date
Pauli Virtanen fef0981488 bluez5: fixup BLE MIDI selinux README
The SELinux configuration should allow passing sockets also from PW to
bluetoothd.
2023-01-24 08:27:56 +00:00
Pauli Virtanen 25f36e4334 bluez5: add info key indicating glib mainloop is usable 2023-01-24 08:27:56 +00:00
Pauli Virtanen 93a473eff6 bluez5: prevent unloading spa-bluez5.so
GObject is not compatible with unloading shared libraries using it, so
add linker flags preventing that.
2023-01-24 08:27:56 +00:00
Pauli Virtanen 661569febc bluez5: use GDBus in midi-node 2023-01-24 08:27:56 +00:00
Pauli Virtanen 89542289ac bluez5: use GDBus in midi-server 2023-01-24 08:27:56 +00:00
Pauli Virtanen f1b5575ec3 bluez5: use GDBus in midi-enum 2023-01-24 08:27:56 +00:00
Pauli Virtanen de595a78ff bluez5: add GDBus-based object monitor framework 2023-01-24 08:27:56 +00:00
Pauli Virtanen 8d438d26ab bluez5: remove libdbus object manager wrappers 2023-01-24 08:27:56 +00:00
Pauli Virtanen bd45f846fc bluez5: midi: refcounting and other correctness fixes
Use stdalign.h instead of union.
Fix some refcounting and return values.
Fail early in add_filters.
Minor style cleanups.
Less magical spa_dbus_async_call.
2023-01-24 08:27:56 +00:00
Pauli Virtanen 2f8691b64f bluez5: add comments on possible SELinux + BLE MIDI issues 2023-01-24 08:27:56 +00:00
Pauli Virtanen e13fed1a80 bluez5: midi: put node nick in GATT Characteristic User Description
As server, put node nick in GATT Characteristic User Description, so
that clients have some information which endpoint is which in case we
have multiple.  This is not in BLE MIDI standard, but cannot hurt.

As client, make use of that information, if present.
2023-01-24 08:27:56 +00:00
Pauli Virtanen 2ef126885a bluez5: midi-node: implement server role 2023-01-24 08:27:56 +00:00
Pauli Virtanen d30a0c5ee6 bluez5: add MIDI server/peripheral implementation dbus part 2023-01-24 08:27:56 +00:00
Pauli Virtanen fe11bfdba0 bluez5: implement Bluetooth MIDI nodes
Implement BLE MIDI node, providing an input and output port.  MIDI data
received is normalized and produced on output port.  Data from input
port is converted to BLE MIDI and sent to the device.

Event timestamps come from device clock, whose offset to wall clock we
determine by correlating packet reception times with their timestamps.
The jitter in packet reception is likely much larger than device clock
error, so we average over that.
2023-01-24 08:27:56 +00:00
Pauli Virtanen fe3ca50818 bluez5: Add BLE MIDI parser/writer tests 2023-01-24 08:27:56 +00:00
Pauli Virtanen 5d6f25e8f0 bluez5: implement BLE midi data writer 2023-01-24 08:27:56 +00:00
Pauli Virtanen e3cf7f6d87 bluez5: implement BLE MIDI parser 2023-01-24 08:27:56 +00:00
Pauli Virtanen 931e8da3ea bluez5: implement Bluetooth MIDI device enumeration
Add monitor for enumerating connected Bluetooth MIDI devices.
2023-01-24 08:27:56 +00:00
Pauli Virtanen a07dfbbdb9 bluez5: add convenience helper for dbus pending calls 2023-01-24 08:27:56 +00:00
Pauli Virtanen 42e463f726 bluez5: add abstraction for remote DBus objects
Add framework for enumerating remote objects via DBus object manager
interfaces.
2023-01-24 08:27:56 +00:00
Pauli Virtanen 57956ad100 bluez5: add abstraction for local DBus object manager
Add framework for exposing local objects via DBus object manager
interfaces.
2023-01-24 08:27:56 +00:00
Arun Raghavan 134a20c3c5 spa: Minor documentation copy-pasto fix 2023-01-18 16:59:05 +00:00
Wim Taymans 6207d98ff1 spa: add debug log context
Make a real debug context with a log function and move it to a new file.
This way we don't need to redefine a macro.
Make a new context for debugging to a log file. Make new functions to
debug to a log file.
Move the stringbuffer to string utils.
Integrate file/line/func and topics into the debug log.
We can remove some more things from the pipewire log_object function and
also add support for topics.
2023-01-18 17:51:16 +01:00
Wim Taymans 3c67821c4a spa: add context to debug functions
Add new spa_debugc_ funnctions that take a context. The user should also
redefine the spa_debugc macro to handle the context.

Use this to let some plugins log the pod and format to the log without
using the global logger.

Also use this to remove our custom pod logger function by reusing the
spa one with a custom context.
2023-01-18 13:12:16 +01:00
Wim Taymans f472fd736d fix includes
Only include debug we need. We usually only need the debug types.
2023-01-18 13:12:16 +01:00
Wim Taymans 5e58e03da7 spa: redirect adapter log to logfile
Fixes #2923
2023-01-18 13:12:16 +01:00
Pauli Virtanen 4b408e2978 bluez5: fix reported BAP profile index 2023-01-17 20:14:14 +02:00
Pauli Virtanen 37d78ce29e bluez5: disable LE Audio if using legacy bluez API 2023-01-17 19:58:42 +02:00
Pauli Virtanen a372c89544 bluez5: lc3: handle multiple PACs in capabilities
BlueZ may send multiple PACs in the capabilities delimited by zero LTV.
Handle this case by selecting the "best" one.

The configuration size may also for BAP generally be different from PAC
size.
2023-01-17 19:58:42 +02:00
Wim Taymans 1d9640af5a spa: Fix audioconvert overflow when scaling
Add SPA_SCALE32_UP that scales a uint32 without overflow.
Use this for scaling the threshold in ALSA.
Fix the scaling in audioconvert of the buffer size, the scaling was
wrong and it was also causing an overflow resulting in choppy sound in
some cases.

See #2680
2023-01-16 18:28:31 +01:00
Wim Taymans 32a7c85c84 alsa: guard against some invalid values
Avoid division by 0 and other strange things when invalid values
are detected.

Fixes #2953
2023-01-16 16:05:17 +01:00
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 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
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 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 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
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
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