Commit graph

3402 commits

Author SHA1 Message Date
Barnabás Pőcze 83a510cba3 spa: libcamera: fix hook adding logic
Previously, if "add_listener" was called on the monitor device, then it
did not necessarily emit events about all devices because it called
`enum_devices()` which does not emit events about already existing
devices. So the very first listener would get all existing devices,
but subsequent ones would not get events about the existence of devices
that have already been seen by the monitor. Fix that by simply emitting
events about all existing devices if the current listener is not the first.
2022-09-15 11:17:47 +00:00
Barnabás Pőcze 74b66d939a spa: libcamera: do not try to acquire CameraManager if there is already one 2022-09-15 11:17:47 +00:00
Barnabás Pőcze 0f6c5a04c7 spa: libcamera: fix CameraManager event handling
libcamera's CameraManager runs the event handlers on its own thread,
thus synchronization is needed to ensure correct functionality.
Implement that by collecting hotplug events into a mutex protected queue
and signalling the main loop where they can be processed and the
"object_info" event can be safely emitted.
2022-09-15 11:17:47 +00:00
Barnabás Pőcze f9796fc024 spa: libcamera: remove unnecessary typedef 2022-09-15 11:17:47 +00:00
Barnabás Pőcze 02f2d6b48d spa: libcamera: remove unnecessary have_config member
An extra flag is not needed because the `config` pointer can be
checked to determine if a configuration has already been retrieved.
2022-09-15 11:17:47 +00:00
Barnabás Pőcze 9374c15c3d spa: libcamera: use std::optional intead of separate bool flag + value
`std::optional` conveniently encapsulates a value and a bool flag,
so use that instead of manually replicating it.
2022-09-15 11:17:47 +00:00
Barnabás Pőcze 13357fec20 spa: libcamera: manage libcamera::CameraManager via a shared_ptr
Using a shared_ptr removes the need for manually calling
`libcamera_manager_release()` to drop the reference as it is done
automatically whenever the shared_ptr is destroyed or reset.
2022-09-15 11:17:47 +00:00
Barnabás Pőcze 330686d3aa spa: libcamera: rework construction/destruction of libcamera source impl
Move some things into constructors and try not to depend on the
fact that the storage is zero initialized, try to initialize
everything properly.
2022-09-15 11:17:47 +00:00
Barnabás Pőcze 98193f7d67 spa: libcamera: remove two unused members from libcamera source
Neither `next_fmt`, nor `next_size` were actually used, remove them.
2022-09-15 11:17:47 +00:00
Barnabás Pőcze 222368e562 spa: libcamera: properly construct/destruct libcamera manager impl
Previously, the libcamera manager `impl` object was neither properly
constructed neither properly destructed. As a consequence, for example,
the shared pointers in the `devices` array weren't properly destructed,
although this has been somewhat mitigated by a previous change
that modifed `clear_devices()`.
2022-09-15 11:17:47 +00:00
Barnabás Pőcze cc229d4b05 spa: libcamera: properly construct/deconstruct libcamera device impl
Previously, the "impl" object was never properly constructed or
destructed, but it more or less worked out since the memory was initialized
to zero bytes and each member had trivial constructors. Except std::shared_ptr,
but an all zero storage happened to be equivalent to a default constructed
shared_ptr.

However, there was the still the problem that the shared_ptr was never
destructed, so it kept the referenced `Camera` object alive, which lead
to memory leaks.

An additional, somewhat unrelated change is that the "props" struct
is removed, and the device identifier is now stored in an `std::string`.
The reason is that `CameraManager::get()` already takes a const std::string reference,
so an std::string must be constructed in any case, so we might as well
take advantage of that and use `std::string` in the "impl" object as well.

Furthermore, wrap the `impl` struct in an anonymous namespace
to avoid name resolution problems.
2022-09-15 11:17:47 +00:00
Barnabás Pőcze f699fa698e spa: libcamera: remove main loop from manager
The libcamera manager does not actually use the event loop
that it acquires during initialization. Remove it.
2022-09-15 11:17:47 +00:00
Barnabás Pőcze 13208220d8 spa: libcamera: print camera id when it appears/disappears 2022-09-15 11:17:47 +00:00
Barnabás Pőcze 086de7dcac spa: libcamera: properly dispose of shared_ptr
Previously, in `remove_device()`, the last device would be copied into
the slot of the to-be-remove device. The problem with this is that it
left the shared_ptr untouched in the previously last slot, and hence
creating an extra reference. Fix this by moving instead of copying.

A similar problem is present in `clear_devices()` which also
did not properly dispose of the shared_ptrs. Fix that by
calling `reset()` on each device's camera pointer.
2022-09-15 11:17:47 +00:00
Barnabás Pőcze 442a0c54ea spa: libcamera: move shared_ptr to avoid copy 2022-09-15 11:17:47 +00:00
Barnabás Pőcze ba04a0f936 spa: libcamera: take raw pointer to avoid shared_ptr copy 2022-09-15 11:17:47 +00:00
Barnabás Pőcze 9370fbee3d spa: libcamera: indent with tabs instead of spaces 2022-09-15 11:17:47 +00:00
Frédéric Danis fdccc10bc7 bluez5: Use SelectProperties Endpoint property to detect device role
BlueZ adds the Endpoint property to the Properties dictionary of
SelectProperties.
This allows to know which remote Endpoint is an acceptor, and so which
local transport should be used as an initiator.
2022-09-15 11:17:20 +00:00
Frédéric Danis d4b639419a bluez5: Init BAP LC3 coder/decoder depending on direction
For LE Audio, sink and source have their own media transport endpoint.
Media sink or source only needs the coder or decoder respectively.
2022-09-15 11:17:20 +00:00
Frédéric Danis 28b4fbecfb bluez5: Manage BAP linked transports
Multiple transport from the same device may share the same stream (CIS)
and group (CIG) but for different direction, e.g. a speaker and a
microphone. In this case they are linked.
In this case:
- On acquire, if another transport has already been acquired, the new
  transport should not call Acquire or TryAcquire but re-use values from
  the previously acquired transport,
