void OmxDecTestBase::StartTestApp() { if (!IsAdded()) { AddToScheduler(); } RunIfNotReady(); OsclExecScheduler* sched = OsclExecScheduler::Current(); if (sched) { sched->StartScheduler(); } }
int MetadataDriver::retrieverThread() { LOGV("retrieverThread"); if (!InitializeForThread()) { LOGV("InitializeForThread fail"); mSyncSem->Signal(); return -1; } OMX_MasterInit(); OsclScheduler::Init("PVAuthorEngineWrapper"); mState = STATE_CREATE; AddToScheduler(); RunIfNotReady(); OsclExecScheduler *sched = OsclExecScheduler::Current(); sched->StartScheduler(); mSyncSem->Signal(); // Signal that doSetDataSource() is done. OsclScheduler::Cleanup(); OMX_MasterDeinit(); UninitializeForThread(); return 0; }
void PVMediaInputAuthorEngineTest::test() { iTotalSuccess = 0; iTotalFail = 0; iTotalError = 0; PVAECmdType resetState = PVAE_CMD_OPEN; while ((iNextTestCase <= iLastTest) || (iNextTestCase < Invalid_Test)) { if (iCurrentTest) { delete iCurrentTest; iCurrentTest = NULL; // Shutdown PVLogger and scheduler before checking mem stats CleanupLoggerScheduler(); #if !(OSCL_BYPASS_MEMMGT) // Print out the memory usage results for this test case OsclAuditCB auditCB; OsclMemInit(auditCB); if (auditCB.pAudit) { MM_Stats_t* stats = auditCB.pAudit->MM_GetStats(""); if (stats) { uint32 alloclks = stats->numAllocs - iNumAllocs; fprintf(iFile, " Mem stats: TotalAllocs(%d), TotalBytes(%d),\n AllocFailures(%d), AllocLeak(%d)\n", stats->totalNumAllocs - iTotalAlloc, stats->totalNumBytes - iTotalBytes, stats->numAllocFails - iAllocFails, stats->numAllocs - iNumAllocs); } else { fprintf(iFile, "Retrieving memory statistics after running test case failed! Memory statistics result is not available.\n"); } } else { fprintf(iFile, "Memory audit not available! Memory statistics result is not available.\n"); } #endif } //iCurrentTest #if !(OSCL_BYPASS_MEMMGT) // Obtain the current mem stats before running the test case OsclAuditCB auditCB; OsclMemInit(auditCB); if (auditCB.pAudit) { MM_Stats_t* stats = auditCB.pAudit->MM_GetStats(""); if (stats) { iTotalAlloc = stats->totalNumAllocs; iTotalBytes = stats->totalNumBytes; iAllocFails = stats->numAllocFails; iNumAllocs = stats->numAllocs; } else { fprintf(iFile, "Retrieving memory statistics before running test case failed! Memory statistics result would be invalid.\n"); } } else { fprintf(iFile, "Memory audit not available! Memory statistics result would be invalid.\n"); } #endif //stop at last test if (iNextTestCase > iLastTest) { iNextTestCase = Invalid_Test; } else { fprintf(iFile, "\nStarting Test %d: ", iNextTestCase); InitLoggerScheduler(); } PVAuthorAsyncTestParam testparam; testparam.iObserver = this; testparam.iTestCase = this; testparam.iTestCaseNum = iNextTestCase; testparam.iStdOut = iFile; switch (iNextTestCase) { case PVMediaInput_Open_Compose_Stop_Test: { fprintf(iFile, "Open Compose Stop test with AVI/WAV MIO Comp:\n"); iCurrentTest = new pv_mediainput_async_test_opencomposestop(testparam, iMediaInputParam, false); // Go to next test ++iNextTestCase; } break; case PVMediaInput_Open_RealTimeCompose_Stop_Test: { fprintf(iFile, "Open Real Time Compose Stop test with AVI/WAV MIO Comp:\n"); iMediaInputParam.iRealTimeAuthoring = true; iCurrentTest = new pv_mediainput_async_test_opencomposestop(testparam, iMediaInputParam, false); // Go to next test ++iNextTestCase; } break; case PVMediaInput_Pause_Resume_Test: { fprintf(iFile, "Pause Resume test with AVI/WAV MIO Comp:\n"); iCurrentTest = new pv_mediainput_async_test_opencomposestop(testparam, iMediaInputParam, true); // Go to next test ++iNextTestCase; } break; case PVMediaInput_ErrorHandling_Test_WrongFormat: { fprintf(iFile, "Error Handling Wrong Format test with AVI/WAV MIO Comp\n"); iMediaInputParam.iIPFileInfo = FILE_NAME_ERROR_HANDLING; iMediaInputParam.iInputFormat = DEFAULTSOURCEFORMATTYPE; iCurrentTest = new pv_mediainput_async_test_errorhandling(testparam, iMediaInputParam, false, true); // Go to next test ++iNextTestCase; } break; case PVMediaInput_ErrorHandling_Test_WrongIPFileName: { fprintf(iFile, "Error Handling wrong IP File test with AVI/WAV MIO Comp\n"); iMediaInputParam.iIPFileInfo = WRONGIPFILENAME_ERRORHANDLING; iMediaInputParam.iInputFormat = DEFAULTSOURCEFORMATTYPE; iCurrentTest = new pv_mediainput_async_test_errorhandling(testparam, iMediaInputParam, false, false); // Go to next test ++iNextTestCase; } break; case PVMediaInput_Reset_Test: { fprintf(iFile, "Reset test with AVI/WAV MIO Comp\n"); switch (resetState) { case PVAE_CMD_OPEN: { fprintf(iFile, "Current reset state: PVAE_CMD_OPEN\n"); } break; case PVAE_CMD_ADD_DATA_SOURCE: { fprintf(iFile, "Current reset state: PVAE_CMD_ADD_DATA_SOURCE\n"); } break; case PVAE_CMD_SELECT_COMPOSER: { fprintf(iFile, "Current reset state: PVAE_CMD_SELECT_COMPOSER\n"); } break; case PVAE_CMD_ADD_MEDIA_TRACK: { fprintf(iFile, "Current reset state: PVAE_CMD_ADD_MEDIA_TRACK\n"); } break; case PVAE_CMD_INIT: { fprintf(iFile, "Current reset state: PVAE_CMD_INIT\n"); } break; case PVAE_CMD_START: { fprintf(iFile, "Current reset state: PVAE_CMD_START\n"); } break; case PVAE_CMD_PAUSE: { fprintf(iFile, "Current reset state: PVAE_CMD_PAUSE\n"); } break; case PVAE_CMD_RECORDING: { fprintf(iFile, "Current reset state: PVAE_CMD_RECORDING\n"); } break; default: break; } iCurrentTest = new pv_mediainput_async_test_reset(testparam, iMediaInputParam, false, resetState); resetState = ((pv_mediainput_async_test_reset*)iCurrentTest)->GetNextResetState(); //run reset test for all states. if (PVAE_CMD_STOP == resetState) { // Go to next test ++iNextTestCase; } } break; case AVI_Input_Longetivity_Test: { fprintf(iFile, "AVI Input Longetivity test:\n"); iCurrentTest = new pv_mediainput_async_test_opencomposestop(testparam, iMediaInputParam, false); // Go to next test ++iNextTestCase; } break; default: { iCurrentTest = NULL; break; } } if (iCurrentTest) { // Setup Scheduler OsclExecScheduler *sched = OsclExecScheduler::Current(); if (sched) { iCurrentTest->StartTest(); #if USE_NATIVE_SCHEDULER // Have PV scheduler use the scheduler native to the system sched->StartNativeScheduler(); #else int32 err; OSCL_TRY(err, sched->StartScheduler();); #endif } else { fprintf(iFile, "ERROR! Scheduler is not available. Test case could not run."); iNextTestCase++; } }
int PlayerDriver::playerThread() { int error; LOGV("InitializeForThread"); if(!InitializeForThread()) { LOGV("InitializeForThread fail"); mPlayer = NULL; mSyncSem->Signal(); return -1; } LOGV("OMX_Init"); PV_MasterOMX_Init(); LOGV("OsclScheduler::Init"); OsclScheduler::Init("AndroidPVWrapper"); LOGV("CreatePlayer"); OSCL_TRY(error, mPlayer = PVPlayerFactory::CreatePlayer(this, this, this)); if (error) { // Just crash the first time someone tries to use it for now? mPlayer = NULL; mSyncSem->Signal(); return -1; } LOGV("AddToScheduler"); AddToScheduler(); LOGV("PendForExec"); PendForExec(); LOGV("OsclActiveScheduler::Current"); OsclExecScheduler *sched = OsclExecScheduler::Current(); LOGV("StartScheduler"); sched->StartScheduler(mSyncSem); LOGV("DeletePlayer"); PVPlayerFactory::DeletePlayer(mPlayer); delete mDownloadContextData; mDownloadContextData = NULL; delete mDataSource; mDataSource = NULL; delete mAudioSink; PVMediaOutputNodeFactory::DeleteMediaOutputNode(mAudioNode); delete mAudioOutputMIO; delete mVideoSink; if (mVideoNode) { PVMediaOutputNodeFactory::DeleteMediaOutputNode(mVideoNode); delete mVideoOutputMIO; } mSyncStatus = OK; mSyncSem->Signal(); // note that we only signal mSyncSem. Deleting it is handled // in enqueueCommand(). This is done because waiting for an // already-deleted OsclSemaphore doesn't work (it blocks), // and it's entirely possible for this thread to exit before // enqueueCommand() gets around to waiting for the semaphore. // do some of destructor's work here // goodbye cruel world delete this; //Moved after the delete this, as Oscl cleanup should be done in the end. //delete this was cleaning up OsclSemaphore objects, eventually causing a crash OsclScheduler::Cleanup(); LOGV("OsclScheduler::Cleanup"); PV_MasterOMX_Deinit(); UninitializeForThread(); return 0; }