|
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 "BassBoostEffectImpl.h" |
|
20 #include <BassBoostBase.h> |
|
21 #include <ControlObserver.h> |
|
22 |
|
23 using namespace multimedia; |
|
24 |
|
25 CBassBoostEffect::CBassBoostEffect() |
|
26 { |
|
27 // No Impl |
|
28 } |
|
29 |
|
30 CBassBoostEffect::~CBassBoostEffect() |
|
31 { |
|
32 delete iPrevBassBoostProxy; |
|
33 delete iBassBoostProxy; |
|
34 iObservers.Close(); |
|
35 } |
|
36 |
|
37 TInt CBassBoostEffect::PostConstructor() |
|
38 { |
|
39 TRAPD( status, CEffectControlBase::ConstructL(KUidBassBoostEffect) ); |
|
40 return status; |
|
41 } |
|
42 |
|
43 // From MControl begins |
|
44 TInt CBassBoostEffect::AddObserver( MControlObserver& aObserver ) |
|
45 { |
|
46 return iObservers.Append(&aObserver); |
|
47 } |
|
48 |
|
49 TInt CBassBoostEffect::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 CBassBoostEffect::Type() |
|
60 { |
|
61 return KBassBoostEffectControl; |
|
62 } |
|
63 |
|
64 TControlType CBassBoostEffect::ControlType() |
|
65 { |
|
66 return EEffectControl; |
|
67 } |
|
68 |
|
69 // From MControl ends |
|
70 |
|
71 // From MEffectControl begins |
|
72 TInt CBassBoostEffect::Apply() |
|
73 { |
|
74 return DoApply(); |
|
75 } |
|
76 |
|
77 // From MEffectControl ends |
|
78 |
|
79 TInt CBassBoostEffect::DoApply() |
|
80 { |
|
81 TInt error(KErrNone); |
|
82 if(iBassBoostProxy) |
|
83 { |
|
84 TRAP(error,iBassBoostProxy->ApplyL()); |
|
85 } |
|
86 else |
|
87 { |
|
88 error = KErrNotReady; |
|
89 } |
|
90 return error; |
|
91 } |
|
92 |
|
93 // From MBassBoostEffect begins |
|
94 // From MBassBoostEffect ends |
|
95 |
|
96 // From MAudioEffectControl |
|
97 /** |
|
98 * Disable the effect |
|
99 * @since 5.0 |
|
100 */ |
|
101 TInt CBassBoostEffect::Disable() |
|
102 { |
|
103 TInt status(KErrNone); |
|
104 if(iBassBoostProxy) |
|
105 { |
|
106 TRAP(status,iBassBoostProxy->DisableL()); |
|
107 } |
|
108 else |
|
109 { |
|
110 status = KErrNotReady; |
|
111 } |
|
112 return status; |
|
113 } |
|
114 |
|
115 /** |
|
116 * Enable the effect |
|
117 * @since 5.0 |
|
118 */ |
|
119 TInt CBassBoostEffect::Enable() |
|
120 { |
|
121 TInt status(KErrNone); |
|
122 RDebug::Print(_L("CBassBoostEffect::Enable() [%x]"),iBassBoostProxy); |
|
123 if(iBassBoostProxy) |
|
124 { |
|
125 TRAP(status,iBassBoostProxy->EnableL()); |
|
126 } |
|
127 else |
|
128 { |
|
129 status = KErrNotReady; |
|
130 } |
|
131 return status; |
|
132 } |
|
133 |
|
134 /** |
|
135 * Enforce the effect. |
|
136 * @since 5.0 |
|
137 * @param aEnforced Indicate the effect is to be enforced or not. ETrue = Enforced. |
|
138 */ |
|
139 TInt CBassBoostEffect::Enforce( TBool &aEnforced ) |
|
140 { |
|
141 TInt status(KErrNone); |
|
142 if(iBassBoostProxy) |
|
143 { |
|
144 TRAP(status,iBassBoostProxy->EnforceL(aEnforced)); |
|
145 } |
|
146 else |
|
147 { |
|
148 status = KErrNotReady; |
|
149 } |
|
150 return status; |
|
151 } |
|
152 |
|
153 /** |
|
154 * Check if this effect object currently has update rights. |
|
155 * A client can lose update rights in some hardware platforms where there are a limited |
|
156 * number of instances of an effect that can exist at the same time. When an effect instance |
|
157 * has lost update rights the user can still change settings, but any calls to Apply the |
|
158 * settings will be deferred until update rights are regained. |
|
159 * @since 5.0 |
|
160 * @return ETrue if this object currently has rights to update the settings of this effect, |
|
161 * EFalse otherwise. |
|
162 */ |
|
163 TInt CBassBoostEffect::HaveUpdateRights(TBool &aHaveUpdateRights) |
|
164 { |
|
165 TInt status(KErrNone); |
|
166 if(iBassBoostProxy) |
|
167 { |
|
168 aHaveUpdateRights = iBassBoostProxy->HaveUpdateRights(); |
|
169 } |
|
170 else |
|
171 { |
|
172 status = KErrNotReady; |
|
173 } |
|
174 return status; |
|
175 } |
|
176 |
|
177 /** |
|
178 * Check if the effect is enabled |
|
179 * @since 5.0 |
|
180 * @return ETrue if the effect is enabled, EFalse if the effect is disabled. |
|
181 */ |
|
182 TInt CBassBoostEffect::IsEnabled(TBool &aEnabled) |
|
183 { |
|
184 TInt status(KErrNone); |
|
185 if(iBassBoostProxy) |
|
186 { |
|
187 aEnabled = iBassBoostProxy->IsEnabled(); |
|
188 } |
|
189 else |
|
190 { |
|
191 status = KErrNotReady; |
|
192 } |
|
193 return status; |
|
194 } |
|
195 |
|
196 /** |
|
197 * Check if the effect is enforced. |
|
198 * @since 5.0 |
|
199 * @return ETrue if the effect is enforced, EFalse if the effect isn ot enforced. |
|
200 */ |
|
201 TInt CBassBoostEffect::IsEnforced(TBool &aEnforced) |
|
202 { |
|
203 TInt status(KErrNone); |
|
204 if(iBassBoostProxy) |
|
205 { |
|
206 aEnforced = iBassBoostProxy->IsEnforced(); |
|
207 } |
|
208 else |
|
209 { |
|
210 status = KErrNotReady; |
|
211 } |
|
212 return status; |
|
213 } |
|
214 |
|
215 /* |
|
216 * Get the unique identifier of the audio effect |
|
217 * @since 5.0 |
|
218 * @return Unique identifier of the audio effect object. |
|
219 */ |
|
220 TInt CBassBoostEffect::Uid(TUid &aUid) |
|
221 { |
|
222 TInt status(KErrNone); |
|
223 if(iBassBoostProxy) |
|
224 { |
|
225 aUid = iBassBoostProxy->Uid(); |
|
226 } |
|
227 else |
|
228 { |
|
229 status = KErrNotReady; |
|
230 } |
|
231 return status; |
|
232 } |
|
233 // From MAudioEffectControl Ends |
|
234 |
|
235 |
|
236 // From CEffectControlBase begins |
|
237 void CBassBoostEffect::Event( TEffectControlEvent aEvent ) |
|
238 { |
|
239 TInt status(KErrNone); |
|
240 // Controller Loaded with ECIBuilderCreated |
|
241 if ( aEvent == ECIBuilderCreated ) |
|
242 { |
|
243 RDebug::Print(_L("Deleting Proxy")); |
|
244 status = DeleteEffectProxy(); |
|
245 RDebug::Print(_L("Deleting Proxy [%d]"),status); |
|
246 status = CreateEffectProxy(); |
|
247 RDebug::Print(_L("Creating Proxy [%d]"),status); |
|
248 if(status == KErrNone) |
|
249 { |
|
250 SavePreviousSettings(); |
|
251 } |
|
252 else |
|
253 { |
|
254 for ( TInt i = 0; i < iObservers.Count(); i++ ) |
|
255 { |
|
256 iObservers[i]->Event(this,MAudioEffectControl::KDisabled,NULL); |
|
257 } |
|
258 } |
|
259 } |
|
260 else if ( aEvent == EMessageHandlerDeleted ) |
|
261 { |
|
262 if(status == KErrNone) |
|
263 { |
|
264 DeleteEffectProxy(); |
|
265 } |
|
266 } |
|
267 } |
|
268 |
|
269 // From CEffectControlBase ends |
|
270 |
|
271 TInt CBassBoostEffect::CreateEffectProxy() |
|
272 { |
|
273 TInt status(KErrNone); |
|
274 status = GetMessageHandle(iMsgHndlrHandlePckg); |
|
275 if(status != KErrNone) |
|
276 { |
|
277 return status; |
|
278 } |
|
279 iCustomCommand = GetCustomCommand(); |
|
280 if(!iCustomCommand) |
|
281 { |
|
282 return KErrNotReady; |
|
283 } |
|
284 |
|
285 TRAP(status,iBassBoostProxy = CBassBoostProxy::NewL(iMsgHndlrHandlePckg, *iCustomCommand, NULL)); |
|
286 if(status == KErrNone) |
|
287 { |
|
288 TRAP(status,iBassBoostProxy->RegisterObserverL(*this)); |
|
289 } |
|
290 |
|
291 return status; |
|
292 } |
|
293 |
|
294 TInt CBassBoostEffect::DeleteEffectProxy() |
|
295 { |
|
296 TInt status(KErrNone); |
|
297 if(iBassBoostProxy) |
|
298 { |
|
299 iPrevBassBoostProxy = iBassBoostProxy; |
|
300 } |
|
301 iBassBoostProxy = NULL; |
|
302 return status; |
|
303 } |
|
304 |
|
305 TInt CBassBoostEffect::SavePreviousSettings() |
|
306 { |
|
307 TInt status(KErrNone); |
|
308 if(iPrevBassBoostProxy) |
|
309 { |
|
310 TBool enforce = iPrevBassBoostProxy->IsEnforced(); |
|
311 iBassBoostProxy->EnforceL(enforce); |
|
312 |
|
313 TBool enable = iPrevBassBoostProxy->IsEnabled(); |
|
314 if(enable) |
|
315 { |
|
316 iBassBoostProxy->EnableL(); |
|
317 } |
|
318 |
|
319 delete iPrevBassBoostProxy; |
|
320 iPrevBassBoostProxy = NULL; |
|
321 } |
|
322 return status; |
|
323 } |
|
324 |
|
325 void CBassBoostEffect::EffectChanged( const CAudioEffect* /*aObservedEffect*/, TUint8 aEvent ) |
|
326 { |
|
327 for ( TInt i = 0; i < iObservers.Count(); i++ ) |
|
328 { |
|
329 iObservers[i]->Event(this,aEvent,NULL); |
|
330 } |
|
331 } |
|
332 |
|
333 // End of file |