Commit graph

40 commits

Author SHA1 Message Date
Wim Taymans
5850044599 improve error handling 2019-06-18 16:55:37 +02:00
Wim Taymans
504d78cd18 improve error handling
Set errno for functions returning NULL if relevant.
Propagate errno and result codes better.
Handle more error cases.
2019-06-07 10:11:23 +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
81c7dd4433 support: abstract some system functions
Make a new API to hide some the implementation of eventfd, timerfd
and signalfd along with clock and read/write/ioctl/close functions.
We would like to have plugins use the abstractions so that we
can switch them to something else when needed.
2019-06-04 17:07:34 +02:00
Wim Taymans
7bb6515800 loop: cleanups 2019-05-23 15:11:49 +02:00
Wim Taymans
ff946e3d4b interface: add an interface struct
The interface struct has the type,version and methods of the
interface.
Make spa interfaces extend from spa_interface and make a
separate structure for the methods.
Pass a generic void* as the first argument of methods, like
we don in PipeWire.
Bundle the methods + implementation in a versioned inteface
and use that to invoke methods. This way we can do version
checks on the methods.
Make resource and proxy interfaces that we can can call. We
can then make the core interfaces independent on proxy/resource and
hide them in the lower layers.
Add add_listener method to methods of core interfaces, just
like SPA.
2019-05-23 12:59:24 +02: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
a563050797 spa: don't use constructor attribute to register factories 2019-02-06 12:14:25 +01:00
Wim Taymans
e918f9f77c fix sign confusion 2019-01-07 15:52:42 +01:00
Wim Taymans
85f2e93c54 Relicense as MIT/X11
Remove some obsolete files
2018-11-05 17:48:52 +01:00
Wim Taymans
39240fb9c0 use _list_consume to destroy objects 2018-09-25 13:05:13 +02:00
Wim Taymans
90c1a95eef More type cleanups
SPA_ID_* -> SPA_TYPE_*. We use 'type' for all registered types.
ID refers to either a registered type or an enum.
Improve introspection of object ids. Make 0 an invalid enum and
use it to look up the object id type.
Move some type-info files together.
Swap type and id of the object, we first specify the type and then
the id because the meaning of the id depends on the object type.
2018-08-27 15:03:11 +02:00
Wim Taymans
fca3e1d85d Remove dynamic types
Do not use dynamic types anymore. The reason is that it's difficult:

- to maintain a shared type database over a network.
- the extra overhead when translating between processes and for
  maintaining the translation tables.
- race conditions in translating in RT-threads, this is a problem
  because we want to make event streams.

