Commit graph

1111 commits

Author SHA1 Message Date
Wim Taymans
e5f7e040dc loop: simplify before and after events
Because the signal can't be removed from the callback we can
simply iterate backwards and then forwards.

The first added hook (the unlock/lock pair) is called last before
going into the poll and first when leaving. This executes all other
callbacks inside a locked situation. And removing them with the lock
is not going to cause problems.
2020-09-16 13:31:47 +02:00
Wim Taymans
05ae8a24de loop: make safe version of befor and after signal
Use a safer version of the before and after hooks. First call
all before hooks and save them in reverse order in a save list.
Then call the after event for the ones remaining in the save list
and move them back to the hook list.

This makes it possible to remove the hooks from one the callbacks or
even from other threads with the right locks. Found as a solution to
the following problem as observed in vlc:

main thread                            thread_loop

pw_thread_loop_lock()            before hook: lock suspend thread
pw_context_destroy()
  - removes before hook to flush clients
pw_thread_loop_unlock()
                                 before hook: lock acquired, resume
				 before hook: flush client hook executed
				   *crash*

pw_thread_loop_stop()
pw_thread_loop_destroy()

Any of the safer cursor methods (like spa_hook_list_call()) would also
work but are more expensive and don't reverse the before/after
order.
2020-09-15 20:13:32 +02:00
Wim Taymans
8332d3e3ed alsa: don't change the resampler delay value
Don't change the resampler delay value, we need it to make sure
we keep samples around for the next round. With small period sizes,
we set the delay to 0 and mess up the resampler and cause dropouts
and clicking.

Fixes #287
2020-09-15 13:22:41 +02:00
Wim Taymans
f29bf9cb40 resample: reset resample state when starting
Update the initial delay and size in the rate_match io area when
starting.
2020-09-15 13:22:41 +02:00
Wim Taymans
c10feda5ce merger: follow the position duration if we can 2020-09-15 13:22:41 +02:00
Wim Taymans
8825a21e86 fmtconvert: improve channel debug names 2020-09-15 13:22:41 +02:00
Wim Taymans
2b0b44edc0 alsa: add option do use chmap from alsa, disable by default
This should be more in line with what PulseAudio does and so lead
to less surprises.

See #289
2020-09-14 20:19:44 +02:00
Simon McVittie
8dcf76f661 audioconvert tests: Default to using an installed libspa-support
This makes installed-tests (see commit b852b58f) do the right thing.
For build-time testing, spa/plugins/audioconvert/meson.build overrides
this with the SPA_PLUGIN_DIR environment variable, and for ad-hoc
testing by developers, pw-uninstalled.sh sets the necessary variables.

Signed-off-by: Simon McVittie <smcv@debian.org>
2020-09-14 18:16:49 +00:00
Wim Taymans
e59c4675a7 audioconvert: send the command to the children
Send the command on the converter to all children as well.
Reset the resampler when we are paused so that we don't end up
with old data.

Fixes #288
2020-09-14 16:39:42 +02:00
Wim Taymans
320e63fe48 fmtconvert: place unknown channels at end
Sort the unknown channels to the end of the remap array.
2020-09-14 11:03:52 +02:00
Wim Taymans
d456893f31 acp-device: just always select the best port/profile for now 2020-09-09 14:12:00 +02:00
Wim Taymans
4a35fcaf09 acp: update Route and Profile param on availability change 2020-09-09 14:10:17 +02:00
Wim Taymans
6e339200af acp: improve port and profile index select
Keep 3 options, the available ports, unknown and highest priority
other ports.
2020-09-09 14:08:15 +02:00
Wim Taymans
5f38562d38 acp: remove active_port_index
It is not clear if the port index is in the card or device port array
and it doesn't work when many ports are active. So simply iterate the
device ports and find the ones with the active flag set.
2020-09-09 13:57:33 +02:00
Wim Taymans
a956c265a2 acp: also act on new available ports 2020-09-08 16:49:07 +02:00
Wim Taymans
5e368b1ad6 acp: add option to switch profile and ports
Enable an option to switch to the next best profile and port when
the current one becomes unavailable.
2020-09-08 16:39:47 +02:00
Wim Taymans
185a3d4c36 alsa: update route param when profile changed
When the profile changes, also update the route param.
Use defines to index the parameters
2020-09-07 14:32:56 +02:00
Wim Taymans
9a7cbeea83 channelmix: improve undefined channel layout
When we have no channel layout, just copy input to output
channel.
Optimize this case in the mixer implementation.
2020-09-04 13:41:24 +02:00
Wim Taymans
3eafa6312f channelmix: add default channelmap for 5 and 7 channels 2020-09-04 12:22:30 +02:00
Wim Taymans
f7d8fef070 channelmix: normalize volumes
Normalize the volumes.
Don't mix in LFE by default but add an option
Move some booleans to flags
Improve some checks for fastpaths.
2020-09-03 13:20:36 +02:00
Wim Taymans
b62fa9faf2 channelmix: disable normalize for now
Volume is too low and we don't choose the right functions all the
time. Needs more work.
2020-09-02 18:50:01 +02:00
Wim Taymans
5dea431372 channelmix: normalize matrix to avoid clipping 2020-09-02 18:36:42 +02:00
Wim Taymans
b8d65895c2 a2dp: try to completely process the queue
Continue processing the input data until we can't send anymore. When
we are following another driver, we need to process each buffer in
the cycle completely or we will start lagging behind.
2020-09-02 17:51:33 +02:00
Wim Taymans
b54571c5a1 a2dp: fix check 2020-09-02 17:16:16 +02:00
Wim Taymans
d7fb382b7b a2dp: place buffer id in io when reusing 2020-09-02 17:04:19 +02:00
Wim Taymans
6b50279364 bluez5: add a simple clock to sinks/sources
Fixes #269
2020-09-02 13:36:22 +02:00
Wim Taymans
4867edb947 channelmix: read mix coefficients correctly
Fix 5p1 to stereo mixdown by reading the coefficients correctly.
Align 5p1 to quad SSE and C implementation

