Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.arch.embedded > #26626
| From | John Speth <johnspeth@yahoo.com> |
|---|---|
| Newsgroups | comp.arch.embedded |
| Subject | Re: Sync to Android frame rate |
| Date | 2017-05-19 12:51 -0700 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <ofnib9$b5m$1@gioia.aioe.org> (permalink) |
| References | <ofipi2$n4g$1@gioia.aioe.org> <ofkqto$1pv4$1@gioia.aioe.org> |
On 5/18/2017 11:59 AM, John Speth wrote:
>> I'm looking for a way to synchronize some code activity to the Android
>> display frame rate. It's a short bit of code that will simply set the
>> color of a small display region, nothing more. Is there some sort of
>> method or hook that I can exploit for this purpose?
>
> I'll answer my own question, partially that is. It appears one solution
> is to use the Choreographer class which provides a way to hook a
> callback function into the frame rate. Below is the code. It executes
> but the timing is sloppy.
>
> I can time the calls to doFrame() using System.nanoTime(). A little
> testing shows me the timing of calls to doFrame() is not uniform
> (ranging from 12 msec to 20 msec, expecting about 16 msec). The
> callback argument is rock steady (about 16 msec) which makes me think
> it's a value that is computed at initialization time.
>
> It's a solution but it's not doing what I wanted because the callback is
> not timing precisely enough. Still seeking advice, thank you.
>
> JJS
>
> ///////////////////////////////////////////////////////////////
>
> private FrameCallback frameCallback = null;
> private boolean frameCallbackPending = false;
>
> public void armVSyncHandler() {
> if(!frameCallbackPending) {
> frameCallbackPending = true;
> if(frameCallback == null)
> {
> frameCallback = new FrameCallback() {
> @Override
> public void doFrame(long frameTimeNanos) {
> frameCallbackPending = false;
>
> // Do some work here
>
> armVSyncHandler();
> }
> };
> }
> Choreographer.getInstance().postFrameCallback(frameCallback);
> }
> }
Update: I ran this code on a newer and probably faster phone (Samsung
Galaxy Grand Prime). It seems to work like I wanted (no aliasing). I
conclude the original phone (ZTE X752C) was way short of compute capacity.
JJS
Back to comp.arch.embedded | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Sync to Android frame rate John Speth <johnspeth@yahoo.com> - 2017-05-17 17:23 -0700
Re: Sync to Android frame rate John Speth <johnspeth@yahoo.com> - 2017-05-18 11:59 -0700
Re: Sync to Android frame rate rickman <gnuarm@gmail.com> - 2017-05-18 21:53 -0400
Re: Sync to Android frame rate Theo Markettos <theom+news@chiark.greenend.org.uk> - 2017-05-19 18:28 +0100
Re: Sync to Android frame rate rickman <gnuarm@gmail.com> - 2017-05-19 13:47 -0400
Re: Sync to Android frame rate John Speth <johnspeth@yahoo.com> - 2017-05-19 12:47 -0700
Re: Sync to Android frame rate John Speth <johnspeth@yahoo.com> - 2017-05-19 12:51 -0700
Re: Sync to Android frame rate Theo Markettos <theom+news@chiark.greenend.org.uk> - 2017-05-22 11:00 +0100
Re: Sync to Android frame rate John Speth <johnspeth@yahoo.com> - 2017-05-22 09:24 -0700
Re: Sync to Android frame rate Theo Markettos <theom+news@chiark.greenend.org.uk> - 2017-05-22 22:30 +0100
csiph-web