- on release, the closing of transport fd and call to Release should be
  done only for the last transport.
2022-09-15 11:17:20 +00:00
Frédéric Danis 81f70aa1ec bluez5: Allow media source connection for BAP 2022-09-15 11:17:20 +00:00
Frédéric Danis cd50188787 bluez5: Fix node creation depending on device role
We can't determine which remote endpoint or device the
SelectConfiguration() call is associated with. For LE Audio BAP, as this
method is called only for the Initiator we set the whole instance as a
Central/Initiator.
This flag is unset on BAP media endpoint removal.
2022-09-15 11:17:20 +00:00
Frédéric Danis e0c79959fc bluez5: Add stereo support to LE Audio LC3 codec 2022-09-15 11:17:20 +00:00
Frédéric Danis fd1b331353 bluez5: Fix sink timeout for BAP
Data should be written to the ISO Stream fd every 10ms or 7.5ms depending
on the configuration selected.
2022-09-15 11:17:20 +00:00
Frédéric Danis 071730ecab bluez5: Use delay from QoS for BAP 2022-09-15 11:17:20 +00:00
Frédéric Danis 39ef812ed5 bluez5: Complete BAP audio location mapping 2022-09-15 11:17:20 +00:00
Frédéric Danis f428b13d06 bluez5: Set BAP QoS depending on selected configuration
This move the QoS setup to be codec specific and fills it depending on the
selected codec configuration.
2022-09-15 11:17:20 +00:00
Frédéric Danis 284da66deb bluez5: Add BAP_SINK/SOURCE from PACS UUID to adapter profiles
BAP sink/source are characteristics of the PACS profile, but we're more
interested by those characteristics then the more generic profile.
2022-09-15 11:17:20 +00:00
Frédéric Danis 496dda1bcc bluez5: Check if BlueZ daemon support LE Audio
Legacy BlueZ 5 API doesn't support to register BAP codecs, which prevents
to register A2DP enhanced codecs.
2022-09-15 11:17:20 +00:00
Frédéric Danis b7ad1d1869 bluez5: Add SelectProperties DBus method support 2022-09-15 11:17:20 +00:00
Frédéric Danis 96acc5a79a bluez5: Add LE Audio BAP support to bluez5-device 2022-09-15 11:17:20 +00:00
Frédéric Danis 201fd7755d bluez5: Add LC3 codec support to LE Audio BAP
By default this codec is disabled as the BlueZ support for LE Audio is
still experimental.
2022-09-15 11:17:20 +00:00
Frédéric Danis fd0bcb1699 bluez5: Add LE Audio BAP support to media-codecs 2022-09-15 11:17:20 +00:00
Frédéric Danis 00d51c3d31 bluez5: Rename codec API from *a2dp* to *media*
The BlueZ Media1 interface will not only be used for A2DP but also for
LE Audio and code related can be shared.
2022-09-15 11:17:20 +00:00
Wim Taymans 565bb2c493 resample: fix peaks sse code
Fix the shuffle arguments.
Use another way of making 0x80000000 and use andnot to remove the
sign bit.
2022-09-14 16:58:41 +02:00
Dmitry Sharshakov 3b89e6f369 alsa-seq: add an option to disable longname in MIDI ports
Untested yet

Signed-off-by: Dmitry Sharshakov <d3dx12.xx@gmail.com>
2022-09-13 07:46:40 +00:00
Dmitry Sharshakov ea646c2d98 alsa-seq: set card long name or number in port names
Signed-off-by: Dmitry Sharshakov <d3dx12.xx@gmail.com>
2022-09-13 07:46:40 +00:00
Wim Taymans 5e890925a0 module-echo-cancel: don't load newer modules
Add some version comments for the new AEC methods
2022-09-13 09:44:36 +02:00
Jonas Holmberg 70471989e5 module-echo-cancel: Add activate/deactivate methods
Add methods activate() that is called before first call to run() when
stream starts and deactivate() that is called after last call to run()
when stream stops. This makes it possible for aec-plugins to reset their
state between streams.
2022-09-12 18:24:07 +00:00
Wim Taymans 634d7107a4 v4l2: use the device name to open in BeginParams 2022-09-12 09:51:55 +02:00
Wim Taymans a7c28d64ae resample-peaks: small improvement
Makes it easier for the compiler to make a constant.
2022-09-08 15:40:01 +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 903f831b2d alsa: scale min value back to nominal rate 2022-09-07 23:39:51 +02:00
Wim Taymans 7057cca05e alsa: adjust min and max rates
Use the DSD scaler and interleave factors to calculate the min and
max rates.
2022-09-07 21:58:32 +02:00
Wim Taymans 955815b468 alsa: only scale DSD samplerates 2022-09-07 21:42:45 +02:00
Wim Taymans 68581235ae alsa: fix min dsd rate
We just need to allow from DSD64 onwards. Remove some unused fields.
2022-09-07 20:23:53 +02:00
Wim Taymans 72b6788c68 alsa: don't set impossible rates
When the max rate is smaller than the min rate, don't add the DSD
format at all because it is not possible to play it.

See #93
2022-09-07 19:58:30 +02:00
Wim Taymans 23522651f9 alsa: dsd rates are expressed in byte rate
DSD64 would be a rate of 44100 * 64 / 8. When packed in U32_BE, we would
negotiate 44100 * 8 / 4 (88200) with the device, this means all rates
from 88200 and up are allowed for DSD64 in U32_BE.
2022-09-07 19:54:09 +02:00
Wim Taymans c9ee142b78 resample-peaks: unroll loop a little 2022-09-07 16:18:58 +02:00
Wim Taymans 187006f30e audioconvert: remove some double defines 2022-09-07 16:08:21 +02:00
Wim Taymans 6e9e02b420 audioconvert: refactor peaks resampler
Use common code in macro and generate arch specific version.
Compile with -Ofast to optimize some fmaxf calls.
2022-09-07 16:00:31 +02:00
Wim Taymans 968bc382af log: initialize pos to help the compiler
Although pos will be set to 0 in the first iteration, the compiler does
not seem to figure this out, so help it a little:

../spa/include/spa/support/log.h:306:21: warning: ‘pos’ may be used uninitialized [-Wmaybe-uninitialized]
  306 |                 pos += sprintf(str + pos, "%02x ", buf[i]);                             \
      |                     ^~
../spa/include/spa/support/log.h:301:13: note: ‘pos’ was declared here
  301 |         int pos;                                                                        \
      |             ^~~
2022-09-07 09:17:19 +02:00
Frédéric Danis 2c72597271 bluez5: Use spa_log_hexdump() to dump media properties/configuration 2022-09-07 07:50:23 +02:00
Frédéric Danis 1d39ea004e log: Add spa_log_hexdump 2022-09-07 07:50:23 +02:00
Wim Taymans 5b2b93f915 alsa: add period-size, period-num and headroom in props
Add the currently configured alsa hw_params in the properties for
easier access.
2022-09-06 20:16:29 +02:00
Wim Taymans ffc09ce55e videoconvert: refresh with latest audioadapter copy 2022-09-06 17:48:00 +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
Wim Taymans 7b432aec88 spa: make default samplerate 48000
Remove some 44100 default rates and use 48000 instead.
2022-09-05 12:21:20 +02:00
Wim Taymans cad7db9f58 libcamera: close camera in error path 2022-09-05 09:25:42 +02:00
Pauli Virtanen df858cae7c bluez5: clarify OPUS-A2DP spec
Also remove DRAFT tag.
2022-09-03 19:08:27 +00:00
Wim Taymans 9123710971 spa: clean up some port io checks
We should not generate a warning.
2022-09-01 15:39:34 +02:00
Wim Taymans 2fa1b4384b spa: don't warn for NULL io
The io is set to NULL when the port becomes unnegotiated.
2022-09-01 15:31:14 +02:00
Wim Taymans 2054dcf36f alsa: Improve format negotiation
When the device is not running but has a format, close/open the
device to get all the available formats again. Do the same when
setting a format.

Otherwise, the configuration space of the device is restricted to the
current negotiated format and we can't query the other possibilities
or change it.

Fixes #2625
2022-08-31 10:03:39 +02:00
Wim Taymans b33ffcf683 test: print channel map as reported by alsa as well
See #1707
2022-08-30 16:45:35 +02:00
Wim Taymans 24f6225c5d audioconvert: don't emit changed events for rate changes
Rate changes can happen very often when a stream is doing rate control,
so don't emit the changes every time.
2022-08-30 16:00:00 +02:00
Thomas Weißschuh 2394413ec3 hook: don't remove from unitialized list
A lot of code calls spa_hook_remove() from error paths where the hook
and therefore the list may not have been initialized.
This leads to null-derefences.
2022-08-30 11:52:42 +00:00
Thomas Weißschuh b23b0e6125 list: add spa_list_is_initialized()
This function can be used to test if a list has been initialized.
2022-08-30 11:52:42 +00:00
Wim Taymans e04e3ef40e audioconvert: fix rate match for sources
Only update the resampler rate when we ask for more data, when we have
more input data, use the previously configured rate to calculate how
many samples we will consume.

Fixes resync errors with multiple sources. One source would do rate
matching, audioconvert would ask it to produce X samples, the source is
scheduled to produce the samples, the rate match is updated with the new
rate correction, audioconvert is scheduled again. It should now use the
X samples it asked to produce and apply the new rate correction for the
next iteration.
2022-08-30 12:43:14 +02:00
Pauli Virtanen c0e8b397f6 bluez5: avoid (harmless) integer overflow
If no packets have been received and spa_bt_decode_buffer_process is
called, this->packet_size.max == INT32_MIN, which can give overflows.

Guard against this condition, although it should be harmless.
2022-08-24 16:59:21 +00:00
Thomas Weißschuh 6531bedcdb spa: add SPA_WARN_UNUSED_RESULT 2022-08-19 07:35:02 +00:00
Frédéric Danis 6b3390387d bluez5: Test transport pointer before using it
If this->transport is NULL the debug log will crash.
2022-08-18 12:57:04 +02:00
Barnabás Pőcze 68ff3ad841 treewide: meson.build: use host_machine instead of build_machine
At the moment, cross compilation may not work in certain cases because
checks are carried out against the build machine instead of the host machine.
Replace uses of `build_machine` with `host_machine` to fix that.

In native compilation, all three "machine objects" available in meson
are the same, so this change should have no effect in that case.

More: https://mesonbuild.com/Cross-compilation.html
2022-08-17 07:34:20 +00:00
Barnabás Pőcze 358254f20a spa: meson.build: add missing new line 2022-08-17 07:34:20 +00:00
Pauli Virtanen b9baeeb587 bluez5: opus: react faster to too long packet queue
React immediately to "bad" buffer level. Use smaller bitrate
increments/decrements.  Fix ABR timer increment for fragmented packets.
Handle actual bitrate being smaller than target during silence.
2022-08-13 15:58:08 +03:00
Pauli Virtanen c1acb5168d bluez5: bump Opus max bitrates
Limit bitrates to 2-2.5x Opus recommended "good quality", instead of
1.5x, which is safer quality-wise for CVBR.
2022-08-13 15:12:35 +03:00
Gleb Popov 4a0395d23e Enable AVB on Linux only. 2022-08-11 17:23:16 +03:00
Wim Taymans 3df0fb21a0 channelmix: only produce REAR/SIDE from FC in simple upmix
Only simple upmixing would replicate the FC channel into REAR/SIDE.
The PSD method would take the diff between FL/FR (which would
be 0 if only FC is available) and not generate output.
2022-08-11 09:37:43 +02:00
Wim Taymans da9868594d channelmix: produce STEREO from FC
Make it possible to produce STEREO from FC.
2022-08-11 09:35:54 +02:00
Wim Taymans b03b57c77a channelmix: also filter FC and LFE when no layout
Always apply filter based on dest layout, even when distributing,
averaging or copying a signal.
2022-08-11 09:33:34 +02:00
Wim Taymans 0ad7cb3298 loop: flush items before stopping
Before leaving the loop, flush out any pending items in the invoke
queue.

