Commit graph

192 commits

Author SHA1 Message Date
Wim Taymans
9934e62fe4 don't use error() 2019-06-21 16:14:36 +02:00
Wim Taymans
5b7e95c71c system: make system functions return error on error
Return -errno from system functions instead of -1 in errors. This
makes it easier to pass along the result without having to go to
errno etc..
2019-06-20 17:31:29 +02:00
Wim Taymans
5850044599 improve error handling 2019-06-18 16:55:37 +02:00
Wim Taymans
497a8364c5 printf format fixes 2019-06-07 17:16:02 +02:00
Wim Taymans
db88e9f954 System: More work on making system functions pluggable
Move the epoll functions to the system functions and make the loop
use those. Use simple mask for events instead of enum.
Add the used system api in pw_loop.
Add System API to spa_support and use it where possible.
Pass the system API used in the realtime loops in spa_support as
well and use this in the realtime paths.
Improve bootstrapping, load only the log and cpu interfaces because
those can/need to be shared between instances. Let the core load
the other interfaces.
Add keys to configure the System and Loop implementations used in
pw_loop.
2019-06-06 15:31:53 +02:00
Wim Taymans
857b2a0cfb spa: add result type
We need this to know the type of result, especially when serializing.
2019-05-28 13:59:48 +02:00
Wim Taymans
e009fead09 io: remove unused range 2019-05-16 16:42:49 +02:00
Wim Taymans
6ee192dff5 hooks: use hook to implement the callbacks
This way we get the version check implemented and save some
code.
2019-05-15 11:19:23 +02:00
Wim Taymans
5ac383e7f7 alsa: improve capture slave resync
When we underrun, send out a buffer of 0 samples and catch up next
time.
Detect discont in the master and resync.
2019-04-29 10:00:42 +02:00
Wim Taymans
b43844e7c6 alsa: improve capture resync
Make sure we capture enough data even when the ringbuffer wraps
around.
Use the clock nsec to get timing, we don't need to get the new time.
Improve sync in capture.
2019-04-26 15:48:21 +02:00
Wim Taymans
317fd9fac5 alsa: handle quantum changes 2019-04-25 16:15:52 +02:00
Wim Taymans
d8f39a7c02 alsa: improve clock slaving for source 2019-04-25 12:53:23 +02:00
Wim Taymans
24f6fc2a34 alsa: handle master/slave changes 2019-04-24 15:38:06 +02:00
Wim Taymans
bc85837e26 alsa: small cleanup 2019-04-24 12:40:58 +02:00
Wim Taymans
b7cc9ea102 alsa: improve rate control
Try to match the delay with the target delay. Use the rate to
adjust the timeout period for master or the resampler rate for slaves.
2019-04-23 17:31:29 +02:00
Wim Taymans
715594c6ef alsa: rework source a little in the case of slave
When we are slaved, read as much data as we have available and return
this from process.
2019-04-11 16:44:07 +02:00
Wim Taymans
a44ee31abe alsa: write as much as we can
Always write as much data as we can and don't stop when we written
up to the threshold.
2019-04-02 23:04:09 +02:00
Wim Taymans
5a2ccee1ff Add FASTPATH trace log
Add a trace_fp that can be optimized away when FASTPATH is defined.
2019-03-21 11:31:53 +01:00
Wim Taymans
74cf412f47 utils: add debugable spa_memcpy 2019-03-20 19:27:46 +01:00
Wim Taymans
e31f54fac5 alsa: list formats in order of preference 2019-03-20 13:05:16 +01:00
Wim Taymans
66ea505f22 alsa: improve debug 2019-03-13 15:02:04 +01:00
Wim Taymans
0390969228 node: make add_listener method
Make struct spa_node_events for events emited from the main thread
and keep the spa_node_callbacks for the data thread callbacks.

The add_listener method installs the events and it's possible to
install multiple handles. Adding a listener first emits the info
and port_info events when installed, similar to how the PipeWire
proxy bind works.

This removes the need for the spa_pending_queue and makes it easier
to implement the _sync versions.

Add some helpers to make it easier for plugins to emit all the info
to new listeners.

Use the listeners for devices as well.
2019-03-01 12:00:42 +01:00
Wim Taymans
aab2b5594f utils: don't remove pending after first callback
Let the caller remove the pending result when finished.
Use non _sync verions to enum_params in node/port/device.
Set result.id in alsa and v4l2 correctly.
2019-02-25 20:19:33 +01:00
Wim Taymans
d2c18c7b1a Improve async handling
Don't use special callback in node to receive the results. Instead,
use a generic result callback to receive the result. This makes things
a bit more symetric and generic again because then you can choose how
to match the result to the request and you have a generic way to handle
both the sync and async case. We can then also remove the wait method.
This also makes the remote interface and spa interface to objects very
similar.

Make a helper object to receive and dispatch results. Use this in the
helper for enum_params.

Make device use the same result callbacks.
2019-02-25 12:29:57 +01:00
Wim Taymans
98463b689b node: improve pending results
Make a special function for pending results to make it clear that it
is different from normal results. Don't pass result code to result
function, it is not useful because since the callback is called, all
must be fine.

The spa_pending is removed from the list right before the callback
and can thus be freed in the callback. Pass the spa_pending in
the pending callback so that extra data can be added that way.

Reuse spa_pending objects in link and nodes instead of allocating. We
always only have one pending operation and we can cancel any pending
previous operation by removing the pending.
2019-02-21 12:14:25 +01:00
Wim Taymans
7b12212eeb node: improve async handling
Remove the done and error callbacks. The error callback is in an
error message. The done callback is replace with spa_pending.

Make enum_params take a callback and data for the results. This allows
us to push the results one after another to the app and avoids ownership
issues of the passed data. We can then extend this to handle the async
case by doing a _wait call with a spa_pending+callback+data that will
be called when the _enum_params returns and async result.
Add a sync method.

All methods can now return SPA_RESULT_IS_ASYNC return values and you
can use spa_node_wait() to register a callback when they complete
with optional extra parameters. This makes it easier to sync and
handle the reply.

Make helper methods to simulate the sync enum_params behaviour for
sync nodes.

Let the transport generate the sequence number for pw_resource_sync()
and pw_proxy_sync(). That way we don't need to keep track of numbers
ourselves and we can match the reply to the request easily.
2019-02-21 09:40:12 +01:00
Wim Taymans
3c78036a97 node: process -> ready
Change the process callback to ready to avoid confusion with the
process method and it also describes better what happened.
2019-02-14 17:04:59 +01:00
Wim Taymans
5de7898808 node: implement activation
Make an eventfd for each node and listen for events when the node
is activated.
Reorganize some graphs links to make it possible to activiate nodes
by signaling the eventfd
Pass the peer node to each remote node and let the remote node
directly activate the peer when needed.
Let each node signal the driver node when finished.
With this we don't need to go through the daemon to schedule the
graph, nodes will simply activate eachother. We only go to the
server when there is a server node to schedule.
Keep stats about the state of each node and the time it was
triggered, running and finished.
2019-02-12 17:42:33 +01:00
Wim Taymans
1baef2625c alsa: fix chmaps leak 2019-01-29 12:10:15 +01:00
Wim Taymans
351fb9ce29 pod: improve parser and builder
Remove the spa_pod_iter helpers
Remove builder/parser vararg recurse option, you have to
manually recurse into structures when needed. This simplifies
things a lot.
Pass spa_pod_frames to builder and parser explicitly, we don't
have to keep an internal stack anymore.
The parser is now almost a mirror image of the builder.
Make the parser safer when iterating over objects, add functions
to check and get pod contents in a safe way.
Make the builder return errno style results on errors
Improve performance of object properties when they are stored and
retrieved in the same order.
Add many more tests for the builder and parser
Add some benchmarks
2019-01-22 17:38:23 +01:00
Wim Taymans
5376832676 builder: control_header -> control 2019-01-17 17:11:58 +01:00
Wim Taymans
e4bde73552 alsa: use min_latency when no position is given 2019-01-16 17:38:28 +01:00
Wim Taymans
80cfda89c1 pod: improve the vararg pod builder and parser
Automatically parse and build key/value when in objects without having
to prefix the key with ":"
Automatically build control/value when in sequence without the "."
prefix.
Remove the builder with key/pod, taking a reference to the stack built
temporary pods is not allowed in c++. We can use the varargs version
with the same convenient syntax.
Remove the parser "*" option, it is unused.
Improve spa_pod_builder_add_* and spa_pod_parser_get_* and make them
look similar.
2019-01-16 11:05:12 +01:00
Wim Taymans
b0f4be5fbc fix more compile errors
Avoid void * arithmetic
Do explicit casts to target type to make c++ happy
2019-01-08 11:53:36 +01:00
Wim Taymans
5b7ddb0105 buffer: remove buffer id
The buffer id is not needed/used, we use the index of the buffer in the
buffer array when configuring the port.
2019-01-07 17:57:03 +01:00
Wim Taymans
e918f9f77c fix sign confusion 2019-01-07 15:52:42 +01:00
Wim Taymans
bf1c927087 alsa: reset queued and free buffers on start
When we are out of buffers, drop the available samples.
2018-12-05 11:23:30 +01:00
Wim Taymans
4e7af5644b alsa: set period size to something larger
Setting a small period size will also result in a small buffer, on some
cards smaller than what we can deal with right now.
2018-12-03 15:56:53 +01:00
Wim Taymans
d6836d89ee alsa: stop try writing samples when no progress 2018-11-30 17:52:48 +01:00
Wim Taymans
354bb042e2 alsa: retry _avail after xrun
..or else we pretend all is fine and end up with no available samples
to read in an infinite loop.
2018-11-29 15:19:33 +01:00
Wim Taymans
b27206c24a alsa: debug->trace 2018-11-20 16:13:56 +01:00
Wim Taymans
d70b4b2b10 alsa: more tweaks
Set the lowest possible period time, this lowers the latency.
Adjust slaved stream when we are drifting too much.
Use faster snd_pcm_avail and only use get_status when in error.
2018-11-20 16:08:57 +01:00
Wim Taymans
afd9a6c95f alsa: fix capture again 2018-11-19 18:03:45 +01:00
Wim Taymans
7e9b223216 alsa: reduce start latency 2018-11-19 12:01:36 +01:00
Wim Taymans
27451e4350 alsa: tweak dll some more after xrun 2018-11-19 11:51:51 +01:00
Wim Taymans
0343297257 alsa: rework timing
Use a DLL to track the hardware pointer and use this to set the
timer.
Handle XRUN and recover.
2018-11-16 17:00:40 +01:00
Wim Taymans
d8db090ac2 alsa: only remove sources when they were added 2018-11-12 15:52:11 +01:00
Wim Taymans
416b9c254e alsa: have slaved sink
When we are slaved, calculate our rate difference with the master
2018-11-12 10:18:21 +01:00
Wim Taymans
6f555c63e2 alsa: set buffer_id in io to INVALID when in use 2018-11-12 09:56:45 +01:00
Wim Taymans
e69cf24f24 alsa: add dll to estimate clock drift
Make delay signed in the clock io so that we can simply add it to the
tick to get the hw position.
Add clock drift to clock info
2018-11-09 15:26:08 +01:00