Esempio n. 1
0
UtlBoolean MpResource::handleMessages(OsMsgQ& msgQ)
{
   UtlBoolean handledAllMsgs = FALSE;
   while(!msgQ.isEmpty())
   {
      OsMsg* msg;
      OsStatus recvStat = msgQ.receive(msg, OsTime::NO_WAIT_TIME);
      UtlBoolean curMsgHandled = FALSE;
      if (recvStat == OS_SUCCESS)
      {
         if (msg->getMsgType() == OsMsg::MP_FLOWGRAPH_MSG)
         {
            MpFlowGraphMsg* fgMsg = static_cast<MpFlowGraphMsg*>(msg);
            if (fgMsg != NULL)
            {
               curMsgHandled = handleMessage(*fgMsg);
            }
         }
         else if (msg->getMsgType() == OsMsg::MP_RESOURCE_MSG)
         {
            MpResourceMsg* rMsg = static_cast<MpResourceMsg*>(msg);
            if (rMsg != NULL)
            {
               curMsgHandled = handleMessage(*rMsg);
            }
         }

         // TODO: If message received is not handled, it might be good
         //       to stuff the message back into the front of the queue
         //       with msgQ.sendUrgent(msg, OsTime::NO_WAIT_TIME);
         //       I haven't thought through the ramifications of this,
         //       so I haven't implemented it yet.
      }

      // Stop at the first message we encounter that is not handled.
      if (curMsgHandled == FALSE)
      {
         break;
      }

      // If the queue is empty at this point,
      // then all messages have been handled.
      if (msgQ.isEmpty())
      {
         handledAllMsgs = TRUE;
      }
   }
   return handledAllMsgs;
}
Esempio n. 2
0
   void testEnabledNoData()
   {
       MprToSpkr*        pToSpkr    = NULL;
       OsMsgQ*           pSpkQ      = NULL;
       OsMsgQ*           pEchoQ     = NULL;
       MpAudioBufPtr     pBuf;
       OsStatus          res;

       // Create message queues to get data from MprToSpkr
       pSpkQ = new OsMsgQ(MSG_Q_LEN);
       CPPUNIT_ASSERT(pSpkQ != NULL);
       pEchoQ = new OsMsgQ(MSG_Q_LEN);
       CPPUNIT_ASSERT(pEchoQ != NULL);

       pToSpkr = new MprToSpkr("MprToSpkr",
                               pSpkQ, pEchoQ);
       CPPUNIT_ASSERT(pToSpkr != NULL);

       setupFramework(pToSpkr);

       // pToSpkr enabled, there are no buffers on the input 0, message queue
       // is empty.
       CPPUNIT_ASSERT(mpSourceResource->disable());
       CPPUNIT_ASSERT(pToSpkr->enable());

       res = mpFlowGraph->processNextFrame();
       CPPUNIT_ASSERT(res == OS_SUCCESS);

       // No buffers processed
       CPPUNIT_ASSERT(  !mpSourceResource->mLastDoProcessArgs.outBufs[0].isValid()
                     && !mpSinkResource->mLastDoProcessArgs.inBufs[0].isValid()
                     && pSpkQ->isEmpty()
                     && pEchoQ->isEmpty()
                     );

       // Stop flowgraph
       haltFramework();

       // Free message queues
       delete pSpkQ;
       delete pEchoQ;
   }