Commit graph

2055 commits

Author SHA1 Message Date
Wim Taymans 0fd5e3fdb2 libcamera: implement allocation and dataflow
Keep track of the negotiated parameters and use those to construct
the Buffers param.

Use the FrameAllocator to allocate buffer memory. Keep a request for
each buffer and queue them.

In requestComplete, put the request metadata info into the buffer and
header and write the finished buffer id to a ringbuffer. Then wake up
the data thread to pop the finished buffer_id and push it in the
graph.

Remove some old files.
2021-11-03 17:49:10 +01:00
Wim Taymans b2c38a2b3b libcamera: work on rewrite
Use manager to hotplug devices
Use StreamConfig to enumerate formats
2021-11-03 17:49:10 +01:00
Wim Taymans 84ecebbd4e cpu: only run SSE code when supported
Check if we can run SSE instructions before executing the denormals
SSE code.

Fixes #1775
2021-11-02 20:12:35 +01:00
Wim Taymans 859e95126b alsa-seq; use port_type to check port type
Don't use the capabilities for checking the port type.
2021-11-02 14:57:36 +01:00
Wim Taymans 9f134ee79d v4l2: add support for ParamBegin/End
To keep the device open while we perform a series of param
enumerations.
2021-10-29 15:41:27 +02:00
Wim Taymans 0ace131d72 audioconvert: add stereo deinterleave neon asm
This can take some shortcuts and convert twice as many samples in one
iteration as the strided stereo deinterleave one.
2021-10-28 11:30:04 +02:00
Wim Taymans 2cddd4a775 cpu: disable VFP asm when not available
Fixes #1746
2021-10-25 16:32:16 +02:00
Philippe Normand f0d3a7cf49 spa: alsa: Fix build warning
`type >=0` always evaluates to true, so remove this condition.
2021-10-25 07:26:15 +00:00
Philippe Normand 6b1c483cf7 spa: v4l2: Convert buf structure to union and fix alignment
The inotify_event field has a variable sized type, so it's recommended to store
it at the end of the storage unit. Fixes gnu-variable-sized-type-not-at-end warning.
2021-10-25 07:26:15 +00:00
Philippe Normand ec7ed1275e spa: alsa: Switch to explicit fallthrough
Use `__attribute__((fallthrough))` through the new FALLTHROUGH macro, if
supported.
2021-10-25 07:26:15 +00:00
Gleb Popov 12a4fbb425 Use uint16_t instead of int16_t to fix a compiler warning. 2021-10-22 19:05:18 +03:00
Gleb Popov e94adaac24 Don't include byteswap.h on FreeBSD, use sys/endian.h instead 2021-10-22 17:50:42 +03:00
Wim Taymans 651f0decea cpu: fix compilation on some architectures 2021-10-21 11:09:48 +02:00
Wim Taymans 67209b9ecc resample: add some float math optimization
Multiplying and adding the smaller floats first will reduce the amount
of rounding errors.
2021-10-18 21:19:43 +02:00
Wim Taymans cc996b6292 resample: use blackman with 0.232 alpha
Gives much better results with less aliasing.
2021-10-18 21:09:16 +02:00
Wim Taymans e1898812b2 acp: remove duplicate AUX channels in pa channelmap
The pulseaudio channel map can only hold 32 AUX channels and we reuse
them when we need more. When we find a duplicate channel, map it to the
next AUX channels.
2021-10-18 10:53:07 +02:00
Wim Taymans a475926f87 acp: move pro channel init to init_auto 2021-10-18 10:51:48 +02:00
Wim Taymans 9dccd79191 acp: ensure we don't make invalid channels
There are only 32 AUX channels in pulseaudio so wrap around when we
have more.
2021-10-18 10:50:09 +02:00
Wim Taymans 6bb21d6abf acp: fix AUX13 channel mapping
Fixes #1727
2021-10-18 10:01:44 +02:00
Wim Taymans 061ab16415 resample: tweak params a little
Gives less aliasing in Sweep-float.wav.
2021-10-15 12:54:49 +02:00
Wim Taymans 57b3fe537e v4l2: handle discrete and stepwize frame size enumeration 2021-10-14 10:15:34 +02:00
Pauli Virtanen 15d1ddfc6b bluez5: fix bugs in spa_bt_player
Fix uninitialized variable, error return.
2021-10-13 18:07:29 +00:00
Wim Taymans 54c0857d57 cpu: also pass the sse_args when compiling with SSE 2021-10-13 15:10:21 +02:00
Wim Taymans 14fd5425af cpu: use intrinsics to modify status register
For better portability. Also only use the code when we can compile with
SSE is available.
2021-10-13 15:00:09 +02:00
Wim Taymans c8c4923fcb spa: use log topics 2021-10-13 10:48:23 +02:00
Peter Hutterer c44d0a6bbc spa: declare a dependency for the dbus lib
When running meson test without a preceding ninja build, we end up with
missing libraries. This somehow happened to work until recently but now
it triggers an issue with libspa-dbus.so not being available during the
valgrind test run, causing a test case to fail.
2021-10-12 09:45:33 +10:00
Wim Taymans 85d5c8cd6c cpu: add zero_denormals method
Add a method to enable/disable the denormals flush-to-zero and
denormals-as-zero CPU options.

