本文整理汇总了C++中sp::asBinder方法的典型用法代码示例。如果您正苦于以下问题:C++ sp::asBinder方法的具体用法?C++ sp::asBinder怎么用?C++ sp::asBinder使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sp
的用法示例。
在下文中一共展示了sp::asBinder方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: allocateNode
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;
}
示例2: setCamera
status_t setCamera(const sp<ICamera>& camera, const sp<ICameraRecordingProxy>& proxy)
{
LOGV("setCamera(%p,%p)", camera.get(), proxy.get());
Parcel data, reply;
data.writeInterfaceToken(IMediaRecorder::getInterfaceDescriptor());
data.writeStrongBinder(camera->asBinder());
data.writeStrongBinder(proxy->asBinder());
remote()->transact(SET_CAMERA, data, &reply);
return reply.readInt32();
}
示例3: setBufferSource
// pass the buffered SurfaceTexture to the camera service
// TODO(XX): Find a good name for this tap-in/tap-out buffer source
status_t setBufferSource(const sp<ISurfaceTexture>& tapin,
const sp<ISurfaceTexture>& tapout)
{
ALOGV("setBufferSource");
Parcel data, reply;
data.writeInterfaceToken(ICamera::getInterfaceDescriptor());
data.writeStrongBinder(tapin->asBinder());
data.writeStrongBinder(tapout->asBinder());
remote()->transact(SET_BUFFER_SOURCE, data, &reply);
return reply.readInt32();
}
示例4: RegisterObserver
virtual int RegisterObserver(sp<IRTCNode> node) {
Parcel data, reply;
data.writeInterfaceToken(IRTCNode::getInterfaceDescriptor());
#if ANDROID_SDK_VERSION >=23
data.writeStrongBinder(node->asBinder(node.get()));
#else
data.writeStrongBinder(node->asBinder());
#endif
remote()->transact(kIDResigerObs, data, &reply);
return reply.readInt32();
}
示例5: allocateNode
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;
}
示例6: setDataSource
status_t setDataSource(const sp<IStreamSource> &source) {
Parcel data, reply;
data.writeInterfaceToken(IMediaPlayer::getInterfaceDescriptor());
data.writeStrongBinder(source->asBinder());
remote()->transact(SET_DATA_SOURCE_STREAM, data, &reply);
return reply.readInt32();
}
示例7: useBuffer
virtual status_t useBuffer(
node_id node, OMX_U32 port_index, const sp<IMemory> ¶ms,
buffer_id *buffer, size_t size) {
#else
virtual status_t useBuffer(
node_id node, OMX_U32 port_index, const sp<IMemory> ¶ms,
buffer_id *buffer) {
#endif
Parcel data, reply;
data.writeInterfaceToken(IOMX::getInterfaceDescriptor());
data.writeIntPtr((intptr_t)node);
data.writeInt32(port_index);
data.writeStrongBinder(params->asBinder());
#if defined(TARGET_OMAP4)
data.writeInt32(size);
#endif
remote()->transact(USE_BUFFER, data, &reply);
status_t err = reply.readInt32();
if (err != OK) {
*buffer = 0;
return err;
}
*buffer = (void*)reply.readIntPtr();
return err;
}
示例8:
void Process::Stub::SmartProxy::unbindService(const sp<Intent>& intent, const sp<IRemoteCallback>& callback) {
if (mRemote->runsOnSameThread()) {
mStub->unbindService(intent, RemoteCallback::Stub::asInterface(callback->asBinder()));
} else {
mProxy->unbindService(intent, callback);
}
}
示例9: _lock
void ChatSession::Advise(const sp<IChatSessionEvents>& eventSink)
{
int callerPid = GetCallerPID();
_TRACE("ChatSession::Advise >>(%s,pid:%d)",DISPLAY_STRING16(m_wszSessionName),callerPid);
if (eventSink == NULL){
_TRACE("ChatSession::Advise << E_INVALIDARG");
return;
}
String16 userName = eventSink->GetUserName();
if(userName.size()&& !m_bAllowAnonymousAccess){
_TRACE("ChatSession::Advise << E_ACCESSDENIED");
return;
}
sp<IBinder> binder = eventSink->asBinder();
binder->linkToDeath(this);
_TRACE("**ADD(cse:%p binder:%p) ",eventSink.get(),binder.get());
_TRACE("add user %s",DISPLAY_STRING16(userName));
Fire_OnNewUser(userName);
//ChatWorker::getInstance().Defer_OnNewUser(this,userName);
Mutex::Autolock _lock(m_csAdviseLock);
m_Listeners.add(callerPid,binder);
_TRACE("ChatSession::Advise << S_OK");
return;
}
示例10: unregisterWriter
virtual void unregisterWriter(const sp<IMemory>& shared) {
Parcel data, reply;
data.writeInterfaceToken(IMediaLogService::getInterfaceDescriptor());
data.writeStrongBinder(shared->asBinder());
status_t status = remote()->transact(UNREGISTER_WRITER, data, &reply);
// FIXME ignores status
}
示例11: removeClient
void CameraService::removeClient(const sp<ICameraClient>& cameraClient) {
int callingPid = getCallingPid();
LOG1("CameraService::removeClient E (pid %d)", callingPid);
for (int i = 0; i < mNumberOfCameras; i++) {
// Declare this before the lock to make absolutely sure the
// destructor won't be called with the lock held.
sp<Client> client;
Mutex::Autolock lock(mServiceLock);
// This happens when we have already disconnected (or this is
// just another unused camera).
if (mClient[i] == 0) continue;
// Promote mClient. It can fail if we are called from this path:
// Client::~Client() -> disconnect() -> removeClient().
client = mClient[i].promote();
if (client == 0) {
mClient[i].clear();
continue;
}
if (cameraClient->asBinder() == client->getCameraClient()->asBinder()) {
// Found our camera, clear and leave.
LOG1("removeClient: clear camera %d", i);
mClient[i].clear();
break;
}
}
LOG1("CameraService::removeClient X (pid %d)", callingPid);
}
示例12: authenticateSurfaceTexture
virtual bool authenticateSurfaceTexture(
const sp<ISurfaceTexture>& surfaceTexture) const
{
Parcel data, reply;
int err = NO_ERROR;
err = data.writeInterfaceToken(
ISurfaceComposer::getInterfaceDescriptor());
if (err != NO_ERROR) {
LOGE("ISurfaceComposer::authenticateSurfaceTexture: error writing "
"interface descriptor: %s (%d)", strerror(-err), -err);
return false;
}
err = data.writeStrongBinder(surfaceTexture->asBinder());
if (err != NO_ERROR) {
LOGE("ISurfaceComposer::authenticateSurfaceTexture: error writing "
"strong binder to parcel: %s (%d)", strerror(-err), -err);
return false;
}
err = remote()->transact(BnSurfaceComposer::AUTHENTICATE_SURFACE, data,
&reply);
if (err != NO_ERROR) {
LOGE("ISurfaceComposer::authenticateSurfaceTexture: error "
"performing transaction: %s (%d)", strerror(-err), -err);
return false;
}
int32_t result = 0;
err = reply.readInt32(&result);
if (err != NO_ERROR) {
LOGE("ISurfaceComposer::authenticateSurfaceTexture: error "
"retrieving result: %s (%d)", strerror(-err), -err);
return false;
}
return result != 0;
}
示例13: icl
status_t ProCamera2Client::createStream(int width, int height, int format,
const sp<IGraphicBufferProducer>& bufferProducer,
/*out*/
int* streamId)
{
if (streamId) {
*streamId = -1;
}
ATRACE_CALL();
ALOGV("%s (w = %d, h = %d, f = 0x%x)", __FUNCTION__, width, height, format);
status_t res;
if ( (res = checkPid(__FUNCTION__) ) != OK) return res;
Mutex::Autolock icl(mBinderSerializationLock);
if (!mDevice.get()) return DEAD_OBJECT;
sp<IBinder> binder;
sp<ANativeWindow> window;
if (bufferProducer != 0) {
binder = bufferProducer->asBinder();
window = new Surface(bufferProducer);
}
return mDevice->createStream(window, width, height, format, /*size*/1,
streamId);
}
示例14: setPreviewWindow
// set the Surface that the preview will use
status_t CameraService::Client::setPreviewDisplay(const sp<Surface>& surface) {
LOG1("setPreviewDisplay(%p) (pid %d)", surface.get(), getCallingPid());
sp<IBinder> binder(surface != 0 ? surface->asBinder() : 0);
sp<ANativeWindow> window(surface);
return setPreviewWindow(binder, window);
}
示例15: setObserver
virtual status_t setObserver(const sp<IHDCPObserver> &observer) {
Parcel data, reply;
data.writeInterfaceToken(IHDCP::getInterfaceDescriptor());
data.writeStrongBinder(observer->asBinder());
remote()->transact(HDCP_SET_OBSERVER, data, &reply);
return reply.readInt32();
}