|
1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 |
|
17 |
|
18 #include "logicalaudiogaincontrol.h" |
|
19 #include "logicalaudiocodec.h" |
|
20 #include "logicalbuffersource.h" |
|
21 #include "logicalbuffersink.h" |
|
22 #include "logicalaudiodevicesink.h" |
|
23 #include "logicalaudiodevicesource.h" |
|
24 #include "logicalaudiostream.h" |
|
25 |
|
26 #include <mmf/server/sounddevice.h> |
|
27 #include <a3f/audioprocessingunittypeuids.h> |
|
28 #include <a3f/maudiocodec.h> |
|
29 #include <a3f/maudiocontext.h> |
|
30 #include "audiocontext.h" |
|
31 |
|
32 // TODO: Remove when the MMRC Extension mechanism is ready |
|
33 #include "mstreampositioncontrol.h" |
|
34 #include "mstreampositioncontrol.h" |
|
35 #include "audioprocessingunit.h" |
|
36 |
|
37 #include <ecom/implementationproxy.h> // For making it ECom plugin |
|
38 |
|
39 |
|
40 // Exported proxy for instantiation method resolution |
|
41 // Define the interface UIDs |
|
42 const TImplementationProxy ImplementationTable[] = |
|
43 { |
|
44 IMPLEMENTATION_PROXY_ENTRY(KAudioStreamUid, CLogicalAudioStream::NewL) |
|
45 }; |
|
46 |
|
47 EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount) |
|
48 { |
|
49 aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy); |
|
50 return ImplementationTable; |
|
51 } |
|
52 |
|
53 // --------------------------------------------------------------------------- |
|
54 // Constructor |
|
55 // --------------------------------------------------------------------------- |
|
56 // |
|
57 CLogicalAudioStream::CLogicalAudioStream() |
|
58 : CAudioStreamManager(), |
|
59 iCurrentState(EUninitialized), |
|
60 iMessageType(ERegisterStreamObserver) |
|
61 { |
|
62 TRACE_CREATE(); |
|
63 DP_CONTEXT(CLogicalAudioStream::CLogicalAudioStream *CD1*, CtxDevSound, DPLOCAL); |
|
64 DP_IN(); |
|
65 DP_OUT(); |
|
66 } |
|
67 |
|
68 // --------------------------------------------------------------------------- |
|
69 // CLogicalAudioStream::NewL |
|
70 // --------------------------------------------------------------------------- |
|
71 CLogicalAudioStream* CLogicalAudioStream::NewL(TUid /*aTypeId*/) |
|
72 { |
|
73 DP_STATIC_CONTEXT(CLogicalAudioStream::NewL *CD0*, CtxDevSound, DPLOCAL); |
|
74 DP_IN(); |
|
75 CLogicalAudioStream* self = new(ELeave)CLogicalAudioStream(); |
|
76 CleanupStack::PushL(self); |
|
77 self->ConstructL(); |
|
78 CleanupStack::Pop(self); |
|
79 DP0_RET(self, "0x%x"); |
|
80 } |
|
81 |
|
82 // --------------------------------------------------------------------------- |
|
83 // Second phase constructor |
|
84 // --------------------------------------------------------------------------- |
|
85 void CLogicalAudioStream::ConstructL() |
|
86 { |
|
87 DP_CONTEXT(CLogicalAudioStream::ConstructL *CD1*, CtxDevSound, DPLOCAL); |
|
88 DP_IN(); |
|
89 DP_OUT(); |
|
90 } |
|
91 |
|
92 // --------------------------------------------------------------------------- |
|
93 // Destructor |
|
94 // --------------------------------------------------------------------------- |
|
95 // |
|
96 CLogicalAudioStream::~CLogicalAudioStream() |
|
97 { |
|
98 DP_CONTEXT(CLogicalAudioStream::~CLogicalAudioStream *CD1*, CtxDevSound, DPLOCAL); |
|
99 DP_IN(); |
|
100 iAudioProcessingUnits.Close(); |
|
101 iCISupportObservers.Close(); |
|
102 DP_OUT(); |
|
103 } |
|
104 |
|
105 |
|
106 // From MAudioStream |
|
107 // --------------------------------------------------------------------------- |
|
108 // CLogicalAudioStream::Uninitialize |
|
109 // --------------------------------------------------------------------------- |
|
110 TInt CLogicalAudioStream::Uninitialize() |
|
111 { |
|
112 DP_CONTEXT(CLogicalAudioStream::Uninitialize *CD1*, CtxDevSound, DPLOCAL); |
|
113 DP_IN(); |
|
114 if (iCurrentState != EInitialized) |
|
115 { |
|
116 DP0_RET(KErrNotReady, "%d"); |
|
117 } |
|
118 |
|
119 iCurrentState = EUninitialized; |
|
120 DP0_RET(KErrNone, "%d"); |
|
121 } |
|
122 |
|
123 // --------------------------------------------------------------------------- |
|
124 // CLogicalAudioStream::Initialize |
|
125 // --------------------------------------------------------------------------- |
|
126 TInt CLogicalAudioStream::Initialize() |
|
127 { |
|
128 DP_CONTEXT(CLogicalAudioStream::Initialize *CD1*, CtxDevSound, DPLOCAL); |
|
129 DP_IN(); |
|
130 if (iCurrentState != EUninitialized) |
|
131 { |
|
132 DP0_RET(KErrNotReady, "%d"); |
|
133 } |
|
134 |
|
135 //calling commit?? |
|
136 iCurrentState = EInitialized; |
|
137 DP0_RET(KErrNone, "%d"); |
|
138 } |
|
139 |
|
140 // --------------------------------------------------------------------------- |
|
141 // CLogicalAudioStream::Load |
|
142 // --------------------------------------------------------------------------- |
|
143 TInt CLogicalAudioStream::Load() |
|
144 { |
|
145 DP_CONTEXT(CLogicalAudioStream::Load *CD1*, CtxDevSound, DPLOCAL); |
|
146 DP_IN(); |
|
147 if (iCurrentState != EInitialized) |
|
148 { |
|
149 DP0_RET(KErrNotReady, "%d"); |
|
150 } |
|
151 |
|
152 iCurrentState = EIdle; |
|
153 ResetStreamTime(); |
|
154 DP0_RET(KErrNone, "%d"); |
|
155 } |
|
156 |
|
157 // --------------------------------------------------------------------------- |
|
158 // CLogicalAudioStream::Stop |
|
159 // --------------------------------------------------------------------------- |
|
160 TInt CLogicalAudioStream::Stop() |
|
161 { |
|
162 DP_CONTEXT(CLogicalAudioStream::Stop *CD1*, CtxDevSound, DPLOCAL); |
|
163 DP_IN(); |
|
164 if (iCurrentState != EActive && iCurrentState != EPrimed) |
|
165 { |
|
166 DP0_RET(KErrNotReady, "%d"); |
|
167 } |
|
168 iCurrentState = EIdle; |
|
169 DP0_RET(KErrNone, "%d"); |
|
170 } |
|
171 |
|
172 // --------------------------------------------------------------------------- |
|
173 // CLogicalAudioStream::Unload |
|
174 // --------------------------------------------------------------------------- |
|
175 TInt CLogicalAudioStream::Unload() |
|
176 { |
|
177 DP_CONTEXT(CLogicalAudioStream::Unload *CD1*, CtxDevSound, DPLOCAL); |
|
178 DP_IN(); |
|
179 if (iCurrentState != EIdle) |
|
180 { |
|
181 DP0_RET(KErrNotReady, "%d"); |
|
182 } |
|
183 |
|
184 iCurrentState = EInitialized; |
|
185 DP0_RET(KErrNone, "%d"); |
|
186 } |
|
187 |
|
188 // --------------------------------------------------------------------------- |
|
189 // CLogicalAudioStream::Prime |
|
190 // --------------------------------------------------------------------------- |
|
191 TInt CLogicalAudioStream::Prime() |
|
192 { |
|
193 DP_CONTEXT(CLogicalAudioStream::Prime *CD1*, CtxDevSound, DPLOCAL); |
|
194 DP_IN(); |
|
195 if (iCurrentState != EActive && iCurrentState != EIdle) |
|
196 { |
|
197 DP0_RET(KErrNotReady, "%d"); |
|
198 } |
|
199 |
|
200 iCurrentState = EPrimed; |
|
201 DP0_RET(KErrNone, "%d"); |
|
202 } |
|
203 |
|
204 // --------------------------------------------------------------------------- |
|
205 // CLogicalAudioStream::Flush |
|
206 // --------------------------------------------------------------------------- |
|
207 TInt CLogicalAudioStream::Flush() |
|
208 { |
|
209 DP_CONTEXT(CLogicalAudioStream::Flush *CD1*, CtxDevSound, DPLOCAL); |
|
210 DP_IN(); |
|
211 if (iCurrentState != EIdle && iCurrentState != EPrimed) |
|
212 { |
|
213 DP0_RET(KErrNotReady, "%d"); |
|
214 } |
|
215 |
|
216 if(!iStreamBufferControl) |
|
217 { |
|
218 DP0_RET(KErrNotReady, "%d"); |
|
219 } |
|
220 //Empty any buffers that have been filled |
|
221 iStreamBufferControl->FlushBuffers(); |
|
222 |
|
223 DP0_RET(KErrNone, "%d"); |
|
224 } |
|
225 |
|
226 // --------------------------------------------------------------------------- |
|
227 // CLogicalAudioStream::Activate |
|
228 // --------------------------------------------------------------------------- |
|
229 TInt CLogicalAudioStream::Activate() |
|
230 { |
|
231 DP_CONTEXT(CLogicalAudioStream::Activate *CD1*, CtxDevSound, DPLOCAL); |
|
232 DP_IN(); |
|
233 if (iCurrentState != EIdle && iCurrentState != EPrimed) |
|
234 { |
|
235 DP0_RET(KErrNotReady, "%d"); |
|
236 } |
|
237 |
|
238 //The start-up procedures include requesting permission for audio processing |
|
239 //from audio policy. If permission to start is denied by audio policy, a state |
|
240 //change callback to the current state will occur. |
|
241 iCurrentState = EActive; |
|
242 DP0_RET(KErrNone, "%d"); |
|
243 } |
|
244 |
|
245 // --------------------------------------------------------------------------- |
|
246 // CLogicalAudioStream::AddSource |
|
247 // --------------------------------------------------------------------------- |
|
248 TInt CLogicalAudioStream::AddSource(MAudioProcessingUnit* aSource) |
|
249 { |
|
250 DP_CONTEXT(CLogicalAudioStream::AddSource *CD1*, CtxDevSound, DPLOCAL); |
|
251 DP_IN(); |
|
252 TInt err; |
|
253 if (aSource->IsTypeOf(KUidMmfBufferSource) || aSource->IsTypeOf(KUidAudioDeviceSource)) |
|
254 { |
|
255 if (iCurrentState == EUninitialized) |
|
256 { |
|
257 err = DoAddProcessingUnit(aSource); |
|
258 } |
|
259 else |
|
260 { |
|
261 err = KErrNotReady; |
|
262 } |
|
263 } |
|
264 else |
|
265 { |
|
266 err = KErrNotSupported; |
|
267 } |
|
268 DP0_RET(err, "%d"); |
|
269 } |
|
270 |
|
271 |
|
272 // --------------------------------------------------------------------------- |
|
273 // CLogicalAudioStream::AddSink |
|
274 // --------------------------------------------------------------------------- |
|
275 TInt CLogicalAudioStream::AddSink(MAudioProcessingUnit* aSink) |
|
276 { |
|
277 DP_CONTEXT(CLogicalAudioStream::AddSink *CD1*, CtxDevSound, DPLOCAL); |
|
278 DP_IN(); |
|
279 TInt err; |
|
280 if (aSink->IsTypeOf(KUidMmfBufferSink) || aSink->IsTypeOf(KUidAudioDeviceSink) ) |
|
281 { |
|
282 if (iCurrentState == EUninitialized) |
|
283 { |
|
284 err = DoAddProcessingUnit(aSink); |
|
285 } |
|
286 else |
|
287 { |
|
288 err = KErrNotReady; |
|
289 } |
|
290 } |
|
291 else |
|
292 { |
|
293 err = KErrNotSupported; |
|
294 } |
|
295 DP0_RET(err, "%d"); |
|
296 } |
|
297 |
|
298 // --------------------------------------------------------------------------- |
|
299 // CLogicalAudioStream::AddCodec |
|
300 // --------------------------------------------------------------------------- |
|
301 TInt CLogicalAudioStream::AddAudioCodec(MAudioProcessingUnit* aCodec) |
|
302 { |
|
303 DP_CONTEXT(CLogicalAudioStream::AddAudioCodec *CD1*, CtxDevSound, DPLOCAL); |
|
304 DP_IN(); |
|
305 TInt err; |
|
306 if (iCodec != NULL) |
|
307 { |
|
308 DP0_RET(KErrInUse, "%d"); |
|
309 } |
|
310 |
|
311 if (aCodec->IsTypeOf(KUidAudioCodec)) |
|
312 { |
|
313 if (iCurrentState == EUninitialized) |
|
314 { |
|
315 err = DoAddProcessingUnit(aCodec); |
|
316 } |
|
317 else |
|
318 { |
|
319 err = KErrNotReady; |
|
320 } |
|
321 } |
|
322 else |
|
323 { |
|
324 err = KErrNotSupported; |
|
325 } |
|
326 DP0_RET(err, "%d"); |
|
327 } |
|
328 |
|
329 // --------------------------------------------------------------------------- |
|
330 // CLogicalAudioStream::AddGainControl |
|
331 // --------------------------------------------------------------------------- |
|
332 TInt CLogicalAudioStream::AddGainControl(MAudioProcessingUnit* aGainControl) |
|
333 { |
|
334 DP_CONTEXT(CLogicalAudioStream::AddGainControl *CD1*, CtxDevSound, DPLOCAL); |
|
335 DP_IN(); |
|
336 TInt err(KErrNone); |
|
337 |
|
338 if (iGain != NULL) |
|
339 { |
|
340 DP0_RET(KErrInUse, "%d"); |
|
341 } |
|
342 |
|
343 if (aGainControl->IsTypeOf(KUidAudioGainControl)) |
|
344 { |
|
345 if (iCurrentState == EUninitialized) |
|
346 { |
|
347 err = DoAddProcessingUnit(aGainControl); |
|
348 } |
|
349 else |
|
350 { |
|
351 err = KErrNotReady; |
|
352 } |
|
353 } |
|
354 else |
|
355 { |
|
356 err = KErrNotSupported; |
|
357 } |
|
358 DP0_RET(err, "%d"); |
|
359 } |
|
360 |
|
361 // --------------------------------------------------------------------------- |
|
362 // CLogicalAudioStream::RemoveProcessigUnit |
|
363 // --------------------------------------------------------------------------- |
|
364 TInt CLogicalAudioStream::RemoveProcessingUnit(MAudioProcessingUnit* aProcessingUnit) |
|
365 { |
|
366 DP_CONTEXT(CLogicalAudioStream::RemoveProcessingUnit *CD1*, CtxDevSound, DPLOCAL); |
|
367 DP_IN(); |
|
368 |
|
369 if(iCurrentState != EUninitialized) |
|
370 { |
|
371 DP0_RET(KErrNotReady, "%d"); |
|
372 } |
|
373 |
|
374 TInt err(KErrNotFound); |
|
375 if (aProcessingUnit != NULL) |
|
376 { |
|
377 TAudioComponentId param = aProcessingUnit->InstanceId(); |
|
378 TUint count= iAudioProcessingUnits.Count(); |
|
379 |
|
380 if (aProcessingUnit->IsTypeOf(KUidAudioCodec)) |
|
381 { |
|
382 iCodec = NULL; |
|
383 } |
|
384 else if (aProcessingUnit->IsTypeOf(KUidAudioGainControl)) |
|
385 { |
|
386 iGain = NULL; |
|
387 } |
|
388 |
|
389 for ( TUint i(0); i < count; i++ ) |
|
390 { |
|
391 // find and remove component |
|
392 if( iAudioProcessingUnits[i]->InstanceId() == param) |
|
393 { |
|
394 iAudioProcessingUnits.Remove(i); |
|
395 break; |
|
396 } |
|
397 } |
|
398 SetMessageType(EComponentDestruction); |
|
399 err = KErrNone; |
|
400 } |
|
401 DP0_RET(err, "%d"); |
|
402 } |
|
403 |
|
404 // --------------------------------------------------------------------------- |
|
405 // CLogicalAudioStream::ResetStreamTime |
|
406 // --------------------------------------------------------------------------- |
|
407 TInt CLogicalAudioStream::ResetStreamTime() |
|
408 { |
|
409 DP_CONTEXT(CLogicalAudioStream::ResetStreamTime *CD1*, CtxDevSound, DPLOCAL); |
|
410 DP_IN(); |
|
411 TInt err(KErrNone); |
|
412 if (iCurrentState != EIdle) |
|
413 { |
|
414 DP0_RET(KErrNotReady, "%d"); |
|
415 } |
|
416 if(iPositionControl) |
|
417 { |
|
418 iPositionControl->ResetControlPosition(); |
|
419 } |
|
420 iTimeProcessed = 0; |
|
421 DP0_RET(err, "%d"); |
|
422 } |
|
423 |
|
424 |
|
425 // --------------------------------------------------------------------------- |
|
426 // CLogicalAudioStream::GetStreamTime |
|
427 // --------------------------------------------------------------------------- |
|
428 TInt CLogicalAudioStream::GetStreamTime(TTimeIntervalMicroSeconds& aStreamTime) |
|
429 { |
|
430 DP_CONTEXT(CLogicalAudioStream::GetStreamTime *CD1*, CtxDevSound, DPLOCAL); |
|
431 DP_IN(); |
|
432 TInt err(KErrNone); |
|
433 |
|
434 if(iPositionControl) |
|
435 { |
|
436 err = iPositionControl->GetControlPosition(aStreamTime); |
|
437 if(err == KErrNone) |
|
438 { |
|
439 iTimeProcessed = aStreamTime; |
|
440 } |
|
441 } |
|
442 else |
|
443 { |
|
444 aStreamTime = iTimeProcessed; |
|
445 } |
|
446 DP0_RET(err, "%d"); |
|
447 } |
|
448 |
|
449 // --------------------------------------------------------------------------- |
|
450 // CLogicalAudioStream::Interface |
|
451 // --------------------------------------------------------------------------- |
|
452 TAny* CLogicalAudioStream::Interface(TUid aType) |
|
453 { |
|
454 DP_CONTEXT(CLogicalAudioStream::Interface *CD1*, CtxDevSound, DPLOCAL); |
|
455 DP_IN(); |
|
456 TAny* interface(NULL); |
|
457 if( aType == KUidAudioStream) |
|
458 { |
|
459 interface = static_cast<MAudioStream*>(this); |
|
460 } |
|
461 else if( aType == KUidExtensionInferface) |
|
462 { |
|
463 interface = static_cast<MCustomInterfaceSupport*>(this); |
|
464 } |
|
465 else if (aType == KUidAudioStreamAdaptationObserver) |
|
466 { |
|
467 interface = static_cast<MAudioStreamAdaptationObserver*>(this); |
|
468 DP0_RET(interface, "0x%x"); |
|
469 } |
|
470 else if (aType == KUidAudioCodecObserver) |
|
471 { |
|
472 interface = static_cast<MAudioCodecObserver*>(this); |
|
473 DP0_RET(interface, "0x%x"); |
|
474 } |
|
475 |
|
476 DP_OUT(); |
|
477 return interface; |
|
478 } |
|
479 |
|
480 // --------------------------------------------------------------------------- |
|
481 // From MCustomInterfaceSupport |
|
482 // CAudioStream::RequestCustomInterface |
|
483 // --------------------------------------------------------------------------- |
|
484 TInt CLogicalAudioStream::RequestCustomInterface(TUid aUid, TAny*& aPtr) |
|
485 { |
|
486 DP_CONTEXT(CLogicalAudioStream::RequestCustomInterface *CD1*, CtxDevSound, DPLOCAL); |
|
487 DP_IN(); |
|
488 TInt err = KErrNone; |
|
489 if (aUid == KA3FBackdoorAccessIfUid) |
|
490 { |
|
491 MA3FBackdoorAccessIf* self = this; |
|
492 aPtr = self; |
|
493 } |
|
494 else if(iInterfaceProvider) |
|
495 { |
|
496 err = iInterfaceProvider->RequestCustomInterface(aUid, aPtr); |
|
497 if (err != KErrNone) |
|
498 { |
|
499 aPtr = NULL; |
|
500 } |
|
501 } |
|
502 else |
|
503 { |
|
504 err = KErrNotReady; |
|
505 } |
|
506 DP0_RET(err, "%d"); |
|
507 } |
|
508 |
|
509 // --------------------------------------------------------------------------- |
|
510 // From MCustomInterfaceSupport |
|
511 // CAudioStream::RegisterObserver |
|
512 // --------------------------------------------------------------------------- |
|
513 TInt CLogicalAudioStream::RegisterObserver(MCustomInterfaceSupportObserver& aObserver) |
|
514 { |
|
515 DP_CONTEXT(CLogicalAudioStream::RegisterObserver *CD1*, CtxDevSound, DPLOCAL); |
|
516 DP_IN(); |
|
517 TInt err = KErrNone; |
|
518 err = iCISupportObservers.Find(&aObserver); |
|
519 if( err != KErrNotFound ) |
|
520 { |
|
521 err = KErrAlreadyExists; |
|
522 } |
|
523 else |
|
524 { |
|
525 err = iCISupportObservers.Append(&aObserver); |
|
526 } |
|
527 DP0_RET(err, "%d"); |
|
528 } |
|
529 |
|
530 // --------------------------------------------------------------------------- |
|
531 // From MCustomInterfaceSupport |
|
532 // CAudioStream::UnRegisterObserver |
|
533 // --------------------------------------------------------------------------- |
|
534 void CLogicalAudioStream::UnRegisterObserver(MCustomInterfaceSupportObserver& aObserver) |
|
535 { |
|
536 DP_CONTEXT(CLogicalAudioStream::UnRegisterObserver *CD1*, CtxDevSound, DPLOCAL); |
|
537 DP_IN(); |
|
538 TInt idxOrErr = iCISupportObservers.Find(&aObserver); |
|
539 if( idxOrErr != KErrNotFound ) |
|
540 { |
|
541 iCISupportObservers.Remove(idxOrErr); |
|
542 } |
|
543 DP_OUT(); |
|
544 } |
|
545 |
|
546 // --------------------------------------------------------------------------- |
|
547 // From MCustomInterfaceSupport |
|
548 // CAudioStream::CustomInterfaceRemoval |
|
549 // --------------------------------------------------------------------------- |
|
550 void CLogicalAudioStream::CustomInterfaceRemoval(TUid aInterfaceUid, TAny* aPtr) |
|
551 { |
|
552 DP_CONTEXT(CLogicalAudioStream::CustomInterfaceRemoval *CD1*, CtxDevSound, DPLOCAL); |
|
553 DP_IN(); |
|
554 TUint count = iCISupportObservers.Count(); |
|
555 for ( TUint idx(0); idx < count; idx++ ) |
|
556 { |
|
557 iCISupportObservers[idx]->CustomInterfaceRemoval(aInterfaceUid, aPtr); |
|
558 } |
|
559 DP_OUT(); |
|
560 } |
|
561 |
|
562 // --------------------------------------------------------------------------- |
|
563 // From MAudioStreamAdaptationObserver |
|
564 // CAudioStream::PhysicalAdaptationEvent |
|
565 // --------------------------------------------------------------------------- |
|
566 void CLogicalAudioStream::PhysicalAdaptationEvent(TPhysicalEvent /*aEvent*/, TInt /*aError*/) |
|
567 { |
|
568 DP_CONTEXT(CLogicalAudioStream::PhysicalAdaptationEvent *CD1*, CtxDevSound, DPLOCAL); |
|
569 DP_IN(); |
|
570 DP_OUT(); |
|
571 } |
|
572 |
|
573 // --------------------------------------------------------------------------- |
|
574 // CAudioStream::StateEvent |
|
575 // --------------------------------------------------------------------------- |
|
576 void CLogicalAudioStream::StateEvent(TInt aReason, TAudioState aNewState) |
|
577 { |
|
578 DP_CONTEXT(CLogicalAudioStream::StateEvent *CD1*, CtxDevSound, DPLOCAL); |
|
579 DP_IN(); |
|
580 #ifdef _DEBUG |
|
581 RDebug::Print(_L("CLogicalAudioStream::StateEvent Error %d Stay %d"), aReason, aNewState); |
|
582 #endif |
|
583 TUint count = iAudioStreamObserver.Count(); |
|
584 for ( TUint idx(0); idx < count; idx++ ) |
|
585 { |
|
586 iAudioStreamObserver[idx]->StateEvent(*this, aReason, aNewState); |
|
587 } |
|
588 iCurrentState = aNewState; |
|
589 DP_OUT(); |
|
590 } |
|
591 |
|
592 // --------------------------------------------------------------------------- |
|
593 // CLogicalAudioStream::AddProcessingUnitComplete |
|
594 // --------------------------------------------------------------------------- |
|
595 void CLogicalAudioStream::AddProcessingUnitComplete(TUid aType, TInt aError) |
|
596 { |
|
597 DP_CONTEXT(CLogicalAudioStream::AddProcessingUnitComplete *CD1*, CtxDevSound, DPLOCAL); |
|
598 DP_IN(); |
|
599 MAudioProcessingUnit* instance = NULL; |
|
600 MapUidToProcessingUnit(aType, instance); |
|
601 TUint count = iAudioStreamObserver.Count(); |
|
602 for ( TUint idx(0); idx < count; idx++ ) |
|
603 { |
|
604 iAudioStreamObserver[idx]->AddProcessingUnitComplete(*this, instance, aError); |
|
605 } |
|
606 DP_OUT(); |
|
607 } |
|
608 |
|
609 // --------------------------------------------------------------------------- |
|
610 // CLogicalAudioStream::RemoveProcessingUnitComplete |
|
611 // --------------------------------------------------------------------------- |
|
612 void CLogicalAudioStream::RemoveProcessingUnitComplete(TUid aType, TInt aError) |
|
613 { |
|
614 DP_CONTEXT(CLogicalAudioStream::RemoveProcessingUnitComplete *CD1*, CtxDevSound, DPLOCAL); |
|
615 DP_IN(); |
|
616 MAudioProcessingUnit* instance = NULL; |
|
617 MapUidToProcessingUnit(aType, instance); |
|
618 TUint count = iAudioStreamObserver.Count(); |
|
619 for ( TUint idx(0); idx < count; idx++ ) |
|
620 { |
|
621 iAudioStreamObserver[idx]->RemoveProcessingUnitComplete(*this, instance, aError); |
|
622 } |
|
623 DP_OUT(); |
|
624 } |
|
625 |
|
626 // --------------------------------------------------------------------------- |
|
627 // From MAudioStreamAdaptationObserver |
|
628 // CLogicalAudioStream::ProcessingFinished |
|
629 // --------------------------------------------------------------------------- |
|
630 void CLogicalAudioStream::ProcessingFinished() |
|
631 { |
|
632 DP_CONTEXT(CLogicalAudioStream::ProcessingFinished *CD1*, CtxDevSound, DPLOCAL); |
|
633 DP_IN(); |
|
634 TUint count = iAudioStreamObserver.Count(); |
|
635 for ( TUint idx(0); idx < count; idx++ ) |
|
636 { |
|
637 iAudioStreamObserver[idx]->ProcessingFinished(*this); |
|
638 } |
|
639 DP_OUT(); |
|
640 } |
|
641 |
|
642 // --------------------------------------------------------------------------- |
|
643 // CLogicalAudioStream::FlushComplete |
|
644 // --------------------------------------------------------------------------- |
|
645 void CLogicalAudioStream::FlushComplete(TInt aError) |
|
646 { |
|
647 DP_CONTEXT(CLogicalAudioStream::FlushComplete *CD1*, CtxDevSound, DPLOCAL); |
|
648 DP_IN(); |
|
649 TUint count = iAudioStreamObserver.Count(); |
|
650 for ( TUint idx(0); idx < count; idx++ ) |
|
651 { |
|
652 iAudioStreamObserver[idx]->FlushComplete(*this, aError); |
|
653 } |
|
654 DP_OUT(); |
|
655 } |
|
656 |
|
657 |
|
658 // --------------------------------------------------------------------------- |
|
659 // Internal |
|
660 // CLogicalAudioStream::DoAddProcessingUnit |
|
661 // --------------------------------------------------------------------------- |
|
662 TInt CLogicalAudioStream::DoAddProcessingUnit(MAudioProcessingUnit* aProcessingUnit) |
|
663 { |
|
664 DP_CONTEXT(CLogicalAudioStream::DoAddProcessingUnit *CD1*, CtxDevSound, DPLOCAL); |
|
665 DP_IN(); |
|
666 TInt err(KErrNone); |
|
667 |
|
668 if (aProcessingUnit->IsTypeOf(KUidAudioCodec) ) |
|
669 { |
|
670 // Need for tone handling error |
|
671 CAudioProcessingUnit* pUnit = static_cast<CAudioProcessingUnit*>(aProcessingUnit); |
|
672 iCodec = static_cast<MAudioProcessingUnit*>(pUnit); |
|
673 } |
|
674 else if (aProcessingUnit->IsTypeOf(KUidAudioGainControl) ) |
|
675 { |
|
676 CAudioProcessingUnit* pUnit = static_cast<CAudioProcessingUnit*>(aProcessingUnit); |
|
677 iGain = static_cast<MAudioProcessingUnit*>(pUnit); |
|
678 } |
|
679 |
|
680 err = iAudioProcessingUnits.Append(aProcessingUnit); |
|
681 SetMessageType(EComponentCreation); |
|
682 |
|
683 DP0_RET(err, "%d"); |
|
684 } |
|
685 |
|
686 // --------------------------------------------------------------------------- |
|
687 // Internal |
|
688 // CLogicalAudioStream::MapUidToProcessingUnit |
|
689 // --------------------------------------------------------------------------- |
|
690 void CLogicalAudioStream::MapUidToProcessingUnit(TUid aType, MAudioProcessingUnit*& aInstance) |
|
691 { |
|
692 DP_CONTEXT(CLogicalAudioStream::MapUidToProcessingUnit *CD1*, CtxDevSound, DPLOCAL); |
|
693 DP_IN(); |
|
694 TUint count = iAudioProcessingUnits.Count(); |
|
695 for(TUint i=0; i<count; i++) |
|
696 { |
|
697 aInstance = static_cast<MAudioProcessingUnit*>(iAudioProcessingUnits[i]); |
|
698 if ( aInstance->IsTypeOf(aType) ) |
|
699 { |
|
700 break; |
|
701 } |
|
702 aInstance = NULL; |
|
703 } |
|
704 DP_OUT(); |
|
705 } |
|
706 |
|
707 // From MLogicalChain |
|
708 // --------------------------------------------------------------------------- |
|
709 // CLogicalAudioStream::SetMessageType |
|
710 // --------------------------------------------------------------------------- |
|
711 void CLogicalAudioStream::SetMessageType(TMMRCMessageType aMessageType) |
|
712 { |
|
713 DP_CONTEXT(CLogicalAudioStream::SetMessageType *CD1*, CtxDevSound, DPLOCAL); |
|
714 DP_IN(); |
|
715 iMessageType |= aMessageType; |
|
716 DP_OUT(); |
|
717 } |
|
718 |
|
719 // --------------------------------------------------------------------------- |
|
720 // CLogicalAudioStream::ResetMessage |
|
721 // --------------------------------------------------------------------------- |
|
722 void CLogicalAudioStream::ResetMessage() |
|
723 { |
|
724 DP_CONTEXT(CLogicalAudioStream::SetMessageType *CD1*, CtxDevSound, DPLOCAL); |
|
725 DP_IN(); |
|
726 iMessageType = ENoMessage; |
|
727 DP_OUT(); |
|
728 } |
|
729 |
|
730 // --------------------------------------------------------------------------- |
|
731 // CLogicalAudioStream::MessageType |
|
732 // --------------------------------------------------------------------------- |
|
733 TUint CLogicalAudioStream::MessageType() |
|
734 { |
|
735 DP_CONTEXT(CLogicalAudioStream::MessageType *CD1*, CtxDevSound, DPLOCAL); |
|
736 DP_IN(); |
|
737 DP0_RET(iMessageType, "Message type %d"); |
|
738 } |
|
739 |
|
740 |
|
741 // --------------------------------------------------------------------------- |
|
742 // CLogicalAudioStream::AudioProcessingUnitUid |
|
743 // --------------------------------------------------------------------------- |
|
744 TUid CLogicalAudioStream::AudioProcessingUnitUid(TInt aIndex) |
|
745 { |
|
746 DP_CONTEXT(CLogicalAudioStream::AudioProcessingUnitUid *CD1*, CtxDevSound, DPLOCAL); |
|
747 DP_IN(); |
|
748 TUid uid = {0}; |
|
749 MAudioProcessingUnit* pUnit(NULL); |
|
750 if (aIndex >= 0) |
|
751 { |
|
752 pUnit = static_cast<MAudioProcessingUnit*>(iAudioProcessingUnits[aIndex]); |
|
753 } |
|
754 |
|
755 if (pUnit != NULL) |
|
756 { |
|
757 if (pUnit->IsTypeOf(KUidAudioDecoder)) |
|
758 { |
|
759 uid = KUidAudioDecoder; |
|
760 } |
|
761 else if (pUnit->IsTypeOf(KUidAudioEncoder)) |
|
762 { |
|
763 uid = KUidAudioEncoder; |
|
764 } |
|
765 else if (pUnit->IsTypeOf(KUidMmfBufferSource)) |
|
766 { |
|
767 uid = KUidMmfBufferSource; |
|
768 } |
|
769 else if (pUnit->IsTypeOf(KUidAudioGainControl)) |
|
770 { |
|
771 uid = KUidAudioGainControl; |
|
772 } |
|
773 else if (pUnit->IsTypeOf(KUidAudioDeviceSink)) |
|
774 { |
|
775 uid = KUidAudioDeviceSink; |
|
776 } |
|
777 else if (pUnit->IsTypeOf(KUidMmfBufferSink)) |
|
778 { |
|
779 uid = KUidMmfBufferSink; |
|
780 } |
|
781 else if (pUnit->IsTypeOf(KUidAudioDeviceSource)) |
|
782 { |
|
783 uid = KUidAudioDeviceSource; |
|
784 } |
|
785 else if (pUnit->IsTypeOf(KUidAudioCodec)) |
|
786 { |
|
787 uid = KUidAudioCodec; |
|
788 } |
|
789 } |
|
790 DP_OUT(); |
|
791 return uid; |
|
792 } |
|
793 |
|
794 // --------------------------------------------------------------------------- |
|
795 // CLogicalAudioStream::AudioProcessingUnitsCount |
|
796 // --------------------------------------------------------------------------- |
|
797 TInt CLogicalAudioStream::AudioProcessingUnitsCount() |
|
798 { |
|
799 DP_CONTEXT(CLogicalAudioStream::AudioProcessingUnitsCount *CD1*, CtxDevSound, DPLOCAL); |
|
800 DP_IN(); |
|
801 DP0_RET(iAudioProcessingUnits.Count(), "%d"); |
|
802 } |
|
803 |
|
804 // --------------------------------------------------------------------------- |
|
805 // CLogicalAudioStream::StreamState |
|
806 // --------------------------------------------------------------------------- |
|
807 TAudioState CLogicalAudioStream::StreamState() |
|
808 { |
|
809 DP_CONTEXT(CLogicalAudioStream::StreamState *CD1*, CtxDevSound, DPLOCAL); |
|
810 DP_IN(); |
|
811 DP0_RET(iCurrentState, "Stream state %d"); |
|
812 } |
|
813 |
|
814 // --------------------------------------------------------------------------- |
|
815 // From MLogicalChain |
|
816 // CLogicalAudioStream::SetStreamState |
|
817 // --------------------------------------------------------------------------- |
|
818 void CLogicalAudioStream::SetStreamState(TAudioState aAudioState) |
|
819 { |
|
820 DP_CONTEXT(CLogicalAudioStream::StreamState *CD1*, CtxDevSound, DPLOCAL); |
|
821 DP_IN(); |
|
822 iCurrentState = aAudioState; |
|
823 DP_OUT(); |
|
824 } |
|
825 |
|
826 // --------------------------------------------------------------------------- |
|
827 // From MLogicalChain |
|
828 // CLogicalAudioStream::CodecFormat |
|
829 // --------------------------------------------------------------------------- |
|
830 TUid CLogicalAudioStream::CodecFormat() |
|
831 { |
|
832 DP_CONTEXT(CLogicalAudioStream::CodecFormat *CD1*, CtxDevSound, DPLOCAL); |
|
833 DP_IN(); |
|
834 CLogicalAudioCodec* codec = static_cast<CLogicalAudioCodec*>(iCodec); |
|
835 DP_OUT(); |
|
836 TUid tuidnull = {0}; |
|
837 if(codec) |
|
838 { |
|
839 return codec->iFormat; |
|
840 } |
|
841 else |
|
842 { |
|
843 return tuidnull; |
|
844 } |
|
845 } |
|
846 |
|
847 // --------------------------------------------------------------------------- |
|
848 // From MLogicalChain |
|
849 // CLogicalAudioStream::GetSampleRate |
|
850 // --------------------------------------------------------------------------- |
|
851 TInt CLogicalAudioStream::GetSampleRate() |
|
852 { |
|
853 DP_CONTEXT(CLogicalAudioStream::GetSampleRate *CD1*, CtxDevSound, DPLOCAL); |
|
854 DP_IN(); |
|
855 const TUint KDefaultSampleRate = 8000; // Default sample rate |
|
856 CLogicalAudioCodec* codec = static_cast<CLogicalAudioCodec*>(iCodec); |
|
857 DP_OUT(); |
|
858 TInt sampleRateValue = KDefaultSampleRate; |
|
859 if(codec) |
|
860 { |
|
861 sampleRateValue = codec->iSampleRateConfig; |
|
862 } |
|
863 return sampleRateValue; |
|
864 } |
|
865 |
|
866 // --------------------------------------------------------------------------- |
|
867 // From MLogicalChain |
|
868 // CLogicalAudioStream::GetMode |
|
869 // --------------------------------------------------------------------------- |
|
870 TUid CLogicalAudioStream::GetMode() |
|
871 { |
|
872 DP_CONTEXT(CLogicalAudioStream::GetMode *CD1*, CtxDevSound, DPLOCAL); |
|
873 DP_IN(); |
|
874 CLogicalAudioCodec* codec = static_cast<CLogicalAudioCodec*>(iCodec); |
|
875 TUid tuidnull = {0}; |
|
876 DP_OUT(); |
|
877 if(codec) |
|
878 { |
|
879 return codec->iModeConfig; |
|
880 } |
|
881 else |
|
882 { |
|
883 return tuidnull; |
|
884 } |
|
885 } |
|
886 |
|
887 |
|
888 // --------------------------------------------------------------------------- |
|
889 // From MLogicalChain |
|
890 // CLogicalAudioStream::Priority |
|
891 // --------------------------------------------------------------------------- |
|
892 TInt CLogicalAudioStream::Priority() |
|
893 { |
|
894 DP_CONTEXT(CLogicalAudioStream::Priority*CD1*, CtxDevSound, DPLOCAL); |
|
895 DP_IN(); |
|
896 DP0_RET(iAudioTypeSettings.iPriority, "Priority %d"); |
|
897 } |
|
898 |
|
899 // --------------------------------------------------------------------------- |
|
900 // From MLogicalChain |
|
901 // CLogicalAudioStream::GetVolumeRampParameters |
|
902 // --------------------------------------------------------------------------- |
|
903 void CLogicalAudioStream::GetVolumeRampParameters(TUid& aRampOperation, TTimeIntervalMicroSeconds& aRampDuration) |
|
904 { |
|
905 DP_CONTEXT(CLogicalAudioStream::GetVolumeRampParameters*CD1*, CtxDevSound, DPLOCAL); |
|
906 DP_IN(); |
|
907 CLogicalAudioGainControl* gain = static_cast<CLogicalAudioGainControl*>(iGain); |
|
908 if(gain) |
|
909 { |
|
910 aRampOperation = gain->iDesiredRampOperation; |
|
911 aRampDuration = gain->iDesiredRampTime; |
|
912 } |
|
913 DP_OUT(); |
|
914 } |
|
915 |
|
916 // --------------------------------------------------------------------------- |
|
917 // From MLogicalChain |
|
918 // CLogicalAudioStream::CopySettings |
|
919 // @param the logical chain from where the parameter will be copied |
|
920 // --------------------------------------------------------------------------- |
|
921 void CLogicalAudioStream::CopySettings(const MLogicalChain& aChain) |
|
922 { |
|
923 DP_CONTEXT(CLogicalAudioStream::CopySettings *CD1*, CtxDevSound, DPLOCAL); |
|
924 DP_IN(); |
|
925 CopyStreamSettings(aChain); |
|
926 CopyCodecSettings(aChain); |
|
927 CopyGainSettings(aChain); |
|
928 DP_OUT(); |
|
929 } |
|
930 |
|
931 void CLogicalAudioStream::CopyStreamSettings(const MLogicalChain& aChain) |
|
932 { |
|
933 DP_CONTEXT(CLogicalAudioStream::CopyStreamSettings *CD1*, CtxDevSound, DPLOCAL); |
|
934 DP_IN(); |
|
935 // LogicalAudioStream settings |
|
936 CLogicalAudioStream& srcChain = static_cast<CLogicalAudioStream&>(const_cast<MLogicalChain&>(aChain)); |
|
937 |
|
938 iAudioTypeSettings = srcChain.iAudioTypeSettings; |
|
939 iCurrentState = srcChain.iCurrentState; |
|
940 iRequestState = srcChain.iRequestState; |
|
941 iMessageType = srcChain.iMessageType; |
|
942 iTimeProcessed = srcChain.iTimeProcessed; |
|
943 DP_OUT(); |
|
944 } |
|
945 |
|
946 void CLogicalAudioStream::CopyCodecSettings(const MLogicalChain& aChain) |
|
947 { |
|
948 DP_CONTEXT(CLogicalAudioStream::CopyCodecSettings *CD1*, CtxDevSound, DPLOCAL); |
|
949 DP_IN(); |
|
950 |
|
951 CLogicalAudioStream& srcChain = static_cast<CLogicalAudioStream&>(const_cast<MLogicalChain&>(aChain)); |
|
952 // Copy codec settings |
|
953 CLogicalAudioCodec* srcCodec = static_cast<CLogicalAudioCodec*>(srcChain.iCodec); |
|
954 if(iCodec && srcCodec) |
|
955 { |
|
956 CLogicalAudioCodec* logicalCodec = static_cast<CLogicalAudioCodec*>(iCodec); |
|
957 logicalCodec->iFormat = srcCodec->iFormat; |
|
958 logicalCodec->iSampleRateConfig = srcCodec->iSampleRateConfig; |
|
959 logicalCodec->iModeConfig = srcCodec->iModeConfig; |
|
960 } |
|
961 DP_OUT(); |
|
962 } |
|
963 |
|
964 |
|
965 void CLogicalAudioStream::CopyGainSettings(const MLogicalChain& aChain) |
|
966 { |
|
967 DP_CONTEXT(CLogicalAudioStream::CopyGainSettings *CD1*, CtxDevSound, DPLOCAL); |
|
968 DP_IN(); |
|
969 |
|
970 CLogicalAudioStream& srcChain = static_cast<CLogicalAudioStream&>(const_cast<MLogicalChain&>(aChain)); |
|
971 // Copy gain settings |
|
972 CLogicalAudioGainControl* srcGain = static_cast<CLogicalAudioGainControl*>(srcChain.iGain); |
|
973 if (iGain && srcGain ) |
|
974 { |
|
975 if(srcGain->iDesiredChannels.Count() > 0) |
|
976 { |
|
977 CLogicalAudioGainControl* logicalGain = static_cast<CLogicalAudioGainControl*>(iGain); |
|
978 TUint count = srcGain->iDesiredChannels.Count(); |
|
979 for (TUint i(0); i < count; i++) |
|
980 { |
|
981 logicalGain->iDesiredChannels[i] = srcGain->iDesiredChannels[i]; |
|
982 } |
|
983 logicalGain->iDesiredRampOperation = srcGain->iDesiredRampOperation; |
|
984 logicalGain->iDesiredRampTime = srcGain->iDesiredRampTime; |
|
985 } |
|
986 } |
|
987 DP_OUT(); |
|
988 } |
|
989 |
|
990 // --------------------------------------------------------------------------- |
|
991 // From MLogicalChain |
|
992 // CLogicalAudioStream::CloneL |
|
993 // --------------------------------------------------------------------------- |
|
994 MLogicalChain* CLogicalAudioStream::CloneL() |
|
995 { |
|
996 DP_CONTEXT(CLogicalAudioStream::CloneL *CD1*, CtxDevSound, DPLOCAL); |
|
997 DP_IN(); |
|
998 TInt err = KErrNone; |
|
999 MLogicalChain* newLogicalChain = NULL; |
|
1000 |
|
1001 // Create another audiostream |
|
1002 CAudioStreamManager *manager = NULL; |
|
1003 manager = CAudioStreamManager::NewL(KUidAudioStream); |
|
1004 // Copy stream settings |
|
1005 CLogicalAudioStream* logicalAudioStream = static_cast<CLogicalAudioStream*>(manager); |
|
1006 |
|
1007 MAudioProcessingUnit* pUnit=NULL; |
|
1008 TInt count = iAudioProcessingUnits.Count(); |
|
1009 for(TInt i = 0; i < count ; i++) |
|
1010 { |
|
1011 // Create processing unit |
|
1012 TUid type = AudioProcessingUnitUid(i); |
|
1013 TComponentParameters cParameters; |
|
1014 cParameters.iTypeUid = type; |
|
1015 cParameters.iInstanceId = 0; |
|
1016 cParameters.iContextId = 0; |
|
1017 cParameters.iSettingsObserver = NULL; |
|
1018 pUnit = CAudioProcessingUnit::NewL(cParameters); |
|
1019 |
|
1020 // If no error then add to the stream |
|
1021 if ( (type == KUidAudioDecoder) || (type == KUidAudioEncoder) ) |
|
1022 { |
|
1023 err = logicalAudioStream->AddAudioCodec(pUnit); |
|
1024 } |
|
1025 else if (type == KUidMmfBufferSource || (type == KUidAudioDeviceSource) ) |
|
1026 { |
|
1027 err = logicalAudioStream->AddSource(pUnit); |
|
1028 } |
|
1029 else if (type == KUidAudioGainControl) |
|
1030 { |
|
1031 err = logicalAudioStream->AddGainControl(pUnit); |
|
1032 } |
|
1033 else if (type == KUidAudioDeviceSink || ( type == KUidMmfBufferSink) ) |
|
1034 { |
|
1035 err = logicalAudioStream->AddSink(pUnit); |
|
1036 } |
|
1037 // TODO: |
|
1038 // Check this couldn't be added |
|
1039 if(err != KErrNone) |
|
1040 { |
|
1041 logicalAudioStream->iAudioProcessingUnits.Remove(iAudioProcessingUnits.Count()-1); |
|
1042 delete pUnit; |
|
1043 } |
|
1044 } |
|
1045 // Cast to MLogicalChain |
|
1046 newLogicalChain = static_cast<MLogicalChain*>(logicalAudioStream); |
|
1047 newLogicalChain->CopySettings(*this); |
|
1048 |
|
1049 DP0_RET(newLogicalChain, "0x%x"); |
|
1050 } |
|
1051 |
|
1052 // --------------------------------------------------------------------------- |
|
1053 // From MLogicalChain |
|
1054 // CLogicalAudioStream::Release |
|
1055 // --------------------------------------------------------------------------- |
|
1056 void CLogicalAudioStream::Release() |
|
1057 { |
|
1058 DP_CONTEXT(CLogicalAudioStream::Release *CD1*, CtxDevSound, DPLOCAL); |
|
1059 DP_IN(); |
|
1060 // ResetAndDestroy |
|
1061 TInt count = iAudioProcessingUnits.Count(); |
|
1062 TInt i; |
|
1063 for (i=0; i<count; i++) |
|
1064 { |
|
1065 CAudioProcessingUnit* pUnit = static_cast<CAudioProcessingUnit*>(iAudioProcessingUnits[i]); |
|
1066 delete pUnit; |
|
1067 } |
|
1068 iAudioProcessingUnits.Reset(); |
|
1069 DP_OUT(); |
|
1070 delete this; |
|
1071 } |
|
1072 |
|
1073 // --------------------------------------------------------------------------- |
|
1074 // From MLogicalChain |
|
1075 // CLogicalAudioStream::GetComponent |
|
1076 // --------------------------------------------------------------------------- |
|
1077 TAny* CLogicalAudioStream::GetComponent(TUid aType) |
|
1078 { |
|
1079 DP_CONTEXT(CLogicalAudioStream::GetComponent *CD1*, CtxDevSound, DPLOCAL); |
|
1080 DP_IN(); |
|
1081 TAny* interface = NULL; |
|
1082 |
|
1083 // go through this or our subcomponents to see if somebody knows about the interface |
|
1084 interface = Interface(aType); |
|
1085 if (interface==NULL) |
|
1086 { |
|
1087 TUint count = iAudioProcessingUnits.Count(); |
|
1088 // go through components looking for valid interface |
|
1089 for ( TInt i=0; i < count; i++ ) |
|
1090 { |
|
1091 interface = iAudioProcessingUnits[i]->Interface(aType); |
|
1092 if (interface!=NULL) |
|
1093 { |
|
1094 break; |
|
1095 }; |
|
1096 } |
|
1097 }; |
|
1098 |
|
1099 |
|
1100 DP0_RET(interface, "0x%x"); |
|
1101 } |
|
1102 |
|
1103 |
|
1104 |
|
1105 // --------------------------------------------------------------------------- |
|
1106 // From MLogicalChain |
|
1107 // CLogicalAudioStream::SetAdaptationSource |
|
1108 // --------------------------------------------------------------------------- |
|
1109 void CLogicalAudioStream::SetAdaptationSource(MMMFBufferSource& aSource) |
|
1110 { |
|
1111 DP_CONTEXT(CLogicalAudioStream::SetAdaptationSource *CD1*, CtxDevSound, DPLOCAL); |
|
1112 DP_IN(); |
|
1113 MapUidToProcessingUnit(KUidMmfBufferSource, iAudioProcessingUnit); |
|
1114 ASSERT(iAudioProcessingUnit); |
|
1115 |
|
1116 CAudioProcessingUnit* cUnit = static_cast<CAudioProcessingUnit*>(iAudioProcessingUnit); |
|
1117 CLogicalBufferSource* bufferSource = (static_cast<CLogicalBufferSource*>(cUnit)); |
|
1118 |
|
1119 bufferSource->iAdaptationBufferSource = &aSource; |
|
1120 aSource.SetDataSupplier(*bufferSource); |
|
1121 |
|
1122 iAudioProcessingUnit = NULL; |
|
1123 DP_OUT(); |
|
1124 } |
|
1125 |
|
1126 // --------------------------------------------------------------------------- |
|
1127 // From MLogicalChain |
|
1128 // CLogicalAudioStream::SetAdaptationSink |
|
1129 // --------------------------------------------------------------------------- |
|
1130 void CLogicalAudioStream::SetAdaptationSink(MMMFBufferSink& aSink) |
|
1131 { |
|
1132 DP_CONTEXT(CLogicalAudioStream::SetAdaptationSink *CD1*, CtxDevSound, DPLOCAL); |
|
1133 DP_IN(); |
|
1134 MapUidToProcessingUnit(KUidMmfBufferSink, iAudioProcessingUnit); |
|
1135 ASSERT(iAudioProcessingUnit); |
|
1136 |
|
1137 CAudioProcessingUnit* cUnit = static_cast<CAudioProcessingUnit*>(iAudioProcessingUnit); |
|
1138 CLogicalBufferSink* bufferSink = (static_cast<CLogicalBufferSink*>(cUnit)); |
|
1139 |
|
1140 bufferSink->iAdaptationBufferSink = &aSink; |
|
1141 aSink.SetDataConsumer(*bufferSink); |
|
1142 |
|
1143 iAudioProcessingUnit = NULL; |
|
1144 DP_OUT(); |
|
1145 } |
|
1146 |
|
1147 // --------------------------------------------------------------------------- |
|
1148 // From MLogicalChain |
|
1149 // CLogicalAudioStream::SetAdaptationGainControl |
|
1150 // --------------------------------------------------------------------------- |
|
1151 void CLogicalAudioStream::SetAdaptationGainControl(MAudioGainControl& aGain) |
|
1152 { |
|
1153 DP_CONTEXT(CLogicalAudioStream::SetAdaptationGainControl *CD1*, CtxDevSound, DPLOCAL); |
|
1154 DP_IN(); |
|
1155 ASSERT(iGain); |
|
1156 CLogicalAudioGainControl* gain = static_cast<CLogicalAudioGainControl*>(iGain); |
|
1157 gain->iAdaptationGain = &aGain; |
|
1158 aGain.RegisterAudioGainControlObserver(*gain); |
|
1159 DP_OUT(); |
|
1160 } |
|
1161 |
|
1162 |
|
1163 |
|
1164 // --------------------------------------------------------------------------- |
|
1165 // From MLogicalChain |
|
1166 // CLogicalAudioStream::SetPositionControl |
|
1167 // --------------------------------------------------------------------------- |
|
1168 void CLogicalAudioStream::SetStreamPositionControl(MStreamPositionControl& aPositionControl) |
|
1169 { |
|
1170 DP_CONTEXT(CLogicalAudioStream::SetStreamPositionControl *CD1*, CtxDevSound, DPLOCAL); |
|
1171 DP_IN(); |
|
1172 iPositionControl = &aPositionControl; |
|
1173 DP_OUT(); |
|
1174 } |
|
1175 |
|
1176 // --------------------------------------------------------------------------- |
|
1177 // CLogicalAudioStream::SetAdaptationStream |
|
1178 // --------------------------------------------------------------------------- |
|
1179 void CLogicalAudioStream::SetAdaptationStream(MConfigurationHelper& aStream) |
|
1180 { |
|
1181 DP_CONTEXT(CLogicalAudioStream::SetAdaptationStream *CD1*, CtxDevSound, DPLOCAL); |
|
1182 DP_IN(); |
|
1183 CLogicalAudioCodec* codec = static_cast<CLogicalAudioCodec*>(iCodec); |
|
1184 if (codec != NULL) |
|
1185 { |
|
1186 if (codec->iAdaptationStream == NULL) |
|
1187 { |
|
1188 codec->iAdaptationStream = &aStream; |
|
1189 } |
|
1190 } |
|
1191 DP_OUT(); |
|
1192 } |
|
1193 |
|
1194 // --------------------------------------------------------------------------- |
|
1195 // CLogicalAudioStream::SetStreamBufferControl |
|
1196 // --------------------------------------------------------------------------- |
|
1197 void CLogicalAudioStream::SetStreamBufferControl(MStreamBufferControl& aStreamBufferControl) |
|
1198 { |
|
1199 DP_CONTEXT(CLogicalAudioStream::SetAdaptationStream *CD1*, CtxDevSound, DPLOCAL); |
|
1200 DP_IN(); |
|
1201 iStreamBufferControl = &aStreamBufferControl; |
|
1202 DP_OUT(); |
|
1203 } |
|
1204 |
|
1205 |
|
1206 // --------------------------------------------------------------------------- |
|
1207 // CLogicalAudioStream::SetCustomInterfaceProvider |
|
1208 // --------------------------------------------------------------------------- |
|
1209 void CLogicalAudioStream::SetCustomInterfaceProvider(MCustomInterfaceSupport& aInterfaceProvider) |
|
1210 { |
|
1211 DP_CONTEXT(CLogicalAudioStream::SetCustomInterfaceProvider *CD1*, CtxDevSound, DPLOCAL); |
|
1212 DP_IN(); |
|
1213 iInterfaceProvider = &aInterfaceProvider; |
|
1214 DP_OUT(); |
|
1215 } |
|
1216 |
|
1217 // --------------------------------------------------------------------------- |
|
1218 // CLogicalAudioStream::SampleRateSet |
|
1219 // --------------------------------------------------------------------------- |
|
1220 void CLogicalAudioStream::SampleRateSet(TInt aError) |
|
1221 { |
|
1222 DP_CONTEXT(CLogicalAudioStream::SampleRateSet *CD1*, CtxDevSound, DPLOCAL); |
|
1223 DP_IN(); |
|
1224 CLogicalAudioCodec* codec = static_cast<CLogicalAudioCodec*>(iCodec); |
|
1225 if(codec) |
|
1226 { |
|
1227 TUint count = codec->iAudioCodecObserver.Count(); |
|
1228 for ( TUint idx(0); idx < count; idx++ ) |
|
1229 { |
|
1230 codec->iAudioCodecObserver[idx]->SampleRateSet(aError); |
|
1231 } |
|
1232 } |
|
1233 DP_OUT(); |
|
1234 } |
|
1235 |
|
1236 // --------------------------------------------------------------------------- |
|
1237 // CLogicalAudioStream::ModeSet |
|
1238 // --------------------------------------------------------------------------- |
|
1239 void CLogicalAudioStream::ModeSet(TInt aError) |
|
1240 { |
|
1241 DP_CONTEXT(CLogicalAudioStream::SampleRateSet *CD1*, CtxDevSound, DPLOCAL); |
|
1242 DP_IN(); |
|
1243 CLogicalAudioCodec* codec = static_cast<CLogicalAudioCodec*>(iCodec); |
|
1244 if(codec) |
|
1245 { |
|
1246 TUint count = codec->iAudioCodecObserver.Count(); |
|
1247 for ( TUint idx(0); idx < count; idx++ ) |
|
1248 { |
|
1249 codec->iAudioCodecObserver[idx]->ModeSet(aError); |
|
1250 } |
|
1251 } |
|
1252 DP_OUT(); |
|
1253 } |
|
1254 |
|
1255 // --------------------------------------------------------------------------- |
|
1256 // CLogicalAudioStream::GetSupportedSampleRatesComplete |
|
1257 // --------------------------------------------------------------------------- |
|
1258 void CLogicalAudioStream::GetSupportedSampleRatesComplete (TInt aError) |
|
1259 { |
|
1260 DP_CONTEXT(CLogicalAudioStream::SampleRateSet *CD1*, CtxDevSound, DPLOCAL); |
|
1261 DP_IN(); |
|
1262 CLogicalAudioCodec* codec = static_cast<CLogicalAudioCodec*>(iCodec); |
|
1263 if(codec) |
|
1264 { |
|
1265 TUint count = codec->iAudioCodecObserver.Count(); |
|
1266 for ( TUint idx(0); idx < count; idx++ ) |
|
1267 { |
|
1268 codec->iAudioCodecObserver[idx]->GetSupportedSampleRatesComplete(aError); |
|
1269 } |
|
1270 } |
|
1271 DP_OUT(); |
|
1272 } |
|
1273 |
|
1274 // --------------------------------------------------------------------------- |
|
1275 // CLogicalAudioStream::GetSupportedModesComplete |
|
1276 // --------------------------------------------------------------------------- |
|
1277 void CLogicalAudioStream::GetSupportedModesComplete (TInt aError) |
|
1278 { |
|
1279 DP_CONTEXT(CLogicalAudioStream::SampleRateSet *CD1*, CtxDevSound, DPLOCAL); |
|
1280 DP_IN(); |
|
1281 CLogicalAudioCodec* codec = static_cast<CLogicalAudioCodec*>(iCodec); |
|
1282 if(codec) |
|
1283 { |
|
1284 TUint count = codec->iAudioCodecObserver.Count(); |
|
1285 for ( TUint idx(0); idx < count; idx++ ) |
|
1286 { |
|
1287 codec->iAudioCodecObserver[idx]->GetSupportedModesComplete(aError); |
|
1288 } |
|
1289 } |
|
1290 DP_OUT(); |
|
1291 } |
|
1292 |
|
1293 // --------------------------------------------------------------------------- |
|
1294 // CLogicalAudioStream::SetParentContext |
|
1295 // --------------------------------------------------------------------------- |
|
1296 void CLogicalAudioStream::SetParentContext(const CAudioContext& aContext) |
|
1297 { |
|
1298 iParentContext = const_cast<CAudioContext*>(&aContext); |
|
1299 } |
|
1300 |
|
1301 |
|
1302 // from MA3FBackdoorAccessIf |
|
1303 |
|
1304 MAudioContext* CLogicalAudioStream::AudioContext() |
|
1305 { |
|
1306 return iParentContext; |
|
1307 } |
|
1308 |
|
1309 MAudioStream* CLogicalAudioStream::AudioStream() |
|
1310 { |
|
1311 return this; |
|
1312 } |
|
1313 |
|
1314 MAudioProcessingUnit* CLogicalAudioStream::ProcessingUnit(TUid aType) |
|
1315 { |
|
1316 // look through our processing units for something of the correct type |
|
1317 TInt numProcessingUnits = iAudioProcessingUnits.Count(); |
|
1318 for (TInt index=0; index < numProcessingUnits; index++) |
|
1319 { |
|
1320 MAudioProcessingUnit* ptr = iAudioProcessingUnits[index]; |
|
1321 if (ptr->IsTypeOf(aType)) |
|
1322 { |
|
1323 return ptr; |
|
1324 } |
|
1325 } |
|
1326 return NULL; |
|
1327 } |