See #2631
2022-08-09 20:38:06 +02:00
Wim Taymans f971362f76 alsa: improve test
Add capture mode, add more info for class
2022-08-09 12:16:37 +02:00
Wim Taymans 80b59a4971 alsa: add test for dumping hw_params
See #2620
2022-08-09 11:51:20 +02:00
Pauli Virtanen 8f0478a2ce bluez5: sco-source: deal with incomplete CVSD frames
Rarely BT adapter may send CVSD packets with incomplete frames.  Ignore
such packets, as it's not clear if they contain valid data at all.
2022-08-05 13:12:24 +00:00
Wim Taymans 54b499b1cf alsa: do the right log level checks
spa_log_level_enabled does not work when a custom log level has
been set. Use spa_log_level_topic_enabled instead.
2022-08-05 15:03:22 +02:00
Wim Taymans 73073eb33f alsa: redirect alsa output to log file
Make a custom snd_output object that redirects output to the log
file.
2022-08-05 14:01:37 +02:00
Wim Taymans 0dc5a08bfd alsa: debug hw_params 2022-08-05 13:00:44 +02:00
Wim Taymans a9ced45d4b acp: add debug for open and close
Debug open and close calls.
Make pa_alsa_close to close the device.
2022-08-05 12:31:28 +02:00
Wim Taymans 34c1c1614e alsa: add some more debug
See #2614
2022-08-04 14:25:24 +02:00
Wim Taymans 1118c35956 acp: handle some more mixer NULL cases
These are in pulseaudio handled with asserts.

Fixes #2612
2022-08-04 09:06:28 +02:00
Wim Taymans 6c5ec409bf audioconvert: Improve buffer params
Scale the default size of the buffer with the sample rate conversion
factor.
2022-08-03 17:21:48 +02:00
Wim Taymans 6144d037ce acp: handle NULL mixer_handle
It can be NULL for some UCM configs.

Fixes #2612
2022-08-03 12:34:13 +02:00
Wim Taymans e22e522ab8 alsa-pcm: limit the target to the buffer size
Don't try to wait for more samples than can fit in the ringbuffer.

See #2603
2022-08-03 12:22:38 +02:00
Wim Taymans a23d154952 audioconvert: always use DSP rate on DSP ports
Always use the DSP rate on DSP ports for format conversion, not the
previous used rate.

This avoids some resampler reconfiguration as it negotiates a non-passthrough
rate conversion and then switches to passthrough when the rate correction is
done to match the graph rate.

See #2614
2022-08-03 11:32:10 +02:00
Frédéric Danis e7f17e1523 bluez5: use lower case for UUIDs
BlueZ uses lower case version for the UUIDs in its DBus interface.
This will simplify future UUID tests.
2022-08-03 06:15:54 +00:00
Frédéric Danis 76adcfaabe bluez5: Add AAC decoder 2022-08-02 11:12:25 +02:00
Isa Mert Gurbuz f32017c874 bluez5: Disable hw-volume for Soundcore Motion B 2022-08-01 19:34:39 +00:00
Pauli Virtanen 3579857a64 bluez5: opus: tweak ABR
Count retry from last non-good interval.  Minimum retry interval 5sec.
2022-08-01 19:23:07 +00:00
Pauli Virtanen 5724d405d6 bluez5: opus: better default bitrates
Use smaller bitrate caps, as it's not necessary to use all bandwidth
available.
2022-08-01 19:23:07 +00:00
Barnabás Pőcze aab15433c8 spa: aec: rename first argument of methods in spa_audio_aec_methods
The first parameter is a pointer to the object implementing the aec
interface, the name `object` is better than `data`.
2022-07-23 08:58:18 +00:00
Barnabás Pőcze 44e7817702 spa: aec: mark aec method tables const 2022-07-23 08:58:18 +00:00
Barnabás Pőcze c2d357b5af spa: aec: null: remove unnecessary cast 2022-07-23 08:58:18 +00:00
Barnabás Pőcze e88df3a324 spa: aec: null: initialize variable when defined 2022-07-23 08:58:18 +00:00
Barnabás Pőcze 98c0092ee7 spa: aec: null: specify vtable version 2022-07-23 08:58:18 +00:00
Barnabás Pőcze c9cc2fe6dc spa: aec: mark handle factory objects static 2022-07-23 08:58:18 +00:00
Barnabás Pőcze a506ddd799 spa: aec: webrtc: use static_cast to cast from void * 2022-07-23 08:58:18 +00:00
Barnabás Pőcze 35c011b955 spa: aec: webrtc: simplify webrtc_get_spa_bool() 2022-07-23 08:58:18 +00:00
Huang-Huang Bao c5bce24f01
bluez5: correct type of arguments to a dbus function
The 3rd "value" arguments to dbus_message_iter_append_basic() should be the address of a basic-typed value.

Fixes #2591
2022-07-23 16:35:01 +08:00
Frédéric Danis 343ae88bbf bluez5: Simplify DBus append_basic_* helpers
String key is used in all calls to append_basic_variant_dict_entry() and
append_basic_array_variant_dict_entry().
2022-07-22 19:10:26 +00:00
Frédéric Danis e560468800 bluez5: Removed unused variables in meson.build 2022-07-22 18:46:35 +02:00
Wim Taymans b1b8b0985a audioconvert: fix rounding on arm neon
Add the neon functions to the test
2022-07-21 17:24:55 +02:00
Pauli Virtanen 67c41336db bluez5: fix minor issues / warnings
Make static analysis happier.
2022-07-21 07:12:22 +00:00
Wim Taymans 38b3d027ec audioconvert: remove S32_SCALE
We don't use it, we use S24_SCALE and then shift. Also adjust the
S32_MIN and S32_MAX values, based on S24 values.
2022-07-20 17:45:34 +02:00
Barnabás Pőcze 5cdf4d6c64 spa: libcamera: remove unnecessary cast 2022-07-20 10:48:24 +00:00
Barnabás Pőcze 8bccad3ade spa: libcamera: only add "api.libcamera.location" property when available 2022-07-20 10:48:24 +00:00
Barnabás Pőcze 4072f63ab6 spa: libcamera: make cameraLoc() return a static string
There is no compelling reason to use `std::string`.
2022-07-20 10:48:24 +00:00
Barnabás Pőcze 237174b7f2 spa: libcamera: mark two functions static
`cameraLoc()` and `cameraModel()` are only used in one
translation unit.
2022-07-20 10:48:24 +00:00
Barnabás Pőcze 89d5d51bb3 spa: libcamera: fix build error due to return type change
libcamera commit 1c4d4801850559d6f919eef5c2ffbaf7675dbc46
changed the return type of libcamera::ControlList::get()
to be std::optional<T>. Adapt the code to this change.

