예제 #1
0
// Handle an incoming event message (timer expiration).
// Return TRUE if the message was handled, otherwise FALSE.
UtlBoolean PsButtonTask::handleEventMessage(const OsEventMsg& rMsg)
{
   int           index;
   PsButtonInfo* pButtonInfo;
   PsPhoneTask*  pPhoneTask;
   UtlBoolean     processed;
   OsTimer*      pTimer;
   OsStatus      res;

   OsWriteLock lock(mMutex);        // acquire a write lock

   if (mpButtonInfo == NULL)        // if not yet initialized, just return
      return FALSE;

   processed = TRUE;

   switch(rMsg.getMsgSubType())
   {
   case OsEventMsg::NOTIFY:
      rMsg.getUserData(index);                  // get button index
      rMsg.getEventData((int&) pTimer);         // get timer object
      assert(index > 0 && index <= mMaxBtnIdx);  // check for valid index
      pButtonInfo = &mpButtonInfo[index];        // get ptr to button info

      // In order to send the phone set task a button repeat message, three
      // conditions must be satisfied:
      // 1) The button must currently be down
      // 2) The BUTTON_REPEAT event must be enabled for this button
      // 3) The pointers to the OsTimer object in the mpRepTimers array and
      //    the event message must match (otherwise, we may be processing an
      //    event message for an OsTimer object that has already be released.
      if ((pButtonInfo->getState() == PsButtonInfo::DOWN) &&
          (pButtonInfo->getEventMask() & PsButtonInfo::BUTTON_REPEAT) &&
          (mpRepTimers[index] == pTimer))
      {                             // post msg to the phone set
         pPhoneTask = PsPhoneTask::getPhoneTask();
         res = pPhoneTask->postEvent(PsMsg::BUTTON_REPEAT,  // msg type
                                     this,                  // source
                                     index,                 // button index
                                     pButtonInfo->getId()); // button id
         assert(res == OS_SUCCESS);
      }
      break;
   default:
      processed = FALSE;            // unexpected message subtype
      break;
   }

   return processed;
}
예제 #2
0
// Handle messages directed to this server task.
UtlBoolean MpStreamPlaylistPlayer::handleMessage(OsMsg& rMsg)
{
   switch (rMsg.getMsgType())
   {
      case OsMsg::OS_EVENT:
         OsEventMsg* pMsg = (OsEventMsg*) &rMsg;
         intptr_t status;
         int index;
	 void* indexVoid;

         pMsg->getUserData(indexVoid);
	 index = (int)(intptr_t)indexVoid;
         if (pMsg->getEventData(status) == OS_SUCCESS)
         {
            PlayListEntry* e = (PlayListEntry*)mPlayListDb->at(index) ;
#ifdef MP_STREAM_DEBUG /* [ */
            osPrintf("MpStreamPlaylistPlayer::handleMessage(%p): Received Feeder event: %s \n",
                     this, getFeederEventString(status));

            OsSysLog::add(FAC_MP, PRI_DEBUG,
               "MpStreamPlaylistPlayer::handleMessage(%p): Received Feeder event: %s index=%d e->index=%d",
                  this, getFeederEventString(status), index, e?e->index:-1);
#endif /* MP_STREAM_DEBUG ] */
            switch (status)
            {
               case FeederRealizedEvent:
                  setEntryState(e, PlayerRealized);
                  break;

               case FeederPrefetchedEvent:
                  setEntryState(e, PlayerPrefetched);
                  break;

               case FeederStoppedEvent:
                  if (mAggregateState != PlayerPlaying)
                  {
                     setEntryState(e, PlayerPrefetched);
                  }
                  break;

               case FeederRenderingEvent:
                  break;

               case FeederFailedEvent:
                  setEntryState(e, PlayerFailed);
                  break;

               case FeederStreamPlayingEvent:
                  setEntryState(e, PlayerPlaying);
                  break;

               case FeederStreamPausedEvent:
                  setEntryState(e, PlayerPaused);
                  break;

               case FeederStreamStoppedEvent:
                  setEntryState(e, PlayerStopped);
                  break;

               case FeederStreamDestroyedEvent:
                  setEntryState(e, PlayerDestroyed);
                  break;

               case FeederStreamAbortedEvent:
                  setEntryState(e, PlayerStopped);
                  break;

            }
         }
         break;
   }

   return TRUE;
}
예제 #3
0
// Handles OS server task events/messages
UtlBoolean MpStreamPlayer::handleMessage(OsMsg& rMsg)
{
   switch (rMsg.getMsgType())
   {
      case OsMsg::OS_EVENT:
         OsEventMsg* pMsg = (OsEventMsg*) &rMsg ;
         intptr_t status ;
         if (pMsg->getEventData(status) == OS_SUCCESS)
         {
#ifdef MP_STREAM_DEBUG /* [ */
            osPrintf("MpStreamPlayer(%08X): received event: %s \n",
                  this, getFeederEventString(status)) ;
#endif /* MP_STREAM_DEBUG ] */

            switch (status)
            {
               case FeederRealizedEvent:
                  setState(PlayerRealized) ;
                  break ;
               case FeederPrefetchedEvent:
                  if (getState() != PlayerPlaying)
                     setState(PlayerPrefetched) ;
                  break ;
               case FeederRenderingEvent:
                  break ;
               case FeederStoppedEvent:
                  break ;
               case FeederFailedEvent:
                  setState(PlayerFailed) ;
                  break ;
               case FeederStreamPlayingEvent:
                  setState(PlayerPlaying) ;
                  break ;
               case FeederStreamPausedEvent:
                  setState(PlayerPaused) ;
                  break ;
               case FeederStreamAbortedEvent:
                  if (getState() != PlayerDestroyed)
                     setState(PlayerAborted) ;
                  break;
               case FeederStreamStoppedEvent:
                  //rewind and play again if miLoopCount >1 or -1
                  //flag is on.
                  if ( (miLoopCount > 1 || miLoopCount ==-1) &&
                       (getState() != PlayerAborted) &&
                       ((miLoopCount ==-1)?true:miTimesAlreadyLooped < miLoopCount) )
                  {
                     MpStreamMsg msg(MpStreamMsg::STREAM_REWIND, mTarget, mHandle);
                     status = mpMsgQ->send(msg) ;
                     MpStreamMsg msg2(MpStreamMsg::STREAM_PLAY, mTarget, mHandle);
                     mpMsgQ->send(msg2) ;
                     miTimesAlreadyLooped++;
                  }
                  else
                  {
                     if ((getState() != PlayerAborted) && (getState() != PlayerDestroyed))
                     {
                        setState(PlayerStopped) ;
                     }
                  }
                  break ;

               case FeederStreamDestroyedEvent:
                  setState(PlayerDestroyed) ;
                  break ;
            }
         }
         break ;
   }

   return TRUE ;
}
예제 #4
0
// Handle an incoming event message (timer expiration).
// Return TRUE if the message was handled, otherwise FALSE.
// A write lock should be acquired before calling this method.
UtlBoolean PsHookswTask::handleEventMessage(const OsEventMsg& rMsg)
{
   int          debounceInterval;
   int          hookswState;
   PsPhoneTask* pPhoneTask;
   UtlBoolean    processed;
   OsTimer*     pTimer;
   OsStatus     res;

   processed = TRUE;
   switch(rMsg.getMsgSubType())
   {
   case OsEventMsg::NOTIFY:
      rMsg.getEventData((int&) pTimer); // get timer object
      assert(pTimer == mpTimer);

      hookswState = readHwHookswState();// determine HW hook state
#ifdef HOOKSW_TEMP_HACK
      if (oldStyleHooksw)
      {
         if (hookswState == mHookswState)
         {                                 // no change since last time,
            if (mHookswState == ON_HOOK)   //  enable the hooksw interrupt
               mpHookswDev->enableIntr(TRUE);  //  look for off hook
            else
               mpHookswDev->enableIntr(FALSE); //  look for on hook
         }
         else
         {
            mHookswState = hookswState;    // update the hookswitch state

            // Send a hookswitch message to the phone set with the new state
            pPhoneTask = PsPhoneTask::getPhoneTask();
            res = pPhoneTask->postEvent(PsMsg::HOOKSW_STATE, // msg type
                                        this,            // source
                                        mHookswState,    // hooksw state
                                        0);              // not used
            assert(res == OS_SUCCESS);

            startDebounceTimer();          // rearm the debounce timer
         }
      }
      else
      {
#endif
      mDebounceTicks++;
      switch (mDebounceState)
      {
      case SHORT_DEBOUNCE:
      case LONG_DEBOUNCE:
         debounceInterval = ((mDebounceState == SHORT_DEBOUNCE)
                             ? SHORT_DEBOUNCE_MSECS : LONG_DEBOUNCE_MSECS);
         if (mDebounceHookswState != hookswState)  // is state still bouncing?
         {
            mDebounceHookswState = hookswState;    // stay in the current
            mDebounceTicks = 0;                    // state
         }

         if ((mDebounceTicks * DEBOUNCE_TIMER_MSECS) >= debounceInterval)
         {
            if (mDebounceHookswState != mHookswState)
            {
               mHookswState = hookswState;    // update the hookswitch state

               // Send a hookswitch message to the phone set with the new state
               pPhoneTask = PsPhoneTask::getPhoneTask();
               res = pPhoneTask->postEvent(PsMsg::HOOKSW_STATE, // msg type
                                           this,                // source
                                           mHookswState,        // hooksw state
                                           0);                  // not used
               assert(res == OS_SUCCESS);
               mDebounceState = ((mDebounceState == SHORT_DEBOUNCE)
                                 ? LONG_DEBOUNCE : WAIT_FOR_INTR);
               mDebounceTicks = 0;
            }
            else
            {
               mDebounceState = WAIT_FOR_INTR;// enable the hooksw interrupt
               mDebounceTicks = 0;
            }
         }
         break;
      case WAIT_FOR_INTR:                     // fall through
      default:
         assert(FALSE);
         break;
      }
      if (mDebounceState == WAIT_FOR_INTR)
      {
         if (mHookswState == ON_HOOK)       //  enable the hooksw interrupt
            mpHookswDev->enableIntr(TRUE);  //  look for off hook
         else
            mpHookswDev->enableIntr(FALSE); //  look for on hook
      }
      else
      {
         startDebounceTimer();
      }
#ifdef HOOKSW_TEMP_HACK
      }
#endif
      break;
   default:
      processed = FALSE;                // unexpected message subtype
      break;
   }

   return processed;
}