summaryrefslogtreecommitdiff
path: root/src/common/loop.c
diff options
context:
space:
mode:
authorBerke Güzel <wenekar1@gmail.com>2026-10-12 15:23:19 +0300
committerBerke Güzel <wenekar1@gmail.com>2026-10-12 15:23:19 +0300
commit41c25aac6384e6e429a51ace166fffcf219efeca (patch)
treebe57952589cadffdd5b34b2a8cfa17d3462f1d6e /src/common/loop.c
parent4145406fae437dce2f0af6e078e35566634f2c19 (diff)
Unify surface input queue, frame clock, and optimize scaling and timers
Diffstat (limited to 'src/common/loop.c')
-rw-r--r--src/common/loop.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/common/loop.c b/src/common/loop.c
index 18d62b1..1c6a612 100644
--- a/src/common/loop.c
+++ b/src/common/loop.c
@@ -199,11 +199,9 @@ static void timer_cleanup_deleted(struct yasl_loop *l)
if (!l || l->timer_firing_depth > 0) return;
int dest = 0;
for (int src = 0; src < l->timer_count; src++) {
- if (!l->timers[src].deleted) {
- if (dest != src)
- l->timers[dest] = l->timers[src];
- dest++;
- }
+ struct yasl_timer_source t = l->timers[src];
+ l->timers[dest] = t;
+ dest += !t.deleted;
}
l->timer_count = dest;
}
@@ -270,11 +268,16 @@ yasl_timer_id yasl_loop_add_timer(struct yasl_loop *l, uint64_t interval_ns,
bool yasl_loop_del_timer(struct yasl_loop *l, yasl_timer_id id)
{
if (!l || id == 0) return false;
- for (int i = 0; i < l->timer_count; i++) {
+ for (int i = l->timer_count - 1; i >= 0; i--) {
if (l->timers[i].id == id && !l->timers[i].deleted) {
l->timers[i].deleted = true;
if (l->timer_firing_depth == 0) {
- timer_cleanup_deleted(l);
+ if (i == l->timer_count - 1) {
+ while (l->timer_count > 0 && l->timers[l->timer_count - 1].deleted)
+ l->timer_count--;
+ } else {
+ timer_cleanup_deleted(l);
+ }
}
return true;
}