+ // updateTexImage will check and spew any prior gl errors,
+ // clear them before we call updateTexImage.
+ glGetError();
+
+ // this is key, after calling releaseOutputBuffer, we must
+ // wait a little for MediaCodec to render to the surface.
+ // Then we can updateTexImage without delay. If we do not
+ // wait, then video playback gets jerky. To optomize this,
+ // we hook the SurfaceTexture OnFrameAvailable callback
+ // using CJNISurfaceTextureOnFrameAvailableListener and wait
+ // on a CEvent to fire. 20ms seems to be a good max fallback.
+ m_frameready->WaitMSec(20);
+