We now have simple enums with types and extension points for all
types. This is also nicer to use in general.
We don't need the mapper anymore or pass strings around as types.
There is a parallel type info system to get more info about ids and
enums and their hierarchy. It can also be used for debugging.
2018-08-23 17:47:57 +02:00
Wim Taymans
a63523650d hooks: enforce version on hook emission
Pass the minimum required version to the hook emission and only call
events when the handler is recent enough.
Add some macros to make event emission easier to read.
2018-08-01 21:41:25 +02:00
Wim Taymans
1bfb1d9228 loop: return number of dispatched fds and update docs 2018-06-01 11:16:53 +02:00
Wim Taymans
c2cd56d903 loop: inline frequently used function 2018-04-27 17:29:39 +02:00
Wim Taymans
0eb73f0f06 loop: add back the destroy loop
We need to keep the sources around until all sources are dispatched. If
not: source A and B are active after poll, A is dispatched first and
removes B, when B is then dispatched, the memory is gone. We don't
free the source but simply mark the fd invalid and move it do a
destroy list. After all sources are dispatched we destroy.
This is safe because removing a source is either done from the poll
context (with invoke) or when holding the right locks.
2018-04-20 16:28:47 +02:00
Wim Taymans
ebd13a2a74 loop: blocking wait
Release the locks before waiting.
2018-04-19 22:01:18 +02:00
Wim Taymans
de36330917 handle: make method to get size 2018-04-09 10:06:17 +02:00
Wim Taymans
33a322b96e graph: new scheduling model
Make explicit links between elements that are used to activate the
next element in the graph.
Make subgraphs a special regular node. Make a link from the
subgraph children to the parent so that the subgraph completes when
all the children completed.
Implement a single process function in plugins
Remove many messages in the client node
2018-04-03 16:29:36 +02:00
Wim Taymans
638916e065 loop: remove the destroy_list
Don't use a destroy_list anymore, it's not safe anyway. Instead require
that sources be removed with (a blocking) invoke. Make sure we don't
dispatch sources that were removed from the loop.
2018-03-14 14:51:36 +01:00
Wim Taymans
8e2ceb773e Improve some debug 2018-03-01 09:01:52 +01:00
Wim Taymans
4d6ac37398 Use int instead of bool as result
Prefer to use an int return from a function instead of bool because
it can contain more info about failures.
2017-12-18 11:38:30 +01:00
Wim Taymans
5bebfe022b cleanups
Follow the data/size argument order convention to make the api
more consistent.
2017-11-20 15:26:44 +01:00
Wim Taymans
2923b623b3 Meta: rework ringbuffer meta
ringbuffer: remove size and mask from the ringbuffer, we have that
elsewhere in the user of the ringbuffer.
Remove the buffer data offset and size fields and replace with a
ringbuffer. We then have a ringbuffer in all buffer data, which
simplifies things.
We can now remove the ringbuffer metadata.
2017-11-15 17:25:36 +01:00
Wim Taymans
c78fe6a353 port: work on port commands 2017-11-14 15:44:48 +01:00
Wim Taymans
6fb0f580ea Use errno for result errors
Make new enumeration for data transport status and use errno
style error numbers for errors.
2017-11-13 09:41:41 +01:00
Wim Taymans
caaeaff223 Reorganise SPA tree
Reorganise the SPA includes to make it more extensible later
Simplify the naming of the buffer and meta params
2017-11-10 13:36:14 +01:00
Wim Taymans
323c644084 fix crashes and leaks on shutdown 2017-10-17 10:14:56 +02:00
Wim Taymans
577f86be0d graph: use spa_node as implementation
Always use a spa_node as the graph implementation, implementing the
methods is just as easy.
Plug some mem leaks in remote
2017-08-27 12:12:14 +02:00
Wim Taymans
c25834a692 Work on cleanup
Add signal handlers for daemon to shut down
Add destroy listeners for modules and do cleanup
Fix some leaks
Simplify port registration in new nodes
Hide some more data structures
Let the node implementation take care of the reuse_buffer signal because
then we can get to the graph nodes to find the destination port.
Destroy modules in core cleanup. Modules should undo everything they
have done.
Activate the link after we negotiated format and buffers.
2017-08-22 18:30:10 +02:00
Wim Taymans
9ad1f911b2 Improve loop callbacks
Pass just one data item to the callbacks.
Add properties to port.
Add user data to link
Handle autolink with multiple ports
More work on jack support
2017-08-11 19:21:31 +02:00
Wim Taymans
eeda53dbef Fix leaks
Add some docs
Add properties to loop objects for future use
2017-08-08 18:24:15 +02:00
Wim Taymans
600055bd68 Move listeners to spa and rename to hooks
The listeners are generally useful in spa, move it there and rename
to hooks. Implement loop hooks with it.
Fix some cleanup issues in stream and remote
2017-08-08 16:56:29 +02:00
Wim Taymans
3d9f28c676 Use remote to join nodes on remote graphs
Make a new method that can take a local node and run it in a remote
pipeline. This basically replaces all functionality of the streams
and more.
Add 2 examples for exporting a sink and a v4l2 node
Make some more things const
Cleanups
Make it possible to do things when the node needs scheduling. The
default node will schedule the local pipeline but the remote node might
also schedule the remote pipeline.
2017-07-25 19:52:31 +02:00
Wim Taymans
91d54364fc loop: add signal count to callback
Don't try to signal too many times
2017-07-19 10:44:03 +02:00
Wim Taymans
791137e9e5 loop: fix ringbuffer handling 2017-07-04 10:18:24 +02:00
Wim Taymans
bc56c59597 loop: add block flag to invoke
Remove async shutdown and block instead.
2017-06-26 10:41:19 +02:00
Wim Taymans
c3b73ba47d Add versions to structures
Use versions instead of size
Remove user_data from callbacks, we can simply pass the callback struct.
2017-06-14 18:32:39 +02:00
Wim Taymans
4a219e81dd loop: move to plugin
Move the loop implementation to a plugin.
Organize the hooks in a list so that we can add many.
2017-06-14 16:27:04 +02:00