omerjerk
omerjerk

Reputation: 4269

timeoutUs in MediaCodec API android

I'm using MediaCodec API in one of my app. I used the code from bigflake and the app is running pretty fine. But I'm still not able to understand the parameter timeoutUs in both the functions dequeueInputBuffer() and the function dequeueOutputBuffer() even after reading about it in the API reference. It would be great if anyone could nicely explain the use and effect of this parameter. And should it be same in both the above function calls ?

Upvotes: 1

Views: 708

Answers (1)

Marlon
Marlon

Reputation: 1473

Well, the main idea is that internally, below the MediaCodec layer components work is asynchronous. So when you call dequeueInputBuffer() or dequeueOutputBuffer() no actuall work is done is the calling thread, just checking the internal component state during selected timeout until response is ready or timeout happens. From my experience even buffer allocation is async, so if no internal buffer is ready for dequeue... small timeout can result in INFO_TRY_AGAIN_LATER. But mainly it is for decoding\encoding. You submit input frame for processing by non-blocking call, processing happens in another thread and you check output frame readiness also with non-blocking call. So all pipline does not sleep for every heavy (decoding\encoding\etc) operation and could perform other operations

Upvotes: 2

Related Questions