Fixes #2575
2022-07-20 10:48:24 +00:00
Wim Taymans 0bf7911b37 audioconvert: tweak resampler window some more
By: Kevin Yin

R->A calculation removed: it wasn't valid anyway. No behavior change.
Placed existing A in there directly.

cosh window -> strangely tweaked exp window: remove the discontinuity
at the border, which is wrong for a window function. If A changes in the
future, this window will be better. With the current A, you will not be
able to tell the difference on any graph. (Of course, it's not a cosh
window anymore.)

Fixes #2574
2022-07-20 10:18:47 +02:00
Wim Taymans 5a8af97a40 audioconvert: use SPA_CLAMPF to clamp floats
It generates better assembler.
2022-07-19 17:59:14 +02:00
Pauli Virtanen 434cc6a90b bluez5: add Opus as a (Pipewire-specific) A2DP vendor codec
Support Opus as A2DP vendor codec.

The specification for vendor A2DP codec is our Pipewire-specific one, so
it is compatible only with devices running Pipewire.
2022-07-19 13:44:56 +00:00
Pauli Virtanen bf52b2acff bluez5: add opus-a2dp-0.5 caps 2022-07-19 13:44:56 +00:00
Pauli Virtanen b6d237fa43 bluez5: add OPUS-A2DP specification 2022-07-19 13:44:56 +00:00
Pauli Virtanen 0dc8255057 bluez5: handle sink vs. source correctly in get_supported_codecs
Make a distinction between sink and source endpoints when determining
supported codecs.
2022-07-19 13:44:56 +00:00
Pauli Virtanen 889d507e9c bluez5: enable logging for codecs
Add codec->set_log for setting the logging object for each codec.

Bump codec API.
2022-07-19 13:44:56 +00:00
Pauli Virtanen d29aafd857 bluez5: enable A2DP duplex volume boost only if codec asks for it
Make A2DP volume boost conditional on a flag the codec sets.

Bump codec API version.
2022-07-19 13:44:56 +00:00
Pauli Virtanen 92b2b44954 bluez5: pass global setting dict to codec select_config / preference_cmp
The device is not know at SelectConfiguration time, so the settings
argument in select_config is currently unused. Pass on a global settings
dict instead, so that codec parameters can be configured.

Also add settings argument to caps_preference_cmp.

Bump codec API version.
2022-07-19 13:44:56 +00:00
Pauli Virtanen a8eb146d39 bluez5: tell the codec whether endpoint is sink or source
Add a flag A2DP_CODEC_FLAG_SINK to incidate a sink endpoint.

Also enum_config and caps_preference_cmp may need to know whether the
codec is being configured for SRC or SNK. Also add the flags argument to
init_props.

Bump codec API version.
2022-07-19 13:44:56 +00:00
Pauli Virtanen 8d66b2b2f7 bluez5: a2dp-source: more duplex codec workarounds
a2dp-sink writing duplex data to the BT socket breaks a2dp-source source
polling, also in A2DP source role. Hence, use the timer-based polling
workaround always in duplex mode.
2022-07-19 13:44:56 +00:00
Pauli Virtanen f593a44069 bluez5: a2dp-sink: support duplex codec
Allow running a2dp-sink using the duplex codec, when the local endpoint
is the A2DP sink.
2022-07-19 13:44:56 +00:00
Wim Taymans aaa015d0c0 avb: fix compilation on big endian 2022-07-19 13:06:52 +02:00
Wim Taymans 3c87541219 Revert "mixer-dsp: mix a quantum of data at a time"
This reverts commit ecc0eecf0f.

The io-position is not actually set or updated on the mixer node so it
might use the wrong values.

Fixes #2525
2022-07-18 21:34:57 +02:00
Pauli Virtanen d82cd959e7 audioconvert: add different channel remap testcase 2022-07-18 20:33:05 +02:00
Pauli Virtanen 977d6e2321 audioconvert: fix input remapping
As currently implemented, input format convert channel remap is no-op.
This is because although the out_datas array is permuted, the original
pointer array is not referred to later on, so the only effect is that
the temporary data array is stored in permuted order.

Fix the permutation by permuting the pointers only for the conversion
step.
2022-07-18 20:31:46 +02:00
Wim Taymans 4eb81b13ac audioconvert: add test
Add test for F32_7p1_remapped to F32P_7p1_remapped

See #1324
2022-07-18 18:55:30 +02:00
Wim Taymans 67754ad3bc meson: remove sse_args from plain c build 2022-07-18 13:00:12 +02:00
Wim Taymans ada39f3048 audioconvert: improve noise bits
Make a new noise method called PATTERN and use it to add a slow (every
1024 samples) repeating pattern of -1, 0.
Only use this method when we don't already use triangular dither.

