|
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: Project file for EnhancedMediaClient Utility |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "StereoWideningEffectImpl.h" |
|
20 #include <StereoWideningBase.h> |
|
21 #include <ControlObserver.h> |
|
22 |
|
23 using namespace multimedia; |
|
24 |
|
25 CStereoWideningEffect::CStereoWideningEffect() |
|
26 { |
|
27 // No Impl |
|
28 } |
|
29 |
|
30 CStereoWideningEffect::~CStereoWideningEffect() |
|
31 { |
|
32 delete iPrevStereoWideningProxy; |
|
33 delete iStereoWideningProxy; |
|
34 iObservers.Close(); |
|
35 } |
|
36 |
|
37 TInt CStereoWideningEffect::PostConstructor() |
|
38 { |
|
39 TRAPD( status, CEffectControlBase::ConstructL(KUidStereoWideningEffect) ); |
|
40 return status; |
|
41 } |
|
42 |
|
43 // From MControl begins |
|
44 TInt CStereoWideningEffect::AddObserver( MControlObserver& aObserver ) |
|
45 { |
|
46 return iObservers.Append(&aObserver); |
|
47 } |
|
48 |
|
49 TInt CStereoWideningEffect::RemoveObserver( MControlObserver& aObserver ) |
|
50 { |
|
51 TInt index = iObservers.Find(&aObserver); |
|
52 if( index != KErrNotFound ) |
|
53 { |
|
54 iObservers.Remove(index); |
|
55 } |
|
56 return index; |
|
57 } |
|
58 |
|
59 TUid CStereoWideningEffect::Type() |
|
60 { |
|
61 return KStereoWideningEffectControl; |
|
62 } |
|
63 |
|
64 TControlType CStereoWideningEffect::ControlType() |
|
65 { |
|
66 return EEffectControl; |
|
67 } |
|
68 |
|
69 // From MControl ends |
|
70 |
|
71 // From MEffectControl begins |
|
72 TInt CStereoWideningEffect::Apply() |
|
73 { |
|
74 return DoApply(); |
|
75 } |
|
76 |
|
77 // From MEffectControl ends |
|
78 |
|
79 TInt CStereoWideningEffect::DoApply() |
|
80 { |
|
81 TInt error(KErrNone); |
|
82 if(iStereoWideningProxy) |
|
83 { |
|
84 TRAP(error,iStereoWideningProxy->ApplyL()); |
|
85 } |
|
86 else |
|
87 { |
|
88 error = KErrNotReady; |
|
89 } |
|
90 return error; |
|
91 } |
|
92 |
|
93 // From MStereoWideningEffect begins |
|
94 /** |
|
95 * Check if continuous level is supported for stereo widening. |
|
96 * @since 5.0 |
|
97 * @param ETrue if continuous level is supported for stereo widening. If this returns |
|
98 * EFalse, then the adaptation is actually setting the level to the nearest supported discrete |
|
99 * value, when SetStereoWidenlingLevelL is called. |
|
100 * @return Error Code |
|
101 */ |
|
102 TInt CStereoWideningEffect::IsContinuousLevelSupported(TBool& aSupported) |
|
103 { |
|
104 TInt status(KErrNone); |
|
105 if(iStereoWideningProxy) |
|
106 { |
|
107 aSupported = iStereoWideningProxy->IsContinuousLevelSupported(); |
|
108 } |
|
109 else |
|
110 { |
|
111 status = KErrNotReady; |
|
112 } |
|
113 return status; |
|
114 } |
|
115 |
|
116 /** |
|
117 * Set stereo widening level. |
|
118 * @since 5.0 |
|
119 * @param aLevel Stereo widening level ranges from 0-100, where 0 is None and 100 is Maximum widening. |
|
120 */ |
|
121 TInt CStereoWideningEffect::SetStereoWideningLevel( TInt aLevel ) |
|
122 { |
|
123 TInt status(KErrNone); |
|
124 if(iStereoWideningProxy) |
|
125 { |
|
126 TRAP(status,iStereoWideningProxy->SetStereoWideningLevelL(aLevel)); |
|
127 } |
|
128 else |
|
129 { |
|
130 status = KErrNotReady; |
|
131 } |
|
132 return status; |
|
133 } |
|
134 |
|
135 /** |
|
136 * Get the stereo widening settings. |
|
137 * @since 5.0 |
|
138 * @param aLevel Gets the Current Stereo widening level |
|
139 * @return Error Code |
|
140 */ |
|
141 TInt CStereoWideningEffect::StereoWideningLevel(TInt& aLevel) |
|
142 { |
|
143 TInt status(KErrNone); |
|
144 if(iStereoWideningProxy) |
|
145 { |
|
146 aLevel = iStereoWideningProxy->StereoWideningLevel(); |
|
147 } |
|
148 else |
|
149 { |
|
150 status = KErrNotReady; |
|
151 } |
|
152 return status; |
|
153 } |
|
154 |
|
155 // From MStereoWideningEffect ends |
|
156 |
|
157 // From MAudioEffectControl |
|
158 /** |
|
159 * Disable the effect |
|
160 * @since 5.0 |
|
161 */ |
|
162 TInt CStereoWideningEffect::Disable() |
|
163 { |
|
164 TInt status(KErrNone); |
|
165 if(iStereoWideningProxy) |
|
166 { |
|
167 TRAP(status,iStereoWideningProxy->DisableL()); |
|
168 } |
|
169 else |
|
170 { |
|
171 status = KErrNotReady; |
|
172 } |
|
173 return status; |
|
174 } |
|
175 |
|
176 /** |
|
177 * Enable the effect |
|
178 * @since 5.0 |
|
179 */ |
|
180 TInt CStereoWideningEffect::Enable() |
|
181 { |
|
182 TInt status(KErrNone); |
|
183 RDebug::Print(_L("CStereoWideningEffect::Enable() [%x]"),iStereoWideningProxy); |
|
184 if(iStereoWideningProxy) |
|
185 { |
|
186 TRAP(status,iStereoWideningProxy->EnableL()); |
|
187 } |
|
188 else |
|
189 { |
|
190 status = KErrNotReady; |
|
191 } |
|
192 return status; |
|
193 } |
|
194 |
|
195 /** |
|
196 * Enforce the effect. |
|
197 * @since 5.0 |
|
198 * @param aEnforced Indicate the effect is to be enforced or not. ETrue = Enforced. |
|
199 */ |
|
200 TInt CStereoWideningEffect::Enforce( TBool &aEnforced ) |
|
201 { |
|
202 TInt status(KErrNone); |
|
203 if(iStereoWideningProxy) |
|
204 { |
|
205 TRAP(status,iStereoWideningProxy->EnforceL(aEnforced)); |
|
206 } |
|
207 else |
|
208 { |
|
209 status = KErrNotReady; |
|
210 } |
|
211 return status; |
|
212 } |
|
213 |
|
214 /** |
|
215 * Check if this effect object currently has update rights. |
|
216 * A client can lose update rights in some hardware platforms where there are a limited |
|
217 * number of instances of an effect that can exist at the same time. When an effect instance |
|
218 * has lost update rights the user can still change settings, but any calls to Apply the |
|
219 * settings will be deferred until update rights are regained. |
|
220 * @since 5.0 |
|
221 * @return ETrue if this object currently has rights to update the settings of this effect, |
|
222 * EFalse otherwise. |
|
223 */ |
|
224 TInt CStereoWideningEffect::HaveUpdateRights(TBool &aHaveUpdateRights) |
|
225 { |
|
226 TInt status(KErrNone); |
|
227 if(iStereoWideningProxy) |
|
228 { |
|
229 aHaveUpdateRights = iStereoWideningProxy->HaveUpdateRights(); |
|
230 } |
|
231 else |
|
232 { |
|
233 status = KErrNotReady; |
|
234 } |
|
235 return status; |
|
236 } |
|
237 |
|
238 /** |
|
239 * Check if the effect is enabled |
|
240 * @since 5.0 |
|
241 * @return ETrue if the effect is enabled, EFalse if the effect is disabled. |
|
242 */ |
|
243 TInt CStereoWideningEffect::IsEnabled(TBool &aEnabled) |
|
244 { |
|
245 TInt status(KErrNone); |
|
246 if(iStereoWideningProxy) |
|
247 { |
|
248 aEnabled = iStereoWideningProxy->IsEnabled(); |
|
249 } |
|
250 else |
|
251 { |
|
252 status = KErrNotReady; |
|
253 } |
|
254 return status; |
|
255 } |
|
256 |
|
257 /** |
|
258 * Check if the effect is enforced. |
|
259 * @since 5.0 |
|
260 * @return ETrue if the effect is enforced, EFalse if the effect isn ot enforced. |
|
261 */ |
|
262 TInt CStereoWideningEffect::IsEnforced(TBool &aEnforced) |
|
263 { |
|
264 TInt status(KErrNone); |
|
265 if(iStereoWideningProxy) |
|
266 { |
|
267 aEnforced = iStereoWideningProxy->IsEnforced(); |
|
268 } |
|
269 else |
|
270 { |
|
271 status = KErrNotReady; |
|
272 } |
|
273 return status; |
|
274 } |
|
275 |
|
276 /* |
|
277 * Get the unique identifier of the audio effect |
|
278 * @since 5.0 |
|
279 * @return Unique identifier of the audio effect object. |
|
280 */ |
|
281 TInt CStereoWideningEffect::Uid(TUid &aUid) |
|
282 { |
|
283 TInt status(KErrNone); |
|
284 if(iStereoWideningProxy) |
|
285 { |
|
286 aUid = iStereoWideningProxy->Uid(); |
|
287 } |
|
288 else |
|
289 { |
|
290 status = KErrNotReady; |
|
291 } |
|
292 return status; |
|
293 } |
|
294 // From MAudioEffectControl Ends |
|
295 |
|
296 |
|
297 // From CEffectControlBase begins |
|
298 void CStereoWideningEffect::Event( TEffectControlEvent aEvent ) |
|
299 { |
|
300 TInt status(KErrNone); |
|
301 // Controller Loaded with ECIBuilderCreated |
|
302 if ( aEvent == ECIBuilderCreated ) |
|
303 { |
|
304 RDebug::Print(_L("Deleting Proxy")); |
|
305 status = DeleteEffectProxy(); |
|
306 RDebug::Print(_L("Deleting Proxy [%d]"),status); |
|
307 status = CreateEffectProxy(); |
|
308 RDebug::Print(_L("Creating Proxy [%d]"),status); |
|
309 if(status == KErrNone) |
|
310 { |
|
311 SavePreviousSettings(); |
|
312 } |
|
313 else |
|
314 { |
|
315 for ( TInt i = 0; i < iObservers.Count(); i++ ) |
|
316 { |
|
317 iObservers[i]->Event(this,MAudioEffectControl::KDisabled,NULL); |
|
318 } |
|
319 } |
|
320 } |
|
321 else if ( aEvent == EMessageHandlerDeleted ) |
|
322 { |
|
323 if(status == KErrNone) |
|
324 { |
|
325 DeleteEffectProxy(); |
|
326 } |
|
327 } |
|
328 } |
|
329 |
|
330 // From CEffectControlBase ends |
|
331 |
|
332 TInt CStereoWideningEffect::CreateEffectProxy() |
|
333 { |
|
334 TInt status(KErrNone); |
|
335 status = GetMessageHandle(iMsgHndlrHandlePckg); |
|
336 if(status != KErrNone) |
|
337 { |
|
338 return status; |
|
339 } |
|
340 iCustomCommand = GetCustomCommand(); |
|
341 if(!iCustomCommand) |
|
342 { |
|
343 return KErrNotReady; |
|
344 } |
|
345 |
|
346 TRAP(status,iStereoWideningProxy = CStereoWideningProxy::NewL(iMsgHndlrHandlePckg, *iCustomCommand, NULL)); |
|
347 if(status == KErrNone) |
|
348 { |
|
349 TRAP(status,iStereoWideningProxy->RegisterObserverL(*this)); |
|
350 } |
|
351 |
|
352 return status; |
|
353 } |
|
354 |
|
355 TInt CStereoWideningEffect::DeleteEffectProxy() |
|
356 { |
|
357 TInt status(KErrNone); |
|
358 if(iStereoWideningProxy) |
|
359 { |
|
360 iPrevStereoWideningProxy = iStereoWideningProxy; |
|
361 } |
|
362 iStereoWideningProxy = NULL; |
|
363 return status; |
|
364 } |
|
365 |
|
366 TInt CStereoWideningEffect::SavePreviousSettings() |
|
367 { |
|
368 TInt status(KErrNone); |
|
369 if(iPrevStereoWideningProxy) |
|
370 { |
|
371 TBool enforce = iPrevStereoWideningProxy->IsEnforced(); |
|
372 iStereoWideningProxy->EnforceL(enforce); |
|
373 |
|
374 TBool enable = iPrevStereoWideningProxy->IsEnabled(); |
|
375 if(enable) |
|
376 { |
|
377 iStereoWideningProxy->EnableL(); |
|
378 } |
|
379 |
|
380 delete iPrevStereoWideningProxy; |
|
381 iPrevStereoWideningProxy = NULL; |
|
382 } |
|
383 return status; |
|
384 } |
|
385 |
|
386 void CStereoWideningEffect::EffectChanged( const CAudioEffect* /*aObservedEffect*/, TUint8 aEvent ) |
|
387 { |
|
388 for ( TInt i = 0; i < iObservers.Count(); i++ ) |
|
389 { |
|
390 iObservers[i]->Event(this,aEvent,NULL); |
|
391 } |
|
392 } |
|
393 |
|
394 // End of file |