Commit graph

308 commits

Author SHA1 Message Date
Wim Taymans
ccfe439786 Cache node, port and device params
So that we don't need to keep asking when it didn't change.

Fixes #455
2020-12-09 17:07:34 +01:00
Wim Taymans
7434986452 context: return -ENOENT for destroyed globals
Set the destroyed flag on globals and make sure they are not
available anymore during the signal emissions. One such instance
is where a global is destroyed, the resources are destroyed,
a waiting client is resumed, the clients asks to bind to the
global and causes an error.

See #298
2020-11-19 11:34:44 +01:00
Wim Taymans
f84eacdd5b private: node and port flags are uin64_t 2020-10-09 16:33:23 +02:00
Wim Taymans
089ec424d7 impl: emit error on resource when error
When the state of the object changes to ERROR, emit an error message
on the resources as well. Also pass the error code around for this
purpose.
2020-09-03 14:21:59 +02:00
Wim Taymans
44e74c599f node: add group_id property
Nodes with the same group id are scheduled by the same driver, even
if they are not in any way linked to eachother.
2020-08-06 18:00:46 +02:00
Wim Taymans
e71936f870 Improve naming
master -> driving
priority_master -> priority_driver
segment_master -> segment_owner
2020-08-06 13:49:33 +02:00
Wim Taymans
e32a7a8d65 make some errors into debug
With the debug and return value we can delay writing error messages
in the log until we really need to.
2020-07-29 11:30:11 +02:00
Wim Taymans
8e366a17ee port: add param_changed event 2020-06-18 15:47:29 +02:00
Wim Taymans
108bf82a10 context: improve param debug
Make it possible to log more info in the param debug functions
2020-06-18 15:29:21 +02:00
Wim Taymans
16d61e98e8 link: implement passive links again
Check if a driver is only connected to other nodes with passive
links, if that's the case, set the driver and all followers in
IDLE.
2020-06-17 12:22:58 +02:00
Wim Taymans
5d5bb23e2b proxy: add pw_proxy_ref() private method 2020-06-04 17:30:41 +02:00
Wim Taymans
a7225090c8 core: improve cleanup
When the core is disconnected, first do _remove on all active
proxies and then run the _destroy handles. This makes it easier
to clean up dependent resources.

Remove the modules after removing all objects. It's harder for
 odules to track and remove all objects.
2020-06-03 15:38:13 +02:00
Wim Taymans
be8263208d log: add option to set log before pw_init()
Make it possible to call pw_log_set() before pw_init() so that it's
used for everything.
2020-05-08 11:00:48 +02:00
Wim Taymans
f02c339645 Improve debug
Dump enum_params of failed format and buffer negotiation to error log.
2020-05-07 17:15:43 +02:00
Wim Taymans
3712ebc434 proxy: fix cleanup
Keep track if the proxy is still in the core object map or not
and make sure to only delete it once.

In _remove, just remove the item from the object map if the proxy
is destroyed. There is no need to call _proxy_destroy again (and
do the extra unref)
2020-05-07 17:09:07 +02:00
Wim Taymans
4e9fd6633b node: rate-limit the graph warnings 2020-05-04 16:49:32 +02:00
Wim Taymans
856e1fe812 client-node: don't error in cleanup
It's possible the cleanup code might try to clean up ports we
already removed, don't show an error on that.
2020-04-28 13:56:23 +02:00
Wim Taymans
f5e4a6b225 link: track active state of nodes
Keep track of the node active state, when both are active, we can
prepare (negotiate) the link.

After a link has been prepared we can activate it. When we deactivate
the link, we don't need to prepare again.

When a port loses buffers or format, set the link back to the
unprepared state.

This fixes the case where:
 1) a node becomes inactive and goes to suspend, the link becomes
    unprepared
 2) the node becomes active again and need to be prepared again
