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:
Barnabás Pőcze 2026-03-26 14:36:05 +01:00
parent 7599079d61
commit 29b221671f
7 changed files with 53 additions and 81 deletions

View file

@ -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);