Commit graph

3628 commits

Author SHA1 Message Date
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
499dd3ff22 node: add port and node params
Add a new struct spa_param_info that lists the available params on
a node/port and if they are readable/writable/updated. We can use
this to replace and improve the PARAM_List and also to notify
property change and updates.

Update elements and code to deal with this new param stuff. Add
port and node info to most elements and signal changes.

Use async enum_params in -inspect and use the param info to know
which ones to enumerate.

Use the port info to know what parameters to update in the
remote-node.
2019-02-27 16:43:01 +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
245a0d5634 global: pass bind function to _new
Make the bind function a callback instead of an event. We can then
get a return value and use that to clean up the pending proxy and
generate an error.
2019-02-25 17:16:40 +01:00
Wim Taymans
f2ff6f393b more async improvements
Make the sequence number an int.

Keep track of the last received seq number and pass it in error
replies.

Pass seq in for_each methods.
2019-02-25 16:25:27 +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
a3ca2df0fe link: handle the right port in the callback 2019-02-21 10:30:40 +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
b743518f78 node: add props to add_port 2019-02-18 13:22:46 +01:00
Wim Taymans
eea062ee53 interfaces: improve remote API
Add return values to events and method callbacks. This makes it
possible to pass any error or async return value.
Add sync/done/error in both directions so that both proxy and resource
and perform/reply sync and produce errors.
Return a SPA_ASYNC from remote method calls (and events), keep the
sequence number in the connection.
With the core sync/done we can remove the client-node done method and
it's internal sequence number along with the seq number in method calls.
We can also use the method/event async return value to perform a sync
with as the unique sequence number for this method.
Add sync method and done/error event to proxy and resource.
2019-02-18 12:31:36 +01:00
Wim Taymans
0d8821096a client-node: only update info when change_mask set 2019-02-14 17:48:56 +01:00
Wim Taymans
755d7ca329 client-node: handle NULL info in update 2019-02-14 17:45:42 +01:00
Wim Taymans
e9bedae5fa node: add max_ports to node info 2019-02-14 17:40:01 +01:00
Wim Taymans
21957e9e8d node: Add port_info event
Add a port_info event. With this, we get updates to ports pushed to
us, which is more convenient and also allows for better dynamic
add/remove of ports.
We don't need to the PortChanged event anymore
We can remove the get_port_ids/get_n_ports/port_get_info methods.
Update plugins
2019-02-14 17:08:46 +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
8ae5424359 resource: improve error handling
Make some more varargs error functions
Make pw_resource_error always just send the error to the resource id.
Make sure we send errors to the right destination.
Add proxy error event and emit it when the core finds an error for
the given proxy id.
The client error is supposed to be sent to all resources of a client
for the given global.
2019-02-14 16:53:42 +01:00
Wim Taymans
7a1bd163f7 node: remove port_send_command
We don't want to do this, we use a sequence to change things
at runtime.
2019-02-13 12:43:15 +01:00
Wim Taymans
04f1046113 node: pass struct to info callback to make it more extensible 2019-02-13 11:44:58 +01:00
George Kiagiadakis
27e997a032 daemon: getopt returns int, declare it as such to avoid comparison issues
On some toolchains/architectures, a char with -1 value is not equal
to the integer -1, resulting in this code to think that it got
an unrecognized command line option
2019-02-13 11:23:18 +01:00
George Kiagiadakis
71eb538fba meson: prefix the names of the tests so that they are unique in the tree
meson < 0.46 does not allow two targets to share the same name;
meson >= 0.46 relaxes that requirement, but I see no reason to require
a new version of meson just for this
2019-02-13 11:22:45 +01:00
George Kiagiadakis
24eeea62e7 remote: use 0 for pw_proxy_new() user_data_size argument
pw_proxy_new() expects a size for its user data structure
as the last argument, not a proxy version
2019-02-13 11:20:39 +01:00
George Kiagiadakis
ba653fccfc add .editorconfig files
These files help editors choose the correct coding style
conventions, mostly useful for the indentation style

