1 /* |
|
2 * Copyright (c) 2005-2007 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: Group for effect controls |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <logger.h> |
|
21 #include "cammseffectcontrolgroup.h" |
|
22 #include "cammseffectcontrol.h" |
|
23 |
|
24 |
|
25 // ============================ MEMBER FUNCTIONS =============================== |
|
26 |
|
27 // Destructor |
|
28 CAMMSEffectControlGroup::~CAMMSEffectControlGroup() |
|
29 { |
|
30 LOG( EJavaAMMS, EInfo, "AMMS::CAMMSEffectControlGroup::~ +"); |
|
31 |
|
32 delete iPresetNames; |
|
33 delete iActiveSchedulerWait; |
|
34 |
|
35 if (iEmptyPlayerUtility) |
|
36 { |
|
37 iEmptyPlayerUtility->Close(); |
|
38 delete iEmptyPlayerUtility; |
|
39 } |
|
40 |
|
41 LOG( EJavaAMMS, EInfo, "AMMS::CAMMSEffectControlGroup::~ -"); |
|
42 } |
|
43 |
|
44 // ----------------------------------------------------------------------------- |
|
45 // CAMMSEffectControlGroup::PresetL |
|
46 // Gets the current preset. |
|
47 // (other items were commented in a header). |
|
48 // ----------------------------------------------------------------------------- |
|
49 void CAMMSEffectControlGroup::GetPresetL(TDes& aPreset) |
|
50 { |
|
51 LOG( EJavaAMMS, EInfo, "AMMS::CAMMSEffectControlGroup::GetPresetL +"); |
|
52 |
|
53 // Return KNullDesC if no preset is set. |
|
54 if (iPresetIndex >= 0) |
|
55 { |
|
56 aPreset = (*iPresetNames)[ iPresetIndex ]; // CSI: 2 Wrong index means implementation error # |
|
57 } |
|
58 else |
|
59 { |
|
60 aPreset = KNullDesC; |
|
61 } |
|
62 |
|
63 LOG( EJavaAMMS, EInfo, "AMMS::CAMMSEffectControlGroup::GetPresetL -"); |
|
64 } |
|
65 |
|
66 // ----------------------------------------------------------------------------- |
|
67 // CAMMSEffectControlGroup::PresetNamesL |
|
68 // Gets the available preset names |
|
69 // (other items were commented in a header). |
|
70 // ----------------------------------------------------------------------------- |
|
71 const CDesCArray& CAMMSEffectControlGroup::PresetNamesL() |
|
72 { |
|
73 LOG( EJavaAMMS, EInfo, "AMMS::CAMMSEffectControlGroup::PresetNamesL"); |
|
74 |
|
75 return *iPresetNames; |
|
76 } |
|
77 |
|
78 // ----------------------------------------------------------------------------- |
|
79 // CAMMSEffectControlGroup::Scope |
|
80 // Returns the scope in which the effect is present. |
|
81 // (other items were commented in a header). |
|
82 // ----------------------------------------------------------------------------- |
|
83 CAMMSEffectControlGroup::TEffectScope CAMMSEffectControlGroup::Scope() |
|
84 { |
|
85 return iScope; |
|
86 } |
|
87 |
|
88 // ----------------------------------------------------------------------------- |
|
89 // CAMMSEffectControlGroup::Enabled |
|
90 // Returns true if the effect is enabled and false otherwise. |
|
91 // (other items were commented in a header). |
|
92 // ----------------------------------------------------------------------------- |
|
93 TBool CAMMSEffectControlGroup::Enabled() |
|
94 { |
|
95 return iEnabled; |
|
96 } |
|
97 |
|
98 // ----------------------------------------------------------------------------- |
|
99 // CAMMSEffectControlGroup::EnforcedL |
|
100 // Returns the current enforced setting of the effect. |
|
101 // (other items were commented in a header). |
|
102 // ----------------------------------------------------------------------------- |
|
103 TBool CAMMSEffectControlGroup::Enforced() |
|
104 { |
|
105 return iEnforced; |
|
106 } |
|
107 |
|
108 // ----------------------------------------------------------------------------- |
|
109 // CAMMSEffectControlGroup::SetEnabledL |
|
110 // Enables/disables the effect. |
|
111 // (other items were commented in a header). |
|
112 // ----------------------------------------------------------------------------- |
|
113 void CAMMSEffectControlGroup::SetEnabledL(TBool aEnabled) |
|
114 { |
|
115 LOG( EJavaAMMS, EInfo, "AMMS::CAMMSEffectControlGroup::SetEnabledL +"); |
|
116 |
|
117 TInt count = ControlCount(); |
|
118 for (TInt i = 0; i < count; i++) |
|
119 { |
|
120 TypeSafeControl(i)->SetEnabledL(aEnabled); |
|
121 } |
|
122 |
|
123 iEnabled = aEnabled; |
|
124 |
|
125 LOG( EJavaAMMS, EInfo, "AMMS::CAMMSEffectControlGroup::SetEnabledL -"); |
|
126 } |
|
127 |
|
128 // ----------------------------------------------------------------------------- |
|
129 // CAMMSEffectControlGroup::SetEnforcedL |
|
130 // Enforces the effect to be in use. |
|
131 // (other items were commented in a header). |
|
132 // ----------------------------------------------------------------------------- |
|
133 void CAMMSEffectControlGroup::SetEnforcedL(TBool aEnforced) |
|
134 { |
|
135 LOG( EJavaAMMS, EInfo, "AMMS::CAMMSEffectControlGroup::SetEnforcedL +"); |
|
136 |
|
137 TInt count = ControlCount(); |
|
138 for (TInt i = 0; i < count; i++) |
|
139 { |
|
140 TypeSafeControl(i)->SetEnforcedL(aEnforced); |
|
141 } |
|
142 |
|
143 iEnforced = aEnforced; |
|
144 |
|
145 // remember that enforce was set when the group was not yet initialized |
|
146 if (!iInitialized) |
|
147 { |
|
148 iInitialEnforceSet = ETrue; |
|
149 } |
|
150 |
|
151 LOG( EJavaAMMS, EInfo, "AMMS::CAMMSEffectControlGroup::SetEnforcedL -"); |
|
152 } |
|
153 |
|
154 // ----------------------------------------------------------------------------- |
|
155 // CAMMSEffectControlGroup::SetPresetL |
|
156 // Sets the effect according to the given preset. |
|
157 // (other items were commented in a header). |
|
158 // ----------------------------------------------------------------------------- |
|
159 void CAMMSEffectControlGroup::SetPresetL(const TDesC& aPreset) |
|
160 { |
|
161 LOG( EJavaAMMS, EInfo, "AMMS::CAMMSEffectControlGroup::SetPresetL +"); |
|
162 |
|
163 // Leave if the given preset does not exist. |
|
164 TInt presetIndex = -1; |
|
165 if (!(iPresetNames->Find(aPreset, presetIndex) == 0)) |
|
166 { |
|
167 User::Leave(KErrNotFound); |
|
168 } |
|
169 |
|
170 // Set new preset to the controls. |
|
171 TInt count = ControlCount(); |
|
172 for (TInt i = 0; i < count; i++) |
|
173 { |
|
174 TypeSafeControl(i)->SetPresetL(aPreset); |
|
175 } |
|
176 |
|
177 // Change preset. |
|
178 iPresetIndex = presetIndex; |
|
179 |
|
180 // Announce a preset change. |
|
181 PresetChangedL(); |
|
182 |
|
183 LOG( EJavaAMMS, EInfo, "AMMS::CAMMSEffectControlGroup::SetPresetL -"); |
|
184 } |
|
185 |
|
186 // ----------------------------------------------------------------------------- |
|
187 // CAMMSEffectControlGroup::SetScopeL |
|
188 // Sets the scope of the effect. |
|
189 // (other items were commented in a header). |
|
190 // ----------------------------------------------------------------------------- |
|
191 void CAMMSEffectControlGroup::SetScopeL(TEffectScope aScope) |
|
192 { |
|
193 LOG( EJavaAMMS, EInfo, "AMMS::CAMMSEffectControlGroup::SetScopeL +"); |
|
194 |
|
195 TInt count = ControlCount(); |
|
196 for (TInt i = 0; i < count; i++) |
|
197 { |
|
198 TypeSafeControl(i)->SetScopeL(aScope); |
|
199 } |
|
200 |
|
201 iScope = aScope; |
|
202 |
|
203 // remember that scope was set when the group was not yet initialized |
|
204 if (!iInitialized) |
|
205 { |
|
206 iInitialScopeSet = ETrue; |
|
207 } |
|
208 |
|
209 LOG( EJavaAMMS, EInfo, "AMMS::CAMMSEffectControlGroup::SetScopeL -"); |
|
210 } |
|
211 |
|
212 |
|
213 // ----------------------------------------------------------------------------- |
|
214 // CAMMSEffectControlGroup::MapcInitComplete |
|
215 // Called when file KAMMSEmptyGroupSoundPath has been opened. |
|
216 // (other items were commented in a header). |
|
217 // ----------------------------------------------------------------------------- |
|
218 void CAMMSEffectControlGroup::MapcInitComplete(TInt aError, |
|
219 const TTimeIntervalMicroSeconds& /*aDuration*/) |
|
220 { |
|
221 LOG( EJavaAMMS, EInfo, "AMMS::CAMMSEffectControlGroup::MapcInitComplete +"); |
|
222 |
|
223 __ASSERT_DEBUG(iActiveSchedulerWait->IsStarted(), User::Invariant()); |
|
224 |
|
225 iEmptyPlayerUtilityError = aError; |
|
226 |
|
227 // Stop waiting in PrepareEmptyGroupUtilityL() function. |
|
228 iActiveSchedulerWait->AsyncStop(); |
|
229 |
|
230 LOG( EJavaAMMS, EInfo, "AMMS::CAMMSEffectControlGroup::MapcInitComplete -"); |
|
231 } |
|
232 |
|
233 // ----------------------------------------------------------------------------- |
|
234 // CAMMSEffectControlGroup::MapcPlayComplete |
|
235 // Called when KAMMSEmptyGroupSoundPath has been played. |
|
236 // (other items were commented in a header). |
|
237 // ----------------------------------------------------------------------------- |
|
238 void CAMMSEffectControlGroup::MapcPlayComplete(TInt /*aError*/) |
|
239 { |
|
240 // No implementation needed. |
|
241 } |
|
242 |
|
243 // ----------------------------------------------------------------------------- |
|
244 // CAMMSEffectControlGroup::TypeSafeControl |
|
245 // Gets control. Ownership is not tranferred. |
|
246 // (other items were commented in a header). |
|
247 // ----------------------------------------------------------------------------- |
|
248 CAMMSEffectControl* |
|
249 CAMMSEffectControlGroup::TypeSafeControl(TInt aIndex) const |
|
250 { |
|
251 return static_cast<CAMMSEffectControl*>(Control(aIndex)); |
|
252 } |
|
253 |
|
254 // ----------------------------------------------------------------------------- |
|
255 // CAMMSEffectControlGroup::NotifyPlayerAddedL |
|
256 // Called by when a new player is added |
|
257 // (other items were commented in a header). |
|
258 // ----------------------------------------------------------------------------- |
|
259 void CAMMSEffectControlGroup::NotifyPlayerAddedL( |
|
260 CMMAPlayer *aPlayer, |
|
261 CMMAControl* aControl) |
|
262 { |
|
263 LOG( EJavaAMMS, EInfo, "AMMS::CAMMSEffectControlGroup::NotifyPlayerAddedL +"); |
|
264 |
|
265 CAMMSControlGroup::NotifyPlayerAddedL(aPlayer, aControl); |
|
266 |
|
267 CAMMSEffectControl* control = |
|
268 static_cast<CAMMSEffectControl*>(aControl); |
|
269 |
|
270 // set current preset if any |
|
271 if (iPresetIndex >= 0) |
|
272 { |
|
273 control->SetPresetL((*iPresetNames)[ iPresetIndex ]); // CSI: 2 Wrong index means implementation error # |
|
274 } |
|
275 |
|
276 // handle default values if this is the first control added into empty and |
|
277 // uninitialized group |
|
278 if (!iInitialized) |
|
279 { |
|
280 |
|
281 InitializeL(); |
|
282 |
|
283 // if parameters, whose default values are not known, have not been set, |
|
284 // ask them from the first control added to the empty group |
|
285 if (!iInitialEnforceSet) |
|
286 { |
|
287 |
|
288 iEnforced = control->Enforced(); |
|
289 |
|
290 } |
|
291 |
|
292 if (!iInitialScopeSet) |
|
293 { |
|
294 |
|
295 iScope = (TEffectScope) control->Scope(); |
|
296 |
|
297 } |
|
298 |
|
299 iInitialized = ETrue; |
|
300 } |
|
301 |
|
302 // set current parameters |
|
303 |
|
304 control->SetEnabledL(iEnabled); |
|
305 |
|
306 control->SetEnforcedL(iEnforced); |
|
307 |
|
308 control->SetScopeL(iScope); |
|
309 |
|
310 LOG( EJavaAMMS, EInfo, "AMMS::CAMMSEffectControlGroup::NotifyPlayerAddedL -"); |
|
311 } |
|
312 |
|
313 // ----------------------------------------------------------------------------- |
|
314 // CAMMSEffectControlGroup::PresetChangedL |
|
315 // Called when the current preset changes |
|
316 // (other items were commented in a header). |
|
317 // ----------------------------------------------------------------------------- |
|
318 void CAMMSEffectControlGroup::PresetChangedL() |
|
319 { |
|
320 } |
|
321 |
|
322 // ----------------------------------------------------------------------------- |
|
323 // CAMMSEffectControlGroup::InitializeL |
|
324 // Finish initialization (after the 1st player is added) |
|
325 // (other items were commented in a header). |
|
326 // ----------------------------------------------------------------------------- |
|
327 void CAMMSEffectControlGroup::InitializeL() |
|
328 { |
|
329 } |
|
330 |
|
331 // ----------------------------------------------------------------------------- |
|
332 // CAMMSEffectControlGroup::PrepareEmptyGroupUtilitiesL |
|
333 // Creates an utilities that can be used to obtain preset names and preset data. |
|
334 // (other items were commented in a header). |
|
335 // ----------------------------------------------------------------------------- |
|
336 void CAMMSEffectControlGroup::PrepareEmptyGroupUtilitiesL() |
|
337 { |
|
338 LOG( EJavaAMMS, EInfo, "AMMS::CAMMSEffectControlGroup::PrepareEmptyGroupUtilitiesL +"); |
|
339 |
|
340 if (!iEmptyPlayerUtility) |
|
341 { |
|
342 iEmptyPlayerUtility = CMdaAudioPlayerUtility::NewL(*this, |
|
343 EMdaPriorityMin, EMdaPriorityPreferenceNone); |
|
344 |
|
345 iEmptyPlayerUtility->OpenFileL(KAMMSEmptyGroupSoundPath); |
|
346 |
|
347 __ASSERT_DEBUG(!iActiveSchedulerWait->IsStarted(), User::Invariant()); |
|
348 |
|
349 // Wait until MapcInitComplete() has been called. |
|
350 iActiveSchedulerWait->Start(); // CSI: 10 iActiveSchedulerWait cannot be started, also checked in debug build # |
|
351 |
|
352 ELOG1( EJavaAMMS, |
|
353 "AMMS::CAMMSEffectControlGroup::PrepareEmptyGroupUtilitiesL, err=%d", |
|
354 iEmptyPlayerUtilityError); |
|
355 |
|
356 // Leave if file opening returned an error. |
|
357 User::LeaveIfError(iEmptyPlayerUtilityError); |
|
358 } |
|
359 |
|
360 LOG( EJavaAMMS, EInfo, "AMMS::CAMMSEffectControlGroup::PrepareEmptyGroupUtilitiesL -"); |
|
361 } |
|
362 |
|
363 // ----------------------------------------------------------------------------- |
|
364 // CAMMSEffectControlGroup::DeleteEmptyGroupUtilities |
|
365 // Deletes utilities that are used to obtain preset names and preset data. |
|
366 // (other items were commented in a header). |
|
367 // ----------------------------------------------------------------------------- |
|
368 void CAMMSEffectControlGroup::DeleteEmptyGroupUtilities() |
|
369 { |
|
370 LOG( EJavaAMMS, EInfo, "AMMS::CAMMSEffectControlGroup::DeleteEmptyGroupUtilities +"); |
|
371 |
|
372 if (iEmptyPlayerUtility) |
|
373 { |
|
374 iEmptyPlayerUtility->Close(); |
|
375 |
|
376 delete iEmptyPlayerUtility; |
|
377 iEmptyPlayerUtility = NULL; |
|
378 } |
|
379 |
|
380 LOG( EJavaAMMS, EInfo, "AMMS::CAMMSEffectControlGroup::DeleteEmptyGroupUtilities -"); |
|
381 } |
|
382 |
|
383 // ----------------------------------------------------------------------------- |
|
384 // CAMMSEffectControlGroup::CAMMSEffectControlGroup |
|
385 // C++ default constructor can NOT contain any code, that |
|
386 // might leave. |
|
387 // (other items were commented in a header). |
|
388 // ----------------------------------------------------------------------------- |
|
389 CAMMSEffectControlGroup::CAMMSEffectControlGroup(const TDesC& aName) : |
|
390 CAMMSControlGroup(aName) |
|
391 { |
|
392 iScope = CAMMSEffectControlGroup::EScopeLiveOnly; |
|
393 iEnabled = EFalse; |
|
394 iEnforced = ETrue; |
|
395 iPresetIndex = -1; // no preset set |
|
396 } |
|
397 |
|
398 // ----------------------------------------------------------------------------- |
|
399 // CAMMSEffectControlGroup::ConstructL |
|
400 // Symbian 2nd phase constructor can leave. |
|
401 // (other items were commented in a header). |
|
402 // ----------------------------------------------------------------------------- |
|
403 void CAMMSEffectControlGroup::BaseConstructL() |
|
404 { |
|
405 LOG( EJavaAMMS, EInfo, "AMMS::CAMMSEffectControlGroup::BaseConstructL +"); |
|
406 |
|
407 CAMMSControlGroup::ConstructL(); |
|
408 |
|
409 iActiveSchedulerWait = new(ELeave)CActiveSchedulerWait; |
|
410 iPresetNames = new(ELeave)CDesCArrayFlat(KAMMSPresetGranularity); |
|
411 |
|
412 // If the Effect API implementation does not support the effect, |
|
413 // the function leaves with KErrNotSupported. The leaving can be ignored |
|
414 // in this case, the result is that the list of supported presets |
|
415 // remain empty. |
|
416 TRAPD(err, GetPresetNamesL(*iPresetNames)); |
|
417 |
|
418 ELOG1( EJavaAMMS, "AMMS::CAMMSEffectControlGroup::BaseConstructL, err %d", err); |
|
419 |
|
420 // In case of an error, delete possible utilities to save memory. |
|
421 if (err != KErrNone) |
|
422 { |
|
423 DeleteEmptyGroupUtilities(); |
|
424 } |
|
425 |
|
426 // Leave if some error occured (other than KErrNotSupported). |
|
427 if ((err != KErrNone) && (err != KErrNotSupported)) |
|
428 { |
|
429 User::Leave(err); |
|
430 } |
|
431 |
|
432 |
|
433 LOG( EJavaAMMS, EInfo, "AMMS::CAMMSEffectControlGroup::BaseConstructL -"); |
|
434 } |
|
435 |
|
436 // End of File |
|