See #2540
2022-07-18 11:41:57 +02:00
Wim Taymans 57f63feb92 audioconvert: Fix Wannamaker name 2022-07-18 10:22:21 +02:00
Wim Taymans 9dbd016f9d audioconvert: fix compilation warnings 2022-07-17 13:15:00 +02:00
Wim Taymans a4db745a7e audioconvert: improve noise shaping
Reorganize things a little so we can add more noise shapers.
Add sloped triangular noise.
Add wanamaker3 noise shaping.
2022-07-15 12:36:15 +02:00
Wim Taymans a458b39774 tests: add test for rounding 2022-07-14 10:48:37 +02:00
Wim Taymans 419517fd55 audioconvert: build C versions with -Ofast and -ffast-math
Move resampler implementations to a -c version.
Compile some of the functions with other flags to make them more
optimized.
2022-07-14 10:07:07 +02:00
Wim Taymans 0ba3e7c5db audioconvert: round instead of truncate, to reduce distortion
See #2543
2022-07-13 20:56:13 +02:00
Wim Taymans d18428f8bb audiconvert: make macros for conversions
Make a common macro for float to int and int to float so that we can
change the algorithms easily.
2022-07-13 18:10:25 +02:00
Wim Taymans 4062077472 avb: remove wrong cargs
Fix a typo
2022-07-13 13:14:07 +02:00
Wim Taymans e82145aeae spa-resample: don't flush too much
Also clamp the amount of input samples we push when flushing. do several
rounds of zero pushing until we have flushed enough.
Handle the cases where no input is needed or no output is generated.

Fixes crashes when downsampling from 96000 to 1000 Hz or so.
2022-07-13 12:02:12 +02:00
Fabian Vogt ed88cad583 spa/alsa-udev: Check accessibility of pcm devices as well
The order of attribute changes is random, so it's possible that controlCX is
accessible before the other devices, which marks the device as available but it
actually fails to open. Only consider the device accessible if both control and
PCM devices can be accessed.

This requires reacting to ATTRIB changes of pcm devices as well now.

Fixes #2534
2022-07-13 09:17:08 +00:00
Wim Taymans 52281b9a7e alsa: check the offset against the size of the buffer
We need to check the last offset against the size of the buffer, not the
remaining size in the buffer.

When the writing is split, this could cause the buffer to be reused
wrongly.

See #2536
2022-07-13 09:37:01 +02:00
Wim Taymans 11bc60a53d spa-resample: handle init errors 2022-07-12 17:39:58 +02:00
Wim Taymans ce9a912f1a audioconvert: set scale to cutoff when upsampling 2022-07-12 17:39:14 +02:00
Pauli Virtanen d6a7db8020 bluez5: mark HFP/HSP streams with media.role=Communication 2022-07-12 14:04:31 +00:00
Pauli Virtanen 6e37110efd bluez5: adjust source rate control
Use different filter function than spa_dll for the rate control.
Also use a longer window for spike determination.
2022-07-12 13:55:54 +00:00
Wim Taymans ee84f96915 audioconvert: tweak the resampler a bit 2022-07-12 14:35:23 +02:00
Wim Taymans f043922b24 avb: implement maap
Implement the maap state machine.
Use maap for the destination address of talker streams.
2022-07-12 12:27:22 +02:00
Wim Taymans 9f25adc0f6 avb: use spa dll 2022-07-12 12:27:22 +02:00
Wim Taymans af4875eb47 avb: remove libavtp dependency 2022-07-12 12:27:21 +02:00
Wim Taymans c79fddf007 avb: handle xruns better
Don't stop early, fill gaps with silence.
2022-07-12 12:27:21 +02:00
Wim Taymans 87053365ea avb: handle sink follower
We need to flush out the packets when we are a follower and when we get
data because our timer is not running as a sink.
2022-07-12 12:27:21 +02:00
Wim Taymans 4d6c71bf12 avb: use iovec to read from ringbuffer 2022-07-12 12:27:21 +02:00
Wim Taymans 5c3629a165 avb: add follower mode
As a follower we disable our own timer and produce a buffer from what we
have when _process is called.
2022-07-12 12:27:21 +02:00
Wim Taymans ff5201ef3d avb: check seq
Avoid infinite loops.
Check sequence number and warn
Use 32 frames per pdu in example.
2022-07-12 12:27:21 +02:00
Wim Taymans 200f591a3d avb: add source 2022-07-12 12:27:21 +02:00
Wim Taymans 552a0056b5 avb: more work
Handle properties.
Fix format negotiation.
Wait in underrun.
2022-07-12 12:27:21 +02:00
Wim Taymans 537a38355a avb: more work 2022-07-12 12:27:21 +02:00
Wim Taymans f95b8263e6 avb: more improvements 2022-07-12 12:27:21 +02:00
Wim Taymans 1adc94df11 start of AVB support 2022-07-12 12:27:21 +02:00
Wim Taymans 6a8fd7024e audioconvert: add and use AVX2 clamp macros 2022-07-12 10:45:41 +02:00
Wim Taymans 7745346292 audioconvert: add sse2 s16 dither functions 2022-07-12 10:34:13 +02:00
Wim Taymans c31928c5f0 audioconvert: add and use CLAMP macros 2022-07-12 10:33:37 +02:00
Wim Taymans c35006f040 audioconvert: move scaling to setup 2022-07-11 17:50:20 +02:00
Wim Taymans 68f883ff77 audioconvert: fix dither scale
Rectangular dither should be [-0.5, 0.5]
Triangular dither should be [-1.0, 1.0]
Noise should add extra bits.
2022-07-11 17:19:28 +02:00
Wim Taymans e313149f7f audioconvert: improve SSE2 dither generation 2022-07-11 16:41:12 +02:00
Wim Taymans 277addcca6 audioconvert: add triangular dither 2022-07-11 16:28:51 +02:00
Wim Taymans 9a5a71dda9 tests: add test for noise 2022-07-11 15:49:44 +02:00
Wim Taymans 03f918bf15 udev: prefix vendor.id and product.id with 0x
They are hex strings so prefix them with 0x to make sure they get
handled like that in properties.

Fixes #2527
2022-07-11 11:55:42 +02:00
Wim Taymans cbbc4baa3f json: avoid converting random string to floats
Only allow the json float characters when converting to float.
This avoids NAN, INF, 0xffe4 etc to be seen as a json float.
2022-07-11 11:50:58 +02:00
Wim Taymans bdfde2fdf0 Revert "spa: leave vendor.id and product.id in hex"
This reverts commit 0d33760b71.
2022-07-11 11:23:08 +02:00
Wim Taymans dd1d5960b4 audioconvert: implement f64s
Add swapping functions for f64s.
Fix the awkward interleave/deinterleave names for 32s.
2022-07-11 10:58:51 +02:00
Wim Taymans bc1789c3ea Revert "acp: sync with pulseaudio"
This reverts commit 57f0fdf746.

