|
1 // Copyright (c) 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 #include "cdevcommoncontrol.h" |
|
17 #include <a3f/maudiocontext.h> |
|
18 #include <a3f/maudiocodec.h> |
|
19 |
|
20 |
|
21 CDevCommonControl::CDevCommonControl() |
|
22 { |
|
23 TRACE_CREATE(); |
|
24 DP_CONTEXT(CDevCommonControl::CDevCommonControl, CtxDevSound, DPLOCAL); |
|
25 DP_IN(); |
|
26 DP_OUT(); |
|
27 } |
|
28 |
|
29 |
|
30 CDevCommonControl::~CDevCommonControl() |
|
31 { |
|
32 DP_CONTEXT(CDevCommonControl::~CDevCommonControl, CtxDevSound, DPLOCAL); |
|
33 DP_IN(); |
|
34 DP_OUT(); |
|
35 } |
|
36 |
|
37 |
|
38 TInt CDevCommonControl::Stop() // from CDevAudioControl |
|
39 { |
|
40 DP_CONTEXT(CDevCommonControl::Stop, CtxDevSound, DPLOCAL); |
|
41 DP_IN(); |
|
42 |
|
43 TInt err = KErrNone; |
|
44 switch(iDevAudio->iActiveState) |
|
45 { |
|
46 case EDevSoundAdaptorActive_Active: |
|
47 case EDevSoundAdaptorPaused_Primed: |
|
48 err = iDevAudio->iAudioStream->Stop(); |
|
49 if (err == KErrNone) |
|
50 { |
|
51 err = iDevAudio->iAudioContext->Commit(); |
|
52 } |
|
53 if (err == KErrNone) |
|
54 { |
|
55 iDevAudio->iActiveState = EDevSoundAdaptorStopping; |
|
56 } |
|
57 break; |
|
58 case EDevSoundAdaptorGoingActive: |
|
59 iDevAudio->iActiveState = EDevSoundAdaptorStopping; |
|
60 break; |
|
61 default: |
|
62 break; |
|
63 } |
|
64 |
|
65 if(err == KErrNone) |
|
66 { |
|
67 iDevAudio->iStop = ETrue; |
|
68 } |
|
69 |
|
70 DP0_RET(err,"%d"); |
|
71 } |
|
72 |
|
73 |
|
74 TInt CDevCommonControl::Pause() // from CDevAudioControl |
|
75 { |
|
76 DP_CONTEXT(CDevCommonControl::Pause, CtxDevSound, DPLOCAL); |
|
77 DP_IN(); |
|
78 |
|
79 TInt err = iDevAudio->iAudioStream->Prime(); |
|
80 if ( err == KErrNone) |
|
81 { |
|
82 err = iDevAudio->iAudioContext->Commit(); |
|
83 } |
|
84 if (err == KErrNone) |
|
85 { |
|
86 iDevAudio->iActiveState = EDevSoundAdaptorPausing; |
|
87 } |
|
88 |
|
89 DP0_RET(err,"%d"); |
|
90 } |
|
91 |
|
92 |
|
93 TInt CDevCommonControl::Resume() // from CDevAudioControl |
|
94 { |
|
95 DP_CONTEXT(CDevCommonControl::Resume, CtxDevSound, DPLOCAL); |
|
96 DP_IN(); |
|
97 |
|
98 TInt err = KErrNone; |
|
99 if(iDevAudio->iActiveState != EDevSoundAdaptorPaused_Primed) |
|
100 { |
|
101 err = KErrNotReady; |
|
102 } |
|
103 |
|
104 if(err == KErrNone) |
|
105 { |
|
106 err = iDevAudio->iAudioStream->Activate(); |
|
107 } |
|
108 if ( err == KErrNone) |
|
109 { |
|
110 err = iDevAudio->iAudioContext->Commit(); |
|
111 } |
|
112 if (err == KErrNone) |
|
113 { |
|
114 iDevAudio->iActiveState = EDevSoundAdaptorActivating; |
|
115 } |
|
116 |
|
117 DP0_RET(err,"%d"); |
|
118 } |
|
119 |
|
120 |
|
121 void CDevCommonControl::StateEvent(MAudioStream& aStream, TInt aError, // from MAudioProcessingUnitObserver |
|
122 TAudioState aNewState) |
|
123 { |
|
124 DP_CONTEXT(CDevCommonControl::StateEvent, CtxDevSound, DPLOCAL); |
|
125 DP3_IN("activeState %d -> newstate %d, (%d)", |
|
126 iDevAudio->iActiveState, aNewState, aError); |
|
127 |
|
128 __ASSERT_ALWAYS(iDevAudio->iAudioStream == &aStream, Panic(EStreamMismatch)); |
|
129 |
|
130 if(aError != KErrNone || iDevAudio->iActiveStreamState != aNewState) |
|
131 { |
|
132 iDevAudio->iActiveStreamState = aNewState; |
|
133 iStateEventReceived = ETrue; |
|
134 } |
|
135 // Since the audiostream already demoted the state for the most of the cases |
|
136 // only is need when a error comes were the stream was at the middle of A3f two-phase transition |
|
137 else |
|
138 { |
|
139 switch (aNewState) |
|
140 { |
|
141 case EIdle: |
|
142 // Demote the stream state |
|
143 iDevAudio->iActiveStreamState = EIdle; |
|
144 break; |
|
145 default: |
|
146 break; |
|
147 } |
|
148 } |
|
149 iStateEventError = aError; |
|
150 |
|
151 DP_OUT(); |
|
152 } |
|
153 |
|
154 |
|
155 void CDevCommonControl::ProcessingUnitError(MAudioProcessingUnit* /*aInstance*/, // from MAudioProcessingUnitObserver |
|
156 TInt aError) |
|
157 { |
|
158 DP_CONTEXT(CDevCommonControl::ProcessingUnitError, CtxDevSound, DPLOCAL); |
|
159 DP_IN(); |
|
160 |
|
161 if(iCallbackFromAdaptor == KCallbackNone) |
|
162 { |
|
163 iCallbackFromAdaptor = KCallbackProcessingUnitError; |
|
164 iAdaptationObserver->CallbackFromAdaptorReceived(KCallbackProcessingUnitError, KErrNone); |
|
165 iProcessingUnitError = aError; |
|
166 } |
|
167 else |
|
168 { |
|
169 // Multiple callbacks from adaptor |
|
170 DP0(DLINFO, "Multiple callbacks from adaptor"); |
|
171 } |
|
172 |
|
173 DP_OUT(); |
|
174 } |
|
175 |
|
176 |
|
177 void CDevCommonControl::ContextEvent(TUid aEvent, TInt aError) |
|
178 { |
|
179 DP_CONTEXT(CDevCommonControl::ContextEvent, CtxDevSound, DPLOCAL); |
|
180 DP_IN(); |
|
181 |
|
182 // Can't "switch {...}" on UIDs unfortunately: |
|
183 |
|
184 if (aEvent == KUidA3FContextUpdateComplete) |
|
185 { |
|
186 //use a sub state pattern to make premtion cycles like other cycles. |
|
187 if(iBeingPreempted) |
|
188 { |
|
189 DP1(DLERR,"Preemption error=%d", aError); |
|
190 CDevAudioControl::ContextEvent(aEvent, aError); |
|
191 iDevAudio->iActiveState = EDevSoundAdaptorBeingPreempted; |
|
192 iBeingPreempted=EFalse; |
|
193 } |
|
194 ContextEventUpdateComplete(aError); |
|
195 } |
|
196 |
|
197 else if ((aEvent == KUidA3FContextPreEmption) or (aEvent == KUidA3FContextPreEmptedCommit)) |
|
198 { |
|
199 //we are not being preemptied |
|
200 iBeingPreempted=EFalse; |
|
201 ContextEventPreEmption(aEvent, aError); |
|
202 } |
|
203 |
|
204 else if (aEvent == KUidA3FContextAbort) |
|
205 { |
|
206 ContextEventAbort(aError); |
|
207 } |
|
208 |
|
209 DP_OUT(); |
|
210 } |
|
211 |
|
212 |
|
213 void CDevCommonControl::ContextEventAsynchronousPlayCompletion(TInt aError) // from CDevCommonControl |
|
214 { |
|
215 DP_CONTEXT(CDevCommonControl::ContextEvent, CtxDevSound, DPLOCAL); |
|
216 DP_IN(); |
|
217 |
|
218 iAdaptationObserver->AsynchronousOperationComplete(aError, ETrue); |
|
219 |
|
220 if (aError) |
|
221 { |
|
222 FinishWithError(aError); |
|
223 } |
|
224 |
|
225 DP_OUT(); |
|
226 } |
|
227 |
|
228 |
|
229 void CDevCommonControl::ContextEventAsynchronousInitializeComplete(TInt aError) // from CDevCommonControl |
|
230 { |
|
231 DP_CONTEXT(CDevCommonControl::ContextEvent, CtxDevSound, DPLOCAL); |
|
232 DP_IN(); |
|
233 |
|
234 iAdaptationObserver->AsynchronousOperationComplete(aError, ETrue); |
|
235 iAdaptationObserver->InitializeComplete(aError); |
|
236 |
|
237 DP_OUT(); |
|
238 } |
|
239 |
|
240 |
|
241 void CDevCommonControl::ContextEventUpdateComplete(TInt aError) // from CDevCommonControl |
|
242 { |
|
243 DP_CONTEXT(CDevCommonControl::ContextEvent, CtxDevSound, DPLOCAL); |
|
244 DP_IN(); |
|
245 |
|
246 if (iStateEventReceived) |
|
247 { |
|
248 iStateEventReceived = EFalse; |
|
249 DP0(DLINFO,"Context event for that does involve state change"); |
|
250 |
|
251 if (aError) |
|
252 { |
|
253 ContextEventUpdateWithStateEventAndError(aError); |
|
254 } |
|
255 else |
|
256 { |
|
257 ContextEventUpdateWithStateEventNoError(); |
|
258 } |
|
259 DP_OUT(); |
|
260 return; |
|
261 } |
|
262 |
|
263 DP0(DLINFO,"Context event for that doesn't involve state change"); |
|
264 |
|
265 if (aError) |
|
266 { |
|
267 ContextEventUpdateWithoutStateEventButWithError(aError); |
|
268 } |
|
269 else |
|
270 { |
|
271 ContextEventUpdateWithoutStateEventNoError(); |
|
272 } |
|
273 |
|
274 DP_OUT(); |
|
275 } |
|
276 |
|
277 |
|
278 void CDevCommonControl::ContextEventPreEmption(TUid aEvent, TInt aError) // from CDevCommonControl |
|
279 { |
|
280 DP_CONTEXT(CDevCommonControl::ContextEvent, CtxDevSound, DPLOCAL); |
|
281 DP_IN(); |
|
282 |
|
283 DP1(DLERR,"Preemption error=%d", aError); |
|
284 CDevAudioControl::ContextEvent(aEvent, aError); |
|
285 iBeingPreempted=ETrue; |
|
286 |
|
287 DP_OUT(); |
|
288 } |
|
289 |
|
290 |
|
291 void CDevCommonControl::ContextEventAbort(TInt aError) // from CDevCommonControl |
|
292 { |
|
293 DP_CONTEXT(CDevCommonControl::ContextEvent, CtxDevSound, DPLOCAL); |
|
294 DP_IN(); |
|
295 |
|
296 DP1(DLERR,"Abort error=%d", aError); |
|
297 FinishWithError(aError==KErrAbort ? KErrDied:aError); |
|
298 |
|
299 DP_OUT(); |
|
300 } |
|
301 |
|
302 |
|
303 void CDevCommonControl::ContextEventStopDevSoundNotifications() // from CDevCommonControl |
|
304 { |
|
305 DP_CONTEXT(CDevCommonControl::ContextEvent, CtxDevSound, DPLOCAL); |
|
306 DP_IN(); |
|
307 |
|
308 iDevAudio->iAudioStream->UnregisterAudioStreamObserver(*this); |
|
309 iGainControl->UnregisterAudioGainControlObserver(*this); |
|
310 iAudioCodecIf->UnregisterAudioCodecObserver(*this); |
|
311 iAudioCodecIf = NULL; |
|
312 |
|
313 DP_OUT(); |
|
314 } |
|
315 |
|
316 |
|
317 void CDevCommonControl::ContextEventPauseResumeSequenceDueToEmptyBuffers(TBool aFlush) // from CDevCommonControl |
|
318 { |
|
319 DP_CONTEXT(CDevCommonControl::ContextEvent, CtxDevSound, DPLOCAL); |
|
320 DP_IN(); |
|
321 |
|
322 TInt err(KErrNone); |
|
323 |
|
324 if (iPauseResumeSequenceDueToEmptyBuffers) |
|
325 { |
|
326 if (aFlush) |
|
327 { |
|
328 err = iDevAudio->iAudioStream->Flush(); |
|
329 } |
|
330 |
|
331 if ((err) or (aFlush==EFalse)) |
|
332 { |
|
333 iPauseResumeSequenceDueToEmptyBuffers = EFalse; |
|
334 iAdaptationObserver->CallbackFromAdaptorReceived(KCallbackFlushComplete, err); |
|
335 } |
|
336 } |
|
337 else |
|
338 { |
|
339 iAdaptationObserver->AsynchronousOperationComplete(KErrNone, ETrue); |
|
340 } |
|
341 |
|
342 DP_OUT(); |
|
343 } |
|
344 |
|
345 |
|
346 void CDevCommonControl::ContextEventStateDevSoundAdaptorUnloading() // from CDevCommonControl |
|
347 { |
|
348 DP_CONTEXT(CDevCommonControl::ContextEvent, CtxDevSound, DPLOCAL); |
|
349 DP_IN(); |
|
350 |
|
351 // Due destruction sequence or reinitialization |
|
352 if (iDevAudio->iClosing or iDevAudio->iReinitializing) |
|
353 { |
|
354 TInt err = Uninitialize(); |
|
355 if (err and iDevAudio->iReinitializing) |
|
356 { |
|
357 ContextEventAsynchronousInitializeComplete(err); |
|
358 |
|
359 } |
|
360 |
|
361 DP_OUT(); |
|
362 return; |
|
363 } |
|
364 |
|
365 // Notify the user that ProcessingFinished is complete. |
|
366 // Stop call complete, sent callback. |
|
367 if (iCallbackFromAdaptor != KCallbackNone) |
|
368 { |
|
369 iAdaptationObserver->AsynchronousOperationComplete(KErrNone, ETrue); |
|
370 |
|
371 if (iCallbackFromAdaptor == KCallbackProcessingFinished) |
|
372 { |
|
373 FinishWithError(KErrUnderflow); |
|
374 } |
|
375 else if (iCallbackFromAdaptor == KCallbackProcessingUnitError) |
|
376 { |
|
377 FinishWithError(iProcessingUnitError); |
|
378 } |
|
379 |
|
380 iCallbackFromAdaptor = KCallbackNone; |
|
381 DP_OUT(); |
|
382 return; |
|
383 } |
|
384 |
|
385 // Error condition |
|
386 if (iErrorCondition) |
|
387 { |
|
388 FinishWithError(iErrorCondition); |
|
389 iErrorCondition = KErrNone; |
|
390 } |
|
391 else |
|
392 { |
|
393 |
|
394 iAdaptationObserver->AsynchronousOperationComplete(KErrNone, ETrue); |
|
395 } |
|
396 |
|
397 DP_OUT(); |
|
398 } |
|
399 |
|
400 |
|
401 void CDevCommonControl::ContextEventStateDevSoundAdaptorLoading() // from CDevCommonControl |
|
402 { |
|
403 DP_CONTEXT(CDevCommonControl::ContextEvent, CtxDevSound, DPLOCAL); |
|
404 DP_IN(); |
|
405 |
|
406 iDevAudio->RequestGainAndBalance(this); // TODO handle error |
|
407 |
|
408 TInt err = iDevAudio->iAudioStream->Activate(); |
|
409 if (err) |
|
410 { |
|
411 DP_OUT(); |
|
412 return; |
|
413 } |
|
414 |
|
415 err = iDevAudio->iAudioContext->Commit(); |
|
416 if (err) |
|
417 { |
|
418 ContextEventAsynchronousPlayCompletion(err); |
|
419 DP_OUT(); |
|
420 return; |
|
421 } |
|
422 |
|
423 iDevAudio->iActiveState = EDevSoundAdaptorActivating; |
|
424 iAdaptationObserver->AsynchronousOperationComplete(KErrNone, EFalse); |
|
425 |
|
426 DP_OUT(); |
|
427 } |
|
428 |
|
429 |
|
430 void CDevCommonControl::ContextEventStateDevSoundAdaptorStopping() // from CDevCommonControl |
|
431 { |
|
432 DP_CONTEXT(CDevCommonControl::ContextEvent, CtxDevSound, DPLOCAL); |
|
433 DP_IN(); |
|
434 |
|
435 TInt err = Unload(); |
|
436 if (err) |
|
437 { |
|
438 DP0(DLINFO,"Commit failed during stopping"); |
|
439 FinishWithError(err); |
|
440 } |
|
441 |
|
442 __ASSERT_DEBUG(err==KErrNone, Panic(ECommitFailedDuringStop)); |
|
443 |
|
444 DP_OUT(); |
|
445 } |
|
446 |
|
447 |
|
448 void CDevCommonControl::ContextEventStateDevSoundAdaptorBeingPreempted() // from CDevCommonControl |
|
449 { |
|
450 DP_CONTEXT(CDevCommonControl::ContextEvent, CtxDevSound, DPLOCAL); |
|
451 DP_IN(); |
|
452 |
|
453 __ASSERT_DEBUG(iDevAudio->iActiveStreamState == EInitialized, Panic(EStreamBeingDemotedToEIdle)); |
|
454 FinishWithError(KErrInUse); |
|
455 if (iIgnoreAsyncOpComplete) |
|
456 { |
|
457 iAdaptationObserver->PreemptionFinishedCallbackReceived(ETrue); |
|
458 iIgnoreAsyncOpComplete=EFalse; |
|
459 DP_OUT(); |
|
460 return; |
|
461 } |
|
462 |
|
463 ContextEventPauseResumeSequenceDueToEmptyBuffers(EFalse); |
|
464 |
|
465 DP_OUT(); |
|
466 } |
|
467 |
|
468 |
|
469 void CDevCommonControl::ContextEventStateDevSoundAdaptorUninitializing() // from CDevCommonControl |
|
470 { |
|
471 DP_CONTEXT(CDevCommonControl::ContextEvent, CtxDevSound, DPLOCAL); |
|
472 DP_IN(); |
|
473 TInt err = RemoveProcessingUnits(); |
|
474 |
|
475 if (err == KErrNone) |
|
476 { |
|
477 iDevAudio->iActiveState = EDevSoundAdaptorRemovingProcessingUnits; |
|
478 } |
|
479 else if (iDevAudio->iReinitializing) |
|
480 { |
|
481 ContextEventAsynchronousInitializeComplete(err); |
|
482 } |
|
483 |
|
484 DP_OUT(); |
|
485 } |
|
486 |
|
487 |
|
488 void CDevCommonControl::ContextEventErrorStateDevSoundAdaptorActivating(TInt aError) // from CDevCommonControl |
|
489 { |
|
490 DP_CONTEXT(CDevCommonControl::ContextEvent, CtxDevSound, DPLOCAL); |
|
491 DP_IN(); |
|
492 |
|
493 // If the resume operation fails as result of EmptyBuffers |
|
494 // Notify about operation complete through CallbackFromAdaptorReceived |
|
495 // and continue to allow client to receive PlayError() |
|
496 if (iPauseResumeSequenceDueToEmptyBuffers) |
|
497 { |
|
498 iPauseResumeSequenceDueToEmptyBuffers = EFalse; |
|
499 iAdaptationObserver->CallbackFromAdaptorReceived(KCallbackFlushComplete, KErrNone); |
|
500 } |
|
501 |
|
502 iErrorCondition = aError; |
|
503 |
|
504 TInt err = Unload(); |
|
505 if (err) |
|
506 { |
|
507 DP0(DLINFO,"Commit failed during stopping"); |
|
508 FinishWithError(err); |
|
509 } |
|
510 __ASSERT_DEBUG(err==KErrNone, Panic(ECommitFailedDuringStop)); |
|
511 |
|
512 DP_OUT(); |
|
513 } |
|
514 |
|
515 |
|
516 void CDevCommonControl::ContextEventErrorStateDevSoundAdaptorBeingPreempted() // from CDevCommonControl |
|
517 { |
|
518 DP_CONTEXT(CDevCommonControl::ContextEvent, CtxDevSound, DPLOCAL); |
|
519 DP_IN(); |
|
520 |
|
521 __ASSERT_DEBUG(iDevAudio->iActiveStreamState == EInitialized, Panic(EStreamBeingDemotedToEIdle)); |
|
522 FinishWithError(KErrInUse); |
|
523 |
|
524 if(iIgnoreAsyncOpComplete) |
|
525 { |
|
526 iAdaptationObserver->PreemptionFinishedCallbackReceived(ETrue); |
|
527 } |
|
528 |
|
529 DP_OUT(); |
|
530 } |
|
531 |
|
532 |
|
533 void CDevCommonControl::ContextEventUpdateWithoutStateEventNoError() // from CDevCommonControl |
|
534 { |
|
535 DP_CONTEXT(CDevCommonControl::ContextEvent, CtxDevSound, DPLOCAL); |
|
536 DP_IN(); |
|
537 |
|
538 if (iDevAudio->iActiveState != EDevSoundAdaptorRemovingProcessingUnits) |
|
539 { |
|
540 iAdaptationObserver->AsynchronousOperationComplete(KErrNone, ETrue); |
|
541 DP_OUT(); |
|
542 return; |
|
543 } |
|
544 |
|
545 iDevAudio->iActiveState = EDevSoundAdaptorCreated_Uninitialised; |
|
546 |
|
547 if (iDevAudio->iReinitializing) |
|
548 { |
|
549 ContextEventStopDevSoundNotifications(); |
|
550 |
|
551 TInt err = iDevAudio->Initialize(iDevAudio->iTargetFormat, iDevAudio->iTargetMode); |
|
552 if(err) |
|
553 { |
|
554 ContextEventAsynchronousInitializeComplete(err); |
|
555 } |
|
556 |
|
557 iDevAudio->iReinitializing = EFalse; |
|
558 DP_OUT(); |
|
559 return; |
|
560 } |
|
561 |
|
562 iDevAudio->iClosing = EFalse; |
|
563 iAdaptationObserver->AsynchronousOperationComplete(KErrNone, ETrue); |
|
564 |
|
565 DP_OUT(); |
|
566 } |
|
567 |
|
568 |
|
569 void CDevCommonControl::ContextEventUpdateWithoutStateEventButWithError(TInt aError) // from CDevCommonControl |
|
570 { |
|
571 DP_CONTEXT(CDevCommonControl::ContextEvent, CtxDevSound, DPLOCAL); |
|
572 DP_IN(); |
|
573 |
|
574 // NOTE: If no state change then do NOT complete the event. |
|
575 |
|
576 // NOTE: We shouldn't actually be in any of the states below when calling this function. |
|
577 // But just in case we are we will rewind the state before dealing with the error. |
|
578 switch (iDevAudio->iActiveState) |
|
579 { |
|
580 case EDevSoundAdaptorInitialising: |
|
581 iDevAudio->iActiveState = EDevSoundAdaptorCreated_Uninitialised; |
|
582 ContextEventAsynchronousInitializeComplete(aError); |
|
583 break; |
|
584 |
|
585 case EDevSoundAdaptorLoading: |
|
586 iDevAudio->iActiveState = EDevSoundAdaptorInitialised_Initialised; |
|
587 ContextEventAsynchronousPlayCompletion(aError); |
|
588 break; |
|
589 |
|
590 case EDevSoundAdaptorActivating: |
|
591 iDevAudio->iActiveState = EDevSoundAdaptorInitialised_Idle; |
|
592 ContextEventAsynchronousPlayCompletion(aError); |
|
593 break; |
|
594 |
|
595 default: |
|
596 break; |
|
597 } |
|
598 |
|
599 DP_OUT(); |
|
600 } |
|
601 |
|
602 |
|
603 void CDevCommonControl::ContextEventUpdateWithStateEventNoError() // from CDevCommonControl |
|
604 { |
|
605 DP_CONTEXT(CDevCommonControl::ContextEvent, CtxDevSound, DPLOCAL); |
|
606 DP_IN(); |
|
607 |
|
608 switch (iDevAudio->iActiveState) |
|
609 { |
|
610 case EDevSoundAdaptorUninitialising: |
|
611 iDevAudio->iActiveState = EDevSoundAdaptorUnitialised_Uninitialised; |
|
612 ContextEventStateDevSoundAdaptorUninitializing(); |
|
613 break; |
|
614 |
|
615 case EDevSoundAdaptorInitialising: |
|
616 iDevAudio->iActiveState = EDevSoundAdaptorInitialised_Initialised; |
|
617 ContextEventAsynchronousInitializeComplete(KErrNone); |
|
618 break; |
|
619 |
|
620 case EDevSoundAdaptorUnloading: |
|
621 iDevAudio->iActiveState = EDevSoundAdaptorInitialised_Initialised; |
|
622 ContextEventStateDevSoundAdaptorUnloading(); |
|
623 break; |
|
624 |
|
625 case EDevSoundAdaptorLoading: |
|
626 iDevAudio->iActiveState = EDevSoundAdaptorGoingActive; |
|
627 ContextEventStateDevSoundAdaptorLoading(); |
|
628 break; |
|
629 |
|
630 case EDevSoundAdaptorStopping: |
|
631 iDevAudio->iActiveState = EDevSoundAdaptorInitialised_Idle; |
|
632 ContextEventStateDevSoundAdaptorStopping(); |
|
633 break; |
|
634 |
|
635 case EDevSoundAdaptorActivating: |
|
636 iDevAudio->iActiveState = EDevSoundAdaptorActive_Active; |
|
637 ContextEventPauseResumeSequenceDueToEmptyBuffers(EFalse); |
|
638 break; |
|
639 |
|
640 case EDevSoundAdaptorPausing: |
|
641 iDevAudio->iActiveState = EDevSoundAdaptorPaused_Primed; |
|
642 ContextEventPauseResumeSequenceDueToEmptyBuffers(ETrue); |
|
643 break; |
|
644 |
|
645 case EDevSoundAdaptorBeingPreempted: |
|
646 iDevAudio->iActiveState = EDevSoundAdaptorInitialised_Initialised; |
|
647 ContextEventStateDevSoundAdaptorBeingPreempted(); |
|
648 break; |
|
649 |
|
650 default: |
|
651 break; |
|
652 } |
|
653 |
|
654 DP_OUT(); |
|
655 } |
|
656 |
|
657 |
|
658 void CDevCommonControl::ContextEventUpdateWithStateEventAndError(TInt aError) // from CDevCommonControl |
|
659 { |
|
660 DP_CONTEXT(CDevCommonControl::ContextEvent, CtxDevSound, DPLOCAL); |
|
661 DP_IN(); |
|
662 |
|
663 DP1(DLERR,"ContextEvent error=%d", aError); |
|
664 |
|
665 switch(iDevAudio->iActiveState) |
|
666 { |
|
667 case EDevSoundAdaptorInitialising: |
|
668 iDevAudio->iActiveState = EDevSoundAdaptorCreated_Uninitialised; |
|
669 iAdaptationObserver->InitializeComplete(aError); |
|
670 break; |
|
671 |
|
672 case EDevSoundAdaptorLoading: |
|
673 iDevAudio->iActiveState = EDevSoundAdaptorInitialised_Initialised; |
|
674 FinishWithError(aError); |
|
675 break; |
|
676 |
|
677 case EDevSoundAdaptorActivating: |
|
678 iDevAudio->iActiveState = EDevSoundAdaptorInitialised_Idle; |
|
679 ContextEventErrorStateDevSoundAdaptorActivating(aError); |
|
680 break; |
|
681 |
|
682 case EDevSoundAdaptorBeingPreempted: |
|
683 iDevAudio->iActiveState = EDevSoundAdaptorInitialised_Initialised; |
|
684 ContextEventErrorStateDevSoundAdaptorBeingPreempted(); |
|
685 break; |
|
686 |
|
687 default: |
|
688 break; |
|
689 } |
|
690 |
|
691 iCallbackFromAdaptor = KCallbackNone; |
|
692 |
|
693 if(iIgnoreAsyncOpComplete==EFalse) |
|
694 { |
|
695 iAdaptationObserver->AsynchronousOperationComplete(aError, ETrue); |
|
696 } |
|
697 |
|
698 iIgnoreAsyncOpComplete=EFalse; |
|
699 |
|
700 DP_OUT(); |
|
701 } |
|
702 |
|
703 |
|
704 // end of file |