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

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