Android: Replace the java based tick timer implemented with a not as bloated and more accurate linux hrtimer based one. Further reduces idle cpu usage (0% on my phone but still 1-2% on a Samsung Galaxy S).

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@28784 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Thomas Martitz 2010-12-10 15:14:18 +00:00
parent 44cdce9b29
commit c47d813451
4 changed files with 66 additions and 130 deletions

View file

@ -1,76 +0,0 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2010 Thomas Martitz
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
****************************************************************************/
package org.rockbox;
import java.util.Timer;
import java.util.TimerTask;
import android.content.Context;
import android.util.Log;
public class RockboxTimer extends Timer
{
private class RockboxTimerTask extends TimerTask {
private RockboxTimer timer;
public RockboxTimerTask(RockboxTimer parent)
{
super();
timer = parent;
}
@Override
public void run()
{
timerTask();
synchronized(timer) {
timer.notify();
}
}
}
public RockboxTimer(Context c, long period_inverval_in_ms)
{
super("tick timer");
schedule(new RockboxTimerTask(this), 0, period_inverval_in_ms);
}
@SuppressWarnings("unused")
private void LOG(CharSequence text)
{
Log.d("Rockbox", (String) text);
}
/* methods called from native, keep them simple */
public void java_wait_for_interrupt()
{
synchronized(this)
{
try {
this.wait();
} catch (InterruptedException e) {
/* Not an error: wakeup and return */
}
}
}
public native void timerTask();
}