Commit graph

2837 commits

Author SHA1 Message Date
Wim Taymans
0db8d39dd8 spa: fix compilation with c++ 2022-03-01 21:40:30 +01:00
Wim Taymans
3d7ea3ee17 spa: use dyanmic builder for audioadapter 2022-03-01 21:17:08 +01:00
Wim Taymans
d3a1b9fe31 spa: add dynamic builder helper
Resizes the buffer dynamically. Be careful with getting the address
of a pod in the buffer, it might not be valid after building more stuff
with the builder.
2022-03-01 20:32:58 +01:00
Wim Taymans
23db50630d channelmix: add option to filter FC
Add an option to do a lowpass filter on the FC channel to isolate
the voices better and move the higher frequencies to the stereo
channels.

See #861
2022-03-01 11:30:12 +01:00
Wim Taymans
5b3388e4ac audioconvert: add optional hilbert transform to rear channels
Add an option to do a hilbert transform on the generated rear channels
to do a 90 degree pahse shift on them. This can improve spacialization
of the rear channels.

See #861
2022-03-01 11:09:43 +01:00
Wim Taymans
5dd0a12875 channelmix: add option for stereo widen
When generating FC, add an option to subtract some of the generated
FC from the FL and FR channel to move the sound more to the center.

See #861
2022-03-01 10:28:11 +01:00
Wim Taymans
60b338d4cf channelmix: place L-R in rear channels
L-R is supposed to be the ambient sound, which should sound better in
the rear channels.
2022-03-01 10:14:07 +01:00
Wim Taymans
5a307c11e1 audioconvert: add delay to rear channels when upmixing
See #861
2022-03-01 09:56:12 +01:00
Wim Taymans
d62d2764e8 channelmix: improve corssover processing
Apply volume after crossover, optimize when disabled or silent.
2022-03-01 09:08:17 +01:00
Pauli Virtanen
b9b57d32d5 channelmix: set mix log earlier
Set mix.log already in impl_init, since it's not going to change.
Should fix null pointer access under some cases.
2022-02-25 20:32:48 +02:00
Wim Taymans
1cf869cea8 channelmix: fix lfe-cutoff parsing 2022-02-25 11:20:19 +01:00
Wim Taymans
ab8f9be979 channelmix: recalc channelmix when param changed 2022-02-25 11:13:10 +01:00
Wim Taymans
7241bf3c54 channelmix: remove LFE when cutoff is <= 0.0 2022-02-25 11:13:04 +01:00
Julian Bouzas
6dbdb2eecb bluez5: only consider A2DP profiles if HSP/HFP backed is none
This allows BT device to connect instantly instead of waiting for profile
timeout when hsp/hfp backend is none, because all available profiles are
connected.
2022-02-24 15:17:19 +00:00
Wim Taymans
2e8e8938bc channelmix: add stereo to 7.1 upmix 2022-02-24 16:09:14 +01:00
Wim Taymans
b1ca470d99 channelmix: don't pass channels around
We have this info in the channelmix structure.
2022-02-24 13:09:25 +01:00
Wim Taymans
6ed60eb868 channelmix: Fix copy and paste error 2022-02-23 07:39:23 +01:00
Wim Taymans
ac25d126de channelmix: use the right channelmap
For merger setup (consuming a source) we want to expose the channelmap
of the remixed signal (to the application/sink).
For splitter setup (providing data) we want to expose the channelmap
of the original source (before remixing to sink).

Hide the merge channel props because they contain the channelmap before
mising and we want to expose the remixed signal in merger mode.

This fixes some weird volume issues when an input stream is linked
to a source and is remixing, like when a stereo stream is captured
from a mono source.
2022-02-22 18:20:07 +01:00
Wim Taymans
0b7da17083 channelmix: fix 5p1 -> 2 see channelmix
If was applying the volume of the front to all channels.
2022-02-22 18:06:48 +01:00
Wim Taymans
c0727e1efc audioadapter: improve fixation of the format
Keep track of the format as given in the PortConfig.

Instead of blindly fixating the negotiated format to whatever default,
use the PortConfig format to fixate to something better.

This makes the channels/position, rate or format match the PortConfig
format when this is possible and results in the least amount of conversions.

It mostly improves the handling of wildcard formats, were a stream only
specifies some fields and leaves the other free.

A concrete case is WINE that uses the pulseaudio FIX flags to omit the
number of channels and rate. With this change, the stream will negotiate
to the format of the linked sink and obtain the channelmap from it.

See #876
2022-02-21 15:18:20 +01:00
Barnabás Pőcze
16f63a3c8f Revert "loop: remove destroy list"
This reverts commit c474846c42.
In addition, `s->loop` is also checked before dispatching a source.

The destroy list is needed in the presence of threads. The
issue is that a source may be destroyed between `epoll_wait()`
returning and thread loop lock being acquired. If this
source is active, then a use-after-free will be triggered
when the thread loop acquires the lock and starts dispatching
the sources.

  thread 1                       thread 2
 ----------                     ----------
                                loop_iterate
                                  spa_loop_control_hook_before
                                    // release lock

 pw_thread_loop_lock

                                  spa_system_pollfd_wait
                                    // assume it returns with source A

 pw_loop_destroy_source(..., A)
  // frees storage of A

 pw_thread_loop_unlock
                                  spa_loop_control_hook_after
                                    // acquire the lock

                                  for (...) {
                                    struct spa_source *s = ep[i].data;
                                    s->rmask = ep[i].events;
                                      // use-after-free if `s` refers to
                                      // the previously freed `A`

Fixes #2147
2022-02-18 20:31:14 +01:00
Wim Taymans
ae14ef7a49 fix compilation 2022-02-17 16:11:22 +01:00
souravdas142
b50efe0188 spa: fix initializer for old GCC
Older gcc versions seem to require the members to appear in the
designated initializer in the order they are in the definition of
the struct when compiling C++.

otherwise compilation fails with:

../spa/plugins/aec/aec-webrtc.cpp:167:1: sorry, unimplemented:
non-trivial designated initializers not supported
 };
 ^
2022-02-17 15:09:03 +00:00
Wim Taymans
e28b613404 alsa: don't read more than available samples
Keep the original available samples and use them to avoid reading
a chunk when there is not enough data.
2022-02-16 21:30:54 +01:00
Wim Taymans
56c03c11f8 alsa: resync when quantum changes 2022-02-16 21:30:35 +01:00
Wim Taymans
798228a906 alsa: remove useless code
The resync check can be done in check_position_config.
2022-02-16 21:29:55 +01:00
Wim Taymans
4246961070 alsa: use rewind to remove excess delay
When the delay is too big, rewind a little to reduce it when resync.
2022-02-16 21:10:03 +01:00
Wim Taymans
c5c9ecdd87 spa: improve the AEC interface
Place the methods on the interface so that we can call them.
Rename create to init because that is what it does.
Add support for listener and events so that we can signal property
changes later.
2022-02-16 16:18:18 +01:00
Joakim Olsson
9386c70b3a module-echo-cancel: Move backends to dynamic libaries
Move all backends to dynamic libaries loaded with spa_plugin_loader so
new backends not needs changes in pipewire or pipewire dependency to
external code

Change-Id: I702ce047598d0c318d6dc6ac8248062a5c12f643
2022-02-15 15:45:46 +00:00
Wim Taymans
761199be70 alsa: improve resync
Use the max error to do a resync. Don't reset the dll, there is no
reason for that.
Don't use _rewind, but instead limit the amount of samples we read and
write
Should keep more stable sync in most cases.
2022-02-15 16:32:00 +01:00
Wim Taymans
87f4726164 alsa: protect against impossible timeouts
Check if the new timeout is larger than 1sec in the past or future
and reprogram a timeout with a saner timeout.
2022-02-15 15:35:40 +01:00
Wim Taymans
8b899dbc55 alsa: make sure we always trigger a timeout
If we get an error from get_status() make sure program the timer
for one period or else we would just end up with silence.
2022-02-15 15:32:09 +01:00
Wim Taymans
dc76ab2291 alsa: don't use dll when not rate matching
Only use the DLL when we are driver or rate matching with
another driver.
2022-02-15 15:29:40 +01:00
Pauli Virtanen
bae2cc0a6e spa/alsa-udev: ignore all errors in card busy check
If card busy check fails due to error, just log info message and
consider the card not busy.

