multimediacommscontroller/mmccMsrppayloadformat/src/BufferTimer.cpp
branchrcs
changeset 49 64c62431ac08
child 50 1d8943dd8be6
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/multimediacommscontroller/mmccMsrppayloadformat/src/BufferTimer.cpp	Mon Sep 06 17:32:13 2010 +0530
@@ -0,0 +1,94 @@
+/*
+* Copyright (c) 2004-2006 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:    Provides a comfort noise generator class
+*
+*/
+
+
+#include "buffertimer.h"
+#include "msrppayloadformatdefs.h"
+
+CBufferTimer::CBufferTimer(MBufferTimerNotify& aNotify)
+:CActive( EPriorityStandard ),iNotify(aNotify)
+{
+	CActiveScheduler::Add( this );
+}
+ 
+CBufferTimer::~CBufferTimer()
+{	
+	Cancel();
+	iTimer.Close();
+}
+ 
+CBufferTimer* CBufferTimer::NewL(MBufferTimerNotify& aNotify)
+{
+	
+		DP_MSRP_WRITE( "CBufferTimer::NewL" );
+    CBufferTimer* me = new (ELeave) CBufferTimer(aNotify); 
+    CleanupStack::PushL(me);
+		me->ConstructL();
+		CleanupStack::Pop();
+    return me;
+}
+ 
+void CBufferTimer::ConstructL(void)
+{
+	iTimer.CreateLocal();
+}
+ 
+void CBufferTimer::After(TTimeIntervalMicroSeconds32 aInterval)
+{
+	DP_MSRP_WRITE( "CBufferTimer::After()" );
+	iInterval = aInterval;
+	Call(); 
+
+}
+
+ 
+void CBufferTimer::DoCancel()
+{
+	iTimer.Cancel();
+}
+ 
+void CBufferTimer::Call()
+	{
+			DP_MSRP_WRITE( "CBufferTimer::Call()" );
+	    TRequestStatus* stat = &iStatus; 
+     
+      // Cancel the statemachine and set a new state
+    	Cancel();
+      User::RequestComplete( stat, KErrNone );
+      SetActive();
+	} 
+ 
+ 
+void CBufferTimer::RunL()
+{
+	
+	if ( KErrNone == iStatus.Int() )
+		{
+			DP_MSRP_WRITE( "CBufferTimer::RunL()" );
+			iTimer.After(iStatus,iInterval); 
+			iNotify.TimerExpired();
+		}
+	else
+		{
+			  #ifdef _DEBUG
+            RDebug::Print( _L("CBufferTimer::RunL ERROR: %d"), iStatus.Int());
+        #endif
+        User::Leave( iStatus.Int() );
+		}
+	
+}
+