|
1 /* |
|
2 * Copyright (c) 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: Audio Stubs - Utility timer object used for playing tone sequence. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "MmfDevSoundAdaptationBody.h" |
|
22 #include "TonePlayCompleteTimer.h" |
|
23 |
|
24 #ifdef _DEBUG |
|
25 #include "e32debug.h" |
|
26 |
|
27 #define DEBPRN0(str) RDebug::Print(str, this) |
|
28 #define DEBPRN1(str, val1) RDebug::Print(str, this, val1) |
|
29 #else |
|
30 #define DEBPRN0(str) |
|
31 #define DEBPRN1(str, val1) |
|
32 #endif //_DEBUG |
|
33 |
|
34 |
|
35 |
|
36 // ============================ MEMBER FUNCTIONS =============================== |
|
37 |
|
38 // ----------------------------------------------------------------------------- |
|
39 // CTonePlayCompleteTimer::CTonePlayCompleteTimer |
|
40 // C++ default constructor can NOT contain any code, that |
|
41 // might leave. |
|
42 // ----------------------------------------------------------------------------- |
|
43 // |
|
44 CTonePlayCompleteTimer::CTonePlayCompleteTimer( |
|
45 MDevSoundAdaptationObserver& aObserver) : |
|
46 CActive(EPriorityNormal), iObserver(aObserver) |
|
47 { |
|
48 CActiveScheduler::Add(this); |
|
49 } |
|
50 |
|
51 // ----------------------------------------------------------------------------- |
|
52 // CTonePlayCompleteTimer::ConstructL |
|
53 // Symbian 2nd phase constructor can leave. |
|
54 // ----------------------------------------------------------------------------- |
|
55 // |
|
56 void CTonePlayCompleteTimer::ConstructL() |
|
57 { |
|
58 User::LeaveIfError(iTimer.CreateLocal()); |
|
59 } |
|
60 |
|
61 // ----------------------------------------------------------------------------- |
|
62 // CTonePlayCompleteTimer::NewL |
|
63 // Two-phased constructor. |
|
64 // ----------------------------------------------------------------------------- |
|
65 // |
|
66 CTonePlayCompleteTimer* CTonePlayCompleteTimer::NewL( |
|
67 MDevSoundAdaptationObserver& aObserver) |
|
68 { |
|
69 CTonePlayCompleteTimer* self = new (ELeave)CTonePlayCompleteTimer(aObserver); |
|
70 CleanupStack::PushL(self); |
|
71 self->ConstructL(); |
|
72 CleanupStack::Pop(self); |
|
73 return self; |
|
74 } |
|
75 |
|
76 |
|
77 // ----------------------------------------------------------------------------- |
|
78 // CTonePlayCompleteTimer::~CTonePlayCompleteTimer |
|
79 // Destructor |
|
80 // ----------------------------------------------------------------------------- |
|
81 // |
|
82 CTonePlayCompleteTimer::~CTonePlayCompleteTimer() |
|
83 { |
|
84 // Cancel any outstanding requests |
|
85 iTimer.Cancel(); |
|
86 Cancel(); |
|
87 iTimer.Close(); |
|
88 } |
|
89 |
|
90 // ---------------------------------------------------------------------------- |
|
91 // CTonePlayCompleteTimer::SetTimeOut |
|
92 // Sets the timeout duration. |
|
93 // (other items were commented in a header). |
|
94 // ---------------------------------------------------------------------------- |
|
95 void CTonePlayCompleteTimer::SetTimeOut(TTimeIntervalMicroSeconds32& aTimeOut) |
|
96 { |
|
97 iTimeOut = aTimeOut; |
|
98 } |
|
99 |
|
100 // ---------------------------------------------------------------------------- |
|
101 // CTonePlayCompleteTimer::Start |
|
102 // Starts the timer for timeout duration set by SetTimeOut(). |
|
103 // (other items were commented in a header). |
|
104 // ---------------------------------------------------------------------------- |
|
105 void CTonePlayCompleteTimer::Start() |
|
106 { |
|
107 if (!IsActive()) |
|
108 { |
|
109 SetActive(); |
|
110 iTimer.After(iStatus, iTimeOut); |
|
111 } |
|
112 } |
|
113 |
|
114 // ---------------------------------------------------------------------------- |
|
115 // CTonePlayCompleteTimer::RunL |
|
116 // (other items were commented in a header). |
|
117 // ---------------------------------------------------------------------------- |
|
118 void CTonePlayCompleteTimer::RunL() |
|
119 { |
|
120 DEBPRN0(_L("CTonePlayCompleteTimer[0x%x]::RunL")); |
|
121 iObserver.ToneFinished(KErrNone); |
|
122 } |
|
123 |
|
124 // ---------------------------------------------------------------------------- |
|
125 // CTonePlayCompleteTimer::DoCancel |
|
126 // (other items were commented in a header). |
|
127 // ---------------------------------------------------------------------------- |
|
128 void CTonePlayCompleteTimer::DoCancel() |
|
129 { |
|
130 iTimer.Cancel(); |
|
131 } |
|
132 |
|
133 // ---------------------------------------------------------------------------- |
|
134 // CTonePlayCompleteTimer::RunError |
|
135 // (other items were commented in a header). |
|
136 // ---------------------------------------------------------------------------- |
|
137 TInt CTonePlayCompleteTimer::RunError(TInt /*aError*/) |
|
138 { |
|
139 return KErrNone; |
|
140 } |
|
141 |
|
142 // End of File |