Commit graph

214 commits

Author SHA1 Message Date
Wim Taymans
9119e8a26e improve debug 2022-09-23 15:14:50 +02:00
Wim Taymans
ad8fa41678 audioadapter: warn when scheduling a stopped node
Log a warning when we try to schedule a stopped node.

See #2701
2022-09-23 11:30:42 +02: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
cc463da63e audioadapter: adjust max input ports
The control port adds an extra input port.
2022-06-23 11:39:27 +02:00
Wim Taymans
0f62d3442c alsa: handle driver bugs better
Use the NEAREST flag when setting a format. This only works for raw
formats and will update the format with the nearest accepted rate
or channels. We can then query the real configured format and use that
for the converter.

This makes things work when a driver tells us it can do 44100Hz but then
refuses and changes the rate to 48000.

See #2197, #2457, #2455, rhbz#2096193
2022-06-23 10:20:49 +02:00
Wim Taymans
de2e819fec audioconvert2: rename to audioconvert 2022-06-16 09:19:05 +02:00
Wim Taymans
5a60fd7041 audioconvert2: remove unused monitor field 2022-06-16 09:09:27 +02:00
Wim Taymans
7f9ddd0f15 Add audioconvert2 2022-06-16 09:09:27 +02:00
Pauli Virtanen
fc4f831afa audioconvert: forward follower node errors
If the follower of the adapter emits an error event, the adapter needs
to forward it to upper levels so that they know the node has errored,
and handle the situation.
2022-06-05 18:10:01 +00:00
Wim Taymans
411b12f59e audioadapter: improve error reporting
Improve the debug_params output.
Always either print the failed filter or that there was no filter.
Print the index of the enumerated failed param or a message when
there are no params.

See #2383
2022-05-17 09:52:48 +02:00
Wim Taymans
a3e10d6023 audioadapter: add some more debug 2022-05-11 15:13:46 +02:00
Wim Taymans
416dec530c audioconvert: debug result code 2022-05-11 14:55:37 +02:00
Wim Taymans
c2dbe1d64d audioconvert: remove props from info
After emiting the node info, remove the properties from the info again
so that we don't accidentally emit them again later, when the
info and properties are out of scope.
2022-05-11 14:51:14 +02:00
Wim Taymans
32e957345d audioadapter: don't loop forever
Try 8 times to make progress, if nothing after that, xrun.

A stream that keeps sending 0 sized buffers would otherwise get into
an endless loop.

See #2359
2022-05-06 15:33:28 +02:00
Wim Taymans
ca5e0e5837 audioconvert: don't fixate rate
We alwats want to adapt to the rate of the graph and not the
samplerate that was configured with the PortConfig.

This fixes samplerate switching again.
2022-03-08 17:49:13 +01:00
Wim Taymans
3d7ea3ee17 spa: use dyanmic builder for audioadapter 2022-03-01 21:17:08 +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
Wim Taymans
af11fb4804 audioconvert: avoid infinite loop
When the follower has no param to enumerate we would keep on enumerating
the params of the converter forever. Fix this by setting the next value
to something that would then stop the iteration.

Also increase the amount of bits for the follower because it might need
them.
2022-01-05 17:05:17 +01:00
Wim Taymans
35cbe4e939 buffers: make alignment optional
Make the alignment parameter optional when negotiating buffers.
Default to a 16 bytes alignment and adjust for the max cpu
alignment.
Remove the useless align buffer parameter in plugins, we always
set it to 16 anyway.
2022-01-03 12:32:26 +01:00
Wim Taymans
77d66d73d1 audioadapter: return result from enum_param directly
There is no need to pass the result in an argument, just return the
value from the function.
2021-12-02 11:35:13 +01:00
Wim Taymans
e3ddcc3b19 audioadapter: also update the follower PropInfo flags
So that we can enumerate them.
2021-12-02 11:35:12 +01:00
Julian Bouzas
921a9038e1 spa: audioadapter: check if follower supports enum params before requesting them
Some follower nodes don't support all audioadapter params (For example, param
SPA_PARAM_Props is not supported by 'support.null-sink'). This change adds a
check to avoid unsuported errors when requesting a param that is not supported
by the follower.
2021-11-30 17:33:17 +00:00
Wim Taymans
c8c4923fcb spa: use log topics 2021-10-13 10:48:23 +02:00
Wim Taymans
435de99428 Increase pod buffer size
The props of a 64 channel node are at least 2048 bytes long so make sure
we can build and filter them.

Fixes #1574
2021-09-06 15:09:28 +02:00
Wim Taymans
6c3c88f9d3 audioconvert: handle follower EnumFormat changes as well 2021-09-01 13:22:57 +02:00
Wim Taymans
743aaa3dbd audioconvert: don't just copy the converter flags
We need to manage our own flags based on the direction of the follower.

We also need to make sure we only clear the NEED_CONFIGURE flag
after we are actually configured, not just when we configured our
internal converter.

See #1548
2021-08-25 15:11:54 +02:00
Wim Taymans
0af0cceca2 audioadapter: use format directly when reconfiguring
There is no need to parse and then recreate the format.
2021-08-23 11:20:52 +02:00
Wim Taymans
8f7a972a48 audioadapter: fix passthrough switching some more
Remove the follower ports when leaving passthrough, add the DSP
ports.
Set up the link_io between follower and convert again when leaving
passthrough.
2021-08-23 11:20:40 +02:00
Wim Taymans
9090f19b0a audioconvert: improve passthrough mode
When in passthrough mode, use the position io to update the
io_rate_match fields for the follower. This makes it possible for the
follower to also provide the right amount of data when the converter
is not selected in passthrough.

Add an option to configure the converter in None port config where it
removes all the ports. We can use this when removing the converter to
make sure all it's ports are removed.

When we remove the converter, make sure we expose the follower ports
directly so we can use them for passthrough.
2021-08-23 11:11:11 +02:00
Julian Bouzas
cad64bc992 audioadapter: add support for passthrough mode
Allows audioadapter to behave as its follower
2021-08-17 16:01:10 +00:00
Wim Taymans
391465d1cd audioadapter: emit Latency param changed when follower changed
When the follower port Emits a latency param changed, our reported
latency also changes so we need to emit the changed notify.
2021-08-17 10:49:05 +02:00
Wim Taymans
6d196b1d11 alsa: use ProcessLatency param to get and set internal latency 2021-08-17 10:04:12 +02:00
Wim Taymans
acad6b8f2b audioconvert: use the right variable
Keep the result of the follower in res2, fail if we could not set the
properties on both the follower and the converter.
2021-07-06 16:28:57 +02:00
Wim Taymans
8ee9a7b5e5 audioadapter: latency is writable 2021-06-24 12:07:06 +02:00
Wim Taymans
a6b687ee98 audioadapter: proxy Latency param from follower port 2021-06-10 23:42:05 +02:00
Wim Taymans
0222e408e0 audioconvert: use the right latency param
We need to use the latency param of the port direction to configure
the other port.
2021-05-27 15:26:09 +02:00
Wim Taymans
cd32404e92 port: implement latency reporting some more
Implement a port recalculate latency method that takes the min
and max latency of all peer ports and sets that as the new port
latency.
When a link is made, let the output and input port recalculate
latencies.
Pass latency param in audioconvert.
2021-05-27 15:26:09 +02:00
Wim Taymans
1cd6d7b01d spa: Implement latency reporting
Implement latency reporting in alsa
Implement latency reporting on audioconf by passing on the latency
from the follower to outside of the adapter.
2021-05-27 15:26:09 +02:00
Wim Taymans
46ef88e520 spa: save the old change_mask and restore when emitting full
When we add a new listener to an object, it will emit the full state
of the object. For this it temporarily sets the change_mask to all
changes. Restore the previous state after this or else we might not
emit the right change_mask for the next listener.

Consider the case where one there are two listeners on an object.
The object emits a change and the first listener wants to enumerate the
changed params. For this is adds a new listener and then triggers the
enumeration. If we set the change_mask to 0 after adding the listener,
the second listener would get a 0 change_mask and fail to update
its state.
2021-05-27 15:21:44 +02:00
Wim Taymans
89c10dad70 spa: Clean up some of the param handling 2021-05-21 10:10:38 +02:00
Peter Hutterer
7697ed0757 treewide: replace strcmp() == 0 with spa_streq()
This change is only done in source files for now, header files will be done
separately.
2021-05-18 22:10:27 +10:00
Peter Hutterer
2405f0942b spa/buffer: rename SPA_MEMBER to SPA_PTROFF
SPA_MEMBER is misleading, all we're doing here is pointer+offset and a
type-casting the result. Rename to SPA_PTROFF which is more expressive (and
has the same number of characters so we don't need to re-indent).
2021-05-06 09:39:39 +00:00
Wim Taymans
86cf4ad5a5 audioconvert: keep better track of changed params
Keep all the children param flags around and use those to decide
if something changed. Also don't change the param flag serial when
we are simply adding a listener.

This should reduce the number of param updates, most notably the
PropInfo that was updated along with the Props on volume changes.
2021-03-12 11:10:43 +01:00
Wim Taymans
5ae286702e audioconvert: make sure we update the flags
When we get a param update, update with the new flags.
2021-03-01 17:01:46 +01:00
Wim Taymans
44919c83fc audioconvert: keep better track of param changes
Keep track of the param changes with the user counter. Make sure to
flip the serial switch whenever a change is pending. Previously
we copied the param from the channelmixer or follower but that
did not always result in a serial change.

Fixes #764
2021-02-19 09:57:59 +01:00
Wim Taymans
c7b7afa664 audioadapter: fix enum of properties
Keep track of the subelement we're iterating in the result index upper
bits. Use enum_sync to iterate each param and switch to the next
element when we run out of params.

See !468
2021-02-17 09:59:00 +01:00
Wim Taymans
d6afdda898 audioadapter: enumerate node params from follower as well
Enumerate the params from the follower as well.
Configure params on the follower and converter.
When follower params changes, emit event.

See !460
2021-02-15 15:43:03 +01:00
Wim Taymans
e7aa15e475 audioadapter: only check port params when changed 2021-02-15 15:39:39 +01:00
Wim Taymans
be6410909f audioadapter: remove some unused code 2021-02-01 15:16:39 +01:00
Wim Taymans
19be555fa6 audioadapter: run the converter after follower drained
When the follower drained, rerun the converter again to let it drain
as well.
2021-01-18 10:29:50 +01:00