This seems to cause problems and needs to mature a bit more in
pulseaudio it seems.
2022-07-11 10:03:01 +02:00
Wim Taymans 8fe83e5304 audiomixer: optimize avx mixer some more
Add avx mixer to test and benchmark
Rework and unroll the avx mixer some more.
The SSE one is 10 times faster than the C one, The AVX is 20 times
faster. The SSE2 function is 5 times faster than the C one.
2022-07-10 23:13:24 +02:00
Wim Taymans 7a0445cb28 audiomixer: improve sse and sse2 mixer
Add mixer benchmark.
Improve sse and sse2 mixer function by removin some read/write to the
temporary buffer at the expense of more scattered reads.
2022-07-10 21:15:34 +02:00
Wim Taymans 5fbda82cc3 spa: tweak SPA_MIN and SPA_MAX
This generates much better assembler because it can use a cmov in
more cases.
2022-07-09 20:35:47 +02:00
Pauli Virtanen fe7c6bcef9 bluez5: volume changes from headset should be saved
User changing volume via headset buttons should be treated on the same
level as changing from desktop UI.  Also initial headset volume should
be considered saved (even though session managers currently ignore the
initial route values on route restore).

Mark route as saved on volume events.
2022-07-09 18:19:45 +00:00
Pauli Virtanen 77959a2c1c bluez5: get initial node volume from transport
When emitting node, get initial volumes from transport hardware volume,
if available.

The session manager usually overrides these immediately with saved
values, but it's better to show the HW volume when the node first
appears.
2022-07-09 18:19:45 +00:00
Pauli Virtanen d82b3d6479 bluez5: backend-native: set HFP/HSP volume when connecting
The HFP/HSP HW volume on the device is not necessarily what we think it
is.

Sync the device volume to our value at connect time.
2022-07-09 18:19:45 +00:00
Pauli Virtanen 276c4bc554 bluez5: use separate routes for HFP and A2DP
The A2DP and HFP profiles may have different volume curves, so trying to
convert volumes between the two can produce undesirable volume spikes.
For example, when one of them is using hardware volume and the other
software.

Fix by separating HFP and A2DP routes.
2022-07-09 18:19:45 +00:00
Wim Taymans bb2f054d43 tests: add missing file 2022-07-09 20:16:15 +02:00
Wim Taymans abd6806d71 tests: add sse and sse2 versions to tests 2022-07-09 20:11:46 +02:00
Wim Taymans 371b5a1836 audiomixer: rewrite the mixer functions
Let the mixer functions accumulate the intermediate results into a
larger size variable and then clamp to the final precission. This avoids
distortions because of intermediate clamping.

Although the access pattern of the reads are no longer sequential, the
writes are sequential and we don't need to read intermediate values.
Together with the avoided clamping this is probably faster overall.

Add a unit test for the various cases.
2022-07-09 18:11:13 +02:00
Wim Taymans 3ffb9f4b26 audioconvert: improve s24_32 and u24_32 conversion
We should ignore the upper 8 bits, so first shift them out and then
use the s32/u32 conversion functions.
Add a test for this.
2022-07-09 18:07:49 +02:00
Wim Taymans 20172bfbe6 spa: add comment about prefetch 2022-07-08 17:02:46 +02:00
Lucas Holt 4c3f5a7655 When adding MidnightBSD support, I inversed the condition here. 2022-07-08 12:25:58 +02:00
Wim Taymans a1fac201e3 audioconvert: don't use uninitialized max_out
Move the calculation of the expected max output size before collecting
the buffers and doing the monitor ports so that we can get the size
correct.
2022-07-08 11:31:22 +02:00
Wim Taymans e53eefef0d stream: implement prefetch
When the audioconverter needs more data, let it return NEED_DATA. This
can happen before the ports actually have consumed all the input data.
For example, then the next cycle would require 1024 samples but there
are currently only 16 samples queued, the next cycle will consume the
16 samples and then need another buffer to produce output.

For rt streams, this is not a problem because a new buffer will be
fetched in the next cycle synchronously.

When the stream is async, we can use this NEED_DATA to prefetch a
new buffer so that we have one in the next cycle.

This fixes hickups with async streams that provide random sized
buffers.
2022-07-08 10:48:29 +02:00
Wim Taymans 9714ce83d4 audioconvert: only consume what is needed
Move the setup of the output buffers first.
Then figure out how many samples we need to produce and consume.
Make sure we use the resampler to only convert the input samples that
are needed to produce the output samples.

Fixes some muddled sound with mpv when upmixing.
2022-07-08 10:45:44 +02:00
Wim Taymans 7b01068837 audioconvert: consume right amount of input samples
When we are not using the resampler, we consume the same amount of
input samples as output samples.

Fixes #2519
2022-07-08 09:23:31 +02:00
Wim Taymans df40c9bf6a fmt-ops: express 32 bits formats in terms of 32_24 bits formats 2022-07-07 20:11:08 +02:00
Wim Taymans 0343e0da73 fmt-ops: fix some missing shifts and min/max 2022-07-07 18:57:03 +02:00
Wim Taymans b8a4bf880f audioconvert: use 24 bits for 32 formats
The float only preserves 24 bits so use this. Otherwise we get overflows
and errors in clang.
2022-07-07 18:38:32 +02:00
Wim Taymans f9660f5e8f audiomixer: clean up mixer functions
Use the same limits as the format converter.
Use a struct for 24bits.
Use macros to generate the mixers.
2022-07-07 13:12:50 +02:00
Wim Taymans 4a82cb74e8 resample: switch to cosh window function 2022-07-07 12:26:45 +02:00
Wim Taymans 57f0fdf746 acp: sync with pulseaudio 2022-07-07 12:23:28 +02:00
Wim Taymans 273c95d71b resample: tweak cosh parameter, this look really good 2022-07-07 10:18:52 +02:00
Wim Taymans 74bed47a56 audioconvert: don't leak converter data 2022-07-06 21:06:55 +02:00
Wim Taymans 08d918432f tests: add more audioconvert remap test
Add tests for all permutations of input/output remappings.
2022-07-06 20:57:04 +02:00
Wim Taymans 4036b8a3f0 tests: add audioconvert test
Add a little test framework for writing end-to-end audioconvert tests.
2022-07-06 19:20:16 +02:00
Pauli Virtanen df2c5d6a14 alsa: fix uninitialized variable 2022-07-06 14:36:22 +00:00
Pauli Virtanen 783fbc507b bluez5: fix minor error handling/warning issues 2022-07-06 14:36:22 +00:00
Wim Taymans 84d2b2ce3a audioconvert: optimize remapping paths
Remove the redundant remap array.
First set up the array with remapped output pointers in case we
can do passthrough output. Make sure stages write to the remapped
array in passthrough.
Remap the input array after unpack/convert.
This avoid an input and output memcpy in the common case of
remapping.
2022-07-06 15:20:13 +02:00
Wim Taymans 0b351aab99 audioconvert: use blackman window again
I'm not convinced the cosh window is better and it causes some weird
nan numbers in some cases.

