Commit graph

808 commits

Author SHA1 Message Date
Wim Taymans
fc44013d17 device: place the number of routes in the nodes
So that we can know if this node has routes or not.
Nodes without routes might need their volumes restored directly
with the node properties, like streams. Nodes with a route need their
volumes set on the device managing the node.
2021-03-22 16:43:54 +01:00
Wim Taymans
5cddd61c6c acp: remove the soft volume/mute events
Remove the soft mute/volume events, add a new method to get the soft
volume and use the volume_changed event to emit the changed soft and
monitor (real) volumes event for the node.

Make sure the monitor ports always uses the monitor volume, which is the
real volume unaffected by the mixer volumes.

This configures the soft and real volume on the sink/source in all
cases and makes the monitor port follow the real volume of the sink.

See #897
2021-03-21 16:19:57 +01:00
Wim Taymans
8a4d2ed7ce pipewire-pulse: set correct errno values
errno should be set to the positive errno value.

This does not cause problems except for the pulse-server where the
errno value is negated and returned as an error result.
2021-03-19 12:46:05 +01:00
Wim Taymans
fc9a6d6b1e spa: spa_json_get_string does not return the length
The returned string is null terminated.
2021-03-18 18:57:26 +01:00
Wim Taymans
8e590df92f spa: improve info parsing
Make info parsing a bit easier to read by assigning the key and
value to temporary variables.
Improve the parsing of channelmap using json parser to make it
support more cases.
Add a unit test for channelmap parsing options.
2021-03-18 18:40:56 +01:00
Björn Daase
5913eb098c treewide: fix issues found by codespell 2021-03-16 19:11:25 +00:00
Wim Taymans
1b1a3b96ec alsa: improve startup
Start with an extra period of silence.
Reconfigure a new timeout if we are too far off from the desired
buffer fill level. Reduce this level to the maximum error we
tollerate.

With this we use the extra period of silence to reconfigure the
timeout until we are close enough and we can start the dll with a
small error.

See #892
2021-03-16 09:48:12 +01:00
Wim Taymans
b07bfd0661 alsa: fix dll handling
Pass the right value for the rate, we need to pass the graph rate.
Don't reduce bandwidth, it is not needed.

Fixes timings for reading the alsa-sequencer.
2021-03-14 21:42:17 +01:00
Wim Taymans
017900575c alsa: don't compensate for resampler delay
Don't try to move closer to the read/write pointers in the ringbuffer
to compensate for the resampler delay. We might not have enough time
anymore to complete a cycle without xruns. The delay is properly
reported in the clock times and should also be reported on the port
latency eventually.
2021-03-14 17:08:04 +01:00
Wim Taymans
c4e3b5adbc alsa: don't double the resampler delay
The delay of the resampler is what it reports, don't double it.

See #854
2021-03-14 14:13:37 +01:00
Jan Alexander Steffens (heftig)
6e2f78fffc acp: Check return value of asprintf
Building with `-D c_args="-D_FORTIFY_SOURCE=2"` triggers warnings:

    ../spa/plugins/alsa/acp/acp.c: In function ‘add_pro_profile’:
    ../spa/plugins/alsa/acp/acp.c:298:2: warning: ignoring return value of ‘asprintf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
      298 |  asprintf(&device, "hw:%d", index);
          |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ../spa/plugins/alsa/acp/acp.c:334:4: warning: ignoring return value of ‘asprintf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
      334 |    asprintf(&name, "Mapping pro-output-%d", dev);
          |    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ../spa/plugins/alsa/acp/acp.c:364:4: warning: ignoring return value of ‘asprintf’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
      364 |    asprintf(&name, "Mapping pro-input-%d", dev);
          |    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2021-03-13 14:50:42 +00:00
Wim Taymans
9cd9339c2a alsa-pcm: only disable IRQ when not batch
For batch devices we want to keep the IRQ so that the pointers are
updated with the period-size. Brings my UMC404HD to 4.8ms roundtrip
times with IRQ at 6 sample and batch enabled.
2021-03-11 18:37:13 +01:00
Wim Taymans
b4cf78b5a6 alsa-pcm: improve debug 2021-03-11 18:34:55 +01:00
Thibault Saunier
485bae5eb0 meson: Use feature options everywhere it makes sense 2021-03-10 20:18:34 +00:00
Wim Taymans
63a34f4f84 alsa: after XRun, fill with previous threshold
It is possible that the quantum has changed before the xrun and
then we will assume the previous quantum was in the device.
2021-03-09 15:46:44 +01:00
Wim Taymans
aa0e0043d3 alsa: only recompute threshold when quantum changes 2021-03-09 13:21:50 +01:00
Wim Taymans
6fd870a5f0 alsa: pass the right direction to ucm_set_port()
The function requires true for playback ports and false otherwise.

