简体   繁体   中英

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 ?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM