1 /* |
|
2 * Copyright (c) 2003-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 |
|
18 |
|
19 |
|
20 //INCLUDES |
|
21 #include "CamZoomUpdateManager.h" |
|
22 #include "CamUtility.h" |
|
23 #include "CameraUiConfigManager.h" |
|
24 |
|
25 |
|
26 |
|
27 //MACROS |
|
28 |
|
29 // Cooldown period inbetween camera driver updates |
|
30 const TInt KCamZoomCooldown = 200000; // .2 seconds |
|
31 const TInt KCamMaxZoomCooldown = 250000; // .25 seconds |
|
32 |
|
33 |
|
34 // ====================== MEMBER FUNCTIONS ===================== |
|
35 |
|
36 // ----------------------------------------------------------------------------- |
|
37 // CCamZoomUpdateManager::NewL |
|
38 // Two-phased constructor. |
|
39 // ----------------------------------------------------------------------------- |
|
40 // |
|
41 CCamZoomUpdateManager* CCamZoomUpdateManager::NewL( CCamAppController& aController ) |
|
42 { |
|
43 PRINT((_L("CCamZoomUpdateManager::NewL in"))); |
|
44 CCamZoomUpdateManager* self = new(ELeave) CCamZoomUpdateManager( aController ); |
|
45 CleanupStack::PushL(self); |
|
46 self->ConstructL (); |
|
47 CleanupStack::Pop(); |
|
48 PRINT((_L("CCamZoomUpdateManager::NewL out"))); |
|
49 return self; |
|
50 } |
|
51 |
|
52 |
|
53 // ----------------------------------------------------------------------------- |
|
54 // CCamZoomUpdateManager::CCamZoomUpdateManager |
|
55 // C++ default constructor can NOT contain any code, that |
|
56 // might leave. |
|
57 // ----------------------------------------------------------------------------- |
|
58 // |
|
59 CCamZoomUpdateManager::CCamZoomUpdateManager( CCamAppController& aController ) : |
|
60 CActive( /*EPriorityStandard*/ EPriorityUserInput ), |
|
61 iController( aController ) |
|
62 { |
|
63 iDelayedUpdate = EFalse; |
|
64 } |
|
65 |
|
66 // ----------------------------------------------------------------------------- |
|
67 // CCamZoomUpdateManager::~CCamZoomUpdateManager |
|
68 // Destructor. |
|
69 // ----------------------------------------------------------------------------- |
|
70 // |
|
71 |
|
72 CCamZoomUpdateManager::~CCamZoomUpdateManager() |
|
73 { |
|
74 PRINT((_L("CCamZoomUpdateManager::~CCamZoomUpdateManager() in"))); |
|
75 Cancel(); |
|
76 iTimer.Close(); |
|
77 PRINT((_L("CCamZoomUpdateManager::~CCamZoomUpdateManager() out"))); |
|
78 } |
|
79 |
|
80 // ----------------------------------------------------------------------------- |
|
81 // CCamZoomUpdateTimer::ConstructL |
|
82 // Symbian 2nd phase constructor. |
|
83 // ----------------------------------------------------------------------------- |
|
84 // |
|
85 void CCamZoomUpdateManager::ConstructL() |
|
86 { |
|
87 PRINT((_L("CCamZoomUpdateManager::ConstructL() in"))); |
|
88 TRAPD( err, ReadDelayValuesL() ); |
|
89 if( err ) |
|
90 { |
|
91 PRINT((_L("CCamZoomUpdateManager::ConstructL() error in reading delay values"))); |
|
92 } |
|
93 User::LeaveIfError(iTimer.CreateLocal()); |
|
94 CActiveScheduler::Add(this); |
|
95 PRINT((_L("CCamZoomUpdateManager::ConstructL() out"))); |
|
96 } |
|
97 |
|
98 // ----------------------------------------------------------------------------- |
|
99 // CCamZoomUpdateManager::SetZoomValue |
|
100 // |
|
101 // ----------------------------------------------------------------------------- |
|
102 // |
|
103 void CCamZoomUpdateManager::SetZoomValue( TInt aValue ) |
|
104 { |
|
105 PRINT((_L("CCamZoomUpdateManager::SetZoomValue() => in"))); |
|
106 |
|
107 // PUT IN MUTEX???? |
|
108 |
|
109 // update value |
|
110 iValue = aValue; |
|
111 |
|
112 if ( IsActive() ) |
|
113 { |
|
114 // check for starvation |
|
115 TTime current; |
|
116 current.UniversalTime(); |
|
117 TInt64 delay = current.MicroSecondsFrom(iCooldownStart).Int64(); |
|
118 |
|
119 if ( delay > iCamMaxZoomCooldown ) |
|
120 { |
|
121 PRINT((_L("CCamZoomUpdateManager::SetZoomValue() <> IsActive, starved"))); |
|
122 |
|
123 // force update if active object is starved |
|
124 Cancel(); |
|
125 UpdateAndStartWait(); |
|
126 } |
|
127 else |
|
128 { |
|
129 PRINT((_L("CCamZoomUpdateManager::SetZoomValue() <> IsActive, updating iValue"))); |
|
130 |
|
131 // set the delayed update flag and wait |
|
132 iDelayedUpdate = ETrue; |
|
133 } |
|
134 } |
|
135 else |
|
136 { |
|
137 PRINT((_L("CCamZoomUpdateManager::SetZoomValue() <> IsNotActive, setting zoom"))); |
|
138 |
|
139 // notify controller and set active |
|
140 UpdateAndStartWait(); |
|
141 } |
|
142 |
|
143 PRINT((_L("CCamZoomUpdateManager::SetZoomValue() <= out"))); |
|
144 } |
|
145 |
|
146 // ----------------------------------------------------------------------------- |
|
147 // CCamZoomUpdateManager::UpdateAndStartWait |
|
148 // |
|
149 // ----------------------------------------------------------------------------- |
|
150 // |
|
151 void CCamZoomUpdateManager::UpdateAndStartWait() |
|
152 { |
|
153 // update cooldown start time |
|
154 iCooldownStart.UniversalTime(); |
|
155 |
|
156 // reset delayed update flag |
|
157 iDelayedUpdate = EFalse; |
|
158 |
|
159 // notify iController |
|
160 iController.SetZoomValue( iValue ); |
|
161 |
|
162 // activate cooldown period |
|
163 SetActive(); |
|
164 iTimer.After( iStatus, iCamZoomCooldown ); |
|
165 } |
|
166 |
|
167 // ----------------------------------------------------------------------------- |
|
168 // CCamZoomUpdateManager::RunL |
|
169 // |
|
170 // ----------------------------------------------------------------------------- |
|
171 // |
|
172 void CCamZoomUpdateManager::RunL() |
|
173 { |
|
174 PRINT((_L("CCamZoomUpdateManager::RunL() in"))); |
|
175 |
|
176 //PUT IN MUTEX?? |
|
177 |
|
178 if ( iDelayedUpdate ) |
|
179 { |
|
180 // notify controller and set active |
|
181 UpdateAndStartWait(); |
|
182 } |
|
183 |
|
184 PRINT((_L("CCamZoomUpdateManager::RunL() out"))); |
|
185 } |
|
186 |
|
187 // ----------------------------------------------------------------------------- |
|
188 // CCamZoomUpdateManager::DoCancel |
|
189 // Cancels the timer |
|
190 // ----------------------------------------------------------------------------- |
|
191 // |
|
192 void CCamZoomUpdateManager::DoCancel() |
|
193 { |
|
194 PRINT((_L("CCamZoomUpdateManager::DoCancel() in"))); |
|
195 // cancel the timer |
|
196 iTimer.Cancel(); |
|
197 PRINT((_L("CCamZoomUpdateManager::DoCancel() out"))); |
|
198 } |
|
199 |
|
200 // ----------------------------------------------------------------------------- |
|
201 // CCamZoomUpdateManager::ReadDelayValuesL |
|
202 // Gets delay values from cenrep |
|
203 // ----------------------------------------------------------------------------- |
|
204 // |
|
205 void CCamZoomUpdateManager::ReadDelayValuesL() |
|
206 { |
|
207 // default values are used in case of error |
|
208 iCamZoomCooldown = KCamZoomCooldown; |
|
209 iCamMaxZoomCooldown = KCamMaxZoomCooldown; |
|
210 RArray<TInt> delayValues; |
|
211 if( iController.UiConfigManagerPtr() ) |
|
212 { |
|
213 iController.UiConfigManagerPtr()->SupportedZoomDelaysL( delayValues ); |
|
214 iCamZoomCooldown = delayValues[0]*1000; |
|
215 iCamMaxZoomCooldown = delayValues[1]*1000; |
|
216 } |
|
217 } |
|
218 // End of File |
|