Why not separate feedInputBuffer() loop and drainOutputBuffer() loop into different threads?
In my opinion, MediaCodec should be more efficient if dequeue/enqueue operations are concurrent. I have searched the MediaCodec document, not sure MediaCodec whether support to operation in multi threads. Hope you give some useful information.
“Threading model” section of the ExoPlayer Javadoc throws light on the design. There was a discussion on threading - #4463 . Quote from this issue by @natez0r
"... The first reason was the thread safety of MediaCodec access on certain older devices (i believe Galaxy S5), we would see native crashes in the media stack if we did not create all of the Android MediaPlayer objects and do any MediaCodec interrogation (checking of codec supports main/high profile, etc...) and also release any android MediaPlayer instances."
Essentially issuing codec operations from different threads may not be safe across all the devices.
@umangsaini thanks! I have test some devices, MediaCodec works fine. I am looking for Galaxy S5 to test.
Marking as a duplicate of #5796.