Loading media/jni/android_media_MediaCodec.cpp +17 −10 Original line number Diff line number Diff line Loading @@ -2886,6 +2886,10 @@ static void extractMemoryFromContext( jint offset, jint size, sp<hardware::HidlMemory> *memory) { if ((offset + size) > context->capacity()) { ALOGW("extractMemoryFromContext: offset + size provided exceed capacity"); return; } *memory = context->toHidlMemory(); if (*memory == nullptr) { if (!context->mBlock) { Loading @@ -2899,17 +2903,20 @@ static void extractMemoryFromContext( ALOGW("extractMemoryFromContext: failed to obtain secure block"); return; } C2WriteView view = context->mBlock->map().get(); if (view.error() != C2_OK) { ALOGW("extractMemoryFromContext: failed to map C2Block (%d)", view.error()); *memory = context->toHidlMemory(); } if (context->mBlock == nullptr || context->mReadWriteMapping == nullptr) { ALOGW("extractMemoryFromContext: Cannot extract memory as C2Block is not created/mapped"); return; } uint8_t *memoryPtr = static_cast<uint8_t *>(context->mMemory->unsecurePointer()); memcpy(memoryPtr + offset, view.base() + offset, size); context->mBlock.reset(); context->mReadWriteMapping.reset(); *memory = context->toHidlMemory(); if (context->mReadWriteMapping->error() != C2_OK) { ALOGW("extractMemoryFromContext: failed to map C2Block (%d)", context->mReadWriteMapping->error()); return; } // We are proceeding to extract memory from C2Block uint8_t *memoryPtr = static_cast<uint8_t *>(context->mMemory->unsecurePointer()); memcpy(memoryPtr + offset, context->mReadWriteMapping->base() + offset, size); } static void extractBufferFromContext( Loading Loading
media/jni/android_media_MediaCodec.cpp +17 −10 Original line number Diff line number Diff line Loading @@ -2886,6 +2886,10 @@ static void extractMemoryFromContext( jint offset, jint size, sp<hardware::HidlMemory> *memory) { if ((offset + size) > context->capacity()) { ALOGW("extractMemoryFromContext: offset + size provided exceed capacity"); return; } *memory = context->toHidlMemory(); if (*memory == nullptr) { if (!context->mBlock) { Loading @@ -2899,17 +2903,20 @@ static void extractMemoryFromContext( ALOGW("extractMemoryFromContext: failed to obtain secure block"); return; } C2WriteView view = context->mBlock->map().get(); if (view.error() != C2_OK) { ALOGW("extractMemoryFromContext: failed to map C2Block (%d)", view.error()); *memory = context->toHidlMemory(); } if (context->mBlock == nullptr || context->mReadWriteMapping == nullptr) { ALOGW("extractMemoryFromContext: Cannot extract memory as C2Block is not created/mapped"); return; } uint8_t *memoryPtr = static_cast<uint8_t *>(context->mMemory->unsecurePointer()); memcpy(memoryPtr + offset, view.base() + offset, size); context->mBlock.reset(); context->mReadWriteMapping.reset(); *memory = context->toHidlMemory(); if (context->mReadWriteMapping->error() != C2_OK) { ALOGW("extractMemoryFromContext: failed to map C2Block (%d)", context->mReadWriteMapping->error()); return; } // We are proceeding to extract memory from C2Block uint8_t *memoryPtr = static_cast<uint8_t *>(context->mMemory->unsecurePointer()); memcpy(memoryPtr + offset, context->mReadWriteMapping->base() + offset, size); } static void extractBufferFromContext( Loading