For kernels with CONFIG_SND_PROCFS=n, /proc/asound is not present, and
we have to handle that.  It's also better to fail open here, rather than
end up with missing devices.
2022-02-14 20:50:53 +02:00
Wim Taymans
0bca352241 alsa: fill with silence when underrun
Also try to resync when the follower buffer is running empty.
Fill the buffer with silence instead of doing _pcm_forward.
2022-02-12 12:09:25 +01:00
Wim Taymans
9855e2b303 alsa: tweak capture follower
If the follower does not have enough data to capture, skip a cycle
instead of trying to capture and get an XRUN.

Tweak some limits a little.
2022-02-11 18:07:44 +01:00
Barnabás Pőcze
2c71282f16 spa: bluez: remove unused function
The `add_dict` function has not been used since
9785d99821. Remove it.
2022-02-10 23:20:47 +01:00
Julian Bouzas
e34d9d209a alsa: try to resume after suspend before recovering
Fixes no audio after suspending with some audio drivers.

See #2001
2022-02-10 16:57:58 -05:00
Wim Taymans
f636603844 alsa: pass current_time around in get_status()
Pass the current time around in various functions.
Make a higher precission htimestamp based get_delay() function. Seems to
work fine for playback but not for capturee.
2022-02-10 15:31:29 +01:00
Luis Correia
3cba294b65 Update texas-instruments-pcm2902.conf, add info about Behringer U-Phoria UM2 2022-02-09 20:58:20 +00:00
Wim Taymans
14d252ec9d alsa: try to resync on commit error
When we get a commit error, try to resync our pointers. This fixes a
problem of endless commit errors after a quantum change because it never
manages to resync properly.
2022-02-08 18:31:42 +01:00
Barnabás Pőcze
bf886ba209 support: also protect against recursive invocations
Add an extra private field to the source to store the pollevent of
the current iteration. This changes ABI but it seems an embedded source
is not used outside of our own plugins and the unit test doesn't test
this ABI case.

Whenever a source is removed, we can set the data field of the
pollevent to NULL so that it won't be handled in any iteration anymore.

Avoid dispatching the same event multiple times when doing recursive
iterations.

Add some more unit tests for this.

Fixes #2114
2022-02-08 17:21:10 +01:00
Alexandre BIQUE
0b637c3291 support: loop_enter/leave hardening
This commit adds a counter for loop_enter/leave and checks:

 - consecutive enter are used on the same thread
 - leave is used on the same thread as enter
 - at destruction, the enter_count must be 0
2022-02-08 12:02:50 +01:00
Wim Taymans
c346ee5e90 support: close log file when we opened it 2022-02-08 11:30:39 +01:00
Wim Taymans
c474846c42 loop: remove destroy list
Now that sources can't be dispatched anymore after a _remove, we don't
need to keep the destroy_list anymore and we can free the source
immediately.

See #2114
2022-02-08 10:18:02 +01:00
Wim Taymans
45d911641b loop: handle remove while dispatching better
Keep the array of dispatched sources around in the loop. When a source
is removed while dispatching, set the data to NULL so that we don't try
to deref the source again or call its function.

Fixes #2114
2022-02-08 10:17:13 +01:00
Wim Taymans
a16cd95593 spa: move debug log defines to one place
Use spa_debug to debug formats.
Make debug go to stdout by default.
2022-02-07 17:00:38 +01:00
Wim Taymans
8c10080324 pulse-server: make sure we don't exceed maxlength
Make sure the various buffer attributes don't exceed maxlength.
Add some SPA_ROUND_UP and SPA_ROUND_DOWN macros.

Fixes #2100
2022-02-04 11:59:57 +01:00
Barnabás Pőcze
cc73053512 treewide: meson.build: use feature.allowed()
Since meson 0.59.0, a feature object has an `allowed()`
method which returns true when the feature is set to
'enabled' or 'auto'.

Utilize that instead of the previously used

  not feature.disabled()
2022-02-04 00:15:59 +01:00
Barnabás Pőcze
15e7a61aa7 treewide: only define feature macros when the feature is available
Most feature checks already use #ifdef, and do not care about
the value of the macro. Convert all feature checks to do that,
and simplify the meson build scripts by replacing

  if cond
    cdata.set('X', 1)
  endif

with

  cdata.set('X', cond)
2022-02-04 00:15:59 +01:00