sp<PipelineModelBase::HalImageStreamBufferPoolT> PipelineModelBase:: addHalStreamBufferPoolLocked( android::sp<IImageStreamInfo> pStreamInfo ) { if ( pStreamInfo == 0 ) { MY_LOGE("NULL IImageStreamInfo"); return NULL; } // String8 const name = String8::format("%s:%s", getName(), pStreamInfo->getStreamName()); // IImageStreamInfo::BufPlanes_t const& bufPlanes = pStreamInfo->getBufPlanes(); size_t bufStridesInBytes[3] = {0}; size_t bufBoundaryInBytes[3]= {0}; for (size_t i = 0; i < bufPlanes.size(); i++) { bufStridesInBytes[i] = bufPlanes[i].rowStrideInBytes; } IImageBufferAllocator::ImgParam const imgParam( pStreamInfo->getImgFormat(), pStreamInfo->getImgSize(), bufStridesInBytes, bufBoundaryInBytes, bufPlanes.size() ); sp<HalImageStreamBufferPoolT> pPool = new HalImageStreamBufferPoolT( name.string(), HalImageStreamBufferAllocatorT(pStreamInfo.get(), imgParam) ); if ( pPool == 0 ) { MY_LOGE("Fail to new a image pool:%s", name.string()); return NULL; } // MERROR err = pPool->initPool(getName(), pStreamInfo->getMaxBufNum(), pStreamInfo->getMinInitBufNum()); if ( OK != err ) { MY_LOGE("%s: initPool err:%d(%s)", name.string(), err, ::strerror(-err)); return NULL; } if ( OK != pPool->commitPool(getName()) ) { MY_LOGE("%s: commitPool err:%d(%s)", name.string(), err, ::strerror(-err)); return NULL; } // mHalImageStreamBufferPoolMap.add(pStreamInfo->getStreamId(), pPool); return pPool; }
android::sp<android::IBinder> get_service_manager() { static android::sp<android::IBinder> binder; if (binder.get() != NULL) { return binder; } ALOGD("elastos servicemanager try getting...\n"); android::sp<android::IServiceManager> sm = android::defaultServiceManager(); do { binder = sm->getService(android::String16(ELASTOS_SERVICEMGR_NAME)); if (binder != 0) { break; } usleep(500000); } while (true); ALOGD("elastos servicemanager getted.\n"); return binder; }
MERROR PipelineModelBase:: acquireHalStreamBuffer( android::sp<IImageStreamInfo> const pStreamInfo, android::sp<HalImageStreamBuffer>& rpStreamBuffer ) const { RWLock::AutoRLock _l(mRWLock); // StreamId_T const streamId = pStreamInfo->getStreamId(); sp<HalImageStreamBufferPoolT> pPool = mHalImageStreamBufferPoolMap.valueFor(streamId); MY_LOGE_IF(pPool == 0, "NULL HalImageStreamBufferPool - stream:%#"PRIxPTR"(%s)", streamId, pStreamInfo->getStreamName()); MERROR err = pPool == 0 ? UNKNOWN_ERROR : pPool->acquireFromPool(__FUNCTION__, rpStreamBuffer, ::s2ns(10)); MY_LOGA_IF( OK!=err || rpStreamBuffer==0, "[acquireFromPool] err:%d(%s) pStreamBuffer:%p stream:%#"PRIxPTR"(%s)", err, ::strerror(-err), rpStreamBuffer.get(), streamId, pStreamInfo->getStreamName() ); return err; }
virtual void Setup(Compositor* aCompositor, size_t aStep) { mBuf = nullptr; int w = 256; int h = 256; int32_t format = android::PIXEL_FORMAT_RGBA_8888;; mGralloc = new android::GraphicBuffer(w, h, format, android::GraphicBuffer::USAGE_SW_READ_OFTEN | android::GraphicBuffer::USAGE_SW_WRITE_OFTEN | android::GraphicBuffer::USAGE_HW_TEXTURE); mTexture = new mozilla::layers::GrallocTextureSourceOGL((CompositorOGL*)aCompositor, mGralloc.get(), SurfaceFormat::B8G8R8A8); }
MyWifiClient *MyWifiClient::instance() { static android::sp<MyWifiClient> _s_wifiClient = 0; if (!_s_wifiClient.get()) _s_wifiClient = new MyWifiClient; return _s_wifiClient.get(); }