mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-31 22:25:38 -04:00
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.
This commit is contained in:
parent
86dc0496a5
commit
db88e9f954
22 changed files with 455 additions and 342 deletions
|
|
@ -27,9 +27,9 @@
|
|||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/timerfd.h>
|
||||
|
||||
#include <spa/support/log.h>
|
||||
#include <spa/support/system.h>
|
||||
#include <spa/support/loop.h>
|
||||
#include <spa/utils/list.h>
|
||||
#include <spa/utils/keys.h>
|
||||
|
|
@ -113,6 +113,7 @@ struct impl {
|
|||
|
||||
struct spa_log *log;
|
||||
struct spa_loop *data_loop;
|
||||
struct spa_system *data_system;
|
||||
|
||||
uint64_t info_all;
|
||||
struct spa_node_info info;
|
||||
|
|
@ -295,7 +296,8 @@ static void set_timer(struct impl *this, bool enabled)
|
|||
this->timerspec.it_value.tv_sec = 0;
|
||||
this->timerspec.it_value.tv_nsec = 0;
|
||||
}
|
||||
timerfd_settime(this->timer_source.fd, TFD_TIMER_ABSTIME, &this->timerspec, NULL);
|
||||
spa_system_timerfd_settime(this->data_system,
|
||||
this->timer_source.fd, SPA_FD_TIMER_ABSTIME, &this->timerspec, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -304,7 +306,7 @@ static void read_timer(struct impl *this)
|
|||
uint64_t expirations;
|
||||
|
||||
if (this->async || this->props.live) {
|
||||
if (read(this->timer_source.fd, &expirations, sizeof(uint64_t)) != sizeof(uint64_t))
|
||||
if (spa_system_timerfd_read(this->data_system, this->timer_source.fd, &expirations) < 0)
|
||||
perror("read timerfd");
|
||||
}
|
||||
}
|
||||
|
|
@ -972,7 +974,7 @@ static int impl_clear(struct spa_handle *handle)
|
|||
|
||||
if (this->data_loop)
|
||||
spa_loop_remove_source(this->data_loop, &this->timer_source);
|
||||
close(this->timer_source.fd);
|
||||
spa_system_close(this->data_system, this->timer_source.fd);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1004,10 +1006,17 @@ impl_init(const struct spa_handle_factory *factory,
|
|||
this = (struct impl *) handle;
|
||||
|
||||
for (i = 0; i < n_support; i++) {
|
||||
if (support[i].type == SPA_TYPE_INTERFACE_Log)
|
||||
switch (support[i].type) {
|
||||
case SPA_TYPE_INTERFACE_Log:
|
||||
this->log = support[i].data;
|
||||
else if (support[i].type == SPA_TYPE_INTERFACE_DataLoop)
|
||||
break;
|
||||
case SPA_TYPE_INTERFACE_DataLoop:
|
||||
this->data_loop = support[i].data;
|
||||
break;
|
||||
case SPA_TYPE_INTERFACE_DataSystem:
|
||||
this->data_system = support[i].data;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
spa_hook_list_init(&this->hooks);
|
||||
|
|
@ -1031,7 +1040,8 @@ impl_init(const struct spa_handle_factory *factory,
|
|||
|
||||
this->timer_source.func = on_output;
|
||||
this->timer_source.data = this;
|
||||
this->timer_source.fd = timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC);
|
||||
this->timer_source.fd = spa_system_timerfd_create(this->data_system,
|
||||
CLOCK_MONOTONIC, SPA_FD_CLOEXEC);
|
||||
this->timer_source.mask = SPA_IO_IN;
|
||||
this->timer_source.rmask = 0;
|
||||
this->timerspec.it_value.tv_sec = 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue