|
1 /* |
|
2 * Copyright (c) 2009 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: |
|
15 * |
|
16 */ |
|
17 // sfmrlocaltimer.cpp |
|
18 |
|
19 #include "sfmrlocaltimer.h" |
|
20 |
|
21 extern "C" { |
|
22 #include "xarecorditfadaptationmmf.h" |
|
23 } |
|
24 |
|
25 #include "cmmfbackendengine.h" |
|
26 |
|
27 |
|
28 LocalTimer::LocalTimer(CMMFBackendEngine* parent, void* adaptContext) |
|
29 :CActive(CActive::EPriorityStandard), |
|
30 iTime(0) |
|
31 { |
|
32 CActiveScheduler::Add(this); |
|
33 iParent = parent; |
|
34 iAdaptContext = adaptContext; |
|
35 } |
|
36 |
|
37 LocalTimer::~LocalTimer() |
|
38 { |
|
39 Cancel(); |
|
40 iTimer.Close(); |
|
41 } |
|
42 |
|
43 TInt LocalTimer::PostInit() |
|
44 { |
|
45 return iTimer.CreateLocal(); |
|
46 } |
|
47 |
|
48 void LocalTimer::Start(TUint64 aDelay) |
|
49 { |
|
50 if (!IsActive()) |
|
51 { |
|
52 iDelay = aDelay; |
|
53 /* Convert milli to micro */ |
|
54 TTimeIntervalMicroSeconds32 delay(aDelay * 1000); |
|
55 iStatus = KRequestPending; |
|
56 iTimer.After(iStatus, delay); |
|
57 SetActive(); |
|
58 } |
|
59 } |
|
60 |
|
61 void LocalTimer::Stop() |
|
62 { |
|
63 Cancel(); |
|
64 } |
|
65 |
|
66 void LocalTimer::ResetTime() |
|
67 { |
|
68 iTime = 0; |
|
69 } |
|
70 |
|
71 TUint64 LocalTimer::GetTime() |
|
72 { |
|
73 return iTime; |
|
74 } |
|
75 |
|
76 void LocalTimer::RunL() |
|
77 { |
|
78 if (iStatus == KErrNone) |
|
79 { |
|
80 iTime+= iDelay; |
|
81 XAuint64 position; |
|
82 iParent->GetRecordPosition(&position); |
|
83 |
|
84 XARecordItfAdaptMMF_PositionUpdate(iAdaptContext,position); |
|
85 Start(iDelay); |
|
86 } |
|
87 } |
|
88 |
|
89 void LocalTimer::DoCancel() |
|
90 { |
|
91 iTimer.Cancel(); |
|
92 } |