2020-04-28 11:45:52 +02:00
Wim Taymans
ea9a016797 context: reorganize graph recalc
Move quantum calculation after adding unassigned to fallback drivers
so that they also receive the required quantum.
2020-04-28 09:58:43 +02:00
Wim Taymans
667c08ecc4 context: improve graph recalc
Add reason to why we recalculate the graph for debugging purposes
Only recalculate graph when something relevant changed.
Block recalc from being called recursively.
2020-04-24 11:27:00 +02:00
Wim Taymans
2c76ec5193 context: simplify state changes
Keep track of when a link is prepared, this is when the link has
successfully negotiated a format and buffers.

Only follow prepared links when collecting nodes in the graph.

Set the state of the driver and its nodes based on how many active
nodes the driver has. We don't have to do state changes on the nodes
from the link anymore then and we can get rid of the counters.

Only set the io on the mixer ports when prepared because we might
need a special mixer element based on the format.

Remove passive links for now.

This fixes many cases where the graph would stall when linking/unlinking
ports in various combinations.

Fixes #221
2020-04-22 17:09:42 +02:00
Wim Taymans
aafd1e7298 improve debug
Improve log so that debug level 3 gives a reasonably readable overview
of what is going on.
2020-04-22 12:47:18 +02:00
Wim Taymans
b18dacde9a spa: improve draining
Make a new DRAINED status.
Place the DRAINED status on an input IO when a stream is out of
buffers and draining.
All nodes that don't have HAVE_DATA on the input io need to copy
it to the output io and return the status. This makes sure the
DRAINED is forwarded and nodes return DRAINED from _process()
DRAINED on the resampler flushes out the last queued samples and then
forwards the DRAINED in the next iteration.
Emit a new drained signal from the context when a node returns
DRAINED. Use this to trigger the drained signal in the stream.
2020-04-07 17:58:43 +02:00
Wim Taymans
02dc407752 node: improve debug of activation area 2020-04-02 15:43:36 +02:00
Wim Taymans
e76351da79 data-loop: add option to pthread_cancel the thread
Don't use pthread_cancel by default to stop the data thread but
instead use an eventfd. pthread_cancel uses a signal and is not
nice to use in a library as it can cause strange crashes.

See #211
2020-03-02 15:44:47 +01:00
Wim Taymans
b33bd68bac improve error messages
Log an error when we send an error to the client so that we don't need
to log and error anymore.
Improve the error messages when we can
Move some warnings and errors to debug
2020-02-21 15:02:55 +01:00
Wim Taymans
a528189d26 slave -> follower
We use master/follower terminology everywhere.
2020-02-21 10:47:32 +01:00
Wim Taymans
bdeeebfdd4 enable and fix -Werror=suggest-attribute=format 2020-02-20 18:20:04 +01:00
Wim Taymans
293932d4ec v0: improve compatibility
Implement RequestClockUpdate event and ClockUpdate message for
old clients.
2020-02-11 11:23:28 +01:00
Wim Taymans
d2e7f75071 resource: destroy old core_resource
If there is already a core_resource when we are going to make a new
one, remove the old one. This can happen when there is a version
switch.
2020-02-10 16:22:49 +01:00
Wim Taymans
7a395bccaf improve v2 compat mode
Always send the server types when we got the first client types and
don't rely on the message sequence number.
Add some more types in the typemap.
2020-02-06 16:56:19 +01:00
Wim Taymans
41b47e726e context: add some more defaults
Make a property to allow mlock and use it.
mlock in stream and filter when asked to mmap mem.
2020-02-04 17:09:41 +01:00
Wim Taymans
43257e8676 graph: make pending/required fields signed
So that we can check for negative value.
Also don't signal incomplete graph when we signaled more than
expected, this can happen when we add new nodes in the current
cycle and then triggered the driver.
2020-01-31 13:36:44 +01:00
Wim Taymans
cd21f5292b context: emit events for driver
Make new private events to monitor the state of driver nodes. This
can be used to implement profiling.
2020-01-30 17:21:33 +01:00
Wim Taymans
940aba8623 data-loop: use pthread_cancel to stop thread
Use pthread_cancel to terminate the data threads. We need this for
jack support but it's generally useful for a data thread.
2020-01-16 13:27:52 +01:00
Wim Taymans
852ac043d3 Use the DSP format for dsp formats
Use the DSP media subtype to describe DSP formats. DSP formats
don't include the rate, channels and channel position in the
format and must use the rate and duration from the position io. This
makes it possible to later change the samplerate dynamically without
having to renegotiate the graph.

