Android SurfaceTexture updateTexImage 需要很长时间?

Android SurfaceTexture updateTexImage takes long time?

我正在使用 Android MediaCodec class 在使用 SurfaceTexture 的 Surface 上播放视频。现在在某些设备上,对 updateTexImage 的调用平均需要很长时间 ~20ms?知道为什么会发生这种情况吗?如果我使用 Android MediaPlayer 在同一个表面上播放同一个调用需要很短的时间(平均 0-1 毫秒)。这可能与我传递给编解码器的数据大小有关吗?

所以,我解决了这个问题。不知道为什么,但是当我在调用 updateTexImage 之前添加几毫秒(~12 毫秒)睡眠时,调用花费的时间少得多。

我对问题的猜测是我缺少 vSync,它正在等待下一个 vSync 更新纹理。