Commit graph

223 commits

Author SHA1 Message Date
Wim Taymans
05ea4520e6 audioconvert: improve debug 2023-06-14 16:57:13 +02:00
Wim Taymans
09f480ccb3 audioconvert: fix monitor port latency
The monitor port latency is the reverse direction of the input ports.
2023-05-25 20:05:54 +02:00
Wim Taymans
ae9262409f audioconvert: suggest to inline some functions 2023-05-18 10:21:47 +02:00
Wim Taymans
e3cfd73b9e audioconvert: use target_rate/quantum when starting
When the node is starting and negotiating, use the target_rate and
quantum because that is what is going to be used in the next cycle.
2023-05-09 15:53:36 +02:00
Wim Taymans
9967c35bbe audioconvert: exit early to ask more data
We don't need to peek all the output buffers before deciding that we
need more data. Just check if we have input, if not ask more data.
2023-05-05 21:34:53 +02:00
Pauli Virtanen
6e17962ad0 impl-port/audioconvert: add PORT_IGNORE_LATENCY
Add port.ignore-latency prop, which if true causes peer ports to ignore
the latency of the given port.

This is useful for ports that are not intended to affect latency
calculations of other ports, such as ports in monitor streams.
2023-05-03 18:01:00 +00:00
Wim Taymans
b262812643 audioconvert: always allow peaks resampler
When we're using the peaks resampler, allow resampling, even when it is
disabled in the config.

The peaks resampler is just for GUI and would not really change the
signal, so we can allow this.
2023-04-27 17:10:41 +02:00
Wim Taymans
edf2062830 fix compilation 2023-04-05 19:53:33 +02:00
Wim Taymans
6dcf0027d8 audioconvert: implement mix/resample_disabled
Fail when resampling or channelmixing is required but disabled.
2023-04-05 19:51:16 +02:00
Ashok Sidipotu
7dbad54ae5 audioconvert: donot return errors in the volume ramp setparams
Also avoid the divide by zero while generating sequence.
2023-04-05 16:27:48 +05:30
Wim Taymans
d41d8cf983 audioconvert: fix return values
Return negative error numbers for errors.
2023-04-03 21:34:10 +02:00
Ashok Sidipotu
dcec2e785e audioconvert: add a invalid value for scale
The invalid value here is zero, this will help avoid inadvertant parameter
updates and brings this on par with rest of the volume ramp parameters
2023-04-03 19:04:55 +00:00
Ashok Sidipotu
74872250e8 audioconvert: make volume ramp parameters non-sticky
This mean the volume ramp parameters will have to be issued along with volume
every time. They will not be persistant.
2023-04-03 19:04:55 +00:00
Ashok Sidipotu
737bc89ab9 audioconvert: grow the volume ramp buffer
Grow the volume ramp sequence command buffer dynamically, if needed.
2023-04-03 19:04:55 +00:00
Ashok Sidipotu
8bfafaeca2 audioconvert: add support of volume ramp scale parameter
- Add support for Linear and Cubic volume scales
- Also start treating a "zero" value of volume ramp parameters as invalid
2023-04-03 19:04:55 +00:00
Ashok Sidipotu
b0f6c4a8c0 audioconvert: add support for volume ramp time params 2023-04-03 19:04:55 +00:00
Ashok Sidipotu
40cf237eb3 audioconvert: add volume ramp parameters
Add volume ramp parameters and the add ramp up and down funtions which get
triggered on volume change.
2023-04-03 19:04:55 +00:00
Ashok Sidipotu
3b1ce6c268 audioconvert: parameterize channelmix_process_control() function
Decouple the function from control port and parameterize it, so that it can be
called any spa pod sequence.
2023-04-03 19:04:55 +00:00
Wim Taymans
d07e1b5641 audioconvert: disable upmix by default again
But instead ship config override files to enable it again.

The idea is that distros can make extra packages that can than be
installed to enable the upmixing.

Also ship a config file to enable more samplerates.

Fixes #3081
2023-03-22 15:21:55 +01:00
Wim Taymans
689184a5e7 audioconvert: check return value of pod parse 2023-03-16 12:33:08 +01:00
Wim Taymans
670bf8fe8f echo-cancel: add wav debug file support 2023-03-09 16:31:30 +01:00
Wim Taymans
0563e1da52 audioconvert: add debug.wav-path to save wav 2023-03-09 16:22:55 +01:00
Wim Taymans
a2b391b5c7 Improve debug log a little 2023-03-07 19:11:38 +01: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
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
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
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
Wim Taymans
144df8675f audioconvert: enable channelmix.mix-lfe by default
It seems OK and SDL also seems to mix LFE by default so what could
possibly go wrong.

Fixes #2425
2022-12-13 16:29:46 +01:00
Wim Taymans
63f279c826 audioconvert: remove default channel map
If there is no valid channel map, assume MONO channels. A valid channel
map should be assigned at the source of the data, not here.

