예제 #1
0
void GPUHardware::registerCallbackLocked(const sp<IGPUCallback>& callback,
        Client& client)
{
    sp<IBinder> binder = callback->asBinder();
    if (mRegisteredClients.add(binder, client.pid) >= 0) {
        binder->linkToDeath(this);
    }
}
예제 #2
0
파일: main.cpp 프로젝트: Nekotana/silk
/**
 * Activate/deactivate a given sensor
 *
 * @param sensorType - Type of the sensor to activate/deactivate
 * @param activate - 1 to activate and 0 to deactivate the sensor
 * @param rate - sampling rate in microseconds
 */
int SensorsCommand::sensors_activate(int sensorType, int activate, int rate) {
  // Get sensor device handle given the sensor type
  int count;
  for (count = 0; count < mSensorListCount; count++) {
    if (mSensorsList[count].type == sensorType) {
      break;
    }
  }
  LOG_ERROR((count >= mSensorListCount), "No such h/w sensor available %d",
      sensorType);

  int err;
  Value jsonMsg;
  if (activate) {
    // Only activate if not already active
    if (!mActiveSensors.valueFor(mSensorsList[count].handle)) {
      err = mDevice->activate(
          reinterpret_cast<struct sensors_poll_device_t *>(mDevice),
          mSensorsList[count].handle, 1);
      LOG_ERROR((err != 0), "Failed to activate the sensor");

      if (mDevice->common.version >= SENSORS_DEVICE_API_VERSION_1_1) {
        mDevice->batch(mDevice, mSensorsList[count].handle, 0, ms2ns(rate),
            ms2ns(rate));
      } else {
        mDevice->setDelay(
            reinterpret_cast<struct sensors_poll_device_t *>(mDevice),
            mSensorsList[count].handle, ms2ns(rate));
      }
      mActiveSensorCount++;
      mActiveSensors.add(mSensorsList[count].handle, true);
    }
    jsonMsg["eventName"] = "activated";
    mSensorsListener->sendEvent(jsonMsg);
  } else  {
    if (mActiveSensors.valueFor(mSensorsList[count].handle)) {
      mActiveSensorCount--;
      mActiveSensors.removeItem(mSensorsList[count].handle);

      // If no more active sensors then stop polling
      if (mActiveSensorCount <= 0) {
        mSensorsPoll->stop();
        mSensorsPoll = NULL;
      }

      err = mDevice->activate(
          reinterpret_cast<struct sensors_poll_device_t *>(mDevice),
          mSensorsList[count].handle, 0);
      LOG_ERROR((err != 0), "Failed to deactivate the sensor");
    }

    jsonMsg["eventName"] = "deactivated";
    mSensorsListener->sendEvent(jsonMsg);
  }
  return 0;
}
void MCameraClient::dataCallback(int32_t msgType, const sp<IMemory>& data) {
    INFO("%s", __func__);
    int dataSize = data->size();
    INFO("data type = %d, size = %d", msgType, dataSize);
    Mutex::Autolock _l(mLock);
    ssize_t i = mDataCount.indexOfKey(msgType);
    if (i < 0) {
        mDataCount.add(msgType, 1);
        mDataSize.add(msgType, dataSize);
    } else {
        ++mDataCount.editValueAt(i);
        mDataSize.editValueAt(i) = dataSize;
    }
    mCond.signal();

    if (msgType == CAMERA_MSG_VIDEO_FRAME) {
        ASSERT(mReleaser != NULL);
        mReleaser->releaseRecordingFrame(data);
    }
}
void MCameraClient::notifyCallback(int32_t msgType, int32_t ext1, int32_t ext2) {
    INFO("%s", __func__);
    Mutex::Autolock _l(mLock);
    ssize_t i = mNotifyCount.indexOfKey(msgType);
    if (i < 0) {
        mNotifyCount.add(msgType, 1);
    } else {
        ++mNotifyCount.editValueAt(i);
    }
    mCond.signal();
}
예제 #5
0
void LayerScreenshot::setGeometry(const sp<const DisplayDevice>& hw,
        HWComposer::HWCLayerInterface& layer)
{
    LayerBaseClient::setGeometry(hw, layer);

    Mutex::Autolock _l(gLock);

    LayerStatus state;

    const LayerBase::State& s(drawingState());
    const Transform tr(hw->getTransform() * s.transform);
    state.z = s.z;
    state.alpha = s.alpha;
    state.orient = tr.getOrientation();

    gLayerStatus.add(this->getIdentity(), state);

    XLOGI("[%s] add:%d, count:%d", __func__,
        this->getIdentity(), gLayerStatus.size());
}
int RemoteCallbackList::beginBroadcast() {
    Mutex::Autolock _l(_mutex);
	
	DefaultKeyedVector< wp<IBinder>, sp<RemoteCallback> >* pActiveCBs = _activeCBsList.valueFor(pthread_self());
	if(pActiveCBs != NULL) {
        ALOGW("%s called while already in a broadcast\n",__FUNCTION__);
        return -1;
	}

	pActiveCBs = new DefaultKeyedVector< wp<IBinder>, sp<RemoteCallback> >;
	if(pActiveCBs == NULL) {
		ALOGW("[%s]out of memory\n",__FUNCTION__);
		return -2;
	}
	
    int size = _callbacks.size();
    for(int i=0;i<size;i++) {
        pActiveCBs->add(_callbacks.keyAt(i),_callbacks[i]);
    }
	_activeCBsList.add(pthread_self(),pActiveCBs);
    return size;
}
예제 #7
0
__eglMustCastToProperFunctionPointerType eglGetProcAddress(const char *procname)
{
    // eglGetProcAddress() could be the very first function called
    // in which case we must make sure we've initialized ourselves, this
    // happens the first time egl_get_display() is called.

    clearError();

    if (egl_init_drivers() == EGL_FALSE) {
        setError(EGL_BAD_PARAMETER, NULL);
        return  NULL;
    }

    // The EGL_ANDROID_blob_cache extension should not be exposed to
    // applications.  It is used internally by the Android EGL layer.
    if (!strcmp(procname, "eglSetBlobCacheFuncsANDROID")) {
        return NULL;
    }

    __eglMustCastToProperFunctionPointerType addr;
    addr = findProcAddress(procname, sExtentionMap, NELEM(sExtentionMap));
    if (addr) return addr;


    // this protects accesses to sGLExtentionMap and sGLExtentionSlot
    pthread_mutex_lock(&sExtensionMapMutex);

        /*
         * Since eglGetProcAddress() is not associated to anything, it needs
         * to return a function pointer that "works" regardless of what
         * the current context is.
         *
         * For this reason, we return a "forwarder", a small stub that takes
         * care of calling the function associated with the context
         * currently bound.
         *
         * We first look for extensions we've already resolved, if we're seeing
         * this extension for the first time, we go through all our
         * implementations and call eglGetProcAddress() and record the
         * result in the appropriate implementation hooks and return the
         * address of the forwarder corresponding to that hook set.
         *
         */

        const String8 name(procname);
        addr = sGLExtentionMap.valueFor(name);
        const int slot = sGLExtentionSlot;

        LOGE_IF(slot >= MAX_NUMBER_OF_GL_EXTENSIONS,
                "no more slots for eglGetProcAddress(\"%s\")",
                procname);

        if (!addr && (slot < MAX_NUMBER_OF_GL_EXTENSIONS)) {
            bool found = false;
            for (int i=0 ; i<IMPL_NUM_IMPLEMENTATIONS ; i++) {
                egl_connection_t* const cnx = &gEGLImpl[i];
                if (cnx->dso && cnx->egl.eglGetProcAddress) {
                    found = true;
                    // Extensions are independent of the bound context
                    cnx->hooks[GLESv1_INDEX]->ext.extensions[slot] =
                    cnx->hooks[GLESv2_INDEX]->ext.extensions[slot] =
#if EGL_TRACE
                    gHooksDebug.ext.extensions[slot] = gHooksTrace.ext.extensions[slot] =
#endif
                            cnx->egl.eglGetProcAddress(procname);
                }
            }
            if (found) {
                addr = gExtensionForwarders[slot];

                if (!strcmp(procname, "glEGLImageTargetTexture2DOES")) {
                    glEGLImageTargetTexture2DOES_impl = (PFNGLEGLIMAGETARGETTEXTURE2DOESPROC)addr;
                    addr = (__eglMustCastToProperFunctionPointerType)glEGLImageTargetTexture2DOES_wrapper;
                }
                if (!strcmp(procname, "glEGLImageTargetRenderbufferStorageOES")) {
                    glEGLImageTargetRenderbufferStorageOES_impl = (PFNGLEGLIMAGETARGETRENDERBUFFERSTORAGEOESPROC)addr;
                    addr = (__eglMustCastToProperFunctionPointerType)glEGLImageTargetRenderbufferStorageOES_wrapper;
                }

                sGLExtentionMap.add(name, addr);
                sGLExtentionSlot++;
            }
        }

    pthread_mutex_unlock(&sExtensionMapMutex);
    return addr;
}
예제 #8
0
__eglMustCastToProperFunctionPointerType eglGetProcAddress(const char *procname)
{
    // eglGetProcAddress() could be the very first function called
    // in which case we must make sure we've initialized ourselves, this
    // happens the first time egl_get_display() is called.

    clearError();

    if (egl_init_drivers() == EGL_FALSE) {
        setError(EGL_BAD_PARAMETER, NULL);
        return  NULL;
    }

    // These extensions should not be exposed to applications. They're used
    // internally by the Android EGL layer.
    if (!strcmp(procname, "eglSetBlobCacheFuncsANDROID") ||
        !strcmp(procname, "eglDupNativeFenceFDANDROID") ||
        !strcmp(procname, "eglWaitSyncANDROID") ||
        !strcmp(procname, "eglHibernateProcessIMG") ||
        !strcmp(procname, "eglAwakenProcessIMG")) {
        return NULL;
    }

    __eglMustCastToProperFunctionPointerType addr;
    addr = findProcAddress(procname, sExtentionMap, NELEM(sExtentionMap));
    if (addr) return addr;


    // this protects accesses to sGLExtentionMap and sGLExtentionSlot
    pthread_mutex_lock(&sExtensionMapMutex);

        /*
         * Since eglGetProcAddress() is not associated to anything, it needs
         * to return a function pointer that "works" regardless of what
         * the current context is.
         *
         * For this reason, we return a "forwarder", a small stub that takes
         * care of calling the function associated with the context
         * currently bound.
         *
         * We first look for extensions we've already resolved, if we're seeing
         * this extension for the first time, we go through all our
         * implementations and call eglGetProcAddress() and record the
         * result in the appropriate implementation hooks and return the
         * address of the forwarder corresponding to that hook set.
         *
         */

        const String8 name(procname);
        addr = sGLExtentionMap.valueFor(name);
        const int slot = sGLExtentionSlot;

        ALOGE_IF(slot >= MAX_NUMBER_OF_GL_EXTENSIONS,
                "no more slots for eglGetProcAddress(\"%s\")",
                procname);

#if EGL_TRACE
        gl_hooks_t *debugHooks = GLTrace_getGLHooks();
#endif

        if (!addr && (slot < MAX_NUMBER_OF_GL_EXTENSIONS)) {
            bool found = false;

            egl_connection_t* const cnx = &gEGLImpl;
            if (cnx->dso && cnx->egl.eglGetProcAddress) {
                found = true;
                // Extensions are independent of the bound context
                cnx->hooks[egl_connection_t::GLESv1_INDEX]->ext.extensions[slot] =
                cnx->hooks[egl_connection_t::GLESv2_INDEX]->ext.extensions[slot] =
#if EGL_TRACE
                debugHooks->ext.extensions[slot] =
                gHooksTrace.ext.extensions[slot] =
#endif
                        cnx->egl.eglGetProcAddress(procname);
            }

            if (found) {
                addr = gExtensionForwarders[slot];
                sGLExtentionMap.add(name, addr);
                sGLExtentionSlot++;
            }
        }

    pthread_mutex_unlock(&sExtensionMapMutex);
    return addr;
}