Question

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 ?

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top