简体   繁体   English

MediaCodec API android中的timeUs

[英]timeoutUs in MediaCodec API android

I'm using MediaCodec API in one of my app. 我在我的一个应用程序中使用MediaCodec API。 I used the code from bigflake and the app is running pretty fine. 我使用了bigflake的代码,该应用程序运行良好。 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. 但是,即使在API参考中对此进行了了解之后,我仍然无法理解函数dequeueInputBuffer()和函数dequeueOutputBuffer()的参数timeoutUs 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. 好吧,主要思想是在内部,在MediaCodec层之下,组件是异步的。 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. 因此,当您调用dequeueInputBuffer()dequeueOutputBuffer() ,调用线程没有完成任何实际工作,只是在选定的超时期间检查内部组件的状态,直到响应准备就绪或发生超时为止。 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. 根据我的经验,即使缓冲区分配也是异步的,因此,如果没有内部缓冲区准备好出队...超时可能会导致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 因此,所有pipline不会在每次繁重的操作(解码\\编码\\等)时都处于休眠状态,并且可以执行其他操作

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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