MediaCodec Async Callback is not occurring if other thread has blocking wait

北城余情 提交于 2020-01-06 08:57:29

问题


I am using MediaCodec OnAsyncInputAvailable and OnAsyncOutputAvailable callbacks introduced in API 28.

void OnAsyncInputAvailable(
    AMediaCodec *codec,
    void *userdata,
    int32_t index)
{
    CallbackData* callbackData = (CallbackData *) (userdata);
    callbackData->addInputBufferId(index);
}

void OnAsyncOutputAvailable(
    AMediaCodec *codec,
    void *userdata,
    int32_t index,
    AMediaCodecBufferInfo *bufferInfo)
{
    CallbackData* callbackData = (CallbackData *) (userdata);
    callbackData->addOutputBuffer(index, bufferInfo);
}

In my application i have created a queue, in which indexes of available buffers are entered when callback is triggered on native thread. If other thread which Pop from this queue do a blocking wait, then i can see that call from NDK is not coming. One thread is waiting to Pop the element , as queue is empty (it is doing conditional wait ), on the other end Native thread is waiting for the callback to trigger. So application goes in hang state. Is this known issue with native API's? Or am i missing any thing to handle?

来源:https://stackoverflow.com/questions/55302242/mediacodec-async-callback-is-not-occurring-if-other-thread-has-blocking-wait

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!