The same goes for the video DSP format, which uses the io_video_size
from the io_position to get the size/stride. Set this up in the node
based on the defaults from the context.

Make it possible to define defaults in the daemon config file, such
as samplerate, quantum, video size and framerate. This is stored in
the context and used for the DSP formats.
2020-01-09 15:18:59 +01:00
Wim Taymans
df519ee3b3 avoid including private.h
Expose some more methods to make it possible to build without
including the private.h header, especially in modules.
2020-01-02 13:48:50 +01:00
Wim Taymans
d3db9d12bc proxy: never free a proxy automatically
Never free a proxy without the application doing a pw_proxy_destroy.

It's hard to use when proxies are freed randomly when the server
removes the ids. You have to add destroy notify to all proxies and
deal with the arbirary order in which proxies can be freed.
Instead notify the client of the remove and let it destroy the
proxies itself in the right order. This is in line with how wayland
handles proxies.

A pw_proxy_destroy() will now send a destroy to the server and mark
the proxy as a zombie, waiting for the remove_id confirmation and
then destroy the proxy.

A server remove_id will mark the proxy as removed and emits the
removed event. The app should then pw_proxy_destroy the proxy
to free it.

Leaks all proxies in the session manager because cleanup now needs
to be handled by the app correctly.
2019-12-19 15:25:21 +01:00
Wim Taymans
f391353c7f Make interface types a string
This is more in line with wayland and it allows us to create new
interfaces in modules without having to add anything to the type
enum. It also removes some lookups to map type_id to readable
name in debug.
2019-12-19 13:36:04 +01:00
Wim Taymans
98c81fff93 proxy: only call destroy once
Make sure only emit destroy once by making the proxy a zombie
from the first call to destroy. Also make sure we don't call destroy
twice without remove.
2019-12-17 10:44:22 +01:00
Wim Taymans
1bca1b15ea context: add object store
Add method to set and get typed objects from the context. This can
be used to pass around context objects between modules without having
to register them.
2019-12-16 10:28:18 +01:00
Wim Taymans
698ab911c3 loop: pass spa_dict to *_loop_new
Make the thread_loop alloc its own loop by default to simplify
some core. Add extra new_full method to pass a custom pw_loop.
Make other loop implementations ready to support custom loops
if we want that later.
2019-12-13 11:34:25 +01:00
Wim Taymans
f724319e8a context: move core implementation to impl-core.h
Move the core implementation to a separate file. Make a default
core object in the context.

Pass impl-core to server. We now tie the server to a core. Also
keep track of the core that a client connected to.

Fill the properties that we usually use to connect in the context
and copy them when a connection is made.

Use "internal" as the remote name to connect to the default
internal core.
2019-12-12 16:34:01 +01:00
Wim Taymans
2a142edadb pw_impl_port_new -> pw_context_create_port 2019-12-11 18:07:03 +01:00
Wim Taymans
73eea24443 impl-client: improve constructor
Pass the protocol in constructor
Keep the link in the server protocol list private to the prototol.
2019-12-11 17:19:12 +01:00
Wim Taymans
c23006fcdb pw_port_proxy -> pw_port 2019-12-11 15:59:26 +01:00
Wim Taymans
a8f1d756c3 pw_client_proxy -> pw_client 2019-12-11 14:53:39 +01:00
Wim Taymans
898e870997 pw_node -> pw_impl_node 2019-12-11 12:41:45 +01:00
Wim Taymans
f62d1cb357 pw_port -> pw_impl_port 2019-12-11 12:24:03 +01:00
Wim Taymans
b88741dbb9 pw_link -> pw_impl_link 2019-12-11 12:06:08 +01:00