mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-12-14 08:56:37 -05:00
system: use spa_system functions for fds
This commit is contained in:
parent
b14bb1f496
commit
68e94a2e7e
16 changed files with 96 additions and 60 deletions
|
|
@ -27,7 +27,6 @@
|
|||
#include <sys/shm.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/eventfd.h>
|
||||
#include <sys/mman.h>
|
||||
|
||||
#include <alsa/asoundlib.h>
|
||||
|
|
@ -90,7 +89,7 @@ static int pcm_poll_block_check(snd_pcm_ioplug_t *io)
|
|||
(io->state == SND_PCM_STATE_PREPARED && io->stream == SND_PCM_STREAM_CAPTURE)) {
|
||||
avail = snd_pcm_avail_update(io->pcm);
|
||||
if (avail >= 0 && avail < (snd_pcm_sframes_t)pw->min_avail) {
|
||||
read(io->poll_fd, &val, sizeof(val));
|
||||
spa_system_eventfd_read(pw->loop->system, io->poll_fd, &val);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
|
@ -100,9 +99,8 @@ static int pcm_poll_block_check(snd_pcm_ioplug_t *io)
|
|||
|
||||
static inline int pcm_poll_unblock_check(snd_pcm_ioplug_t *io)
|
||||
{
|
||||
uint64_t val = 1;
|
||||
snd_pcm_pipewire_t *pw = io->private_data;
|
||||
write(pw->fd, &val, sizeof(val));
|
||||
spa_system_eventfd_write(pw->loop->system, pw->fd, 1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
@ -118,7 +116,7 @@ static void snd_pcm_pipewire_free(snd_pcm_pipewire_t *pw)
|
|||
if (pw->loop)
|
||||
pw_loop_destroy(pw->loop);
|
||||
if (pw->fd >= 0)
|
||||
close(pw->fd);
|
||||
spa_system_close(pw->loop->system, pw->fd);
|
||||
free(pw);
|
||||
}
|
||||
}
|
||||
|
|
@ -866,7 +864,7 @@ static int snd_pcm_pipewire_open(snd_pcm_t **pcmp, const char *name,
|
|||
if ((err = remote_connect_sync(pw)) < 0)
|
||||
goto error;
|
||||
|
||||
pw->fd = eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK);
|
||||
pw->fd = spa_system_eventfd_create(pw->loop->system, SPA_FD_CLOEXEC | SPA_FD_NONBLOCK);
|
||||
|
||||
pw->io.version = SND_PCM_IOPLUG_VERSION;
|
||||
pw->io.name = "ALSA <-> PipeWire PCM I/O Plugin";
|
||||
|
|
|
|||
|
|
@ -29,7 +29,6 @@
|
|||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/timerfd.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include <bluetooth/bluetooth.h>
|
||||
|
|
@ -59,6 +58,7 @@ struct spa_bt_monitor {
|
|||
|
||||
struct spa_log *log;
|
||||
struct spa_loop *main_loop;
|
||||
struct spa_system *main_system;
|
||||
struct spa_dbus *dbus;
|
||||
struct spa_dbus_connection *dbus_connection;
|
||||
DBusConnection *conn;
|
||||
|
|
@ -546,7 +546,7 @@ static void device_timer_event(struct spa_source *source)
|
|||
struct spa_bt_monitor *monitor = device->monitor;
|
||||
uint64_t exp;
|
||||
|
||||
if (read(source->fd, &exp, sizeof(uint64_t)) != sizeof(uint64_t))
|
||||
if (spa_system_timerfd_read(monitor->main_system, source->fd, &exp) < 0)
|
||||
spa_log_warn(monitor->log, "error reading timerfd: %s", strerror(errno));
|
||||
|
||||
spa_log_debug(monitor->log, "device %p: timeout %08x %08x",
|
||||
|
|
@ -564,7 +564,8 @@ static int device_start_timer(struct spa_bt_device *device)
|
|||
if (device->timer.data == NULL) {
|
||||
device->timer.data = device;
|
||||
device->timer.func = device_timer_event;
|
||||
device->timer.fd = timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC | TFD_NONBLOCK);
|
||||
device->timer.fd = spa_system_timerfd_create(monitor->main_system,
|
||||
CLOCK_MONOTONIC, SPA_FD_CLOEXEC | SPA_FD_NONBLOCK);
|
||||
device->timer.mask = SPA_IO_IN;
|
||||
device->timer.rmask = 0;
|
||||
spa_loop_add_source(monitor->main_loop, &device->timer);
|
||||
|
|
@ -573,7 +574,7 @@ static int device_start_timer(struct spa_bt_device *device)
|
|||
ts.it_value.tv_nsec = 0;
|
||||
ts.it_interval.tv_sec = 0;
|
||||
ts.it_interval.tv_nsec = 0;
|
||||
timerfd_settime(device->timer.fd, 0, &ts, NULL);
|
||||
spa_system_timerfd_settime(monitor->main_system, device->timer.fd, 0, &ts, NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -591,8 +592,8 @@ static int device_stop_timer(struct spa_bt_device *device)
|
|||
ts.it_value.tv_nsec = 0;
|
||||
ts.it_interval.tv_sec = 0;
|
||||
ts.it_interval.tv_nsec = 0;
|
||||
timerfd_settime(device->timer.fd, 0, &ts, NULL);
|
||||
close(device->timer.fd);
|
||||
spa_system_timerfd_settime(monitor->main_system, device->timer.fd, 0, &ts, NULL);
|
||||
spa_system_close(monitor->main_system, device->timer.fd);
|
||||
device->timer.data = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -2258,6 +2259,9 @@ impl_init(const struct spa_handle_factory *factory,
|
|||
case SPA_TYPE_INTERFACE_Loop:
|
||||
this->main_loop = support[i].data;
|
||||
break;
|
||||
case SPA_TYPE_INTERFACE_System:
|
||||
this->main_system = support[i].data;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (this->dbus == NULL) {
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@
|
|||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/timerfd.h>
|
||||
|
||||
#include <jack/jack.h>
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@
|
|||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/timerfd.h>
|
||||
|
||||
#include <jack/jack.h>
|
||||
|
||||
|
|
|
|||
|
|
@ -183,7 +183,7 @@ static int impl_clear(struct spa_handle *handle)
|
|||
|
||||
if (this->have_source) {
|
||||
spa_loop_remove_source(this->source.loop, &this->source);
|
||||
close(this->source.fd);
|
||||
spa_system_close(this->system, this->source.fd);
|
||||
this->have_source = false;
|
||||
}
|
||||
return 0;
|
||||
|
|
|
|||
|
|
@ -627,7 +627,7 @@ static void loop_destroy_source(void *object, struct spa_source *source)
|
|||
loop_remove_source(impl->impl, source);
|
||||
|
||||
if (source->fd != -1 && impl->close) {
|
||||
close(source->fd);
|
||||
spa_system_close(impl->impl->system, source->fd);
|
||||
source->fd = -1;
|
||||
}
|
||||
spa_list_insert(&impl->impl->destroy_list, &impl->link);
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@
|
|||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/timerfd.h>
|
||||
|
||||
#include <spa/support/plugin.h>
|
||||
#include <spa/support/log.h>
|
||||
|
|
@ -80,6 +79,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;
|
||||
|
|
@ -205,7 +205,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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -214,7 +215,8 @@ static inline void read_timer(struct impl *this)
|
|||
uint64_t expirations;
|
||||
|
||||
if (this->callbacks.funcs || 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");
|
||||
}
|
||||
}
|
||||
|
|
@ -704,7 +706,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;
|
||||
}
|
||||
|
|
@ -736,10 +738,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);
|
||||
|
|
@ -762,7 +771,7 @@ impl_init(const struct spa_handle_factory *factory,
|
|||
|
||||
this->timer_source.func = on_input;
|
||||
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;
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@
|
|||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/timerfd.h>
|
||||
|
||||
#include <spa/support/plugin.h>
|
||||
#include <spa/support/log.h>
|
||||
|
|
@ -81,6 +80,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;
|
||||
|
|
@ -223,7 +223,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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -232,7 +233,8 @@ static inline void read_timer(struct impl *this)
|
|||
uint64_t expirations;
|
||||
|
||||
if (this->callbacks.funcs || 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");
|
||||
}
|
||||
}
|
||||
|
|
@ -738,7 +740,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;
|
||||
}
|
||||
|
|
@ -770,10 +772,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);
|
||||
|
|
@ -795,7 +804,7 @@ 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;
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@
|
|||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/timerfd.h>
|
||||
|
||||
#include <spa/support/plugin.h>
|
||||
#include <spa/support/log.h>
|
||||
|
|
@ -100,6 +99,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;
|
||||
|
|
@ -272,7 +272,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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -281,7 +282,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");
|
||||
}
|
||||
}
|
||||
|
|
@ -834,7 +835,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;
|
||||
}
|
||||
|
|
@ -866,10 +867,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);
|
||||
|
|
@ -893,7 +901,7 @@ 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;
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@
|
|||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/timerfd.h>
|
||||
|
||||
#include <spa/support/plugin.h>
|
||||
#include <spa/support/log.h>
|
||||
|
|
@ -96,6 +95,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;
|
||||
|
|
@ -244,7 +244,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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -253,7 +254,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");
|
||||
}
|
||||
}
|
||||
|
|
@ -849,7 +850,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;
|
||||
}
|
||||
|
|
@ -881,10 +882,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);
|
||||
|
|
@ -908,7 +916,7 @@ 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;
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@
|
|||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <time.h>
|
||||
#include <sys/eventfd.h>
|
||||
|
||||
#include <spa/monitor/device.h>
|
||||
#include <spa/monitor/utils.h>
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@
|
|||
#include <dlfcn.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/eventfd.h>
|
||||
|
||||
#include <spa/node/node.h>
|
||||
#include <spa/node/utils.h>
|
||||
|
|
@ -317,8 +316,7 @@ static int impl_node_set_io(void *object, uint32_t id, void *data, size_t size)
|
|||
|
||||
static inline void do_flush(struct node *this)
|
||||
{
|
||||
uint64_t cmd = 1;
|
||||
if (write(this->writefd, &cmd, 8) != 8)
|
||||
if (spa_system_eventfd_write(this->data_system, this->writefd, 1) < 0)
|
||||
spa_log_warn(this->log, "node %p: error flushing : %s", this, strerror(errno));
|
||||
|
||||
}
|
||||
|
|
@ -1036,7 +1034,7 @@ static void node_on_data_fd_events(struct spa_source *source)
|
|||
struct pw_client_node0_message message;
|
||||
uint64_t cmd;
|
||||
|
||||
if (read(this->data_source.fd, &cmd, sizeof(uint64_t)) != sizeof(uint64_t))
|
||||
if (spa_system_eventfd_read(this->data_system, this->data_source.fd, &cmd) < 0)
|
||||
spa_log_warn(this->log, "node %p: error reading message: %s",
|
||||
this, strerror(errno));
|
||||
|
||||
|
|
@ -1168,12 +1166,13 @@ static void node_initialized(void *data)
|
|||
struct impl *impl = data;
|
||||
struct pw_client_node0 *this = &impl->this;
|
||||
struct pw_node *node = this->node;
|
||||
struct spa_system *data_system = impl->node.data_system;
|
||||
|
||||
if (this->resource == NULL)
|
||||
return;
|
||||
|
||||
impl->fds[0] = eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK);
|
||||
impl->fds[1] = eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK);
|
||||
impl->fds[0] = spa_system_eventfd_create(data_system, SPA_FD_CLOEXEC | SPA_FD_NONBLOCK);
|
||||
impl->fds[1] = spa_system_eventfd_create(data_system, SPA_FD_CLOEXEC | SPA_FD_NONBLOCK);
|
||||
impl->node.data_source.fd = impl->fds[0];
|
||||
impl->node.writefd = impl->fds[1];
|
||||
impl->other_fds[0] = impl->fds[1];
|
||||
|
|
@ -1192,6 +1191,7 @@ static void node_initialized(void *data)
|
|||
static void node_free(void *data)
|
||||
{
|
||||
struct impl *impl = data;
|
||||
struct spa_system *data_system = impl->node.data_system;
|
||||
|
||||
pw_log_debug("client-node %p: free", &impl->this);
|
||||
node_clear(&impl->node);
|
||||
|
|
@ -1204,9 +1204,9 @@ static void node_free(void *data)
|
|||
pw_array_clear(&impl->mems);
|
||||
|
||||
if (impl->fds[0] != -1)
|
||||
close(impl->fds[0]);
|
||||
spa_system_close(data_system, impl->fds[0]);
|
||||
if (impl->fds[1] != -1)
|
||||
close(impl->fds[1]);
|
||||
spa_system_close(data_system, impl->fds[1]);
|
||||
free(impl);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@
|
|||
#include <errno.h>
|
||||
#include <unistd.h>
|
||||
#include <time.h>
|
||||
#include <sys/eventfd.h>
|
||||
|
||||
#include <spa/monitor/device.h>
|
||||
#include <spa/monitor/utils.h>
|
||||
|
|
|
|||
|
|
@ -33,7 +33,6 @@
|
|||
#include <unistd.h>
|
||||
#include <pthread.h>
|
||||
#include <sys/resource.h>
|
||||
#include <sys/eventfd.h>
|
||||
|
||||
#include "config.h"
|
||||
|
||||
|
|
@ -52,6 +51,7 @@ struct impl {
|
|||
struct pw_core *core;
|
||||
|
||||
struct spa_loop *loop;
|
||||
struct spa_system *system;
|
||||
struct spa_source source;
|
||||
|
||||
struct spa_hook module_listener;
|
||||
|
|
@ -411,7 +411,7 @@ static void module_destroy(void *data)
|
|||
0,
|
||||
true,
|
||||
&impl->source);
|
||||
close(impl->source.fd);
|
||||
spa_system_close(impl->system, impl->source.fd);
|
||||
impl->source.fd = -1;
|
||||
}
|
||||
free(impl);
|
||||
|
|
@ -432,7 +432,7 @@ static void idle_func(struct spa_source *source)
|
|||
long long rttime;
|
||||
uint64_t count;
|
||||
|
||||
read(impl->source.fd, &count, sizeof(uint64_t));
|
||||
spa_system_eventfd_read(impl->system, impl->source.fd, &count);
|
||||
|
||||
rtprio = 20;
|
||||
rttime = 20000;
|
||||
|
|
@ -478,6 +478,7 @@ int pipewire__module_init(struct pw_module *module, const char *args)
|
|||
struct pw_core *core = pw_module_get_core(module);
|
||||
struct impl *impl;
|
||||
struct spa_loop *loop;
|
||||
struct spa_system *system;
|
||||
const struct spa_support *support;
|
||||
uint32_t n_support;
|
||||
int res;
|
||||
|
|
@ -488,6 +489,10 @@ int pipewire__module_init(struct pw_module *module, const char *args)
|
|||
if (loop == NULL)
|
||||
return -ENOTSUP;
|
||||
|
||||
system = spa_support_find(support, n_support, SPA_TYPE_INTERFACE_DataSystem);
|
||||
if (system == NULL)
|
||||
return -ENOTSUP;
|
||||
|
||||
impl = calloc(1, sizeof(struct impl));
|
||||
if (impl == NULL)
|
||||
return -ENOMEM;
|
||||
|
|
@ -496,11 +501,12 @@ int pipewire__module_init(struct pw_module *module, const char *args)
|
|||
|
||||
impl->core = core;
|
||||
impl->loop = loop;
|
||||
impl->system = system;
|
||||
|
||||
impl->source.loop = loop;
|
||||
impl->source.func = idle_func;
|
||||
impl->source.data = impl;
|
||||
impl->source.fd = eventfd(1, EFD_CLOEXEC | EFD_NONBLOCK);
|
||||
impl->source.fd = spa_system_eventfd_create(system, SPA_FD_CLOEXEC | SPA_FD_NONBLOCK);
|
||||
impl->source.mask = SPA_IO_IN;
|
||||
if (impl->source.fd == -1) {
|
||||
res = -errno;
|
||||
|
|
|
|||
|
|
@ -198,7 +198,6 @@ static int core_hello(void *object, uint32_t version)
|
|||
PW_PERM_RWX, PW_VERSION_CLIENT_PROXY, 1)) < 0)
|
||||
return res;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,6 @@
|
|||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <time.h>
|
||||
#include <sys/eventfd.h>
|
||||
|
||||
#include <spa/support/system.h>
|
||||
#include <spa/pod/parser.h>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue