status_t OMX::allocateNode( const char *name, const sp<IOMXObserver> &observer, node_id *node) { Mutex::Autolock autoLock(mLock); *node = 0; OMXNodeInstance *instance = new OMXNodeInstance(this, observer); OMX_COMPONENTTYPE *handle; OMX_ERRORTYPE err = mMaster->makeComponentInstance( name, &OMXNodeInstance::kCallbacks, instance, &handle); if (err != OMX_ErrorNone) { ALOGV("FAILED to allocate omx component '%s'", name); instance->onGetHandleFailed(); return UNKNOWN_ERROR; } *node = makeNodeID(instance); mDispatchers.add(*node, new CallbackDispatcher(instance)); instance->setHandle(*node, handle); mLiveNodes.add(observer->asBinder(), instance); observer->asBinder()->linkToDeath(this); return OK; }
status_t OMX::allocateNode( const char *name, const sp<IOMXObserver> &observer, node_id *node) { ALOGV("%s(%d) try mLock", __FUNCTION__, __LINE__); Mutex::Autolock autoLock(mLock); ALOGV("%s(%d) get mLock", __FUNCTION__, __LINE__); *node = 0; OMXNodeInstance *instance = new OMXNodeInstance(this, observer); OMX_COMPONENTTYPE *handle; #if 0//def CC_SUPPORT_MTK_ANDROID_RM /* To unlock mLock is because preemption flow might have allocateNode => callback (need held mlock) It is ok because mLock seems to protect mDispatchers, mLiveNodes, ... check OMX::freeNode for reference */ mLock.unlock(); ALOGV("%s(%d) free mLock", __FUNCTION__, __LINE__); #endif OMX_ERRORTYPE err = mMaster->makeComponentInstance( name, &OMXNodeInstance::kCallbacks, instance, &handle); #if 0//def CC_SUPPORT_MTK_ANDROID_RM mLock.lock(); ALOGV("%s(%d) get mLock", __FUNCTION__, __LINE__); #endif if (err != OMX_ErrorNone) { ALOGV("FAILED to allocate omx component '%s'", name); instance->onGetHandleFailed(); ALOGV("%s(%d) free mLock", __FUNCTION__, __LINE__); return UNKNOWN_ERROR; } *node = makeNodeID(instance); mDispatchers.add(*node, new CallbackDispatcher(instance)); instance->setHandle(*node, handle); mLiveNodes.add(observer->asBinder(), instance); observer->asBinder()->linkToDeath(this); ALOGV("%s(%d) free mLock", __FUNCTION__, __LINE__); return OK; }