Commit graph

925 commits

Author SHA1 Message Date
Wim Taymans
2adf8d38d5 node: add target_rate and target_duration in io_clock
Place the target rate and duration in the io clock area.

The driver is meant to read these new values at the start of the cycle
and update the position rate and duration.

This used to be done by the pipewire server when it received the ready
callback from the driver but this is in fact too late. Most driver would
start processing and set the next timeout based on the old rate/duration
instead of the new pending ones.

There is still a fallback for the old behaviour (with a warning) when
the driver doesn't yet update the position.
2023-03-23 17:57:16 +01:00
Wim Taymans
345582dd15 module-rtp: add opus encoding 2023-03-12 18:40:36 +01:00
Barnabás Pőcze
39ce32985b spa: support single argument static assertions in older standards
Single argument static_assert() is only available since
C++17 and C23. Some compilers accept it even in earlier language
versions, but some do not.

Single argument static assertions can be supported by using
a GCC extensions, namely that `, ## __VA_ARGS__` removes the
comma if the variadic argument list is empty. This enables a
construction which passes a pre-determined string as the second
argument of the underlying static_assert() when only a single
argument is used in the `SPA_STATIC_ASSERT()` macro.

Fixes #3050
2023-03-04 11:57:51 +00:00
Barnabás Pőcze
934ab3036e treewide: use SPDX tags to specify copyright information
SPDX tags make the licensing information easy to understand and clear,
and they are machine parseable.

See https://spdx.dev for more information.
2023-02-16 10:54:48 +00:00
Wim Taymans
b93c3fb0c5 spa: improve param doc 2023-02-13 17:15:04 +01:00
Wim Taymans
50a1e2db22 utils: remove () around variable declaration
c++ warns about this.
2023-02-05 10:27:12 +01:00
Carlos Rafael Giani
e9a2c6aa34 Rename "compressed-offload to "Compress-Offload" in the code 2023-01-24 08:44:14 +00:00
Sanchayan Maity
6a034cc398 Add support for ALSA compressed offload
See
https://docs.kernel.org/sound/designs/compress-offload.html
https://github.com/alsa-project/tinycompress
2023-01-24 08:44:14 +00:00
Carlos Rafael Giani
f3914e494c spa: Add ENCODED audio format to compressed format builder results
WirePlumber checks for the ENCODED audio format to determine if the
format is compressed/encoded. Without this info, it is not able
to automatically link compressed audio nodes.
2023-01-24 08:44:14 +00:00
Wim Taymans
b66b9f70c4 spa: add APE format 2023-01-24 08:44:14 +00:00
Wim Taymans
e535d4c6c4 spa: add FLAC format 2023-01-24 08:44:14 +00:00
Wim Taymans
efbce802e4 spa: add ALAC format 2023-01-24 08:44:14 +00:00
Wim Taymans
603c28223b spa: add AMR type 2023-01-24 08:44:14 +00:00
Wim Taymans
de5015c77b spa: add Real Audio format 2023-01-24 08:44:14 +00:00
Wim Taymans
6c962d8258 spa: add WMA type 2023-01-24 08:44:14 +00:00
Wim Taymans
d24b3f29b2 spa: add vorbis type 2023-01-24 08:44:14 +00:00
Wim Taymans
2ac8a3f4e2 spa: add AAC format 2023-01-24 08:44:14 +00:00
Wim Taymans
844a3d8534 spa: add mp3 type 2023-01-24 08:44:14 +00:00
Wim Taymans
9e0a7c26f7 spa: add bitrate and blockAlign format props 2023-01-24 08:44:14 +00:00
Pauli Virtanen
25f36e4334 bluez5: add info key indicating glib mainloop is usable 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
931e8da3ea bluez5: implement Bluetooth MIDI device enumeration
Add monitor for enumerating connected Bluetooth MIDI devices.
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
5e58e03da7 spa: redirect adapter log to logfile
Fixes #2923
2023-01-18 13:12:16 +01: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
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
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
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
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
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
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
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
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
Wim Taymans
44d743ed95 spa: make all format parsing fields optional
Just like the optional build, make all field parsing optional. This
will leave the fields with their default values if they are not parsed
from the param.