Add a config option to make it possible to disable this again.

Fixes high CPU usage when dealing with denormals, which can happen
in many DSP functions.

Fixes #1681
2021-10-11 14:57:02 +02:00
Wim Taymans 594f67ec04 a2dp: guard against transport NULL
The transport can become NULL so check that and don't try to
deref it.
2021-10-11 11:22:36 +02:00
Pauli Virtanen 4b831021fb bluez5: add a dummy AVRCP player as a workaround
Some devices (Bose Mini Soundlink II, Air 1 Plus, ...) don't enable
AVRCP volume control, or fail to enable it before a hardware button is
pressed.  However, these devices appear to enable it, if an AVRCP player
is present.

As a workaround, register a dummy AVRCP player for each adapter. It only
displays the current transport acquisition state as playing/stopped, but
just its presence appears to be enough to make devices behave.

Multiple AVRCP players interfere with each other, as BlueZ uses the one
registered earliest as the default player. So add also a config option
for disabling this. (It's not common to have mpris-proxy etc. running,
so defaulting to true should be OK.)

See pipewire#1157
2021-10-10 16:24:41 +03:00
Wim Taymans f6d69f9bcd resample: avoid NULL deref
The function is NULL when the resampler was not initialized.

Fixes #1706
2021-10-09 15:53:40 +02:00
Pauli Virtanen d28b36bb93 bluez5: fix HFP backend behavior when BlueZ goes away
Ensure unavailable backends get unregistered.

Don't log error-level messages on HFP unregistration failures.
2021-10-09 13:03:08 +00:00
Wim Taymans 5f7c4dec34 meson: make it possible to compile without dbus
Make an option to disable dbus and all the code that depends on
it.

Fixes #1685
2021-10-09 15:00:04 +02:00
Björn Daase 10ededf5d4 bluez5: fix mSBC probing documentation 2021-10-07 15:25:29 +00:00
Pauli Virtanen ff8c3d208e bluez5: fix msbc connect probe again
There's a report that on Intel 8086:2723 + Sony WH-1000XM4, the connect
probe shuts the device down.

So, use an invalid dst address instead, since we don't need the host to
be up.

Fixes: 84bc0490a5
Fixes: 717004334b
2021-10-06 19:33:54 +03:00
Dennis D 3512444296 bluez5: update bluez-hardware.conf
Closes https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/1686
2021-10-05 18:23:56 +00:00
Pauli Virtanen c620121529 bluez5: add faststream quirks
For some devices FastStream causes problems. Add quirk for disabling it.
2021-10-03 20:55:02 +03:00
Pauli Virtanen 84bc0490a5 bluez5: tweak msbc adapter probe for Intel adapters
The msbc capability connection probe seems to cause problems on Intel
Bluetooth 8087:0a2b (Intel 8265), resulting to subsequent connections
apparently ending up with wrong altsetting.

