Android MediaCodec slower in async-mode than in synchronous mode?

前端 未结 1 1114
执念已碎
执念已碎 2021-02-09 12:49

Again, I have a question as regards Android\'s MediaCodec class.

I have successfully managed to decode raw h264 content and display the result in two TextureViews. The

1条回答
  •  谎友^
    谎友^ (楼主)
    2021-02-09 13:11

    I would not be surprised if the blocking call in onInputBufferAvailable is the culprit. It feels probable that both onInputBufferAvailable and onOutputBufferAvailable are called within the same thread, and if you block in one, you stop the other one from running.

    I would suggest changing it so that you in onInputBufferAvailable just push the buffer index onto some queue, and signal a different thread that there's another buffer available now, then having this second thread wait for buffers from the queue, and do a blocking fetch of input data there.

    0 讨论(0)
提交回复
热议问题