1

I am debugging a C++ video renderer that uses eglPresentationTimeANDROID() to improve the lipsynk. This egl extension is not available on all devices I tested, but for some (e.g. adreno), it must be manually disabled - otherwise the stream gets stuck. I understand that some devices actually ignore the PTS (cf. Android Native Window timestamp).

I have recently faced more devices (quite exotic) that fail when this feature is enabled, and I consider disabling it altogether. But to make this decision I want to measure the effect of this PTS before I decide to get rid of it.

Community
  • 1
  • 1
Alex Cohn
  • 56,089
  • 9
  • 113
  • 307

1 Answers1

4

Usually, the only way to see the extension having any effect is to use systrace to monitor the output of something like Grafika's "scheduled swap" Activity (which was created for this purpose). There's no reason for a stream to get stuck, at least in the AOSP sources; I don't know what code might have been added by OEMs.

The logic at render time should be:

  • If the desired presentation time for a frame is in the past, and there's no other frame ready for the current display slot, show it;
  • If the desired presentation time is in the past, and there's another frame ready for the next display slot, drop it;
  • If the desired presentation time is in the near future, hold it for now;
  • If the desired presentation time is more than a second into the future, show it now.

Badly-formed PTS values should pause display for at most a second. Timestamps use the monotonic clock, so aren't subject to clock updates.

It's not necessary to use the feature so long as you can pace submission of video frames perfectly. The point of the extension was to make it easier for apps to manage sync. The goal was to use it in the system video players to improve sync, but I don't know if that actually happened. (I don't see it used in AOSP sources.)

fadden
  • 51,356
  • 5
  • 116
  • 166
  • Thank you so much! We could enable systrace for these native OpenGL calls, following your [explanation](http://stackoverflow.com/questions/28001915/is-logging-android-systrace-events-directly-from-native-code-possible-without-j), but this seems to be not worth it in our scenario. We receive a live video stream, and we use exactly the presentation logic you describe above. So, our decision is not to employ `eglPresentationTimeANDROID()` at all. Your observation that it is not used in system video player is a strong argument to support such move. – Alex Cohn Nov 28 '16 at 21:01
  • It's nice to know that badly formed PTS should not be a reason for the video stream to get stuck. Unfortunately, even correctly formed PTS get some Amazon Fire tablets stuck, and we also found that Nvidia GPU may not work correctly. Who knows what other devices should be blacklisted. – Alex Cohn Nov 28 '16 at 21:05