Commit graph

3616 commits

Author SHA1 Message Date
Ashok Sidipotu
7b91d506f1 adapter-control: add support for volume ramp time params
- Add support for both native and non-native modes
- Add "examples" in the help text
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
075fd49ccc adapter-control: add CLI options
-To select between non-native(via control channel) and native modes(via audio
adapter ). The control port will be opened only in the non-native mode.
-To select different sample and sample step sizes. The Legacy non-native
 mode also uses these params now.
-To provide the alsa device.
2023-04-03 19:04:55 +00:00
Ashok Sidipotu
b1b5367d40 adapter-control: use the volume ramp parameters to ramp volume
Add a compiler macro for now to switch between the inband(control port based)
volume ramping and out of band(using volume ramp parameters)
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
Ashok Sidipotu
2a12dfeb47 adapter-control: add more debug messages 2023-04-03 19:04:55 +00:00
Ashok Sidipotu
3ed282fad5 adapter-control: enable SPA debug logs
Also add timestamp to the logs.
2023-04-03 19:04:55 +00:00
Pauli Virtanen
6db234ad0c bluez5: media-sink: use iso-io for BAP
Use the ISO IO helpers to get synchronized BAP output, and rate match to
the ISO schedule.

The rate matching is necessary, since the driver may be ticking at a
corrected rate, different from the ISO interval rate.
2023-04-03 16:35:22 +00:00
Pauli Virtanen
cec050ac25 bluez5: add spa_bt_iso_io that does the low-level part for ISO
Add factored out helper for ISO socket I/O.

ISO sockets need synchronization of writes and audio position for
different stream fds in the same isochronous group, and it's easier to
separate out the part that coordinates it.
2023-04-03 16:35:22 +00:00
Pauli Virtanen
0ed124f0fb bluez5: add rate matching for BAP to media-sink
Add basics for rate matching.
2023-04-03 16:35:22 +00:00
Pauli Virtanen
41c155bb4c bluez5: split rate control out of decode-buffer 2023-04-03 16:35:22 +00:00
Pauli Virtanen
e0939ff8ab bluez5: don't set bluez timeout on transport release
Setting bluez timeout on transport release makes codec switches delayed,
and is not necessary.
2023-04-03 16:35:22 +00:00
Pauli Virtanen
c0d55eae86 bluez5: use release timeout for all transport types
Avoiding unnecessary release + reacquire when nodes restart makes sense
for all transport types.  Do timed releases for all transport types, not
only SCO.
2023-04-03 16:35:22 +00:00
Arun Raghavan
3dc08c09d1 volume: Fix inverted check for buffer validity 2023-03-31 08:19:07 +00:00
Wim Taymans
108715ebfb alsa: add tsched use to info log
Fixes !1580
2023-03-30 17:50:35 +02:00
Wim Taymans
7da61e2dfa examples: fix adapter control
target_rate and duration need to be configured now.

Fixes #3125
2023-03-30 15:15:41 +02:00
Wim Taymans
b3940627dd audioconvert: pass the NODE_ASYNC flag correctly
Pass the follower async flag correctly in the adapter.
2023-03-30 15:03:29 +02:00
Wim Taymans
4fb17d1c03 audioadapter: clear rate matching when not using converter
Ensure that we clear the rate matching when we are not using the
converter. This will make the follower use the quantum instead of the
dummy unused rate matching area.

Exit when we can't make an internal converter because then things really
are not going to work. Remove some of the pointless NULL checks.
2023-03-30 15:03:29 +02:00
Wim Taymans
a163f29a43 improve logging 2023-03-30 15:03:21 +02:00
Wim Taymans
5ae73fccdd alsa: only update alsa sources when added to the data loop 2023-03-29 15:31:21 +02:00
Wim Taymans
b16b80601d alsa: start playback right away in IRQ mode 2023-03-29 15:13:00 +02:00
Wim Taymans
354836075d alsa: setup sources from the data thread
For IRQ based scheduling we might otherwise be woken up after we only
added one of the fds to the poll loop and then we get an error when we
try to update it afterwards. Instead, add the fds from the data thread
to get things nicely in sync.
2023-03-29 12:21:23 +02:00
Wim Taymans
8c264d2dcb alsa: in IRQ mode, disable sources while we wait
In IRQ mode, disable the ALSA fds while we wait for the graph to produce
data. Otherwise we will wake up very quickly over and over.

