问题
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