采用显示和解码共享内存机制,相比较与旧的机制有速度快、IO吞吐量低的特点。
在主线程中:
FFMPlayer::prepareVideo()
–>initRender(mColorFormat, 0,HW);
—–>checkReAllocateBuffers(decoderType, isInfoChange);
———->mNativeWindowBufferAlloctor->initparm()//初始化sp FFMPlayerBase::mNativeWindow;
//NativeWindowBufferAlloctor* FFMPlayerBase::mNativeWindowBufferAlloctor;
void NativeWindowBufferAlloctor::initparm(sp<ANativeWindow> nativeWindow, int w, int h, int dw, int dh)
{
//设置所需要分配内存的基本参数,参数包括NativeWindow指针、虚宽、虚高、实宽、实高。
mNativeWindow = nativeWindow;
mVideoWidth = w;
mVideoHeight = h;
if (dw==0 || dh==0) {
mDisplayWidth = w;
mDisplayHeight = h;
} else {
mDisplayWidth = dw;
mDisplayHeight = dh;
}
}
FFMPlayer::doStart()
–>allocDecoderBuffer(mNewAllocMode);//FFMPlayerBase::allocDecoderBuffer(bool aync)
—–>mNativeWindowBufferAlloctor->allo