We can then remove our custom functions and use the generic ones in
various places.
2022-11-03 13:13:07 +01:00
Wim Taymans
e6fd5888ee param: add a new user seq field in the param-info
Add a new seq field in the param-info struct. Users can use this
field to keep track of pending param updates.

Store the latest seq number of the param update in the seq field. Remove
all params that don't match the sequence number because they are too
old. This avoids duplicate old params in pw-dump output.

Rework the pulseaudio manager with this same method.
2022-10-27 20:10:33 +02:00
Christoffer Gydenius
b35983eb7e module-echo-cancel: aec-plugin parameters
Make it possible for a aec-plugin to provide props/params
through module-echo-cancel and make it possible for a
aec-plugin to listen and react to these props/params getting updated.

Add method enum_props() that is used under setup_streams() to
get props from aec_plugin.
Add get_params() and set_params() for updating and getting
aec-plugin params under the input/output_param_changed calls
and getting params under setup_streams().
2022-10-24 16:58:00 +02:00
Demi Marie Obenour
8e43c41ac1 Add more parentheses
This was missed in the earlier MR.
2022-10-06 12:12:35 -04:00
Wim Taymans
d22feab92a spa: add macro to simplify array iterations some more
uint32_t i;
	for (i = 0; i < SPA_N_ELEMENTS(some_array); i++)
		.. stuff with some_array[i].foo ...

   becomes:

	SPA_FOR_EACH_ELEMENT_VAR(some_array, p)
		.. stuff with p->foo ..
2022-09-30 16:24:26 +02:00
Wim Taymans
365ebcda9b spa: ensure macro args are evaluated only once
In ROUND_UP and ROUND_DOWN
Make some better versions of the ROUND_DOWN_N and ROUND_UP_N
macros.

Fixes #2724
2022-09-30 16:24:26 +02:00
Wim Taymans
07fd063a0d pod: fix alignment check
Use the platform specific alignment for the spa_pod instead of 8.

Fixes things on 32 bits.
2022-09-29 17:06:54 +02:00
Demi Marie Obenour
1e848fc299 SPA POD parser: fix several integer overflows
This fixes several integer overflow problems in the POD parser, as well
as fixing a returns-twice warning from GCC and integer truncation
problems in SPA_FLAG_CLEAR and SPA_ROUND_DOWN_N.  The integer overflows
can result in a tiny POD being treated as a huge one, causing
out-of-bounds reads.
2022-09-27 10:21:17 +00:00
Demi Marie Obenour
fea248d450 SPA POD parser: Fix bug when parsing choice types
spa_pod_parser_can_collect and spa_pod_parser_getv were inconsistent
with each other.  When parsing crafted POD, this could cause a type
confusion or stack overflow.
2022-09-24 15:52:53 +00:00
Demi Marie Obenour
90c955c223 Replace more macros with accessor functions 2022-09-23 11:39:33 -04:00
Demi Marie Obenour
671a7102ff Fix some badly-behaved macros
Some macros evaluated their arguments more than once when it was not
needed, or were missing parentheses.
2022-09-23 11:39:33 -04:00
Wim Taymans
9632145c9a log: make some more macros
Make a macro to log at a certain level with func,line,file added.
Use the new macros to reduce some redundant arguments.
2022-09-21 15:50:41 +02:00
Wim Taymans
7bf84fa5e2 pod: only call the overflow callback when still needed
When we are already past the size of the buffer, don't bother calling
the overflow callback anymore, the buffer is already corrupted.

Otherwise it would be possible to have the overflow callback fail the
first time around, some data will be skipped, and then the next
overflow callback would succeed, giving the impression that all is
fine.

Add a unit test for this.
2022-09-20 16:59:25 +02:00