mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2026-03-27 07:58:16 -04:00
spa: remove timerspec members
These are only used when the timer is set, so convert them to local variables. No functional changes intended.
This commit is contained in:
parent
7599079d61
commit
29b221671f
7 changed files with 53 additions and 81 deletions
|
|
@ -120,7 +120,6 @@ struct impl {
|
|||
|
||||
bool async;
|
||||
struct spa_source timer_source;
|
||||
struct itimerspec timerspec;
|
||||
|
||||
bool started;
|
||||
uint64_t start_time;
|
||||
|
|
@ -317,21 +316,21 @@ static int impl_node_set_io(void *object, uint32_t id, void *data, size_t size)
|
|||
static void set_timer(struct impl *this, bool enabled)
|
||||
{
|
||||
if (this->async || this->props.live) {
|
||||
struct itimerspec ts = {0};
|
||||
|
||||
if (enabled) {
|
||||
if (this->props.live) {
|
||||
uint64_t next_time = this->start_time + this->elapsed_time;
|
||||
this->timerspec.it_value.tv_sec = next_time / SPA_NSEC_PER_SEC;
|
||||
this->timerspec.it_value.tv_nsec = next_time % SPA_NSEC_PER_SEC;
|
||||
ts.it_value.tv_sec = next_time / SPA_NSEC_PER_SEC;
|
||||
ts.it_value.tv_nsec = next_time % SPA_NSEC_PER_SEC;
|
||||
} else {
|
||||
this->timerspec.it_value.tv_sec = 0;
|
||||
this->timerspec.it_value.tv_nsec = 1;
|
||||
ts.it_value.tv_sec = 0;
|
||||
ts.it_value.tv_nsec = 1;
|
||||
}
|
||||
} else {
|
||||
this->timerspec.it_value.tv_sec = 0;
|
||||
this->timerspec.it_value.tv_nsec = 0;
|
||||
}
|
||||
|
||||
spa_system_timerfd_settime(this->data_system,
|
||||
this->timer_source.fd, SPA_FD_TIMER_ABSTIME, &this->timerspec, NULL);
|
||||
this->timer_source.fd, SPA_FD_TIMER_ABSTIME, &ts, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1105,10 +1104,6 @@ impl_init(const struct spa_handle_factory *factory,
|
|||
CLOCK_MONOTONIC, SPA_FD_CLOEXEC | SPA_FD_NONBLOCK);
|
||||
this->timer_source.mask = SPA_IO_IN;
|
||||
this->timer_source.rmask = 0;
|
||||
this->timerspec.it_value.tv_sec = 0;
|
||||
this->timerspec.it_value.tv_nsec = 0;
|
||||
this->timerspec.it_interval.tv_sec = 0;
|
||||
this->timerspec.it_interval.tv_nsec = 0;
|
||||
|
||||
if (this->data_loop)
|
||||
spa_loop_add_source(this->data_loop, &this->timer_source);
|
||||
|
|
|
|||
|
|
@ -91,7 +91,6 @@ struct impl {
|
|||
struct spa_io_clock *clock;
|
||||
|
||||
struct spa_source timer_source;
|
||||
struct itimerspec timerspec;
|
||||
int clock_fd;
|
||||
|
||||
bool started;
|
||||
|
|
@ -182,13 +181,16 @@ static void set_timeout(struct impl *this, uint64_t next_time)
|
|||
* returning -ECANCELED.)
|
||||
* If timerfd is used with a non-realtime clock, the flag is ignored.
|
||||
* (Note that the flag only works in combination with SPA_FD_TIMER_ABSTIME.) */
|
||||
struct itimerspec ts;
|
||||
|
||||
spa_log_trace(this->log, "set timeout %"PRIu64, next_time);
|
||||
this->timerspec.it_value.tv_sec = next_time / SPA_NSEC_PER_SEC;
|
||||
this->timerspec.it_value.tv_nsec = next_time % SPA_NSEC_PER_SEC;
|
||||
ts.it_value.tv_sec = next_time / SPA_NSEC_PER_SEC;
|
||||
ts.it_value.tv_nsec = next_time % SPA_NSEC_PER_SEC;
|
||||
ts.it_interval.tv_sec = 0;
|
||||
ts.it_interval.tv_nsec = 0;
|
||||
spa_system_timerfd_settime(this->data_system,
|
||||
this->timer_source.fd, SPA_FD_TIMER_ABSTIME |
|
||||
SPA_FD_TIMER_CANCEL_ON_SET, &this->timerspec, NULL);
|
||||
SPA_FD_TIMER_CANCEL_ON_SET, &ts, NULL);
|
||||
}
|
||||
|
||||
static inline uint64_t gettime_nsec(struct impl *this, clockid_t clock_id)
|
||||
|
|
@ -1043,10 +1045,6 @@ impl_init(const struct spa_handle_factory *factory,
|
|||
|
||||
this->timer_source.mask = SPA_IO_IN;
|
||||
this->timer_source.rmask = 0;
|
||||
this->timerspec.it_value.tv_sec = 0;
|
||||
this->timerspec.it_value.tv_nsec = 0;
|
||||
this->timerspec.it_interval.tv_sec = 0;
|
||||
this->timerspec.it_interval.tv_nsec = 0;
|
||||
|
||||
spa_loop_add_source(this->data_loop, &this->timer_source);
|
||||
|
||||
|
|
|
|||
|
|
@ -114,7 +114,6 @@ struct impl {
|
|||
unsigned int started:1;
|
||||
unsigned int following:1;
|
||||
struct spa_source timer_source;
|
||||
struct itimerspec timerspec;
|
||||
uint64_t next_time;
|
||||
};
|
||||
|
||||
|
|
@ -179,11 +178,15 @@ static int impl_node_enum_params(void *object, int seq,
|
|||
|
||||
static void set_timeout(struct impl *this, uint64_t next_time)
|
||||
{
|
||||
struct itimerspec ts;
|
||||
|
||||
spa_log_trace(this->log, "set timeout %"PRIu64, next_time);
|
||||
this->timerspec.it_value.tv_sec = next_time / SPA_NSEC_PER_SEC;
|
||||
this->timerspec.it_value.tv_nsec = next_time % SPA_NSEC_PER_SEC;
|
||||
ts.it_value.tv_sec = next_time / SPA_NSEC_PER_SEC;
|
||||
ts.it_value.tv_nsec = next_time % SPA_NSEC_PER_SEC;
|
||||
ts.it_interval.tv_sec = 0;
|
||||
ts.it_interval.tv_nsec = 0;
|
||||
spa_system_timerfd_settime(this->data_system,
|
||||
this->timer_source.fd, SPA_FD_TIMER_ABSTIME, &this->timerspec, NULL);
|
||||
this->timer_source.fd, SPA_FD_TIMER_ABSTIME, &ts, NULL);
|
||||
}
|
||||
|
||||
static int set_timers(struct impl *this)
|
||||
|
|
@ -929,10 +932,6 @@ impl_init(const struct spa_handle_factory *factory,
|
|||
SPA_FD_CLOEXEC | SPA_FD_NONBLOCK);
|
||||
this->timer_source.mask = SPA_IO_IN;
|
||||
this->timer_source.rmask = 0;
|
||||
this->timerspec.it_value.tv_sec = 0;
|
||||
this->timerspec.it_value.tv_nsec = 0;
|
||||
this->timerspec.it_interval.tv_sec = 0;
|
||||
this->timerspec.it_interval.tv_nsec = 0;
|
||||
|
||||
spa_loop_add_source(this->data_loop, &this->timer_source);
|
||||
|
||||
|
|
|
|||
|
|
@ -74,7 +74,6 @@ struct impl {
|
|||
struct spa_callbacks callbacks;
|
||||
|
||||
struct spa_source timer_source;
|
||||
struct itimerspec timerspec;
|
||||
|
||||
bool started;
|
||||
uint64_t start_time;
|
||||
|
|
@ -180,21 +179,21 @@ static int impl_node_set_param(void *object, uint32_t id, uint32_t flags,
|
|||
static void set_timer(struct impl *this, bool enabled)
|
||||
{
|
||||
if (this->callbacks.funcs || this->props.live) {
|
||||
struct itimerspec ts = {0};
|
||||
|
||||
if (enabled) {
|
||||
if (this->props.live) {
|
||||
uint64_t next_time = this->start_time + this->elapsed_time;
|
||||
this->timerspec.it_value.tv_sec = next_time / SPA_NSEC_PER_SEC;
|
||||
this->timerspec.it_value.tv_nsec = next_time % SPA_NSEC_PER_SEC;
|
||||
ts.it_value.tv_sec = next_time / SPA_NSEC_PER_SEC;
|
||||
ts.it_value.tv_nsec = next_time % SPA_NSEC_PER_SEC;
|
||||
} else {
|
||||
this->timerspec.it_value.tv_sec = 0;
|
||||
this->timerspec.it_value.tv_nsec = 1;
|
||||
ts.it_value.tv_sec = 0;
|
||||
ts.it_value.tv_nsec = 1;
|
||||
}
|
||||
} else {
|
||||
this->timerspec.it_value.tv_sec = 0;
|
||||
this->timerspec.it_value.tv_nsec = 0;
|
||||
}
|
||||
|
||||
spa_system_timerfd_settime(this->data_system,
|
||||
this->timer_source.fd, SPA_FD_TIMER_ABSTIME, &this->timerspec, NULL);
|
||||
this->timer_source.fd, SPA_FD_TIMER_ABSTIME, &ts, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -767,10 +766,6 @@ impl_init(const struct spa_handle_factory *factory,
|
|||
SPA_FD_CLOEXEC | SPA_FD_NONBLOCK);
|
||||
this->timer_source.mask = SPA_IO_IN;
|
||||
this->timer_source.rmask = 0;
|
||||
this->timerspec.it_value.tv_sec = 0;
|
||||
this->timerspec.it_value.tv_nsec = 0;
|
||||
this->timerspec.it_interval.tv_sec = 0;
|
||||
this->timerspec.it_interval.tv_nsec = 0;
|
||||
|
||||
if (this->data_loop)
|
||||
spa_loop_add_source(this->data_loop, &this->timer_source);
|
||||
|
|
|
|||
|
|
@ -75,7 +75,6 @@ struct impl {
|
|||
struct spa_callbacks callbacks;
|
||||
|
||||
struct spa_source timer_source;
|
||||
struct itimerspec timerspec;
|
||||
|
||||
bool started;
|
||||
uint64_t start_time;
|
||||
|
|
@ -195,21 +194,21 @@ static int fill_buffer(struct impl *this, struct buffer *b)
|
|||
static void set_timer(struct impl *this, bool enabled)
|
||||
{
|
||||
if (this->callbacks.funcs || this->props.live) {
|
||||
struct itimerspec ts = {0};
|
||||
|
||||
if (enabled) {
|
||||
if (this->props.live) {
|
||||
uint64_t next_time = this->start_time + this->elapsed_time;
|
||||
this->timerspec.it_value.tv_sec = next_time / SPA_NSEC_PER_SEC;
|
||||
this->timerspec.it_value.tv_nsec = next_time % SPA_NSEC_PER_SEC;
|
||||
ts.it_value.tv_sec = next_time / SPA_NSEC_PER_SEC;
|
||||
ts.it_value.tv_nsec = next_time % SPA_NSEC_PER_SEC;
|
||||
} else {
|
||||
this->timerspec.it_value.tv_sec = 0;
|
||||
this->timerspec.it_value.tv_nsec = 1;
|
||||
ts.it_value.tv_sec = 0;
|
||||
ts.it_value.tv_nsec = 1;
|
||||
}
|
||||
} else {
|
||||
this->timerspec.it_value.tv_sec = 0;
|
||||
this->timerspec.it_value.tv_nsec = 0;
|
||||
}
|
||||
|
||||
spa_system_timerfd_settime(this->data_system,
|
||||
this->timer_source.fd, SPA_FD_TIMER_ABSTIME, &this->timerspec, NULL);
|
||||
this->timer_source.fd, SPA_FD_TIMER_ABSTIME, &ts, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -797,10 +796,6 @@ impl_init(const struct spa_handle_factory *factory,
|
|||
SPA_FD_CLOEXEC | SPA_FD_NONBLOCK);
|
||||
this->timer_source.mask = SPA_IO_IN;
|
||||
this->timer_source.rmask = 0;
|
||||
this->timerspec.it_value.tv_sec = 0;
|
||||
this->timerspec.it_value.tv_nsec = 0;
|
||||
this->timerspec.it_interval.tv_sec = 0;
|
||||
this->timerspec.it_interval.tv_nsec = 0;
|
||||
|
||||
if (this->data_loop)
|
||||
spa_loop_add_source(this->data_loop, &this->timer_source);
|
||||
|
|
|
|||
|
|
@ -99,7 +99,6 @@ struct impl {
|
|||
|
||||
bool async;
|
||||
struct spa_source *timer_source;
|
||||
struct itimerspec timerspec;
|
||||
|
||||
bool started;
|
||||
uint64_t start_time;
|
||||
|
|
@ -264,20 +263,20 @@ static int fill_buffer(struct impl *this, struct buffer *b)
|
|||
static void set_timer(struct impl *this, bool enabled)
|
||||
{
|
||||
if (this->async || this->props.live) {
|
||||
struct timespec ts = {0};
|
||||
|
||||
if (enabled) {
|
||||
if (this->props.live) {
|
||||
uint64_t next_time = this->start_time + this->elapsed_time;
|
||||
this->timerspec.it_value.tv_sec = next_time / SPA_NSEC_PER_SEC;
|
||||
this->timerspec.it_value.tv_nsec = next_time % SPA_NSEC_PER_SEC;
|
||||
ts.tv_sec = next_time / SPA_NSEC_PER_SEC;
|
||||
ts.tv_nsec = next_time % SPA_NSEC_PER_SEC;
|
||||
} else {
|
||||
this->timerspec.it_value.tv_sec = 0;
|
||||
this->timerspec.it_value.tv_nsec = 1;
|
||||
ts.tv_sec = 0;
|
||||
ts.tv_nsec = 1;
|
||||
}
|
||||
} else {
|
||||
this->timerspec.it_value.tv_sec = 0;
|
||||
this->timerspec.it_value.tv_nsec = 0;
|
||||
}
|
||||
spa_loop_utils_update_timer(this->loop_utils, this->timer_source, &this->timerspec.it_value, &this->timerspec.it_interval, true);
|
||||
|
||||
spa_loop_utils_update_timer(this->loop_utils, this->timer_source, &ts, NULL, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -907,10 +906,6 @@ impl_init(const struct spa_handle_factory *factory,
|
|||
reset_props(&this->props);
|
||||
|
||||
this->timer_source = spa_loop_utils_add_timer(this->loop_utils, on_output, this);
|
||||
this->timerspec.it_value.tv_sec = 0;
|
||||
this->timerspec.it_value.tv_nsec = 0;
|
||||
this->timerspec.it_interval.tv_sec = 0;
|
||||
this->timerspec.it_interval.tv_nsec = 0;
|
||||
|
||||
port = &this->port;
|
||||
port->info_all = SPA_PORT_CHANGE_MASK_FLAGS |
|
||||
|
|
|
|||
|
|
@ -102,7 +102,6 @@ struct impl {
|
|||
|
||||
bool async;
|
||||
struct spa_source timer_source;
|
||||
struct itimerspec timerspec;
|
||||
|
||||
bool started;
|
||||
uint64_t start_time;
|
||||
|
|
@ -243,21 +242,21 @@ static int impl_node_set_param(void *object, uint32_t id, uint32_t flags,
|
|||
static void set_timer(struct impl *this, bool enabled)
|
||||
{
|
||||
if (this->async || this->props.live) {
|
||||
struct itimerspec ts = {0};
|
||||
|
||||
if (enabled) {
|
||||
if (this->props.live) {
|
||||
uint64_t next_time = this->start_time + this->elapsed_time;
|
||||
this->timerspec.it_value.tv_sec = next_time / SPA_NSEC_PER_SEC;
|
||||
this->timerspec.it_value.tv_nsec = next_time % SPA_NSEC_PER_SEC;
|
||||
ts.it_value.tv_sec = next_time / SPA_NSEC_PER_SEC;
|
||||
ts.it_value.tv_nsec = next_time % SPA_NSEC_PER_SEC;
|
||||
} else {
|
||||
this->timerspec.it_value.tv_sec = 0;
|
||||
this->timerspec.it_value.tv_nsec = 1;
|
||||
ts.it_value.tv_sec = 0;
|
||||
ts.it_value.tv_nsec = 1;
|
||||
}
|
||||
} else {
|
||||
this->timerspec.it_value.tv_sec = 0;
|
||||
this->timerspec.it_value.tv_nsec = 0;
|
||||
}
|
||||
|
||||
spa_system_timerfd_settime(this->data_system,
|
||||
this->timer_source.fd, SPA_FD_TIMER_ABSTIME, &this->timerspec, NULL);
|
||||
this->timer_source.fd, SPA_FD_TIMER_ABSTIME, &ts, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -993,10 +992,6 @@ impl_init(const struct spa_handle_factory *factory,
|
|||
SPA_FD_CLOEXEC | SPA_FD_NONBLOCK);
|
||||
this->timer_source.mask = SPA_IO_IN;
|
||||
this->timer_source.rmask = 0;
|
||||
this->timerspec.it_value.tv_sec = 0;
|
||||
this->timerspec.it_value.tv_nsec = 0;
|
||||
this->timerspec.it_interval.tv_sec = 0;
|
||||
this->timerspec.it_interval.tv_nsec = 0;
|
||||
|
||||
if (this->data_loop)
|
||||
spa_loop_add_source(this->data_loop, &this->timer_source);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue