mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04:00
spa: reuse code to clear the timers
We have set_timeout and enable_flush_timer functions to disable the timers so use those.
This commit is contained in:
parent
78b8e1af57
commit
3698593481
7 changed files with 12 additions and 51 deletions
|
|
@ -2623,8 +2623,8 @@ static int do_reassign_follower(struct spa_loop *loop,
|
|||
void *user_data)
|
||||
{
|
||||
struct state *state = user_data;
|
||||
set_timers(state);
|
||||
spa_dll_init(&state->dll);
|
||||
set_timers(state);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -2667,14 +2667,9 @@ static int do_remove_source(struct spa_loop *loop,
|
|||
void *user_data)
|
||||
{
|
||||
struct state *state = user_data;
|
||||
struct itimerspec ts;
|
||||
|
||||
spa_loop_remove_source(state->data_loop, &state->source);
|
||||
ts.it_value.tv_sec = 0;
|
||||
ts.it_value.tv_nsec = 0;
|
||||
ts.it_interval.tv_sec = 0;
|
||||
ts.it_interval.tv_nsec = 0;
|
||||
spa_system_timerfd_settime(state->data_system, state->timerfd, 0, &ts, NULL);
|
||||
set_timeout(state, 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1192,10 +1192,11 @@ static int do_remove_source(struct spa_loop *loop,
|
|||
struct state *state = user_data;
|
||||
|
||||
spa_loop_remove_source(state->data_loop, &state->timer_source);
|
||||
set_timeout(state, 0);
|
||||
|
||||
if (state->ports[0].direction == SPA_DIRECTION_OUTPUT) {
|
||||
if (state->ports[0].direction == SPA_DIRECTION_OUTPUT)
|
||||
spa_loop_remove_source(state->data_loop, &state->sock_source);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1209,7 +1210,6 @@ int spa_avb_pause(struct state *state)
|
|||
spa_loop_invoke(state->data_loop, do_remove_source, 0, NULL, 0, true, state);
|
||||
|
||||
state->started = false;
|
||||
set_timeout(state, 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1172,16 +1172,10 @@ static int do_remove_source(struct spa_loop *loop,
|
|||
void *user_data)
|
||||
{
|
||||
struct impl *this = user_data;
|
||||
struct itimerspec ts;
|
||||
|
||||
if (this->source.loop)
|
||||
spa_loop_remove_source(this->data_loop, &this->source);
|
||||
ts.it_value.tv_sec = 0;
|
||||
ts.it_value.tv_nsec = 0;
|
||||
ts.it_interval.tv_sec = 0;
|
||||
ts.it_interval.tv_nsec = 0;
|
||||
spa_system_timerfd_settime(this->data_system, this->timerfd, 0, &ts, NULL);
|
||||
|
||||
set_timeout(this, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1193,7 +1187,6 @@ static int do_remove_transport_source(struct spa_loop *loop,
|
|||
void *user_data)
|
||||
{
|
||||
struct impl *this = user_data;
|
||||
struct itimerspec ts;
|
||||
|
||||
this->transport_started = false;
|
||||
|
||||
|
|
@ -1202,11 +1195,7 @@ static int do_remove_transport_source(struct spa_loop *loop,
|
|||
|
||||
if (this->flush_timer_source.loop)
|
||||
spa_loop_remove_source(this->data_loop, &this->flush_timer_source);
|
||||
ts.it_value.tv_sec = 0;
|
||||
ts.it_value.tv_nsec = 0;
|
||||
ts.it_interval.tv_sec = 0;
|
||||
ts.it_interval.tv_nsec = 0;
|
||||
spa_system_timerfd_settime(this->data_system, this->flush_timerfd, 0, &ts, NULL);
|
||||
enable_flush_timer(this, false);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -783,17 +783,12 @@ static int do_remove_source(struct spa_loop *loop,
|
|||
void *user_data)
|
||||
{
|
||||
struct impl *this = user_data;
|
||||
struct itimerspec ts;
|
||||
|
||||
spa_log_debug(this->log, "%p: remove source", this);
|
||||
|
||||
if (this->timer_source.loop)
|
||||
spa_loop_remove_source(this->data_loop, &this->timer_source);
|
||||
ts.it_value.tv_sec = 0;
|
||||
ts.it_value.tv_nsec = 0;
|
||||
ts.it_interval.tv_sec = 0;
|
||||
ts.it_interval.tv_nsec = 0;
|
||||
spa_system_timerfd_settime(this->data_system, this->timerfd, 0, &ts, NULL);
|
||||
set_timeout(this, 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1110,17 +1110,10 @@ static int do_remove_source(struct spa_loop *loop,
|
|||
void *user_data)
|
||||
{
|
||||
struct impl *this = user_data;
|
||||
struct itimerspec ts;
|
||||
|
||||
if (this->timer_source.loop)
|
||||
spa_loop_remove_source(this->data_loop, &this->timer_source);
|
||||
|
||||
ts.it_value.tv_sec = 0;
|
||||
ts.it_value.tv_nsec = 0;
|
||||
ts.it_interval.tv_sec = 0;
|
||||
ts.it_interval.tv_nsec = 0;
|
||||
spa_system_timerfd_settime(this->data_system, this->timerfd, 0, &ts, NULL);
|
||||
|
||||
set_timeout(this, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -1224,7 +1217,6 @@ static int do_reassign_follower(struct spa_loop *loop,
|
|||
void *user_data)
|
||||
{
|
||||
struct impl *this = user_data;
|
||||
|
||||
set_timers(this);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -777,9 +777,9 @@ static int do_remove_source(struct spa_loop *loop,
|
|||
{
|
||||
struct impl *this = user_data;
|
||||
|
||||
set_timeout(this, 0);
|
||||
if (this->source.loop)
|
||||
spa_loop_remove_source(this->data_loop, &this->source);
|
||||
set_timeout(this, 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -792,17 +792,12 @@ static int do_remove_transport_source(struct spa_loop *loop,
|
|||
void *user_data)
|
||||
{
|
||||
struct impl *this = user_data;
|
||||
struct itimerspec ts;
|
||||
|
||||
this->transport_started = false;
|
||||
|
||||
if (this->flush_timer_source.loop)
|
||||
spa_loop_remove_source(this->data_loop, &this->flush_timer_source);
|
||||
ts.it_value.tv_sec = 0;
|
||||
ts.it_value.tv_nsec = 0;
|
||||
ts.it_interval.tv_sec = 0;
|
||||
ts.it_interval.tv_nsec = 0;
|
||||
spa_system_timerfd_settime(this->data_system, this->flush_timerfd, 0, &ts, NULL);
|
||||
enable_flush_timer(this, false);
|
||||
|
||||
/* Drop buffered data in the ready queue. Ideally there shouldn't be any. */
|
||||
drop_port_output(this);
|
||||
|
|
|
|||
|
|
@ -761,15 +761,10 @@ static int do_remove_source(struct spa_loop *loop,
|
|||
void *user_data)
|
||||
{
|
||||
struct impl *this = user_data;
|
||||
struct itimerspec ts;
|
||||
|
||||
if (this->timer_source.loop)
|
||||
spa_loop_remove_source(this->data_loop, &this->timer_source);
|
||||
ts.it_value.tv_sec = 0;
|
||||
ts.it_value.tv_nsec = 0;
|
||||
ts.it_interval.tv_sec = 0;
|
||||
ts.it_interval.tv_nsec = 0;
|
||||
spa_system_timerfd_settime(this->data_system, this->timerfd, 0, &ts, NULL);
|
||||
set_timeout(this, 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue