int SamsungSensorBase::enable(int32_t handle, int en)
{
    int err = 0;
    pthread_mutex_lock(&mLock);
//    if (en != mEnabled) {
    //int fd;
    //fd = open(mInputSysfsEnable, O_RDWR);
    //if (fd >= 0) {
    /*
    err = write(fd, en ? "1" : "0", 2);
    close(fd);
    if (err < 0) {
        goto cleanup;
    }
    */
    //mEnabled = en;
    err = handleEnable(en);
    //} else {
    //    err = -1;
    //}
    //  }
cleanup:
    pthread_mutex_unlock(&mLock);
    return err;
}
示例#2
0
// Handles an incoming resource message for this media processing object.
// Returns TRUE if the message was handled, otherwise FALSE.
UtlBoolean MpResource::handleMessage(MpResourceMsg& rMsg)
{
   UtlBoolean msgHandled = FALSE;

   // Do stuff for resource messages.
   msgHandled = TRUE; // assume we'll handle the msg
   switch (rMsg.getMsg())
   {
   case MpResourceMsg::MPRM_RESOURCE_DISABLE:   // disable this resource
      msgHandled = handleDisable();
      break;
   case MpResourceMsg::MPRM_RESOURCE_ENABLE:    // enable this resource
      msgHandled = handleEnable();
      break;
   case MpResourceMsg::MPRM_DISABLE_ALL_NOTIFICATIONS:
      // Disable all notifications sent out from this resource.
      setNotificationsEnabled(FALSE);
      break;
   case MpResourceMsg::MPRM_ENABLE_ALL_NOTIFICATIONS:
      // Enable all notifications sent out from this resource.
      setNotificationsEnabled(TRUE);
      break;
   default:
      msgHandled = FALSE; // we didn't handle the msg after all
      break;
   }

   return msgHandled;
}
示例#3
0
// Handles an incoming message for the flow graph.
// Returns TRUE if the message was handled, otherwise FALSE.
UtlBoolean MpFlowGraphBase::handleMessage(OsMsg& rMsg)
{
   MpFlowGraphMsg* pMsg = (MpFlowGraphMsg*) &rMsg ;
   UtlBoolean retCode;
   MpResource* ptr1;
   MpResource* ptr2;
   int         int1;
   int         int2;

   retCode = FALSE;

   ptr1 = (MpResource*) pMsg->getPtr1();    // get the parameters out of
   ptr2 = (MpResource*) pMsg->getPtr2();    // the message
   int1 = pMsg->getInt1();
   int2 = pMsg->getInt2();

   switch (pMsg->getMsg())
   {
   case MpFlowGraphMsg::FLOWGRAPH_ADD_LINK:
      retCode = handleAddLink(ptr1, int1, ptr2, int2);
      break;
   case MpFlowGraphMsg::FLOWGRAPH_ADD_RESOURCE:
      retCode = handleAddResource(ptr1, int1);
      break;
   case MpFlowGraphMsg::FLOWGRAPH_DESTROY_RESOURCES:
      retCode = handleDestroyResources();
      break;
   case MpFlowGraphMsg::FLOWGRAPH_DISABLE:
      retCode = handleDisable();
      break;
   case MpFlowGraphMsg::FLOWGRAPH_ENABLE:
      retCode = handleEnable();
      break;
   case MpFlowGraphMsg::FLOWGRAPH_REMOVE_LINK:
      retCode = handleRemoveLink(ptr1, int1);
      break;
   case MpFlowGraphMsg::FLOWGRAPH_REMOVE_RESOURCE:
      retCode = handleRemoveResource(ptr1);
      break;
   case MpFlowGraphMsg::FLOWGRAPH_SET_SAMPLES_PER_FRAME:
      retCode = handleSetSamplesPerFrame(int1);
      break;
   case MpFlowGraphMsg::FLOWGRAPH_SET_SAMPLES_PER_SEC:
      retCode = handleSetSamplesPerSec(int1);
      break;
   case MpFlowGraphMsg::FLOWGRAPH_START:
      retCode = handleStart();
      break;
   case MpFlowGraphMsg::FLOWGRAPH_STOP:
      retCode = handleStop();
      break;
   default:
      break;
   }

   return retCode;
}
示例#4
0
// Handles an incoming flowgraph message for this media processing object.
// Returns TRUE if the message was handled, otherwise FALSE.
UtlBoolean MpResource::handleMessage(MpFlowGraphMsg& fgMsg)
{
   UtlBoolean msgHandled = FALSE;

   msgHandled = TRUE; // assume we'll handle the msg
   switch (fgMsg.getMsg())
   {
   case MpFlowGraphMsg::RESOURCE_DISABLE:   // disable this resource
      msgHandled = handleDisable();
      break;
   case MpFlowGraphMsg::RESOURCE_ENABLE:    // enable this resource
      msgHandled = handleEnable();
      break;
   default:
      msgHandled = FALSE; // we didn't handle the msg after all
      break;
   }
   
   return msgHandled;
}