diff options
author | William Wilgus <me.theuser@yahoo.com> | 2019-10-09 17:22:48 -0500 |
---|---|---|
committer | William Wilgus <me.theuser@yahoo.com> | 2019-10-17 21:19:00 +0200 |
commit | 1da2708a7c48c144605d84da94d0184209713683 (patch) | |
tree | 976a29826def7be4cc2bd24141064ed2cd6209ce /firmware/timer.c | |
parent | 3d6d90382ea368135544ebae875de99df73986ee (diff) | |
download | rockbox-1da2708a7c48c144605d84da94d0184209713683.tar.gz rockbox-1da2708a7c48c144605d84da94d0184209713683.zip |
Fix timer Agptek Rocker (other hosted players)
on timer_unregister callbacks are not removed
It seems (at least on the Rocker) timers continue to fire (for a bit??)
Now we store the registered callback in the sigev structure and check
that the callback matches the one registered when the timer is created.
This should stop the possible case of a new timer getting spurious callbacks
We also now NULL the callbacks on un-register which should stop the segfaults
Added some notes to timer.c and timer.h
Change-Id: Ia155c3a4e4af89f474d55ed845560ccc1fab85aa
Diffstat (limited to 'firmware/timer.c')
-rw-r--r-- | firmware/timer.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/firmware/timer.c b/firmware/timer.c index a923290a94..c618f72e02 100644 --- a/firmware/timer.c +++ b/firmware/timer.c | |||
@@ -42,6 +42,7 @@ bool timer_register(int reg_prio, void (*unregister_callback)(void), | |||
42 | return false; | 42 | return false; |
43 | 43 | ||
44 | pfn_timer = timer_callback; | 44 | pfn_timer = timer_callback; |
45 | /* NOTE: if unreg cb is defined you are in charge of calling timer_unregister() */ | ||
45 | pfn_unregister = unregister_callback; | 46 | pfn_unregister = unregister_callback; |
46 | timer_prio = reg_prio; | 47 | timer_prio = reg_prio; |
47 | 48 | ||
@@ -53,6 +54,9 @@ bool timer_set_period(long cycles) | |||
53 | return timer_set(cycles, false); | 54 | return timer_set(cycles, false); |
54 | } | 55 | } |
55 | 56 | ||
57 | /* NOTE: unregister callbacks are not called by timer_unregister() | ||
58 | * the unregister_callback only gets called when your timer gets | ||
59 | * overwritten by a lower priority timer using timer_register() */ | ||
56 | void timer_unregister(void) | 60 | void timer_unregister(void) |
57 | { | 61 | { |
58 | timer_stop(); | 62 | timer_stop(); |