Pipewire uses tab characters of size 8 in all of its codebase
except in the meson files and in the gstreamer plugins,
which use 2-space indentation
2019-02-13 11:19:21 +01:00
Wim Taymans
ac5ec9bbe2 device: improve callbacks
Pass info structures to device callbacks to make it more extensible.
Also notify about the supported params on the device because we
can.
2019-02-13 11:13:46 +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
f45e0b8966 reorganize some struct members to remove holes 2019-02-08 12:01:50 +01:00
Wim Taymans
658c1da52f node: allocate shared mem for activation
Allocate a per node a piece of shared memory where we place the
activation structure with the graph state and io_position.
We can then give this info to nodes so that they can get the position
in the graph directly but also later, activate the next node in
the graph.
2019-02-07 12:34:54 +01:00
Wim Taymans
db230fc136 floatmix: unroll loop a little 2019-02-07 12:30:36 +01:00
Wim Taymans
8a9c1129a2 spa: make fd in spa_data an int64_t
So that we can store other things in it later as well.
2019-02-07 12:22:51 +01:00
Wim Taymans
569cbb48a9 use SPA_EXPORT to export symbols 2019-02-06 13:24:41 +01:00
Wim Taymans
baa6b1472d client-node: handle _set_io on the node 2019-01-31 17:50:55 +01:00
Wim Taymans
bad9b15a92 node: warn when _set_io fails on the node 2019-01-31 17:50:16 +01:00
Wim Taymans
550a2af044 examples: improve examples 2019-01-31 11:58:35 +01:00
Wim Taymans
31dacd9d6f remote: move node export code to client-node module
Make the code to export objects more generic. Make it possible for
modules to register a type to export.
Make the client-node also able to export plain spa_nodes.
Let the remote signal the global of the exported object if any. We can
then remote the (unused) remote_id from the proxy.
2019-01-31 11:02:13 +01:00
Wim Taymans
7ec9de5ac6 video-src: always set chunk info 2019-01-31 10:59:43 +01:00
Wim Taymans
61194d02b3 stream: small cleanups in notify/control handling 2019-01-30 11:01:17 +01:00
Wim Taymans
2f102a69d6 export-source: fix example 2019-01-30 10:50:42 +01:00
Wim Taymans
39f1309130 conf: remove old module 2019-01-30 10:50:23 +01:00
Wim Taymans
4509bd8cfd media-session: report error when binding 2019-01-30 10:36:00 +01:00
Wim Taymans
e4f58da013 properties: handle prealloc of 0
The argument to array_init is not the prealloc but the extend, so
passing 0 will not work
2019-01-29 16:52:21 +01:00
Wim Taymans
086166058a media-session: handle unknown media 2019-01-29 16:51:55 +01:00
Wim Taymans
bf33ce3fc0 link: don't call use_buffers after alloc_buffers 2019-01-29 12:04:31 +01:00
Wim Taymans
e63adfef25 link-factory: fix cleanup
If the link is destroyed, remove the listeners. Only remove the
resource listener when we actually have one.
If the resource is destroyed first, destroy the global.
If the global is destroyed first, make sure we don't destroy it
again when the resource is destroyed.
2019-01-29 10:45:28 +01:00
Wim Taymans
beae1890d3 global: first emit then destroy, then unregister 2019-01-29 10:31:48 +01:00
Wim Taymans
718847fcd5 audio-dsp: clean ports when the node is destroyed 2019-01-29 10:30:01 +01:00
Wim Taymans
11769aa7e7 media-session: track our DSP link
Set our DSP link proxy to NULL when it gets destroyed so that we
don't accidentally try to do things with it anymore.
2019-01-29 10:29:06 +01:00
Wim Taymans
ac6a568729 global: remove the global from the map when we unlink 2019-01-29 09:51:20 +01:00
Wim Taymans
1c7fa34f57 port: make it possible to clear the mix node again 2019-01-29 09:50:50 +01:00
Wim Taymans
7a8412e81a alloc: document alloc functions 2019-01-25 15:55:39 +01:00
Wim Taymans
93e8074b2c alloc: improve alignment in alloactor
link: use buffer allocator
Add more tests
2019-01-25 13:32:35 +01:00