When we get more data, we activate the sources again to start the next
cycle.
2023-03-29 11:30:40 +02:00
Wim Taymans
dc5aa21c87 alsa-pcm: use full period size in IRQ mode
We can simply wake up every period and check the timers there is no need
to tweak the period size.
2023-03-29 11:29:43 +02:00
Wim Taymans
aa0d9c5b41 alsa: add disable-tsched to params 2023-03-28 18:27:53 +02:00
Arun Raghavan
26e37b6575 alsa: Implement period-based wakeups
Provides configuration to disable timer-based scheduling. This can be
useful at low latencies, for example, where period-based interrupts
might be more reliable than timers.
2023-03-28 16:22:53 +00:00
Wim Taymans
a0457a3bdf camera: work around target_ mishandling
A driver node should use the target_duration and target_rate to adjust
the quantum and rate when the graph starts.

The camera nodes don't currently support any of this and simply enforce
a specific rate and duration for the graph clock. Mark this with a
FIXME. Otherwise, pipewire will complain that the node is ignoring the
configured graph rate.

We should really look at the graph target rate/quantum and only produce
a buffer when it is inside the current graph cycle. This would make it
possible to join audio and camera nodes and have them be in sync.
2023-03-27 09:59:21 +02:00
Pauli Virtanen
6c0434ec9c spa: fix wrong meson check for BAP 2023-03-26 15:12:55 +03:00
Pauli Virtanen
b50ca80281 bluez5: do transport release synchronously
Do transport release synchronously for simplicity.  BlueZ handles
releasing while acquire is pending, but acquire while release is pending
would fail the acquire.

Otherwise we need to maintain an operation chain to handle trying to
acquire/release while the other operation is pending.  This makes things
complex with little gained, as releases generally don't block for a long
time.
2023-03-26 15:12:51 +03:00
Pauli Virtanen
fc56361ffd bluez5: set right transport active when acquiring linked
The linked transport should be activated, the main one was already
activated above.
2023-03-26 12:44:13 +03:00
Wim Taymans
3698593481 spa: reuse code to clear the timers
We have set_timeout and enable_flush_timer functions to disable the
timers so use those.
2023-03-24 17:55:15 +01:00
Wim Taymans
78b8e1af57 node-driver: fix position calculation
Set the driver node position based on the current time when we
start and keep incrementing it with the previous duration.
2023-03-24 17:34:14 +01:00
Wim Taymans
5ea3c10dca support: sync timers with data loop
Start and stop the timers in the data_loop. Otherwise we might be trying
to stop a timer while the data loop is starting it and we end up with
"ready non-active node" messages.
2023-03-24 17:24:56 +01:00
Wim Taymans
157a97cc98 bluez5: do rate matching before next timeout
Because else we might not have a rate and divide by 0.
2023-03-24 16:13:51 +01:00
Wim Taymans
7b6680ba57 plugins: simplify target_ handling
Drivers should only read the target_ values in the timeout, update the
timeout with the new duration and then update the position.

For the position we simply need to add the previous duration to the
position and then set the new duration + rate.

Otherwise, everything else should read the duration/rate and not use
the target_ values.
2023-03-24 11:36:15 +01:00
Wim Taymans
6e8625cf96 node: update the duration/rate from the target
Before scheduling the graph from the driver, update the duration and
rate with the new targets.
2023-03-23 18:39:27 +01:00
Wim Taymans
1bdd5eee69 alsa: update rate/duration from target
Also reorganize some things to reuse more code.
2023-03-23 18:04:36 +01:00
Wim Taymans
2adf8d38d5 node: add target_rate and target_duration in io_clock
Place the target rate and duration in the io clock area.

The driver is meant to read these new values at the start of the cycle
and update the position rate and duration.

This used to be done by the pipewire server when it received the ready
callback from the driver but this is in fact too late. Most driver would
start processing and set the next timeout based on the old rate/duration
instead of the new pending ones.

There is still a fallback for the old behaviour (with a warning) when
the driver doesn't yet update the position.
2023-03-23 17:57:16 +01:00
Wim Taymans
25f5165e4c acp: return EEXIST when seeing a linked device
Otherwise we get ENOENT, which is confusing because it is the same
error when the plugin doesn't exist.

