bluetooth/gavdp/test/tavsrcTimer.h
branchRCL_3
changeset 24 e9b924a62a66
parent 0 29b1cd4cb562
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetooth/gavdp/test/tavsrcTimer.h	Wed Sep 01 12:38:54 2010 +0100
@@ -0,0 +1,62 @@
+// Copyright (c) 2007-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:
+//
+
+#ifndef TAVSRCTIMER_H
+#define TAVSRCTIMER_H
+
+#include <e32base.h>
+
+class CAdaptiveHighResPeriodic;
+
+class MAdaptiveHighResPeriodicClient
+	{
+public:
+	virtual void TimerEvent(CAdaptiveHighResPeriodic& aTimer)=0;
+	virtual void TimerError(CAdaptiveHighResPeriodic& aTimer, TInt aError)=0;
+	};
+
+//adapts the callback to counter drift	
+class CAdaptiveHighResPeriodic : public CTimer
+	{
+public:
+	static CAdaptiveHighResPeriodic* NewL(MAdaptiveHighResPeriodicClient& aClient);
+	~CAdaptiveHighResPeriodic();
+	void Start(TTimeIntervalMicroSeconds32 aPeriod);
+
+	void SetInterval(TTimeIntervalMicroSeconds32 aInterval);
+	
+private:
+	CAdaptiveHighResPeriodic(MAdaptiveHighResPeriodicClient& aClient);
+	void ConstructL();
+	void RunL();
+	TInt RunError(TInt aError);
+	void StartTimer(TTimeIntervalMicroSeconds32 aInterval);
+	
+private:
+	MAdaptiveHighResPeriodicClient& iClient;
+
+	// HAL stuff
+	TBool	iFastCounterIncreases;
+	TInt	iFastCounterFreq;
+	TReal	iFastCounterFreqUs;
+	TReal	iExtraCounts;
+	
+	// what the client asked for in musecs
+	TTimeIntervalMicroSeconds32	iInterval;
+
+	TUint	iIntendedCountOnCallback ;	// the hoped for fast counter reading on callback
+	};
+
+#endif // TAVSRCTIMER_H