Exemple #1
0
void CThreadWatcher::DoCancel()
{
	RThread thread;
	if(thread.Open(iName) == KErrNone) {
		thread.LogonCancel(iStatus);
		thread.Close();
	}
}
/**
   Requests de-initialization of the OpenMAX IL core. It closes the session to
   the IL Core server.

   @return OMX_ERRORTYPE
 */
OMX_ERRORTYPE ROmxILCoreClientSession::DeinitAndClose()
{
    DEBUG_PRINTF(_L8("ROmxILCoreClientSession::DeinitAndClose"));
#ifdef SYMBIAN_PERF_TRACE_OMX_IL
    OstPrintf(TTraceContext(KTracePerformanceTraceUID, EPerFormanceTraceClassification), Ost_OMXIL_Performance::K_OMX_PerformanceTraceFormatMin,
              Ost_OMXIL_Performance::EMeasurementStart, MAKESTRING(E_DeInit));
#endif

#ifdef SYMBIAN_PERF_TRACE_OMX_IL_OSTV1
    OstTrace0( TRACE_API, _DeinitAndClose1, "OMX_Deinit >" );
#endif

    // Param 0
    OMX_ERRORTYPE err = OMX_ErrorNone;
    TPckgBuf<OMX_ERRORTYPE> pckg0;

    // Param 1
    TUint64 serverThreadId = 0;
    TPckgBuf<TUint64> pckg1;

    TIpcArgs arg(&pckg0, &pckg1);
    SendReceive(EOmxILCoreDeinit, arg);

    // Extract the output values returned from the server.
    err = pckg0();
    serverThreadId = pckg1();

    RHandleBase::Close();

    // Release server handle so it will exit cleanly.
    XGlobalILCoreCache* pGlobalILCoreCache = XGlobalILCoreCache::IlCoreCache();

    __ASSERT_ALWAYS(pGlobalILCoreCache != NULL,
                    User::Panic(KOmxILCoreClientPanic, KErrNotReady));

    pGlobalILCoreCache->SetServerHandle(KNullHandle);

    RThread serverThread;
    TInt ret = serverThread.Open(TThreadId(serverThreadId));

    if ((KErrNone == ret) && (serverThread.Handle() != KNullHandle))
    {
        DEBUG_PRINTF2(_L8("ROmxILCoreClientSession::DeinitAndClose : serverThread.Handle =[%d]"), serverThread.Handle());
        TBool logoffFailed = EFalse;
        TRequestStatus logoffStatus;
        serverThread.Logon(logoffStatus);

        if (logoffStatus == KErrNoMemory)
        {
            logoffFailed = ETrue;
        }

        if (!logoffFailed)
        {
            if (logoffStatus == KRequestPending)
            {
                User::WaitForRequest(logoffStatus);
            }
            else
            {
                serverThread.LogonCancel(logoffStatus);
                User::WaitForRequest(logoffStatus);
            }
        }
        else
        {
            serverThread.Kill(KErrDied);
        }
    }

    serverThread.Close();

#if defined(SYMBIAN_PERF_TRACE_OMX_IL) || defined(SYMBIAN_PERF_TRACE_OMX_IL_OSTV1)
    OMX_ERRORTYPE omxError = OMX_ErrorNone;
    if(KErrNone != err)
    {
        omxError = OMX_ErrorUndefined;
    }
#endif
#ifdef SYMBIAN_PERF_TRACE_OMX_IL
    TBuf8<1> DeInitStr;
    OstPrintf(TTraceContext(KTracePerformanceTraceUID, EPerFormanceTraceClassification), Ost_OMXIL_Performance::K_OMX_PerformanceTraceFormat,
              Ost_OMXIL_Performance::EMeasurementEnd, MAKESTRING(E_DeInit), omxError,&DeInitStr);
#endif

#ifdef SYMBIAN_PERF_TRACE_OMX_IL_OSTV1
    OstTrace1( TRACE_API, _DeinitAndClose2, "OMX_Deinit < ReturnVal=%u", omxError );
#endif

    return err;

}
TVerdict CTestDevVideoPlayClock::DoTestStepL()
	{
	TVerdict ret = EPass;
	TTimeIntervalMicroSeconds testTime(0);
	TUint timeUint = 0;

	iClockSource = CSystemClockSource::NewL();

	// Construct a new thread to constantly probe the clock - to test that it'll work from multiple threads
	RThread thread;
	
	TInt error = thread.Create(_L("ClockSourceTestThread"), 
								&CTestDevVideoPlayClock::StartThread,
								KDefaultStackSize, 
								&User::Heap(),
								static_cast<TAny*>(this), 
								EOwnerThread);

	if (error)
		{
		ERR_PRINTF1(_L("Error - Couldn't create periodic utility object"));
		delete iClockSource;
		return EInconclusive;
		}

	TRequestStatus stat;
	thread.Logon(stat);
	if (stat!=KRequestPending)
		{
		delete iClockSource;
		ERR_PRINTF2(_L("Error - Couldn't logon to the thread err=%d"), stat.Int());
		thread.LogonCancel(stat);
		User::WaitForRequest(stat);
		return EInconclusive;
		}
	thread.SetPriority(EPriorityLess);

	// wait for system to calm down
	User::After(KTestClock2Seconds);

	// reset the clock
	iClockSource->Reset();

	thread.Resume();

	// wait for 2 seconds and then check the time == 2 seconds
	User::After(KTestClock2Seconds);
	testTime = iClockSource->Time();
	timeUint = I64LOW(testTime.Int64());

	if (!TimeComparison(timeUint, KTestClock2Seconds, KTestClockDeviationMS))
		{
		ERR_PRINTF3(_L("Error - time comparison failed:  Got %u;  Expected %u"), timeUint, KTestClock2Seconds);
		ret = EFail;
		}
	else 
		{
		INFO_PRINTF3(_L("Time comparison passed:  Got %u;  Expected %u"), timeUint, KTestClock2Seconds);
		}

	// reset the clock back to 2 seconds
	//testTime = KTestClock2Seconds;
	//iClockSource->Reset(testTime);

	// suspend timer for 2 seconds then resume for 2 seconds
	iClockSource->Suspend();
	User::After(KTestClock2Seconds);
	iClockSource->Resume();
	User::After(KTestClock2Seconds);
	testTime = iClockSource->Time();
	timeUint = I64LOW(testTime.Int64());

	if (!TimeComparison(timeUint, KTestClock4Seconds, KTestClockDeviationMS))
		{
		ERR_PRINTF3(_L("Error - Suspend() + Resume() time comparison failed:  Got %u;  Expected %u"), timeUint, KTestClock4Seconds);
		ret = EFail;
		}
	else
		{
		INFO_PRINTF3(_L("Suspend() + Resume() time comparison passed:  Got %u;  Expected %u"), timeUint, KTestClock4Seconds);
		}

	// reset clock to 18 seconds
	testTime = KTestClock18Seconds;
	iClockSource->Reset(testTime);

	// wait for 2 seconds and then check the time == 20 seconds
	User::After(KTestClock2Seconds);
	testTime = iClockSource->Time();
	timeUint = I64LOW(testTime.Int64());

	if (!TimeComparison(timeUint, KTestClock20Seconds, KTestClockDeviationMS))
		{
		ERR_PRINTF3(_L("Error - Reset() time comparison failed:  Got %u;  Expected %u"), timeUint, KTestClock20Seconds);
		ret = EFail;
		}
	else
		{
		INFO_PRINTF3(_L("Reset() time comparison passed:  Got %u;  Expected %u"), timeUint, KTestClock20Seconds);
		}

	// suspend for 2 seconds then resume for 2 seconds
	iClockSource->Suspend();
	User::After(KTestClock2Seconds);
	iClockSource->Resume();
	User::After(KTestClock2Seconds);
	
	testTime = iClockSource->Time();
	timeUint = I64LOW(testTime.Int64());

	if (!TimeComparison(timeUint, KTestClock22Seconds, KTestClockDeviationMS))
		{
		ERR_PRINTF3(_L("Error - Suspend() + Resume() time comparison failed:  Got %u;  Expected %u"), timeUint, KTestClock22Seconds);
		ret = EFail;
		}
	else
		{
		INFO_PRINTF3(_L("Suspend() + Resume() time comparison passed:  Got %u;  Expected %u"), timeUint, KTestClock22Seconds);
		}

	// Now test the periodic utility
	TRAPD(perError, iPeriodicUtility = CMMFClockSourcePeriodicUtility::NewL(*iClockSource, *this));
	if (perError)
		{
		ERR_PRINTF1(_L("Error - Couldn't create periodic utility object"));
		ret = EInconclusive;
		}
	else
		{
		iPeriodicUtilityTestVerdict = EPass;
		TTimeIntervalMicroSeconds32 period = KTestClock2Seconds;
		iClockSource->Reset();
		iPeriodicUtility->Start(period);
		CActiveScheduler::Start();
		ret = iPeriodicUtilityTestVerdict;
		}
	delete iPeriodicUtility;
	iPeriodicUtility = NULL;

	// Clean up the thread
	iShutdownSubthread = ETrue;
	User::WaitForRequest(stat);
	thread.Close();

	delete iClockSource;

	return ret;
	}