virtual dword GetPlayPos() const{ if(!inited) return 0; if(finished) return GetPlayTime(); dword ret; #ifdef USE_OPTIONAL_POSITIONING const_cast<C_simple_sound_player_imp*>(this)->InitLib(); if(mca_GetPosition){ TTimeIntervalMicroSeconds p; #ifdef _DEBUG (plr->*mca_GetPosition)(p); #else mca_GetPosition(plr, p); #endif ret = (p.Int64()/TInt64(1000)).Low(); }else ret = 0; #else TTimeIntervalMicroSeconds p; plr->GetPosition(p); ret = dword(p.Int64()/TInt64(1000)); #endif return Min(ret, GetPlayTime()); }
EXPORT_C int symbian_get_cpu_time(long* sec, long* usec) { // The RThread().GetCpuTime() does not seem to work? // (it always returns KErrNotSupported) // TTimeIntervalMicroSeconds ti; // TInt err = me.GetCpuTime(ti); dTHX; TInt periodus; /* tick period in microseconds */ if (HAL::Get(HALData::ESystemTickPeriod, periodus) != KErrNone) return -1; TUint tick = User::TickCount(); if (PL_timesbase.tms_utime == 0) { PL_timesbase.tms_utime = tick; PL_clocktick = PERL_SYMBIAN_CLK_TCK; } tick -= PL_timesbase.tms_utime; TInt64 tickus = TInt64(tick) * TInt64(periodus); TInt64 tmps = tickus / 1000000; #ifdef __SERIES60_3X__ if (sec) *sec = I64LOW(tmps); if (usec) *usec = I64LOW(tickus) - I64LOW(tmps) * 1000000; #else if (sec) *sec = tmps.Low(); if (usec) *usec = tickus.Low() - tmps.Low() * 1000000; #endif //__SERIES60_3X__ return 0; }
/*CPU and Memory Usage*/ GF_EXPORT Bool gf_sys_get_rti(u32 refresh_time_ms, GF_SystemRTInfo *rti, u32 flags) { TInt ram, ram_free; u32 now, time; #ifdef __SERIES60_3X__ TModuleMemoryInfo mi; #endif TTimeIntervalMicroSeconds tims; RProcess cur_process; RThread cur_th; now = gf_sys_clock(); if (!rti->sampling_instant) { rti->sampling_instant = now; if (cur_th.GetCpuTime(tims) != KErrNone) { return 0; } #ifdef __SERIES60_3X__ rti->process_cpu_time = (u32) (tims.Int64() / 1000); #else rti->process_cpu_time = (u32) ( TInt64(tims.Int64() / 1000).GetTInt() ); #endif return 0; } if (rti->sampling_instant + refresh_time_ms > now) return 0; rti->sampling_period_duration = now - rti->sampling_instant; rti->sampling_instant = now; if (cur_th.Process(cur_process) != KErrNone) { return 0; } #ifdef __SERIES60_3X__ if (cur_process.GetMemoryInfo(mi) != KErrNone) { return 0; } rti->process_memory = mi.iCodeSize + mi.iConstDataSize + mi.iInitialisedDataSize + mi.iUninitialisedDataSize; #endif if (cur_th.GetCpuTime(tims) != KErrNone) { return 0; } #ifdef __SERIES60_3X__ time = (u32) (tims.Int64() / 1000); #else time = (u32) ( TInt64(tims.Int64() / 1000).GetTInt() ); #endif rti->process_cpu_time_diff = time - rti->process_cpu_time; rti->process_cpu_time = time; rti->process_cpu_usage = 100*rti->process_cpu_time_diff / rti->sampling_period_duration; if (rti->process_cpu_usage > 100) rti->process_cpu_usage = 100; HAL::Get(HALData::EMemoryRAM, ram); HAL::Get(HALData::EMemoryRAMFree, ram_free); rti->physical_memory = ram; rti->physical_memory_avail = ram_free; #ifdef GPAC_MEMORY_TRACKING rti->gpac_memory = gpac_allocated_memory; #endif return 1; }
EXPORT_C TTimeIntervalMicroSeconds FrameTimeIntervalCalculation( TUint aFrameSize, TUint aAvgBytesPerSecond) { return(TTimeIntervalMicroSeconds( TInt64(aFrameSize) * TInt64(KOneSecondInMicroSeconds) / TInt64(aAvgBytesPerSecond))); }
virtual dword GetPlayTime() const{ if(!inited) return 0; #ifdef __SYMBIAN_3RD__ return dword(plr->Duration().Int64()/TInt64(1000)); #else return (plr->Duration().Int64()/TInt64(1000)).Low(); #endif }
EXPORT_C TTimeIntervalMicroSeconds DurationCalculation( TUint aDataLength, TUint aAvgBytesPerSecond) { TTimeIntervalMicroSeconds duration(0); //default if (aAvgBytesPerSecond) duration = TTimeIntervalMicroSeconds( (TInt64(aDataLength) * TInt64(KOneSecondInMicroSeconds)) / TInt64(aAvgBytesPerSecond)); return duration; }
// --------------------------------------------------------------------------- // CDTMFPayloadFormatWrite::FrameTimeInterval // Gets audio frame size in milliseconds. // --------------------------------------------------------------------------- // TTimeIntervalMicroSeconds CDTMFPayloadFormatWrite::FrameTimeInterval( TMediaId aMediaType ) const { DP_DTMF_WRITE( _L("CDTMFPayloadFormatWrite::FrameTimeInterval") ); if ( KUidMediaTypeAudio == aMediaType.iMediaType ) { return TTimeIntervalMicroSeconds( TInt64( 0 ) ); } else { return TTimeIntervalMicroSeconds( TInt64( 0 ) ); } }
EXPORT_C TUint DataPosition(TTimeIntervalMicroSeconds aPosition, TUint aSampleRate, TUint aBitsPerSample, TUint aChannels) { TInt64 dataPosition64(0); dataPosition64 = (aPosition.Int64() * TInt64(aSampleRate) * TInt64(aBitsPerSample) * TInt64(aChannels)) / (TInt64(KOneSecondInMicroSeconds) * TInt64(8)); return I64INT(dataPosition64); }
// --------------------------------------------------------------------------- // CDTMFPayloadFormatWrite::Duration // Gets the duration of the sink clip for the specified media ID. // --------------------------------------------------------------------------- // TTimeIntervalMicroSeconds CDTMFPayloadFormatWrite::Duration( TMediaId /*aMediaType*/ ) const { DP_DTMF_WRITE( _L("CDTMFPayloadFormatWrite::Duration") ); return TTimeIntervalMicroSeconds( TInt64( KDurationNotApplicable ) ); }
// --------------------------------------------------------------------------- // // --------------------------------------------------------------------------- // void CAlfExAnalogDialerFeedback::Start( TInt aDurationMilliSeconds, TInt aIntervalMilliSeconds) { iDuration = KFeedbackDefault; iInterval = KFeedbackMinimumInterval; // 1000: convert millis to micros if (iFeedback) { iFeedback->InstantFeedback(ETouchFeedbackBasic); } if ( aIntervalMilliSeconds > KFeedbackMinimumInterval ) { iInterval = 1000*aIntervalMilliSeconds; } if (aDurationMilliSeconds >= KFeedbackMinimumDuration) { iDuration = 1000*aDurationMilliSeconds; iDurationStop.HomeTime(); iDurationStop += TTimeIntervalMicroSeconds(TInt64(iDuration)); iClock->Cancel(); iClock->Start( iInterval, iInterval, TCallBack( HandleInterval, this )); } }
EXPORT_C void COggVorbisFile::SetPositionL(TTimeIntervalMicroSeconds aPos) { // using tremor: so milliseconds not seconds TInt64 milliseconds = aPos.Int64()/TInt64(1000); //RDebug::Printf("SetPositionL: %f\n", milliseconds.GetTInt()); iBody->SetPositionL(milliseconds.GetTInt()); }
EXPORT_C TTimeIntervalMicroSeconds DurationCalculation( TUint aDataLength, TTimeIntervalMicroSeconds aFrameTime, TUint aFrameLength) { TTimeIntervalMicroSeconds duration(0); //default if ((aFrameTime.Int64() != 0) && aFrameLength) { const TInt64 frameTime = aFrameTime.Int64(); duration = TTimeIntervalMicroSeconds( TInt64(aDataLength) / (TInt64(aFrameLength) * frameTime)); } return duration; }
TTimeIntervalMicroSeconds32 SecsToUsecs(TInt secs) { TInt64 us64 = TInt64(secs) * 1000000LL; // max time is around 35 minutes only TInt us = ((us64 > 2147483647LL) ? 2147483647 : (int)us64); return TTimeIntervalMicroSeconds32(us); }
// called by MDataSource to pass back full buffer to the sink void CMMFRawFormatRead::BufferFilledL(CMMFBuffer* aBuffer) { //set position TTimeIntervalMicroSeconds position = //assumes frame numbers begin at frame 1 TTimeIntervalMicroSeconds(TInt64(aBuffer->FrameNumber()-1)*iFrameTimeInterval.Int64()); aBuffer->SetTimeToPlay(position); iDataPath->BufferFilledL(aBuffer); }
void CMMFSwCodecUtility::ConfigAudioRamper(TInt64 aRampTime, TInt aSampleRate, TInt aChannels) { iRampSamples = I64LOW(((TInt64(aSampleRate) * aRampTime) /1000000 )); // Add this iRampSamplesLeft = iRampSamples; iChannels = aChannels; iRampIncr = 0; iSkip = ETrue; }
// ----------------------------------------------------------------------------- // CG711PayloadFormatRead::ConfigurePayloadFormatL // Configure payload decoding parameters. // ----------------------------------------------------------------------------- // void CG711PayloadFormatRead::ConfigurePayloadFormatL( const TDesC8& aConfigParams ) { DP_G711_READ( "CG711PayloadFormatRead::ConfigurePayloadFormatL" ); __ASSERT_ALWAYS( aConfigParams.Size() == sizeof( TMccCodecInfo ), User::Leave( KErrArgument ) ); TMccCodecInfoBuffer infoBuffer; infoBuffer.Copy( aConfigParams ); if ( !infoBuffer() .iIsUpdate ) { iCInfo = infoBuffer(); // Calculates frames/packet, frame size and frame time interval iFramesPerPacket = TInt8( iCInfo.iMaxPtime / iCInfo.iHwFrameTime ); iCInfo.iFrameSize = static_cast<TUint>( KDefaultSampleRateInkHz * iCInfo.iHwFrameTime ); iFrameTimeInterval = TInt64( iCInfo.iHwFrameTime ); // Create two frame buffers used in data transfer with datapath. // Space for two byte additional header needed by HW codec is reserved. iFrameBufferOne = CMMFDataBuffer::NewL( iCInfo.iFrameSize + KVoIPHeaderLength ); iFrameBufferTwo = CMMFDataBuffer::NewL( iCInfo.iFrameSize + KVoIPHeaderLength ); // PayloadBuffer contains data received from network TInt plSize = iCInfo.iFrameSize * iFramesPerPacket; DP_G711_READ3( "CG711PayloadFormatRead::ConfigurePayloadFormatL \ FramesPerPacket: %d, FrameSize: %d" , iFramesPerPacket, iCInfo.iFrameSize ); if ( EGenRedUsed == iCInfo.iAlgoUsed ) { DP_G711_READ2( "CG711PayloadFormatRead::ConfigurePayloadFormatL, RED LEVEL: %d", iCInfo.iRedundancyCount ); if ( iCInfo.iRedundancyCount ) { plSize *= iCInfo.iRedundancyCount; } CPayloadFormatRead* redDecoder = static_cast<CPayloadFormatRead*>( iClip ); TMccRedPayloadReadConfig config; config.iRedBlockCount = iCInfo.iRedundancyCount; config.iMaxPayloadSize = iCInfo.iFrameSize * iFramesPerPacket; config.iNumOfEncodings = 1; config.iRedPayloadType = iCInfo.iRedundantPayload; config.InitPayloadTypes(); config.iEncPayloadTypes[0] = iCInfo.iPayloadType; TMccRedPayloadReadPckg pckg( config ); redDecoder->ConfigurePayloadFormatL( pckg ); } iSourceBuffer = CreateClipBufferL( plSize, iSourceBufOwnership ); }
EXPORT_C TTimeIntervalMicroSeconds DurationCalculation( TUint aDataLength, TUint aSampleRate, TUint aBitsPerSample, TUint aChannels) { TTimeIntervalMicroSeconds duration(0); //default if ((aDataLength) && (aSampleRate) && (aBitsPerSample) && (aChannels)) { TInt64 sampleRate=static_cast<TInt64>(aSampleRate); duration = TTimeIntervalMicroSeconds( (TInt64(aDataLength) * TInt64(KOneSecondInMicroSeconds) * TInt64(8)) / (sampleRate * TInt64(aBitsPerSample) * TInt64(aChannels))); } return duration; }
// ----------------------------------------------------------------------------- // CCalenLunarVietnameseLocalizer::LocalizeMonthAndDayL // ----------------------------------------------------------------------------- // void CCalenLunarVietnameseLocalizer::LocalizeMonthAndDayL( CCalenLunarLocalizedInfo* aLocInfo, TCalenLunarInfo& aInfo) { // Lunar Month and Day TInt dateResource = aInfo.iLunarDate.iLeapMonth ? R_CALE_LUNAR_LEAP_DATE : R_CALE_LUNAR_DATE; TBuf<10> month; TBuf<10> day; month.Num( TInt64(aInfo.iLunarDate.iMonth) ); day.Num( TInt64(aInfo.iLunarDate.iDay )); CPtrCArray* monthAndDaySubs = new (ELeave) CPtrCArray(2); CleanupStack::PushL( monthAndDaySubs ); monthAndDaySubs->AppendL(month); monthAndDaySubs->AppendL(day); HBufC* tmp = StringLoader::LoadLC( dateResource, *monthAndDaySubs ); aLocInfo->iLunarMonthAndDay = *tmp; CleanupStack::PopAndDestroy( tmp ); CleanupStack::PopAndDestroy( monthAndDaySubs ); }
void CTestXonXoff::ReadComplete(TInt aStatus) { if (iTrace) Test.Printf(_L("CTestXonXoff::ReadComplete(%d) len = %d/%d (%d)\r\n"), aStatus, iReader->iDes.Length(), iReader->iDes.MaxLength(), iReader->iTotal); if (aStatus!=KErrNone) { Fail(ETestFailRead, aStatus); return; } switch (iState) { case EWaitIO: iRetries = 0; iTimer->Cancel(); if (!CheckDes(iReader->iDes, 0, iReader->iDes.Length(), '@', 'Z', iCount & 0x3fff)) { Fail(ETestBadData, aStatus); return; } iCount += iReader->iCount; iPackets++; { TTime end; end.UniversalTime(); TInt64 difftime = (end.MicroSecondsFrom(iStartTime).Int64()+TInt64(500000))/TInt64(1000000); if (difftime==0) difftime = 1; TInt64 cps = MAKE_TINT64(0,iCount)/difftime; TInt rate = (I64INT(cps)*10000)/11520; iRate += rate; iSpeed += I64INT(cps); Test.Printf(_L("%c %6d %d (%dbps=%d.%02d%%)\r"), KSpinner[iSpin++ & 3], iPackets, iCount, iSpeed/iPackets, (iRate/iPackets)/100, (iRate/iPackets)%100); } Read(); break; default: break; } }
EXPORT_C void CCMPost::AddRef() const { CALLSTACKITEM_N(_CL("CCMPost"), _CL("AddRef")); #ifdef __WINS__ if (iPostId()==TInt64(0)) { TInt x; x=0; } #endif ++iRefCount; }
// ----------------------------------------------------------------------------- // CG711PayloadFormatRead::FrameTimeInterval // Return the frame time interval for the given media // ----------------------------------------------------------------------------- // TTimeIntervalMicroSeconds CG711PayloadFormatRead::FrameTimeInterval( TMediaId aMediaId ) const { if ( KUidMediaTypeAudio == aMediaId.iMediaType ) { return iFrameTimeInterval; } else { return TTimeIntervalMicroSeconds( TInt64( 0 ) ); } }
void CEraser::DoEraseBlock() // // Issue an erase // { _LIT( KEraseStartMsg, "Eraser starting erase..." ); RDebug::Print( KEraseStartMsg ); TInt r = iDrive.Format( TInt64(iOffset), iLength ); if( KErrNone != r ) { RDebug::Print( _L("Eraser: FAIL: erase request returns %d"), r ); Panic( 2 ); } }
EXPORT_C void CCMPost::Release() const { CALLSTACKITEM_N(_CL("CCMPost"), _CL("Release")); #ifdef __WINS__ if (iPostId()==TInt64(0)) { TInt x; x=0; } #endif --iRefCount; if (iRefCount<0) { User::Panic(_L("CONTEXTMEDIA"), 1); } if (iRefCount==0) delete this; }
uint32 SymbianFileHandler::getAvailableSpace() const { // Sometimes Symbian makes life tricky. TChar driveChar = (*m_fileName16)[0]; TInt currentDrive; int ctdRes = m_fileServer.CharToDrive( driveChar, currentDrive); if ( ctdRes != KErrNone ) { // Something went wrong. Use the default drive. currentDrive = KDefaultDrive; } TVolumeInfo volume; TInt res = m_fileServer.Volume( volume, currentDrive ); if ( res != KErrNone ) { return MAX_UINT32; } // Check if we have _a lot_ of space. if ( volume.iFree > TInt64(TInt(MAX_INT32)) ) { return MAX_INT32; } else { return LOW(volume.iFree); } }
EXPORT_C TTimeIntervalMicroSeconds FrameTimeIntervalCalculation( TUint aFrameSize, TUint aSampleRate, TUint aBitsPerSample, TUint aChannels) { TTimeIntervalMicroSeconds frameTimeInterval(0); //default if ((aSampleRate) && (aBitsPerSample) && (aChannels)) { frameTimeInterval = TTimeIntervalMicroSeconds( (TInt64(aFrameSize) * TInt64(KOneSecondInMicroSeconds) * TInt64(8)) / (TInt64(aSampleRate) * TInt64(aBitsPerSample) * TInt64(aChannels))); } return(frameTimeInterval); }
static void as_ttime (const struct tm& p, TTime& res, TBool normalise=EFalse) { TDateTime dt; TInt err = dt.Set(p.tm_year+1900, (enum TMonth)p.tm_mon, p.tm_mday-1, p.tm_hour, p.tm_min, p.tm_sec, 0); if (err == KErrNone) { res = dt; return; } if (!normalise) { res = TInt64(-1); return; } // Try to normalise things (for mktime) dt.Set(p.tm_year+1900, EJanuary, 0, 0, 0, 0, 0); res = dt; res += TTimeIntervalMonths (p.tm_mon); res += TTimeIntervalDays (p.tm_mday-1); res += TTimeIntervalHours (p.tm_hour); res += TTimeIntervalMinutes(p.tm_min); res += TTimeIntervalSeconds(p.tm_sec); }
CRecordTimeAvailable::CRecordTimeAvailable(CTestModuleIf *aConsole, CStifLogger *aLogger):CRecordingBase(aConsole,aLogger) { errorRange = TInt64(KDefaultErrorRange); timeAvailable = 0; }
void CCustomCommandAsync::MoscoStateChangeEvent(CBase* /*aObject*/, TInt aPreviousState, TInt aCurrentState, TInt aErrorCode) { #ifdef _DEBUG RDebug::Print (_L ("CCustomCommandAsync::MoscoStateChangeEvent")); #endif logger->Log(_L("MoscoStateChangeEvent called, error: %d prev: %d curr : %d"),aErrorCode,aPreviousState,aCurrentState); iCallBackErr = aErrorCode; if (recorder && aErrorCode == KErrNone && aCurrentState == CMdaAudioClipUtility::EOpen && aPreviousState == 0) { TBuf8<25> dataFrom; TRequestStatus status; TMMFMessageDestinationPckg dummyPckg; TInt dummyFunc = 100; TBuf8<8> dummyBuff; // Initialize recorder->SetAudioDeviceMode(CMdaAudioRecorderUtility::ELocal); logger->Log(_L("Mode set")); recorder->SetGain(recorder->MaxGain()); logger->Log(_L("Gain set")); recorder->SetVolume(recorder->MaxVolume()); logger->Log(_L("Volume set")); recorder->SetPosition(TTimeIntervalMicroSeconds(TInt64(0))); logger->Log(_L("Position set")); //RecordController recorder->RecordControllerCustomCommandAsync(dummyPckg, dummyFunc, dummyBuff, dummyBuff, dataFrom, status); User::WaitForRequest(status); logger->Log(_L("RecordControllerCustomCommandAsync with dataFrom")); recorder->RecordControllerCustomCommandAsync(dummyPckg, dummyFunc, dummyBuff, dummyBuff, status); User::WaitForRequest(status); logger->Log(_L("RecordControllerCustomCommandAsync")); //PlayController recorder->PlayControllerCustomCommandAsync(dummyPckg, dummyFunc, dummyBuff, dummyBuff, dataFrom, status); User::WaitForRequest(status); logger->Log(_L("PlayControllerCustomCommandAsync with dataFrom")); recorder->PlayControllerCustomCommandAsync(dummyPckg, dummyFunc, dummyBuff, dummyBuff, status); User::WaitForRequest(status); logger->Log(_L("PlayControllerCustomCommandAsync")); logger->Log(_L("Using UseSharedHeap")); recorder->UseSharedHeap(); recorder->PlayL(); return; } if (recorder && aErrorCode == KErrNone && aCurrentState == CMdaAudioClipUtility::EOpen && aPreviousState == CMdaAudioClipUtility::EPlaying) { recorder->WillResumePlay(); CActiveScheduler::Stop(); } if (aErrorCode != KErrNone) { CActiveScheduler::Stop(); } return; }
void Wins::CalibrateCpuSpeed() // // calculate approx. CPU speed in MHz, 0 if we can't tell // { TInt cycleCount =200*1000*20; //take 20ms at 20MHz // This loop will double the cyclecount until the difference is non-zero. FOREVER { if (cycleCount > (KMaxTUint / 2)) { break; } SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL); LARGE_INTEGER start; if (QueryPerformanceCounter(&start)) { __asm mov eax, cycleCount noploop: __asm dec eax __asm dec eax __asm dec eax __asm dec eax __asm dec eax __asm dec eax __asm dec eax __asm dec eax __asm dec eax __asm dec eax __asm dec eax __asm dec eax __asm dec eax __asm dec eax __asm dec eax __asm dec eax __asm dec eax __asm dec eax __asm dec eax __asm dec eax __asm dec eax __asm dec eax __asm dec eax __asm dec eax __asm dec eax __asm dec eax __asm dec eax __asm dec eax __asm dec eax __asm dec eax __asm dec eax __asm dec eax __asm dec eax __asm dec eax __asm dec eax __asm dec eax __asm dec eax __asm dec eax __asm dec eax __asm dec eax __asm dec eax __asm dec eax __asm dec eax __asm dec eax __asm dec eax __asm dec eax __asm dec eax __asm dec eax __asm sub eax, 2 __asm jnz noploop // LARGE_INTEGER end; QueryPerformanceCounter(&end); LARGE_INTEGER f; QueryPerformanceFrequency(&f); TInt64 diff = (end.QuadPart - start.QuadPart); if(diff!=0) { TInt64 hz = (TInt64(cycleCount) / 1000000) * (f.QuadPart / diff); iRealCpuSpeed = (TUint)(hz); break; } } cycleCount *= 2; // Double the count!! }
// ----------------------------------------------------------------------------- // CAnyPayloadFormatRead::FrameTimeInterval // Return the frame time interval for the given media // ----------------------------------------------------------------------------- // TTimeIntervalMicroSeconds CAnyPayloadFormatRead::FrameTimeInterval( TMediaId /*aMediaId*/ ) const { return TTimeIntervalMicroSeconds( TInt64( 0 ) ); }