diff -r 2ed61feeead6 -r 6f7ceef7b1d1 khronosfws/openmax_al/src/mmf_adaptation/positionupdatetimer.cpp --- a/khronosfws/openmax_al/src/mmf_adaptation/positionupdatetimer.cpp Fri May 28 19:26:28 2010 -0500 +++ b/khronosfws/openmax_al/src/mmf_adaptation/positionupdatetimer.cpp Fri Jun 11 19:59:23 2010 -0500 @@ -1,38 +1,38 @@ /* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Handles new position timer implementation -* -*/ + * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". + * + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description: Handles new position timer implementation + * + */ #include "positionupdatetimer.h" #include #include #include -extern "C" { +extern "C" + { #include "xarecorditfadaptationmmf.h" -} + } #define RET_ERR_IF_ERR(s) if (s!=KErrNone) return s; #define RET_IF_ERR(s) if (s!=KErrNone) return; CPositionUpdateTimer::CPositionUpdateTimer( CMdaAudioPlayerUtility* aAudioPlayer, - CVideoPlayerUtility2* aVideoPlayer) -:CActive(CActive::EPriorityStandard), - iAudioPlayer(aAudioPlayer), - iVideoPlayer(aVideoPlayer) + CVideoPlayerUtility2* aVideoPlayer) : + CActive(CActive::EPriorityStandard), iAudioPlayer(aAudioPlayer), + iVideoPlayer(aVideoPlayer) { CActiveScheduler::Add(this); } @@ -47,7 +47,8 @@ CMdaAudioPlayerUtility* aAudioPlayer, CVideoPlayerUtility2* aVideoPlayer) { - CPositionUpdateTimer* self = new (ELeave)CPositionUpdateTimer(aAudioPlayer, aVideoPlayer); + CPositionUpdateTimer* self = new (ELeave) CPositionUpdateTimer( + aAudioPlayer, aVideoPlayer); CleanupStack::PushL(self); self->CostructL(); CleanupStack::Pop(self); @@ -56,18 +57,18 @@ void CPositionUpdateTimer::CostructL() { - User::LeaveIfError(iTimer.CreateLocal()); + User::LeaveIfError(iTimer.CreateLocal()); } void CPositionUpdateTimer::SetContext(TAny* aCtx) { - iCtx = aCtx; + iCtx = aCtx; } void CPositionUpdateTimer::SetPositionUpdatePeriod(XAmillisecond aPos) { iPositionUpdatePeriod = aPos; - iDelay = TTimeIntervalMicroSeconds32(aPos*1000); + iDelay = TTimeIntervalMicroSeconds32(aPos * 1000); } void CPositionUpdateTimer::SetCallbackEventMask(XAuint32 aMask) @@ -82,11 +83,11 @@ void CPositionUpdateTimer::UseAudioPlayer() { - iPlayerToUse = static_cast(iAudioPlayer); + iPlayerToUse = static_cast (iAudioPlayer); } void CPositionUpdateTimer::UseVideoPlayer() { - iPlayerToUse = static_cast(iVideoPlayer); + iPlayerToUse = static_cast (iVideoPlayer); } void CPositionUpdateTimer::ResetPlayer() @@ -101,13 +102,13 @@ { Cancel(); } - if ((iCallbackEventMask & XA_PLAYEVENT_HEADATNEWPOS) && - iCallback && - iPlayerToUse) + if ((iCallbackEventMask & XA_PLAYEVENT_HEADATNEWPOS) && iCallback + && iPlayerToUse) { TTimeIntervalMicroSeconds curPlayPos; /* Convert milli to micro */ - TTimeIntervalMicroSeconds posUpdatePeriod(iPositionUpdatePeriod * 1000); + TTimeIntervalMicroSeconds posUpdatePeriod(iPositionUpdatePeriod + * 1000); TTimeIntervalMicroSeconds32 delay; /* Convert milli to micro */ TReal res; @@ -134,7 +135,7 @@ iSyncToPlayHeadStartPos.Int64(), delay.Int()); #endif /* POSITIONUPDATETIMERLOG */ - if ( delay >= TTimeIntervalMicroSeconds32(0)) + if (delay >= TTimeIntervalMicroSeconds32(0)) { iStatus = KRequestPending; iTimer.After(iStatus, delay); @@ -153,11 +154,8 @@ { TInt retVal(KErrNone); /* Make sure some of the attributes are not unset */ - if ((iStatus == KErrNone) && - iCtx && - (iCallbackEventMask & XA_PLAYEVENT_HEADATNEWPOS) && - iCallback && - iPlayerToUse) + if ((iStatus == KErrNone) && iCtx && (iCallbackEventMask + & XA_PLAYEVENT_HEADATNEWPOS) && iCallback && iPlayerToUse) { TTimeIntervalMicroSeconds curPlayPos; if (iSyncToPlayHead) @@ -169,16 +167,17 @@ if (curPlayPos == iSyncToPlayHeadStartPos) { #ifdef POSITIONUPDATETIMERLOG - RDebug::Print(_L("CPositionUpdateTimer::RunL:CurPlayPos[%u]SyncPlayHead[%u]microSec. Restart"), - iSyncToPlayHeadStartPos.Int64(), - curPlayPos.Int64()); + RDebug::Print(_L("CPositionUpdateTimer::RunL:CurPlayPos[%u]SyncPlayHead[%u]microSec. Restart"), + iSyncToPlayHeadStartPos.Int64(), + curPlayPos.Int64()); #endif /* POSITIONUPDATETIMERLOG */ Start(); return; } /* Play head has moved. calculate remaining time and set the timer */ /* Convert milli to micro */ - TTimeIntervalMicroSeconds posUpdatePeriod(iPositionUpdatePeriod * 1000); + TTimeIntervalMicroSeconds posUpdatePeriod(iPositionUpdatePeriod + * 1000); TReal res; TReal p; TReal q(posUpdatePeriod.Int64()); @@ -189,14 +188,15 @@ retVal = Math::Mod(res, p, q); RET_IF_ERR(retVal); - TTimeIntervalMicroSeconds32 delay = (posUpdatePeriod.Int64() - res); + TTimeIntervalMicroSeconds32 delay = (posUpdatePeriod.Int64() + - res); #ifdef POSITIONUPDATETIMERLOG RDebug::Print(_L("CPositionUpdateTimer::RunL:CurPlayPos[%u]SyncPlayHead[%u]Delay Reset[%u]microSec"), iSyncToPlayHeadStartPos.Int64(), curPlayPos.Int64(), delay.Int()); #endif /* POSITIONUPDATETIMERLOG */ - if ( delay >= TTimeIntervalMicroSeconds32(0)) + if (delay >= TTimeIntervalMicroSeconds32(0)) { iStatus = KRequestPending; iTimer.After(iStatus, delay); @@ -209,8 +209,12 @@ retVal = GetCurrentPlayPosition(curPlayPos); RDebug::Print(_L("CPositionUpdateTimer::RunL:CurPlayPos[%u]microSec. Posting XA_PLAYEVENT_HEADATNEWPOS."), curPlayPos.Int64()); #endif /* POSITIONUPDATETIMERLOG */ - XAAdaptEvent xaevent = {XA_PLAYITFEVENTS, XA_PLAYEVENT_HEADATNEWPOS, 0, 0 }; - XAAdaptationBase_SendAdaptEvents((XAAdaptationBaseCtx*)iCtx, &xaevent ); + XAAdaptEvent xaevent = + { + XA_PLAYITFEVENTS, XA_PLAYEVENT_HEADATNEWPOS, 0, 0 + }; + XAAdaptationBase_SendAdaptEvents((XAAdaptationBaseCtx*) iCtx, + &xaevent); iStatus = KRequestPending; iTimer.After(iStatus, iDelay); SetActive(); @@ -222,20 +226,21 @@ iTimer.Cancel(); } -TInt CPositionUpdateTimer::RunError(TInt /*aError*/) +TInt CPositionUpdateTimer::RunError(TInt aError) { - return KErrNone; + return aError; } -TInt CPositionUpdateTimer::GetCurrentPlayPosition(TTimeIntervalMicroSeconds& aPos) +TInt CPositionUpdateTimer::GetCurrentPlayPosition( + TTimeIntervalMicroSeconds& aPos) { TTimeIntervalMicroSeconds pos; TInt err(KErrNone); - if (iPlayerToUse == iAudioPlayer) + if (iPlayerToUse && (iPlayerToUse == iAudioPlayer)) { iAudioPlayer->GetPosition(aPos); } - else if (iPlayerToUse == iVideoPlayer) + else if (iPlayerToUse && (iPlayerToUse == iVideoPlayer)) { TRAP(err, aPos = iVideoPlayer->PositionL()); }