Fixes #272
2020-09-02 11:15:23 +02:00
Frédéric Danis
d607a461ce bluez5: backend-hsphfpd: Fix crash when switching profile to HFP 2020-08-25 16:43:03 +02:00
Wim Taymans
e8640683bb support: add null audio sink 2020-08-20 18:00:00 +02:00
Frédéric Danis
7120bfe059 bluez5: backend-hsphfpd: Add spa_bt_transport support
The ConnectAudio method triggers Introspect and NewConnection calls from
hsphfpd to the backend, which will set the fd to use for the SCO data.
This imply to run the DBus loop while waiting for ConnectAudio reply to be
able to reply to those method calls.

MTU is hard-coded to 48. Using MTU from hsphfpd may prevent correct
sound operations.

Volume management is not yet implemented.
2020-08-19 17:49:36 +00:00
Frédéric Danis
6d0c48cc82 bluez5: Add transport find function using a test callback
hsphfpd backend needs a way to retrieve bt_transport based on other entries
than the path one
2020-08-19 17:49:36 +00:00
Frédéric Danis
7bad76737e bluez5: Create backend skeleton for HSP/HFP support using hsphfpd
As hsphfpd is a prototype and its API subject to change, this backend is
disable by default.

This skeleton connects to hsphfpd daemon and list the managed devices.
2020-08-19 17:49:36 +00:00
Wim Taymans
5f4fd14a40 audioconvert: optimize prefered formats
First planar, then packed, then packed other endian formats.
First F32, S32, S24_32, S16, S24, U8 because of quality and
optimizations.
2020-08-19 13:45:57 +02:00
Wim Taymans
cfdd6cab20 acp: fix UCM off profile 2020-08-18 16:52:09 +02:00
Wim Taymans
a67af43cad alsa: sync with latest pulseaudio
Move some things around to make it easier to merge in changes.
2020-08-18 12:41:34 +02:00
Emmanuel Gil Peyrot
14fdf07e8f Run codespell on the entire codebase
This tool detects and fixes common English spelling mistakes, with
generally very few mistakes.

Here is the command I used to generate this commit.  There were a few
changes that had to be done manually, and of course adding the ignore
file:
```shell
codespell -I .codespell-ignore -x .codespell-ignore -w
```

I didn’t add it to the CI, but this would be a good place for it.
2020-08-17 17:16:31 +00:00
Wim Taymans
03f1dfcf99 acp: handle unset profile
The active profile is set to -1 initially, don't try to do anything
with the profile if it is invalid.

See rhbz#1868332
2020-08-17 11:33:17 +02:00
Wim Taymans
dadb3a884d profile: refactor code to make EnumProfile and Profile params
Use the same code to enumerate the profiles and the current profile,
this makes sure we have all info in the Profile param as well and
don't need to do a lookup in the EnumProfile.
2020-08-17 11:08:26 +02:00
Wim Taymans
90e12299f1 acp: add current profile in the route 2020-08-14 15:09:00 +02:00
Wim Taymans
5e9091a285 node: add new NEED_CONFIGURE flag
Add a new node flag that is set when the node needs more configuration.
Don't try to Start nodes that have the NEED_CONFIGURE flag set.
Make audioadapter clear the NEED_CONFIGURE flag when it has the
PortConfig.

These changes now make it possible to run:

gst-launch-1.0 -v pipewiresrc path=51 stream-properties="props,node.group=1" ! audio/x-raw ! pipewiresink stream-properties="props,node.group=1"

The pipewiresink and pipewiresrc will be added to the same scheduling
group (1) and the devices they connect to will be slaved, even if they
are otherwise not linked.

Without the NEED_CONFIGURE flag, pipewiresink would be added to the
pipewiresrc group and would be started by the daemon before the
session manager has a chance to configure (and link) the node.

Fixes #4
2020-08-10 16:57:14 +02:00
Wim Taymans
2362953931 audioadapter: update flags 2020-08-10 16:48:03 +02:00
Wim Taymans
374210c890 acp: add per device port list
Add the list of possible ports for a device.
Pass the allowed devices in the routes.
Store the active port in the device.

Fixes enumeration of ports on devices with UCM.
2020-08-10 14:25:03 +02:00
Wim Taymans
cb3f1b51aa adapter: only become started on success 2020-08-07 10:49:52 +02:00
Wim Taymans
f4e8ebab51 improve debug and error messages 2020-08-07 10:47:18 +02:00
Wim Taymans
e71936f870 Improve naming
master -> driving
priority_master -> priority_driver
segment_master -> segment_owner
2020-08-06 13:49:33 +02:00
Wim Taymans
77bd687bac acp: fix size of array 2020-08-04 12:05:56 +02:00
Wim Taymans
9943733b8c acp: pass all properties when creating a card
They might contain other info like prefered card name etc.
2020-08-03 18:15:04 +02:00
Wim Taymans
7f7a8ccc88 acp: use some existing keys and add some new ones 2020-08-03 17:08:46 +02:00
Wim Taymans
a655e8f6df alsa-util: fix check for digit
Fix the check for a digit by checking if the value is between the
*character* '0' (not *value* 0) and '9'.
2020-08-03 10:10:04 +02:00
Julian Bouzas
c388df1cf3 bluez5: include profile classes when doing enum profile 2020-07-31 10:53:51 +00:00