49
|
1 |
/*
|
|
2 |
* Copyright (c) 2004-2006 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description: Provides a comfort noise generator class
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#include "buffertimer.h"
|
|
20 |
#include "msrppayloadformatdefs.h"
|
|
21 |
|
|
22 |
CBufferTimer::CBufferTimer(MBufferTimerNotify& aNotify)
|
|
23 |
:CActive( EPriorityStandard ),iNotify(aNotify)
|
|
24 |
{
|
|
25 |
CActiveScheduler::Add( this );
|
|
26 |
}
|
|
27 |
|
|
28 |
CBufferTimer::~CBufferTimer()
|
|
29 |
{
|
|
30 |
Cancel();
|
|
31 |
iTimer.Close();
|
|
32 |
}
|
|
33 |
|
|
34 |
CBufferTimer* CBufferTimer::NewL(MBufferTimerNotify& aNotify)
|
|
35 |
{
|
|
36 |
|
|
37 |
DP_MSRP_WRITE( "CBufferTimer::NewL" );
|
|
38 |
CBufferTimer* me = new (ELeave) CBufferTimer(aNotify);
|
|
39 |
CleanupStack::PushL(me);
|
|
40 |
me->ConstructL();
|
|
41 |
CleanupStack::Pop();
|
|
42 |
return me;
|
|
43 |
}
|
|
44 |
|
|
45 |
void CBufferTimer::ConstructL(void)
|
|
46 |
{
|
|
47 |
iTimer.CreateLocal();
|
|
48 |
}
|
|
49 |
|
|
50 |
void CBufferTimer::After(TTimeIntervalMicroSeconds32 aInterval)
|
|
51 |
{
|
|
52 |
DP_MSRP_WRITE( "CBufferTimer::After()" );
|
|
53 |
iInterval = aInterval;
|
|
54 |
Call();
|
|
55 |
|
|
56 |
}
|
|
57 |
|
|
58 |
|
|
59 |
void CBufferTimer::DoCancel()
|
|
60 |
{
|
|
61 |
iTimer.Cancel();
|
|
62 |
}
|
|
63 |
|
|
64 |
void CBufferTimer::Call()
|
|
65 |
{
|
|
66 |
DP_MSRP_WRITE( "CBufferTimer::Call()" );
|
|
67 |
TRequestStatus* stat = &iStatus;
|
|
68 |
|
|
69 |
// Cancel the statemachine and set a new state
|
|
70 |
Cancel();
|
|
71 |
User::RequestComplete( stat, KErrNone );
|
|
72 |
SetActive();
|
|
73 |
}
|
|
74 |
|
|
75 |
|
|
76 |
void CBufferTimer::RunL()
|
|
77 |
{
|
|
78 |
|
|
79 |
if ( KErrNone == iStatus.Int() )
|
|
80 |
{
|
|
81 |
DP_MSRP_WRITE( "CBufferTimer::RunL()" );
|
|
82 |
iTimer.After(iStatus,iInterval);
|
|
83 |
iNotify.TimerExpired();
|
|
84 |
}
|
|
85 |
else
|
|
86 |
{
|
|
87 |
#ifdef _DEBUG
|
|
88 |
RDebug::Print( _L("CBufferTimer::RunL ERROR: %d"), iStatus.Int());
|
|
89 |
#endif
|
|
90 |
User::Leave( iStatus.Int() );
|
|
91 |
}
|
|
92 |
|
|
93 |
}
|
|
94 |
|