See #2483
2022-07-06 09:57:52 +02:00
Wim Taymans 76350cebef audioconvert: fix PROP_INFO
The description needs to be set. The name is the unique name of the
property and the id the predefined property id.

Fixes #2488
2022-07-05 20:41:01 +02:00
Carlos Rafael Giani 7e44909741 alsa: add lower rate bound for DSD playback
This prevents errors when trying to play at a rate
that's lower than DSD64 (the lowest rate available).
2022-07-05 16:56:50 +00:00
Wim Taymans 651f4af0ae audioadapter: ask more data when converter empty
When we are actively driving the stream and the converter needs more
data, call the stream process function again to get it so that we
don't underrun.

Fixes #2494
2022-07-05 17:54:44 +02:00
Wim Taymans 987784b629 tests: add test for s24/u24 swap 2022-07-05 16:34:22 +02:00
Pauli Virtanen e1cb7c6fb2 bluez5: sco-source: implement sco-source the same way as a2dp-source 2022-07-05 14:21:04 +00:00
Pauli Virtanen 51356ea3d0 bluez5: a2dp-source: separate clock from recv + handle buffering
a2dp-source as driver does not produce regularly spaced graph cycles,
because A2DP is not isochronous. This causes e.g. crackling for alsa
etc. that expect regular timings. It also does not rate match.

Change a2dp-source to trigger graph on regular intervals. Change recv to
only accumulate data to a buffer, and put data to buffers in process().

Rate match with DLL, keeping average buffer level constant.  Keep track
of jitter to determine a safe target value.
2022-07-05 14:21:04 +00:00
Pauli Virtanen 459a1114f1 bluez5: sco-io: we should always read from socket
Not reading from the socket appears to cause messages to pile up to some
limit, which causes problems if we start the source after some point.
2022-07-05 14:21:04 +00:00
Pauli Virtanen 02bdfcb115 bluez5: ad2p-sink: adjust debug log message
timeout -> timer, since "timeout" looks like error to users
2022-07-05 14:21:04 +00:00
Frédéric Danis 036bb13474 audioconvert: Fix s24/u24 byte swapping 2022-07-05 14:06:31 +00:00
Wim Taymans c4cc13c094 audioconvert: use right scale value
Disable assert, it seems to fail on clang.
2022-07-05 16:02:24 +02:00
Wim Taymans f62244d7a9 audioconvert: tweak more conversion constants
Tweak some more constants to make lossless conversions work.
Add some tests for lossless conversion.
Add some more tests.
2022-07-05 15:50:05 +02:00
Wim Taymans 22317da685 audioconvert: tweak conversion constants
Tweak the conversion constants a bit so that they handle the
extreme ranges a bit better.
Align the C and vector instructions.
Reactivate the unit test asserts when a conversion fails.
2022-07-05 12:20:02 +02:00
Wim Taymans e3951cc1f1 audioconvert: fix pack/unpack of s24/u24
Copy the values into the right place in the struct.
2022-07-05 12:18:57 +02:00
Wim Taymans 12bee0edf8 audioconvert: fix channel remapping
Do the channel remapping to the cannonical format when we
deinterleave/interleave instead. Otherwise we would completely skip
the remapping when we have interleaved input.

Fixes #2502, #2490
2022-07-04 17:38:20 +02:00
Wim Taymans ffedc2d1e8 null-sink: add option to debug memory 2022-07-04 13:38:07 +02:00
Wim Taymans 67f648cc66 audioconvert: handle NAN from window function
The window function can generate NAN, convert those to 0.0.

Fixes #2491
2022-07-03 20:37:48 +02:00
Wim Taymans a2521bb3e0 audioconvert: fix draining
When we get something else that a drain status as input, bring us back
to the non-drained state.

When we are draining, don't remove the drained flag on the input
io status. This needs to be cleared by the host when the draining is
finished.

Fixes speaker-test
2022-07-01 21:49:13 +02:00
Wim Taymans 9af9450888 audioconvert: ensure temp buffers are large enough
Ensure that our temporary buffers can hold at least quantum_limit
samples. When no output or input is connected, we can generate up
to a quantum_limit of silence, which requires all the buffers to
be scaled correctly.

Fixes a segfault in mpv.
2022-07-01 15:25:37 +02:00
Wim Taymans e0b3e06bea audioconvert: remove unused field 2022-07-01 12:40:19 +02:00
Wim Taymans 817d5bd7a4 audioconvert: simplify 24 bits handling
Make a new uint42_t and int24_t type and use that to handle 24 bits
samples. This makes it easier because we can iterate and copy the
structs like other types.
2022-07-01 12:25:58 +02:00
Wim Taymans 06b1cf8663 audioconvert: implement (de)interleave with existing functions 2022-06-30 18:24:05 +02:00
Wim Taymans afd8e8823e audioconvert: use macros to generate code
Most of the outer loops are all the same.
2022-06-30 17:49:44 +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 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