Add ability to set periodic alarms
Adds alarm_set_periodic so the alarm code can have more contextual information when rescheduling alarms. Problem: A2DP would stream for a few seconds and then stop working. Cause: The Java garbage collector. Bluedroid reaches out to javaland to acquire and release the wake lock. Alarm was always reaching out to get the wake lock when it scheduled a short timeout. If GC kicked in during that call out to make sure we have the wake lock, it could take more than 100ms to get back us. That would screw over the alarm implementation particularly for small 20ms timers. So now if the wake lock was already acquired, we don't try to reacquire it. Cool. But we still have thrashing. Why? Because the alarm code doesn't know the alarm is actually being used in a periodic way. Here's what used to happen: alarm expires alarm is removed reschedule alarm callback is called alarm callback sets the alarm again alarm is added reschedule The problem is the first reschedule will get rid of the wake lock if the next alarm is too far out or doesn't exist, meaning the next reschedule needs to get the wake lock again. With the extra periodicity information we can eliminate the unnecessary intermediate reschedule, meaning no thrashing on the wake lock. yay!
Loading
Please register or sign in to comment