See #867
2021-03-08 17:40:32 +01:00
Wim Taymans
cab5cf3ccb alsa: add resampler delay in clock delay reporting 2021-03-08 17:12:00 +01:00
Wim Taymans
2c1f8af2e6 alsa: correct dll error after quantum change
When the quantum is changed, the error between the current and
expected buffer levels needs to be corrected with the quantum
difference.

For example, say we are running with a 1024 quantum and the quantum
is changed to 8192, when we wake up the filled level might be
1016 vs expected 8192, 1024 - 8192 = -7168. The real error for the
timeout was 1016 - 8192 - (-7168) = -8.
2021-03-08 16:29:53 +01:00
Wim Taymans
ffeb2e0f0e alsa: fill with right amount of silence when starting
When we start or after an xrun, we need fill the buffer with one
period + headroom of samples, not period*2. This is because after
start we set our timeout immediately and expect there to be
period + headroom samples in the buffer.

With period*2 we take one period longer to start and we also feed
one period of error in the dll, which causes it to wobble for no
good reason.
2021-03-08 15:36:58 +01:00
Wim Taymans
e89e87ba94 alsa-seq: generate the same name as a2jmidid
It is more descriptive and more compatible.
If we change Midi-Bridge to a2j, some apps will parse our port names
in a special way, even (catia).
2021-03-04 20:40:07 +01:00
Wim Taymans
49846d7550 alsa-seq: only mark hardware ports as terminal/physical
Use the caps of the port to set the right flags on the new port.
We only want to put the terminal/physical flags on ports that look
like hardware ports. Port created by clients should not have this
flag.
2021-03-04 20:16:28 +01:00
Wim Taymans
3af768f124 resample: take into account the number of queued input samples
Take the queued input samples into account when calculating the
required input size. This can be 0 when there is still enough
data queued in the input for another period.

Handle 0 read_size in alsa-source and make it push out a 0 buffer,
this will then drain the resampler and make it ask for a new buffer
size. This makes the transition from one period to another more
seamless for the resampler.

Fixes #805
2021-03-04 10:27:44 +01:00
Wim Taymans
e15104c5cb alsa: make resync less aggressive 2021-03-04 10:20:08 +01:00
Wim Taymans
c135f9c7ee alsa: always set read_size 2021-03-04 10:13:26 +01:00
Wim Taymans
e210c5f21c alsa: include headroom in silence buffers 2021-03-03 17:15:23 +01:00
Wim Taymans
a36af57899 alsa: reschedule the timeout based on new quantum
Always reschedule the timeout based on the new quantum. If the
quantum descreased we want to wait some more until the buffer only
has the new quantum of samples left.
2021-03-03 17:01:12 +01:00
Wim Taymans
3bcc59120a alsa: fix timeout adjustment
Only adjust the timeout when the quantum increases so that we end u
with exactly the number of samples of the new quantum.

Suppose we are handling a quantum of 1024, we wake up with 1024
samples in the device, we now notice a quantum of 8192 and will pull
in the 8192 samples, we then have 1024 + 8192 samples in the buffer.
Schedule a timeout for 1024 samples so that we end up in the timout
with 8192 samples in the device.
2021-03-03 16:55:40 +01:00
Wim Taymans
8981e11c53 alsa: various improvements
Remove some magic constants that are not needed anymore with the
headroom.
Clamp the error to some reasonable value so that we don't adjust the
rate too much but still apply all of the correction calculated by the
dll.
Remove the bandwidth adjustment.
Also update the matching and resample fields when we reassign the
node to a new driver. This could cause the new follower to not activate
the adaptive resampler and get out of sync.
2021-03-03 15:40:10 +01:00
Wim Taymans
c8804c3d6d context: make a new node.max-latency property
node.latency also influences the pipeline latency in that it can
push the latency above the default value.
node.max-latency, instead, is only used to clamp the final latency
of the pipeline.
2021-03-03 13:27:48 +01:00
Wim Taymans
1dfa36d77b alsa: reconfigure max latency based on buffer size
We can't ever support a latency larger than half the buffer size.
Take a fourth of the buffer size to have some extre headroom.

See #724
2021-03-02 10:34:41 +01:00
Wim Taymans
f7d756460e alsa: add option to use device channel map instead of default
See #461
2021-02-25 21:16:16 +01:00
Wim Taymans
20eb61b882 alsa: sync with pulseaudio 2021-02-25 10:28:25 +01:00
Wim Taymans
9e09461113 alsa: gracefully handle NULL params 2021-02-23 18:20:37 +01:00
Wim Taymans
d2fb6db21f alsa: use configured rate and channels when enumerating formats
When we have a rate or channels configured, set this in the hw_params
to restrict the enumeration of the remaining parameters. If we,
for example want 8 channels, some cards restrict the formats in that
case and we don't want to enumerate impossible combinations.

Fixes #782
2021-02-23 17:17:14 +01:00
Wim Taymans
8414092763 Rework profile/route handling
Add save property to Profile and Route params to notify the session
manager that they should be saved. Let the session manager only save
the Profile and Routes with the save flag.
Make pulse-server set the save flag on Profile and Route changes.
The result is that we can make a difference between user requested
changes and automatical changes and only remember the user preferences.
When a port changes availability, first check if we need to perform
a profile switch, if not select the new best port.
2021-02-22 16:51:59 +01:00
Wim Taymans
c067fd0a20 alsa: log device name in visible debug messages 2021-02-22 10:07:50 +01:00
Wim Taymans
0ed7e537fb acp: make Pro devices look better
Omit the Output/Input string from the name
Don't print a number for the first device.

See !466
2021-02-16 20:21:53 +01:00
Wim Taymans
38e0ff55cd acp: don't add pro profile for UCM
For UCM, we can just as well make a use case in the UCM file.
2021-02-16 15:17:26 +01:00
Wim Taymans
b62771c3cb acp: fix mapping name 2021-02-16 12:53:23 +01:00
Wim Taymans
5892403b01 acp: add a Pro Audio profile
The Pro Audio profile exposes all devices and subdevices with maximum
channel count and no channel layout. It also have no hardware volume
and is more suited for Pro Audio usage.

See #731 #704 #57
2021-02-16 12:34:59 +01:00
Wim Taymans
ecd1d3e1d7 Move node.pause-on-idle setting to config files
So that we can configure it.
Add some more docs to the config file
2021-02-08 17:19:47 +01:00
Wim Taymans
94ec577dcd alsa: make sure _recover() works from SUSPENDED
Pass -ESTRPIPE to _recover() when our state is SUSPENDED so that
it always attempts to resume, regardless of the error code.
2021-02-08 11:48:32 +01:00
Wim Taymans
3659d70aef acp: complain louder when profile files are missing 2021-02-04 10:31:55 +01:00
Wim Taymans
2b44f42845 pass the complete buffer size to snprintf
There is no reason to pass size-1, snprintf will always put a \0
at the end.
2021-02-02 12:09:29 +01:00
Wim Taymans
f43bcca35e media-session: implement route selection and restore
Disable automatic port configuration in acp and move the logic
to the session manager.
Implement initial port selection and restore on profile activation.
Implement route switch when unavailable
Implement port settings save.
2021-01-29 16:59:17 +01:00
Wim Taymans
ab5059cd07 alsa: add array of devices in EnumProfile
So that we can enumerate the possible Routes per device for
this profile as well.
2021-01-29 15:27:25 +01:00
Jonas Holmberg
0ccad38df1 alsa-pcm: Fix target calculation
Use threshold instead of last_threshold so that early wakeup is detected
in handle_capture() when duration changes.
2021-01-28 16:18:35 +00:00
Wim Taymans
3312757706 acp: use auto-profile and auto-port properties
Also disable initial automatic profile selection when auto-profile
is set to false
2021-01-27 13:48:10 +01:00
Wim Taymans
64b078d7bb acp: fix port and profile name lookup 2021-01-27 13:48:10 +01:00