The problem is that when a device uses AUX channels, this will be fixed
up here with a surround setup, which is not right.
2022-12-12 09:40:51 +01:00
Wim Taymans
d6101d73e7 audioconvert: fix PortConfig enumeration
Enumerate what we can support in EnumPortConfig.
Enumerate what is configured in PortConfig.
2022-12-05 09:15:48 +01:00
Wim Taymans
bb558b7d95 audioconvert: don't overwrite port
Make a new variable to iterate the other ports so that we can use the
original port to emit notifications.

Fixes Latency and other params set on DSP ports.
2022-11-18 13:21:14 +01:00
Wim Taymans
90f5b4a4bf audioconvert: improve renegotiation
When the follower updates EnumFormat, it probably wants to renegotiate
to a new format, so clear the current format so that we do that when
starting the next time.

EnumFormat should also not only return the current format in case we
are negotiated but it should return all possible formats.

See #2832
2022-11-17 19:26:46 +01:00
Wim Taymans
086ad336ad audioconvert: redo setup when format changes 2022-11-15 16:29:46 +01:00
Wim Taymans
bf3516ba04 audioadapter: perform setup again after a PortConfig
After the ports are reconfigured, we need to perform the setup again so
that buffers and processing can happen with the right settings.

This fixes an issue when autoswitching between A2DP and HFP with
bluetooth headsets when there is also a stereo capture device available.
The input stream of the browser is quickly reconfigured between stereo
and mono with only a Pause command in between, clearing the setup state
is enough to redo the setup when going back to Playing.

Fixes #2764
2022-11-15 15:40:47 +01:00
Wim Taymans
b07e0c1445 audioconvert: debug in and out positions 2022-11-09 15:19:46 +01:00
Wim Taymans
74447acedb Add some more format checks
The format parse functions don't really check if the parsed values
make any sense so we need to to this ourselves.
2022-11-03 13:10:32 +01:00
Wim Taymans
3a7d6b74f2 audioconvert: only reinit channelmix when params change
Don't reinitialize the channel mixer when only the volume changes.
2022-10-13 10:31:09 +02:00
Wim Taymans
0adc351d36 audioconvert: use spa_dtoa to format floats and doubles
The parsing functions expect float values in the default locale so use
the spa_dtoa function to generate such a float.

Fixes setting params with floating point values when the locale is not
the default locale.
2022-10-13 10:15:52 +02:00
Wim Taymans
01058d9b4c audioconvert: avoids pops and clicks when activating resampler
When we were using the resampler and then bypass it when the configured
rate == 1.0, we create a pop because we don't process the queued data in
the resampler anymore.

Avoid this by keeping the resampler active as soon as the rate property
is set on the audioconvert. The resampler itself will use a more
efficient copy method in that case anyway and it is expected that the
rate will change again later when we need to reactivate the resampler.
2022-10-07 15:05:22 +02: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
10f1d545a7 audioconvert: handle NULL params 2022-09-28 12:14:52 +02:00
Wim Taymans
a579fc49ba audioconvert: move peaks functions to separate file
Make a peaks finder helper and use it in the peaks resampler.
2022-09-27 11:25:02 +02:00
Wim Taymans
2d858e0ba2 spa: a Flush command does not stop processing
A flush command is not supposed to stop playback but just clear the
current state. Normally, to avoid complications, an application will
Pause, Flush and optionally Start to do things smoothly without
interfering with the process loop, but things should not crash if that's
not the case.

Fixes #2726
2022-09-26 11:10:02 +02:00
Wim Taymans
e8aef6b4bd audioconvert: only Suspend should trigger negotiate
A Suspend should clear all the negotiated state and start a new
negotiation in Start. Use a flag to control this.

This avoids recalculation of state for each pause/play state change.

See #2701
2022-09-23 15:32:36 +02:00
Wim Taymans
31f9e18edb audioconvert: add resample.prefill option
Add a resampler option to prefill the resampler with 0. This then
results in the resampler always outputing and consuming the same
amount of data instead of a short buffer in the beginning.
2022-09-19 12:35:49 +02:00
Wim Taymans
aca85b49ea audioconvert: set stride on output buffers 2022-09-19 12:01:24 +02:00
Wim Taymans
46c8c9ec03 audioconvert: set monitor port buffer size correctly
Also use quantum_limit samples on the monitor ports.

Fixes #2677
2022-09-08 12:25:28 +02:00
Wim Taymans
201e6ae9fd audioconvert: use given channelmap for volume
Use the given channelmap for the volume, like it used to be in old
audioconvert.

This makes new streams expose a volume even when not negotiated yet.
2022-09-05 15:29:16 +02:00
Wim Taymans
71ec8650ba audioconvert: remove redundant set_volume calls 2022-09-05 13:23:18 +02:00
Wim Taymans
0c47ab76a7 channelmix: Only filter FC/LFE when present 2022-09-05 13:22:40 +02:00