According to testing, the problem is connecting to self, so connect to
device instead.

Fixes #1671
2021-10-03 17:27:42 +00:00
Wim Taymans 392b2f1f96 dbuf: use log topic 2021-10-03 12:27:20 +02:00
Wim Taymans 783ae4d4e9 libcamera: use log topic 2021-10-03 12:26:00 +02:00
Wim Taymans 865635ef10 v4l2: use log topic 2021-10-03 12:12:09 +02:00
Wim Taymans dfdd9a6b3b alsa: don't prefix NAME, log topics are enough 2021-10-03 08:05:40 +02:00
Pauli Virtanen a86ff85444 bluez5: tolerate devices sending incorrect AAC caps
There is a report (#1342) of a device setting multiple bits for AAC
object type in SetConfiguration, although this appears to be forbidden.

It's not completely clear if this was due to e.g. some BlueZ bug, but it
should be safe to be lax and try to guess what is wanted in such case,
instead of being strict, in case it was due to device bug.
2021-10-02 10:29:48 +00:00
Pauli Virtanen 3092e4a7be bluez5: implement validate_config for AAC
Allows bailing out earlier on invalid config, and setting transport
channel info.
2021-10-02 10:29:48 +00:00
Pauli Virtanen 58c7caf1bc bluez5: use log topics
Use log topics instead of prepending NAME: to log messages.
2021-10-02 12:46:02 +03:00
Wim Taymans 9a76feb913 libcamera: handle MemFd buffers
Use EXPBUF when requesting MemFd buffers because it is mostly correct
for v4l2.
2021-10-01 13:19:14 +02:00
Wim Taymans 487792941d libcamera: remove \n in log lines 2021-10-01 12:28:53 +02:00
Pauli Virtanen d6509a243d bluez5: fix device.profile setting
Only keys with names starting with "bluez" are passed on to device
settings dict. Rename device.profile to match this.

Also add some debug.
2021-09-30 22:39:34 +03:00
Pauli Virtanen e84f1c6eed bluez5: update bluez-hardware.conf
Closes #1592
2021-09-30 20:01:06 +03:00
Wim Taymans d71a10b7fa libcamera: handle failure gracefully
Don't try to access NULL pointers
2021-09-30 12:54:29 +02:00
Wim Taymans f8817b4394 cpu: fix compilation on ARM 2021-09-30 11:12:27 +02:00
Peter Hutterer abd5f9fbe8 Remove remaining tabs from meson.build files
No changes, just tab-to-space replacement and a little bit of manual
twiddling.
2021-09-30 00:08:27 +00:00
Wim Taymans 013567524a support: res might be used uninitialized 2021-09-29 17:08:46 +02:00
Barnabás Pőcze 184e80d753 spa: support: use spa_list_consume()
Use `spa_list_consume()` when freeing entities in the pattern
list instead of `spa_list_for_each_safe()`.
2021-09-29 15:07:36 +00:00
Barnabás Pőcze 25a0e3beb4 spa: support: do not include C source file
Previously, `log-patterns.c` was included in two other source files
(`journal.c` and `logger.c`). It was also specified in the sources
list for the libspa-support library, which resulted in the unnecessary
independent compilation of the file, generating "defined but not used"
warnings.

Extract the function definitions into `log-patterns.h` and
use that in `journal.c` and `logger.c`, and remove the inclusion
of `log-patterns.c` from both.
2021-09-29 15:07:36 +00:00
Barnabás Pőcze b292a71220 spa: support: use flexible array member
Use a flexible array member directly to store the pattern.
2021-09-29 15:07:36 +00:00
Wim Taymans a9c64e1609 fix versions of the log interface 2021-09-29 17:03:26 +02:00
Wim Taymans 88d7ea3d88 spa-resample: add some verbose info messages 2021-09-29 10:16:25 +02:00
Wim Taymans 4d85e6aead resample: fix off-by-one
Don't use the previously skipped sample to calculate the remaining
amount of samples or else we remove one sample too much in some cases
and cause distortion, mostly when downsampling.

Fixes #1646
2021-09-28 15:31:07 +02:00
Peter Hutterer b3646743c1 spa: sprinkle more log topics into spa 2021-09-28 09:35:39 +02:00
Peter Hutterer e9d869b46f spa: implement a log topic for alsa 2021-09-28 09:35:39 +02:00
Peter Hutterer 59a5791d41 spa: implement the new topic logging for the provided loggers
Both simple log implementation now support the new topic-based
functions, and so does the journal logger too.
2021-09-28 09:35:38 +02:00
Peter Hutterer 9eda834417 spa: use the spa_log_logv macro to chain the log calls
No need to use the interface call directly here, let's just use the
macro.
2021-09-28 09:35:38 +02:00
George Kiagiadakis becd76de58 bluez5: sco-sink: Add follower mode 2021-09-27 17:31:16 +00:00
Pauli Virtanen dc7b88e1da bluez5: fix CVSD recording on Intel AX200
Intel 8087:0029 at Firmware revision 0.0 build 191 week 21 2021 on
kernel 5.13.19 produces CVSD data stream that consists of 96-byte data
packets interleaved with 96-byte zero packets.

This seems to not occur on other adapters, which usually produce only
48-byte data packets.
2021-09-26 17:58:06 +03:00
Pauli Virtanen 9e94aafaec bluez5: fix FastStream microphone support on some devices
Some devices require the source direction bit to be selected, in order
to send data.
2021-09-25 16:27:57 +00:00
Pauli Virtanen 65f881c222 bluez5: fix kernel version regexps
5.14.x kernels do support msbc-alt1, and should not be rejected.
2021-09-25 16:27:34 +00:00
Pauli Virtanen 0af3c85806 bluez5: don't probe native backend presence
Don't do a blocking probe of native backend presence, because it may
trigger DBus activation for Bluez.  If the DBus activation fails, it
ends up blocking until timeout.

ofono/hsphfpd usually don't have DBus activation configured, so they
fail instantly (which is why this problem was not encountered, even
though they do blocking calls on startup in previous pipewire versions
too).

Instead, select the backend once we have Bluez objects listed.
2021-09-25 16:24:10 +00:00
Wim Taymans f1f5cbc0a6 support: return completion from process
HAVE_DATA|NEED_DATA signals that the graph can continue processing.
OK means that the node will continue asynchronously later. This
is needed to make the dummy driver work as a follower.
2021-09-23 16:36:32 +02:00
Wim Taymans 21616a25ad alsa: sync with pulseaudio
Fixes #1642
2021-09-23 15:02:08 +02:00
Pauli Virtanen 717004334b bluez5: backend-native: don't use libbluetooth hci commands
BlueZ 6 is planning to make most of libbluetooth private.  In
particular, the direct hci access is planned to be removed.  This is
currently used for determining adapter msbc support.

Instead of using libbluetooth API, try to determine msbc support by
a connect() attempt, which the kernel should reject when not supported.
2021-09-22 20:18:50 +03:00
Javier Martinez Canillas 310e6009ca
libcamera: fix a segfault caused by queueing no longer valid requests
The requests_ vector contains the requests created for a camera on start()
but the vector elements are not removed on camera stop(). This leads to a
segfault, when these requests that are no longer valid are queued again.

Also move the streamName_ map clear to LibCamera::stop() where it should
be, since its elements are added in the LibCamera::start() function.
2021-09-21 14:49:08 +02:00
Javier Martinez Canillas 439dc8eb2a
libcamera: disconnect camera in spa_libcamera_stream_off()
The camera is connected in the spa_libcamera_stream_on() function but the
disconnect happen in LibCamera::stop(). It makes more sense to have this
two operations separated as it's done for the connection and start, since
the camera then can be stopped/started without needing to do a reconnect.

Move the camera disconnect to spa_libcamera_stream_off() for the reason
mentioned above but also to make the code more consistent and symmetric.
2021-09-21 14:49:08 +02:00
Javier Martinez Canillas ce9f75abaa
libcamera: free the FrameBufferAllocator buffers before deleting it
The libcamera application developer guide mentions that buffers allocated
by the FrameBufferAllocator must be explicitly freed before deleting it.
2021-09-21 14:49:08 +02:00
Javier Martinez Canillas 21c412dc49
libcamera: fix a use-after-free due an attempt to stop the camera twice
Camera is currently stopped and started in the spa_libcamera_set_format()
function, but this leads to a segfault due attempting to access a buffers
field of an already freed libcamera::FrameBufferAllocator instance.

The FrameBufferAllocator instance is freed in LibCamera::stop(), that is
called by spa_libcamera_stream_off() as handler of the node commands
SPA_NODE_COMMAND_Pause and SPA_NODE_COMMAND_Suspend.

Since the camera was already stopped, there's no need to attempt to stop
it again. In fact, the camera shouldn't be stopped/started at all in the
spa_libcamera_set_format() function but instead only as an action of the
SPA_NODE_COMMAND_{Pause,Suspend} and SPA_NODE_COMMAND_Start commands.

And same for the stop that's done in the LibCamera::close() function, it
shouldn't be needed because the camera is already stopped before closing.

Fixes #1513
2021-09-21 14:49:08 +02:00
Javier Martinez Canillas a7a6f19815
libcamera: don't set camera configuration in LibCamera::start()
There is no need to set and validate the configuration when the camera
is started, since this was already made when the camera was opened.

The configuration only needs to be set again if the port format changes
due a SPA_PARAM_Format parameter.
2021-09-21 14:49:08 +02:00
Javier Martinez Canillas 2d69f775de
libcamera: add a libcamera_set_config() helper function to the wrapper
The libcamera wrapper provides a set of C functions that wraps libcamera's
C++ interface. But there isn't a function to call LibCamera::set_config().
2021-09-21 14:49:08 +02:00
Wim Taymans 7c11dcf808 alsa: enumerate all passthrough formats
Don't use the audio.channels and audio.rate settings influence the
passthrough formats.

See #93
2021-09-21 13:02:48 +02:00
Wim Taymans 0ec77ab09c dsd: show rate in bytes per seconds. 2021-09-21 12:25:42 +02:00
Wim Taymans 670efe2811 alsa: implement set_format for DSD formats 2021-09-21 10:50:45 +02:00
Wim Taymans af6e887077 spa: add interleave DSD param
And make alsa report the interleaving.
2021-09-21 10:50:45 +02:00
Wim Taymans 25d39a5ea1 alsa: only expose DSD format when DSD_U32_BE is supported 2021-09-21 10:50:44 +02:00
Wim Taymans 1b5d02dd31 alsa: add enumeration of DSD formats 2021-09-21 10:50:44 +02:00
Wim Taymans 143f233be3 audioconvert: increase buffer size
64 channels with the new format support needs more space.

See #1620
2021-09-20 20:11:50 +02:00
Wim Taymans 92f35b99a0 alsa: don't mix process return and alsa err
Use a separate error field for the alsa errors, we already use the res
field for the process result.
2021-09-20 12:24:09 +02:00
Peter Hutterer dfb40fb714 test: implement a test for the journal logger 2021-09-20 07:29:03 +00:00
Peter Hutterer 0cbd56f0cd spa: declare a dependency for each used library in meson.build
For SPA libraries that we link against elsewhere in the tree, declare a
declare a dependency "foo_dep" for that library that specifies how to
link to it. Then use that dependency in the various targets.

This removes the knowledge of how to link with the library from the
target which can treat it as just another dependency.

In the case of optional libraries (e.g. the journal support lib) we can
then use declare_dependency() to declare an empty dependencies and thus
link them unconditionally in the target.
2021-09-20 07:29:03 +00:00
Peter Hutterer 56193d474c spa/bluez: correct a library name variable in meson.build
Unused, so no functional change here
2021-09-20 07:29:03 +00:00
Peter Hutterer ebda71d489 spa: fix the indentation in the various meson.build files
Was all over the place using tabs and spaces, let's make this more
consistent.
2021-09-20 07:29:03 +00:00
Pauli Virtanen def45adaec bluez5: fix behavior on HSP/HFP backends with no codec switching
Fix HSP/HFP profile not showing correctly when using hsphfpd/ofono
backends, which don't support codec switching and have no HFP codec
profiles.
2021-09-19 17:41:19 +00:00
Pauli Virtanen 90b4efd98d bluez5: cleanup hfp/hsp backend handling + config file option
It seems not uncommon that people have not properly configured ofono
running, which results to loss of HFP/HSP functionality. It's less
surprising if the backend selection is fixed in the configuration file,
and (by default) does not depend on running services.

Add a configuration file option for selecting HFP/HSP backend, and set
the default value to the native backend. Emit warnings if conflicting
backend services are detected to be running.

Also cleanup hfp/hsp backend handling a bit, now that it's mostly
abstracted behind an interface.
2021-09-19 17:33:32 +00:00
Pauli Virtanen cae1554449 bluez5: move bluez-hardware.conf loading to the plugin
It's not really the responsibility of the session manager to load the
bluez5 device quirks, and it's easier for eg. Wireplumber if it doesn't
need to do it.

Move loading bluez-hardware.conf to be the responsibility of the bluez5
spa plugin, similarly as the alsa plugin deals with the ACP database.

Put the configuration to share/spa-0.2/bluez5, mirroring the plugin
directory structure in lib/spa-0.2/bluez5.
2021-09-19 17:28:17 +00:00
Wim Taymans d04244abb9 audioconvert: add softMute to PropInfo
So that it can be introspected.

Fixes #1613
2021-09-15 20:57:10 +02:00
Georges Basile Stavracas Neto eca2bbb892 v4l2: Pass camera controls and formats in the node itself
Instead of using the Port to do that. This is what audio nodes
do.
2021-09-15 10:25:33 -03:00
Wim Taymans 19a3bf2100 spa: handle last_port correctly
last_port is always 1 more than the highest valid port number.
2021-09-14 21:06:21 +02:00
Wim Taymans d793086174 alsa-seq: fix port delete
We need to first mark the removed port as invalid, and then look for the
last valid port in the port array otherwise last_port becomes 0 and
midi dataflow stops.

Fixes #1601
2021-09-14 18:08:30 +02:00
Wim Taymans 349324b9a6 alsa: pass AES bits to S/PDIF devices
This is the right thing to do and might even fix output to some
devices.
2021-09-14 12:42:03 +02:00
Julian Bouzas 767ac79328 audiomixer: support multiple channels when mixing with AVX, SSE and SSE2 2021-09-10 07:35:55 +00:00
Julian Bouzas 7d0a8b68e8 audiomixer: add support for U8, U16, U24, U32, S24_32 and U24_32 formats 2021-09-08 14:24:31 -04:00
Julian Bouzas 20e64b39da fmtconvert: add support for U16, U24, U32 and U24_32 formats 2021-09-08 14:24:26 -04:00
Wim Taymans 0cf6760ee0 resample: limit the amount of taps
So that we don't allocate too much space but also don't cause an
overflow in the indexes.
2021-09-08 16:28:24 +02:00