Commit graph

9034 commits

Author SHA1 Message Date
Wim Taymans
3853eba32f 0.3.53 2022-06-30 09:15:01 +02:00
Davide Beatrici
e0731f0ffa pulse-server: map "device.sysfs.path" to "sysfs.path" 2022-06-30 08:41:30 +02:00
Wim Taymans
0d33760b71 spa: leave vendor.id and product.id in hex
There is no reason to store this as anything other than the original
hex string. Especially for compatibility with pulseaudio.

See !1298
2022-06-30 08:38:52 +02:00
Wim Taymans
a44c600ade resample: use cosh window function
Seem to produce a little sharper cutoff.

Fixes #2483
2022-06-29 18:03:40 +02:00
Wim Taymans
9b37142ef6 audioconvert: implement noise shaping
To compare the results:

  pw-cat -r test.wav --format=u8 -P '{ dither.method=none }'

vs:

  pw-cat -r test.wav --format=u8 -P '{ dither.method=shaped5 }'
2022-06-29 17:33:37 +02:00
Wim Taymans
7701786016 audioconvert: demote a debug log to trace_fp 2022-06-29 17:30:04 +02:00
Wim Taymans
d1ee783322 pw-cat: read and write raw formats correctly
We need to transform the number of bytes into frames.
2022-06-29 17:29:16 +02:00
Wim Taymans
0b62cea4f9 audioconvert: use faster noise generator 2022-06-29 14:33:58 +02:00
Wim Taymans
938f2b123e audioconvert: improve format conversion
Make dither noise as a value between -0.5 and 0.5 and add this
to the scaled samples.
For this, we first need to do the scaling and then the CLAMP to
the target depth. This optimizes to the same code but allows us
to avoid under and overflows when we add the dither noise.

Add more dithering methods.

Expose a dither.method property on audioconvert. Disable dither when
the target depth > 16.
2022-06-29 14:10:15 +02:00
Wim Taymans
d23b96b033 audioconvert: fix some compiler warnings 2022-06-29 14:08:30 +02:00
Wim Taymans
0b73fa97d0 audioconvert: use loop for channelmix method enum 2022-06-29 14:05:48 +02:00
Wim Taymans
22d02a7891 audioconvert: dither in 24 bits
This saves some shifts.
2022-06-28 17:15:27 +02:00
Wim Taymans
7a0f201dc7 audioconvert: set right flags for functions 2022-06-28 17:02:15 +02:00
Wim Taymans
6b49bded3a audioconvert: move dither and noise to fmt-ops
We need to do dithering and noise when converting f32 to the
target format. This is more natural because we can work in 32 bits
integers instead of floats.

This will also make it possible to actually calculate the error between
source and target values and implement some sort of feedback and
noise shaping later.
2022-06-28 16:55:50 +02:00
Wim Taymans
51f4f1fb69 audioconvert: expose the selected function names
And debug them.
2022-06-28 16:50:14 +02:00
Wim Taymans
048e10ee3b audioconvert: expose upmix-method in PROP_INFO 2022-06-28 11:32:05 +02:00
Wim Taymans
a84bf672e8 audioconvert: add dither passthrough flag 2022-06-28 11:31:40 +02:00
Wim Taymans
b5e0151cc0 audioconvert: add dither noise setting in dither struct
Move the noise setting in the dither struct so that it can be
handled separately.
Setup dither separately.
Set used cpu_flags in structures after setup.
2022-06-28 10:52:31 +02:00
Wim Taymans
b7e26002be audiocovert: improve dither setup
The quantize is the amount of bits we want to keep from the original
signal, subtract the amount of bits for noise. Clamp this to 0 (all
noise).
Calculate the scale factor better with powf() and avoid overflows.

Fixes #2479
2022-06-28 10:11:46 +02:00
Wim Taymans
67c2202044 audioconvert: improve setup of quantization
Use the quantize value to specify how many bits to quantize to.
2022-06-27 20:03:30 +02:00
Wim Taymans
916050aacd audioconvert: handle errors 2022-06-27 20:03:30 +02:00
Wim Taymans
67db81729e modules-raop: handle uninitialized vars 2022-06-27 18:51:28 +02:00
Wim Taymans
00998ffd7e audioconvert: ensure alignment
Allocate a little bit more data to ensure alignment and overread of the
dither data.
Ensure sse2 can load aligned data in all cases.
2022-06-27 17:18:23 +02:00
Wim Taymans
b41d52cfd1 audioconvert: optimize dither
Add sse2 dither optimization
2022-06-27 14:15:01 +02:00
Wim Taymans
9f55708e9d audioconvert: Always apply noise when asked
Rename empty.noise -> dither.noise and always add this amount of noise
when > 0. This also adds the noise to silent sounds, not only when
nothing is connected because that would also be a problem when an amp
needs to be kept alive with an non-0 signal.

Rename noise -> dither because we can use this also for dithering later.

See #705
2022-06-27 11:19:01 +02:00
Wim Taymans
abcf7cb8d8 add some SPA_LIKELY 2022-06-27 09:37:33 +02:00
Takashi Sakamoto
e3b6534872 acp: avoid assertion at alsa-lib mixer API when element removal
PipeWire v0.3.7 or later hits assertion at alsa-lib mixer API due to
wrong handling of removal event for mixer element.

