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
Wim Taymans
13ccccbfbd
audioconvert: add missing file
2022-06-24 14:15:17 +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
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
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
Wim Taymans
a427e602bd
audioconvert: in merge mode, flush input
...
In merge mode we handle 1 quantum and then flush the input and
output. Fixes a case were samples were cut at the start.
2022-06-22 15:48:09 +02:00
Wim Taymans
d13a206866
audioconvert: fix resampler in_offset
...
Only advance the in_offset with the number of samples that were consumed
by the resampler. In case when the resampler is filling up an old
buffer, this can be less than n_samples.
Fixes a2dp source and possibly others.
2022-06-20 12:33:52 +02:00
Lucas Holt
6a15a02ec2
Add support for MidnightBSD
...
Fix build issue
Fix build issue
2022-06-19 18:22:47 +00:00
Barnabás Pőcze
492a328227
spa: audioconvert: free resampler
...
resample::free() needs to be called in `impl_clear()` otherwise the
resampler's private data is leaked when the audioconvert instance is destroyed.
2022-06-16 19:49:50 +02:00
Wim Taymans
3cb5fab176
audioconvert: rework the control loop
...
Use the offset to skip entries in the sequence array.
Use one loop to handle intermediate and trailing samples.
Fixes an issue where the last chunk of a sequence would be ignored.
2022-06-16 16:45:32 +02:00
Wim Taymans
de2e819fec
audioconvert2: rename to audioconvert
2022-06-16 09:19:05 +02:00
Wim Taymans
cf04bb573c
audioconvert: remove old plugins
2022-06-16 09:16:49 +02:00
Wim Taymans
c160cd0176
audioconvert2: implement control port
...
Add a control port when requested in the PortConfig.
Fix the sequence loop.
Make a copy of the sample pointers before changing them.
2022-06-16 09:09:27 +02:00
Wim Taymans
5a60fd7041
audioconvert2: remove unused monitor field
2022-06-16 09:09:27 +02:00
Wim Taymans
194b8e2d97
audioconvert2: emit param change when volume changes
2022-06-16 09:09:27 +02:00
Wim Taymans
0ec41e60ef
audioconvert2: fix for quantum changes
...
Use the offset as the buffer size.
Use the amount of requested - amount of used samples as queued samples.
2022-06-16 09:09:27 +02:00
Wim Taymans
fa9baa6488
examples: fix up adapter-control
...
Negotiate format, then buffers.
Give quantum-limit as a property when making nodes.
Set clock and position io and fill in rate and duration.
2022-06-16 09:09:27 +02:00
Wim Taymans
db49021104
audioconvert2: add control port processing
2022-06-16 09:09:27 +02:00
Wim Taymans
d5c28149f1
audioconvert2: fix in/out queued samples
2022-06-16 09:09:27 +02:00
Wim Taymans
7fe15ee5db
audioconvert2: add beginnings of control ports
2022-06-16 09:09:27 +02:00
Wim Taymans
d3baa16559
audioconvert2: reset node in Flush/Suspend
2022-06-16 09:09:27 +02:00
Wim Taymans
8e6a8a705b
audioconvert2: clamp in and output samples
...
Make sure we don't read or write more samples than available in the
buffers.
2022-06-16 09:09:27 +02:00
Wim Taymans
9e93fe3c36
audioconvert2: remap volumes to right channels
...
We get the volumes with a channelmap of the input/output, remap this to
the channelmixer internal layout.
2022-06-16 09:09:27 +02:00
Wim Taymans
50c37cc801
audioconvert2: rearrange some code
...
Move some code around so that we don't have to prepare the output
buffers when there is no input to process.
2022-06-16 09:09:27 +02:00
Wim Taymans
d5e333eea7
audioconvert2: in merge mode, always process quant samples
2022-06-16 09:09:27 +02:00
Wim Taymans
c4d77d421a
audioconver2: process monitor ports immediately
2022-06-16 09:09:27 +02:00
Wim Taymans
f45f1acd82
audioconvert2: use the position rate as resampler rate
...
For the DSP inputs, use the position rate.
2022-06-16 09:09:27 +02:00
Wim Taymans
58abc1ec15
audioconvert2: Improvements
...
Suggest 2 buffers by default.
Improve rate match flow.
monitor does not need the out_offset
Update rate match when we know the queued samples.
2022-06-16 09:09:27 +02:00
Wim Taymans
2352ae33c3
audioconvert2: add queueing
...
Use in and out offset to read/write partial input/output.
2022-06-16 09:09:27 +02:00
Wim Taymans
d728076d33
audioconvert2: handle drain
2022-06-16 09:09:27 +02:00
Wim Taymans
1c4058b947
audioconvert2: clamp offset and size
2022-06-16 09:09:27 +02:00
Wim Taymans
229a7b6019
audioconvert2: fix default settings
2022-06-16 09:09:27 +02:00
Wim Taymans
f2c1fe106d
audioconvert2: more fixes
2022-06-16 09:09:27 +02:00
Wim Taymans
3806cdaa6f
audioconvert2: more improvements
...
Use a wildcard rate for DSP ports.
Handle wildcards for rate and channels.
Calculate required in/out samples using quantum
Limit monitor and output number of samples.
2022-06-16 09:09:27 +02:00
Wim Taymans
c0f34e9d9d
audioconvert2: set blocks a stride for DSP ports
...
They might not get connected and negotiated but we still need to
use empty buffers in that case.
2022-06-16 09:09:27 +02:00
Wim Taymans
2d6bf00acc
audioconvert2: add options
2022-06-16 09:09:27 +02:00
Wim Taymans
75ebdbdfa0
audioconvert2: start working on monitor ports
2022-06-16 09:09:27 +02:00
Wim Taymans
db2cbdf906
audioconvert2: DSP mode without format gives no ports
2022-06-16 09:09:27 +02:00
Wim Taymans
d53311099f
audioconvert2: format is optional for convert mode
2022-06-16 09:09:27 +02:00
Wim Taymans
e78a93d358
audioconvert2: fix audio rate property
2022-06-16 09:09:27 +02:00
Wim Taymans
9babdee6cd
audioconvert2: do input and output remapping
...
We remap the input channels to our cannonical layout and then remap it
to the target layout.
2022-06-16 09:09:27 +02:00
Wim Taymans
922a088129
audioconvert2: handle volume
2022-06-16 09:09:27 +02:00
Wim Taymans
0099b80098
audioconvert2: add properties
2022-06-16 09:09:27 +02:00