Search code examples
androidopengl-es-2.0android-mediaplayerandroid-mediacodec

Android SurfaceTexture updateTexImage takes long time?


I am using Android MediaCodec class to play video on a Surface that uses a SurfaceTexture. Now on some of the devices the call to updateTexImage takes a very long time ~20ms on average? Any idea why that could happen? If I use Android MediaPlayer to play on the same surface the same call take very short time (0-1ms on average). Could it be related to the data size that I am passing to codec?


Solution

  • So, I resolved the problem. Don't know why, but when I added a few ms (~12ms) sleep before calling updateTexImage, the call is taking much less time.

    My guess for the problem is that I am missing the vSync and it's waiting for the next vSync to update the texture.