wireplumber: mixer.c:149: hctl_elem_event_handler: Assertion `bag_empty(bag)' failed.

The removal event is defined as '~0U', thus it's not distinguished from
the other type of event just by bitwise operator.

At the removal event, class implementator for mixer API should detach
mixer element from hcontrol element in callback handler since alsa-lib
has assertion to check the list of mixer elements for a hcontrol element
is empty or not after calling all of handlers. In detail, please refer to
MR to alsa-lib:

 * https://github.com/alsa-project/alsa-lib/pull/244

This commit fixes the above two issues. The issue can be regenerated by
`samples/ctl` Python 3 script of alsa-gobject.

 * https://github.com/alsa-project/alsa-gobject/

It adds some user-defined elements into sound card 0. When terminated by
SIGINT signal, it removes the elements. Then PulseAudio dies due to the
assertion.

Fixes: 1612f5e4d2 ("alsa-acp: Add libacp based card device")
2022-06-27 10:17:30 +09:00
Barnabás Pőcze
1ac02db6a9 spa: audioconvert: ensure that noise::intesity is not too big
Shifting by 64 or more would not fit into `uint64_t`.
2022-06-24 16:27:43 +02:00
Barnabás Pőcze
bb205d3d85 spa: audioconvert: use unsigned 64-bit integer for creating divisor
Using `int` results in UndefinedBehaviorSanitizer errors
when `noise::intensity` is 31 as that would shift the 1 into
the sign bit of a signed integer type.
2022-06-24 16:27:43 +02:00
Barnabás Pőcze
43f7831d14 spa: audioconvert: use SPA_N_ELEMENTS in noise_init() 2022-06-24 16:27:39 +02:00
Michael Tretter
a745374232 v4l2: fix port param enumeration for devices without controls
It is valid for V4L2 devices to not implement any controls. QUERYCTRL
returns ENOTTY in these cases. Enumerating the controls must not fail in
these cases but return no controls.
2022-06-24 12:16:05 +00:00
Michael Tretter
edd41d8259 v4l2: close v4l2 device on error
The device needs to be closed when the enum_controls function is exited,
but is not closed if the VIDIOC_QUERYCTRL fails. Fix it.
2022-06-24 12:16:05 +00:00
Wim Taymans
13ccccbfbd audioconvert: add missing file 2022-06-24 14:15:17 +02:00
Wim Taymans
5fc7eac9b2 conf: update config files with new default property 2022-06-24 13:58:29 +02:00
Wim Taymans
1c6cb049ce audioconvert: add an option generate silence noise
Add an empty.noise option that specifies the number of bits to
use for noise when the input signal is pure silence.

Some amplifiers can go into suspend mode pretty easily when they
get pure silence. With empty.noise = 1, audioconvert will now generate
a bitpattern that can keep those amplifiers alive, together with
disabling suspend in the session manager.

Fixes #705
2022-06-24 13:45:35 +02:00
Wim Taymans
9430df0ba6 channelmix: undefine the function macro 2022-06-24 13:45:35 +02:00
Wim Taymans
974ab5348e audioconvert: reset props before parsing config
Or else we undo all settings from the config params.
2022-06-24 13:45:35 +02:00
James Hilliard
d61d787afa gst: log warnings if pw_stream_queue_buffer fails
There seem to be some latent issues with buffer recycling, add some
additional logging to simplify tracing buffer recycling issues.
2022-06-24 09:11:42 +00:00
Wim Taymans
f2dee23085 buffer: add EMPTY chunk flag
Add an EMPTY chunk flag to mark a piece of memory as 'empty'. For audio
this means silence.
Use the empty flag to avoid mixing 0 samples.
Set the empty flag in output buffers on audioconvert.
2022-06-24 11:09:01 +02:00
Wim Taymans
71f3c759f4 audiomixer: support offset and clamp size 2022-06-24 10:41:30 +02:00
Wim Taymans
f6938d8364 alsa: simplify writing
We don't use the input buffers as ringbuffers, so remove that
code and simpify fomr things.
2022-06-24 10:38:13 +02:00
Wim Taymans
532fc29c85 docs: improve docs a little 2022-06-23 18:55:02 +02:00
Wim Taymans
df457e99b2 roc: use native float samples 2022-06-23 12:48:59 +02:00
Wim Taymans
60cbc44526 modules: improve docs 2022-06-23 12:48:45 +02:00
Wim Taymans
c8b8b24a9c modules: fix format parsing
Use the same logic for parsing the format.
2022-06-23 12:39:51 +02:00
Wim Taymans
da95043002 channelmix: guard against invalid channels 2022-06-23 11:40:22 +02:00
Wim Taymans
cc463da63e audioadapter: adjust max input ports
The control port adds an extra input port.
2022-06-23 11:39:27 +02:00
Wim Taymans
a365b19110 audioconvert: handle too many channels earlier 2022-06-23 11:28:27 +02:00
Pauli Virtanen
6bfe9a362c audioconvert: avoid crash on 64 channels + monitor enabled
this->monitor enabled adds an additional port in reconfigure_mode. If
there was already the maximum 64, this will crash.

Make maximum number of ports one larger than max channels to avoid
problems.
2022-06-23 09:11:25 +00:00
Wim Taymans
0f62d3442c alsa: handle driver bugs better
Use the NEAREST flag when setting a format. This only works for raw
formats and will update the format with the nearest accepted rate
or channels. We can then query the real configured format and use that
for the converter.

This makes things work when a driver tells us it can do 44100Hz but then
refuses and changes the rate to 48000.

See #2197, #2457, #2455, rhbz#2096193
2022-06-23 10:20:49 +02:00