bluetooth/gavdp/test/tavsrcTimer.h
author Pat Downey <patd@symbian.org>
Wed, 01 Sep 2010 12:38:54 +0100
branchRCL_3
changeset 24 e9b924a62a66
parent 0 29b1cd4cb562
permissions -rw-r--r--
Revert incorrect RCL_3 drop: Revision: 201031 Kit: 201035

// 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