See #2016
2023-03-23 13:24:22 +01:00
Wim Taymans
3decaa6457 audioconvert: use spa_strbuf 2023-03-22 15:41:27 +01:00
Wim Taymans
5d2773a554 audioconvert: fix test
Enable upmix manually because we test that.
2023-03-22 15:41:06 +01: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
2d6669d571 acp: fix pa_strbuf
We need vfprintf.
2023-03-22 15:08:29 +01:00
Wim Taymans
aae770f18b alsa: avoid assert
We're doing something different than pulseaudio when setting up the
ports.
2023-03-21 12:29:37 +01:00
Wim Taymans
2216956e05 alsa: fixup after merge 2023-03-21 10:07:39 +01:00
Wim Taymans
1d3c4501ef alsa: use pa_strbuf 2023-03-21 09:47:10 +01:00
Wim Taymans
c7ca024607 alsa: ucm: Fix spurious mixer path removal on initial profile set
The code that removes the mixer path if probing fails can be called in
the path that sets a non-off device profile on hotplug *before*
card->active_profile is updated, which results in spuriously removing
the mixer path. By this point, context->ucm->active_verb would be set
to the same as the profile name, so we can use that instead to avoid
the issue.

On Apple Silicon machines with the UCM profiles in the Asahi Linux repo,
this manifests as the headphones jack having hardware volume controls
*only* if PA is started with headphones connected and until they are
disconnected. Hotplugs end up triggering the bad codepath, and it falls
back to software volume (which is particularly a problem when the
hardware volume happens to be very low or 0 at that point).

Fixes: a9cc1373e2a7 ("alsa: ucm - update the mixer path also after volume probe")
Signed-off-by: Hector Martin <marcan@marcan.st>
2023-03-20 18:35:15 +01:00
Wim Taymans
8e4a5f5d5e alsa-ucm: Fix more instances of profile-verb conflation
The ucm_get_device_property() function adds to each UCM device's
playback_volumes (or capture_volumes) hash map an associated volume
mixer keyed with the UCM verb. These key-value pairs are then iterated
over in various places which assume the key is a profile name. This
assumption is no longer true since we can generate multiple profiles to
use conflicting devices.

A previous commit 45278904167f ("alsa-ucm: Stop conflating profile name
with UCM verb name") fixes some instances of this assumption, but misses
the relation explained above. Fix more instances of misleading
"profile"s where the UCM verb name is actually meant.

Fixes: 45278904167f ("alsa-ucm: Stop conflating profile name with UCM verb name")
Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
2023-03-20 18:33:36 +01:00
Wim Taymans
8b20675ad1 alsa-ucm: Consider devices using the same PCM as incompatible
Although it's a valid UCM configuration to have multiple devices using
the same PlaybackPCM or CapturePCM, it's unclear how PulseAudio should
handle the cases where multiple of these devices are enabled. Some
options I can think of are:

- Merge all devices sharing the same PCM into the same mapping, open
  only one PCM substream for this mapping, and add 'combination ports'
  that enable combinations of the devices. This has been the case until
  recently, although the combination port logic was broken. A problem
  with this is that we can't independently control device volumes. We
  most likely cannot use hardware volumes either.

- Have one mapping for each device in the same profile, and open one PCM
  substream for each mapping. This is the current state, and it fails
  when there are fewer substreams than devices. Otherwise it works, but
  it's still confusing, as sound directed to a device-specific mapping
  might end up playing at multiple devices.

- Make multiple profiles each with combinations of upto-substream-count
  devices, and have one mapping/substream per device. This still causes
  the confusion mentioned above. And it's likely that the substream
  count will almost always be one, where this case degenerates into the
  last one.

- Have one mapping for each device in the same profile, but open only
  one PCM substream. I assume this is possible with software mixing, but
  it is still confusing like the above, and probably less performant.

- Generate multiple profiles each with one of the shared-PCM devices,
  again with one mapping/substream for that one device. The trade-off
  with this is that we can't use multiple of these devices at the same
  time. However, this doesn't have the output device confusion,
  combination port's volume problems, or the substream count limitation.

This patch takes a short-cut to achieve the last option, by considering
shared-PCM devices implicitly conflicting with each other.

Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
2023-03-20 18:29:51 +01:00