예제 #1
0
   void testEnabledWithData()
   {
       MprSplitter*      pSplitter  = NULL;
       MpBufPtr          pBuf;
       OsStatus          res;

       pSplitter = new MprSplitter("MprSplitter", 2,
                                   TEST_SAMPLES_PER_FRAME, TEST_SAMPLES_PER_SEC);
       CPPUNIT_ASSERT(pSplitter != NULL);

       setupFramework(pSplitter);

       // pSplitter enabled, there are buffers on the input 0
       CPPUNIT_ASSERT(mpSourceResource->enable());
       CPPUNIT_ASSERT(pSplitter->enable());

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

       // Store input buffer for convenience
       pBuf = mpSourceResource->mLastDoProcessArgs.outBufs[0];

       // Buffer is sent to all outputs
       CPPUNIT_ASSERT(  (mpSinkResource->mLastDoProcessArgs.inBufs[0] == pBuf)
                     && (mpSinkResource->mLastDoProcessArgs.inBufs[1] == pBuf)
                     );

       // Free stored buffer
       pBuf.release();

       // Stop flowgraph
       haltFramework();
   }
예제 #2
0
   void testEnabledWithData()
   {
       MprToSpkr*        pToSpkr    = NULL;
       OsMsgQ*           pSpkQ      = NULL;
       OsMsgQ*           pEchoQ     = NULL;
       MpBufferMsg*      pSpkMsg    = NULL;
       MpBufferMsg*      pEchoMsg   = NULL;
       MpBufPtr          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 buffers on the input 0, message queue
       // is not full.
       CPPUNIT_ASSERT(mpSourceResource->enable());
       CPPUNIT_ASSERT(pToSpkr->enable());

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

       // Get messages from the queues (wait for 1 second)
       res = pSpkQ->receive((OsMsg*&)pSpkMsg, OsTime(1000));
       CPPUNIT_ASSERT(res == OS_SUCCESS);
       res = pEchoQ->receive((OsMsg*&)pEchoMsg, OsTime(1000));
       CPPUNIT_ASSERT(res == OS_SUCCESS);

       // Store output buffer for convenience
       pBuf = mpSourceResource->mLastDoProcessArgs.outBufs[0];

       // Buffer is sent to queues and to output
       CPPUNIT_ASSERT(  (mpSinkResource->mLastDoProcessArgs.inBufs[0] == pBuf)
                     && (pSpkMsg->getBuffer().isValid())
                     && (pEchoMsg->getBuffer() == pBuf)
                     );

       // Free received message and stored buffer
       pSpkMsg->releaseMsg();
       pEchoMsg->releaseMsg();
       pBuf.release();

       // Stop flowgraph
       haltFramework();

       // Free message queue
       delete pSpkQ;
       delete pEchoQ;
   }
예제 #3
0
    void testEnabledWithData()
    {
        MprSplitter* pSplitter = NULL;
        MpBufPtr pBuf;
        OsStatus res;

        size_t i;
        for(i = 0; i < sNumRates; i++)
        {
            printf("Test %d Hz\n", sSampleRates[i]);

            // For this test, we want to modify the sample rate and samples per frame
            // so we need to de-inititialize what has already been initialized for us
            // by cppunit, or by a previous loop.
            tearDown();

            // Set the sample rates
            setSamplesPerSec(sSampleRates[i]);
            setSamplesPerFrame(sSampleRates[i]/100);
            setUp();

            // Set up the splitter and framework
            pSplitter = new MprSplitter("MprMixer", 2);
            CPPUNIT_ASSERT(pSplitter != NULL);
            setupFramework(pSplitter);

            // pSplitter enabled
            CPPUNIT_ASSERT(mpSourceResource->enable());
            CPPUNIT_ASSERT(pSplitter->enable());

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

            // Store input buffer for convenience
            pBuf = mpSourceResource->mLastDoProcessArgs.outBufs[0];
            CPPUNIT_ASSERT(pBuf.isValid());

            // Buffer is sent to all outputs
            CPPUNIT_ASSERT(   (mpSinkResource->mLastDoProcessArgs.inBufs[0] == pBuf)
                              && (mpSinkResource->mLastDoProcessArgs.inBufs[1] == pBuf)
                          );

            // Free stored buffer
            pBuf.release();

            // Stop flowgraph
            haltFramework();

            // No need to delete splitter, as haltFramework deletes all resources
            // in the flowgraph.
        }
    }