158 DP_CONTEXT(CDevCommonControl::ProcessingUnitError, CtxDevSound, DPLOCAL); |
158 DP_CONTEXT(CDevCommonControl::ProcessingUnitError, CtxDevSound, DPLOCAL); |
159 DP_IN(); |
159 DP_IN(); |
160 |
160 |
161 if(iCallbackFromAdaptor == KCallbackNone) |
161 if(iCallbackFromAdaptor == KCallbackNone) |
162 { |
162 { |
|
163 iProcessingUnitError = aError; |
163 iCallbackFromAdaptor = KCallbackProcessingUnitError; |
164 iCallbackFromAdaptor = KCallbackProcessingUnitError; |
164 iAdaptationObserver->CallbackFromAdaptorReceived(KCallbackProcessingUnitError, KErrNone); |
165 iAdaptationObserver->CallbackFromAdaptorReceived(KCallbackProcessingUnitError, aError); |
165 iProcessingUnitError = aError; |
|
166 } |
166 } |
167 else |
167 else |
168 { |
168 { |
169 // Multiple callbacks from adaptor |
169 // Multiple callbacks from adaptor |
170 DP0(DLINFO, "Multiple callbacks from adaptor"); |
170 DP0(DLINFO, "Multiple callbacks from adaptor"); |
175 |
175 |
176 |
176 |
177 void CDevCommonControl::ContextEvent(TUid aEvent, TInt aError) |
177 void CDevCommonControl::ContextEvent(TUid aEvent, TInt aError) |
178 { |
178 { |
179 DP_CONTEXT(CDevCommonControl::ContextEvent, CtxDevSound, DPLOCAL); |
179 DP_CONTEXT(CDevCommonControl::ContextEvent, CtxDevSound, DPLOCAL); |
180 DP_IN(); |
180 DP3_IN("ContextEvent aEvent=%x iActiveState=%d aError=%d",aEvent, iDevAudio->iActiveState, aError); |
181 |
181 |
182 // Can't "switch {...}" on UIDs unfortunately: |
182 // Can't "switch {...}" on UIDs unfortunately: |
183 |
|
184 if (aEvent == KUidA3FContextUpdateComplete) |
183 if (aEvent == KUidA3FContextUpdateComplete) |
185 { |
184 { |
186 //use a sub state pattern to make premtion cycles like other cycles. |
185 if(iBeingPreempted && iStateEventReceived) |
187 if(iBeingPreempted) |
186 { |
188 { |
187 //use a sub state pattern to make premtion cycles like other cycles. |
189 DP1(DLERR,"Preemption error=%d", aError); |
188 DP1(DLERR,"Preemption error=%d", aError); |
190 CDevAudioControl::ContextEvent(aEvent, aError); |
|
191 iDevAudio->iActiveState = EDevSoundAdaptorBeingPreempted; |
189 iDevAudio->iActiveState = EDevSoundAdaptorBeingPreempted; |
192 iBeingPreempted=EFalse; |
190 iBeingPreempted=EFalse; |
193 } |
191 } |
194 ContextEventUpdateComplete(aError); |
192 ContextEventUpdateComplete(aError); |
|
193 } |
|
194 |
|
195 else if ((aEvent == KUidA3FContextCommitUpdate)) |
|
196 { |
|
197 iBeingPreempted=EFalse; // clear being preempted |
|
198 TBool adaptorControlsContext = iAdaptationObserver->AdaptorControlsContext(); |
|
199 iIgnoreAsyncOpComplete = !adaptorControlsContext; |
|
200 // if we don't control context, always send a PreemptionFinishedCallbackReceived() |
|
201 iStateEventReceived=EFalse; |
195 } |
202 } |
196 |
203 |
197 else if ((aEvent == KUidA3FContextPreEmption) or (aEvent == KUidA3FContextPreEmptedCommit)) |
204 else if ((aEvent == KUidA3FContextPreEmption) or (aEvent == KUidA3FContextPreEmptedCommit)) |
198 { |
205 { |
199 //we are not being preemptied |
206 // clear iBeingPreepted - will be set in ContextEventPreEmption if req |
200 iBeingPreempted=EFalse; |
207 iBeingPreempted=EFalse; |
|
208 TBool adaptorControlsContext = iAdaptationObserver->AdaptorControlsContext(); |
|
209 iStateEventReceived=EFalse; |
|
210 iIgnoreAsyncOpComplete=EFalse; // clear being iIgnoreAsyncOpComplete |
201 ContextEventPreEmption(aEvent, aError); |
211 ContextEventPreEmption(aEvent, aError); |
|
212 if (!adaptorControlsContext) |
|
213 { |
|
214 iIgnoreAsyncOpComplete = ETrue; // if we don't control context never do AsyncOpComplete |
|
215 } |
202 } |
216 } |
203 |
217 |
204 else if (aEvent == KUidA3FContextAbort) |
218 else if (aEvent == KUidA3FContextAbort) |
205 { |
219 { |
206 ContextEventAbort(aError); |
220 ContextEventAbort(aError); |
226 } |
240 } |
227 |
241 |
228 |
242 |
229 void CDevCommonControl::ContextEventAsynchronousInitializeComplete(TInt aError) // from CDevCommonControl |
243 void CDevCommonControl::ContextEventAsynchronousInitializeComplete(TInt aError) // from CDevCommonControl |
230 { |
244 { |
231 DP_CONTEXT(CDevCommonControl::ContextEvent, CtxDevSound, DPLOCAL); |
245 DP_CONTEXT(CDevCommonControl::ContextEventAsynchronousInitializeComplete, CtxDevSound, DPLOCAL); |
232 DP_IN(); |
246 DP_IN(); |
233 |
247 |
234 iAdaptationObserver->AsynchronousOperationComplete(aError, ETrue); |
248 iAdaptationObserver->AsynchronousOperationComplete(aError, ETrue); |
235 iAdaptationObserver->InitializeComplete(aError); |
249 iAdaptationObserver->InitializeComplete(aError); |
236 |
250 |
275 } |
289 } |
276 |
290 |
277 |
291 |
278 void CDevCommonControl::ContextEventPreEmption(TUid aEvent, TInt aError) // from CDevCommonControl |
292 void CDevCommonControl::ContextEventPreEmption(TUid aEvent, TInt aError) // from CDevCommonControl |
279 { |
293 { |
280 DP_CONTEXT(CDevCommonControl::ContextEvent, CtxDevSound, DPLOCAL); |
294 DP_CONTEXT(CDevCommonControl::ContextEventPreEmption, CtxDevSound, DPLOCAL); |
281 DP_IN(); |
295 DP_IN(); |
282 |
296 |
283 DP1(DLERR,"Preemption error=%d", aError); |
297 DP1(DLERR,"Preemption error=%d", aError); |
284 CDevAudioControl::ContextEvent(aEvent, aError); |
298 CDevAudioControl::ContextEvent(aEvent, aError); |
285 iBeingPreempted=ETrue; |
299 iBeingPreempted=ETrue; |
288 } |
302 } |
289 |
303 |
290 |
304 |
291 void CDevCommonControl::ContextEventAbort(TInt aError) // from CDevCommonControl |
305 void CDevCommonControl::ContextEventAbort(TInt aError) // from CDevCommonControl |
292 { |
306 { |
293 DP_CONTEXT(CDevCommonControl::ContextEvent, CtxDevSound, DPLOCAL); |
307 DP_CONTEXT(CDevCommonControl::ContextEventAbort, CtxDevSound, DPLOCAL); |
294 DP_IN(); |
308 DP_IN(); |
295 |
309 |
296 DP1(DLERR,"Abort error=%d", aError); |
310 DP1(DLERR,"Abort error=%d", aError); |
297 FinishWithError(aError==KErrAbort ? KErrDied:aError); |
311 FinishWithError(aError==KErrAbort ? KErrDied:aError); |
298 |
312 |
300 } |
314 } |
301 |
315 |
302 |
316 |
303 void CDevCommonControl::ContextEventStopDevSoundNotifications() // from CDevCommonControl |
317 void CDevCommonControl::ContextEventStopDevSoundNotifications() // from CDevCommonControl |
304 { |
318 { |
305 DP_CONTEXT(CDevCommonControl::ContextEvent, CtxDevSound, DPLOCAL); |
319 DP_CONTEXT(CDevCommonControl::ContextEventStopDevSoundNotifications, CtxDevSound, DPLOCAL); |
306 DP_IN(); |
320 DP_IN(); |
307 |
321 |
308 iDevAudio->iAudioStream->UnregisterAudioStreamObserver(*this); |
322 iDevAudio->iAudioStream->UnregisterAudioStreamObserver(*this); |
309 iGainControl->UnregisterAudioGainControlObserver(*this); |
323 iGainControl->UnregisterAudioGainControlObserver(*this); |
310 iAudioCodecIf->UnregisterAudioCodecObserver(*this); |
324 iAudioCodecIf->UnregisterAudioCodecObserver(*this); |
445 } |
459 } |
446 |
460 |
447 |
461 |
448 void CDevCommonControl::ContextEventStateDevSoundAdaptorBeingPreempted() // from CDevCommonControl |
462 void CDevCommonControl::ContextEventStateDevSoundAdaptorBeingPreempted() // from CDevCommonControl |
449 { |
463 { |
450 DP_CONTEXT(CDevCommonControl::ContextEvent, CtxDevSound, DPLOCAL); |
464 DP_CONTEXT(CDevCommonControl::ContextEventStateDevSoundAdaptorBeingPreempted, CtxDevSound, DPLOCAL); |
451 DP_IN(); |
465 DP_IN(); |
452 |
466 |
453 __ASSERT_DEBUG(iDevAudio->iActiveStreamState == EInitialized, Panic(EStreamBeingDemotedToEIdle)); |
467 __ASSERT_DEBUG(iDevAudio->iActiveStreamState == EInitialized, Panic(EStreamBeingDemotedToEIdle)); |
454 FinishWithError(KErrInUse); |
468 FinishWithError(KErrInUse); |
455 if (iIgnoreAsyncOpComplete) |
469 if (iIgnoreAsyncOpComplete) |
485 } |
499 } |
486 |
500 |
487 |
501 |
488 void CDevCommonControl::ContextEventErrorStateDevSoundAdaptorActivating(TInt aError) // from CDevCommonControl |
502 void CDevCommonControl::ContextEventErrorStateDevSoundAdaptorActivating(TInt aError) // from CDevCommonControl |
489 { |
503 { |
490 DP_CONTEXT(CDevCommonControl::ContextEvent, CtxDevSound, DPLOCAL); |
504 DP_CONTEXT(CDevCommonControl::ContextEventErrorStateDevSoundAdaptorActivating, CtxDevSound, DPLOCAL); |
491 DP_IN(); |
505 DP_IN(); |
492 |
506 |
493 // If the resume operation fails as result of EmptyBuffers |
507 // If the resume operation fails as result of EmptyBuffers |
494 // Notify about operation complete through CallbackFromAdaptorReceived |
508 // Notify about operation complete through CallbackFromAdaptorReceived |
495 // and continue to allow client to receive PlayError() |
509 // and continue to allow client to receive PlayError() |
513 } |
527 } |
514 |
528 |
515 |
529 |
516 void CDevCommonControl::ContextEventErrorStateDevSoundAdaptorBeingPreempted() // from CDevCommonControl |
530 void CDevCommonControl::ContextEventErrorStateDevSoundAdaptorBeingPreempted() // from CDevCommonControl |
517 { |
531 { |
518 DP_CONTEXT(CDevCommonControl::ContextEvent, CtxDevSound, DPLOCAL); |
532 DP_CONTEXT(CDevCommonControl::ContextEventErrorStateDevSoundAdaptorBeingPreempted, CtxDevSound, DPLOCAL); |
519 DP_IN(); |
533 DP_IN(); |
520 |
534 |
521 __ASSERT_DEBUG(iDevAudio->iActiveStreamState == EInitialized, Panic(EStreamBeingDemotedToEIdle)); |
535 __ASSERT_DEBUG(iDevAudio->iActiveStreamState == EInitialized, Panic(EStreamBeingDemotedToEIdle)); |
522 FinishWithError(KErrInUse); |
536 FinishWithError(KErrInUse); |
523 |
537 |
530 } |
544 } |
531 |
545 |
532 |
546 |
533 void CDevCommonControl::ContextEventUpdateWithoutStateEventNoError() // from CDevCommonControl |
547 void CDevCommonControl::ContextEventUpdateWithoutStateEventNoError() // from CDevCommonControl |
534 { |
548 { |
535 DP_CONTEXT(CDevCommonControl::ContextEvent, CtxDevSound, DPLOCAL); |
549 DP_CONTEXT(CDevCommonControl::ContextEventUpdateWithoutStateEventNoError, CtxDevSound, DPLOCAL); |
536 DP_IN(); |
550 DP2_IN("iActiveState=%d iIgnoreAsyncOpComplete=%d",iDevAudio->iActiveState, iIgnoreAsyncOpComplete); |
537 |
551 |
538 if (iDevAudio->iActiveState != EDevSoundAdaptorRemovingProcessingUnits) |
552 if (iDevAudio->iActiveState != EDevSoundAdaptorRemovingProcessingUnits) |
539 { |
553 { |
540 iAdaptationObserver->AsynchronousOperationComplete(KErrNone, ETrue); |
554 if (iIgnoreAsyncOpComplete) |
|
555 { |
|
556 iAdaptationObserver->PreemptionFinishedCallbackReceived(ETrue); |
|
557 iIgnoreAsyncOpComplete = EFalse; |
|
558 } |
|
559 else |
|
560 { |
|
561 iAdaptationObserver->AsynchronousOperationComplete(KErrNone, ETrue); |
|
562 } |
541 DP_OUT(); |
563 DP_OUT(); |
542 return; |
564 return; |
543 } |
565 } |
544 |
566 |
545 iDevAudio->iActiveState = EDevSoundAdaptorCreated_Uninitialised; |
567 iDevAudio->iActiveState = EDevSoundAdaptorCreated_Uninitialised; |
566 } |
588 } |
567 |
589 |
568 |
590 |
569 void CDevCommonControl::ContextEventUpdateWithoutStateEventButWithError(TInt aError) // from CDevCommonControl |
591 void CDevCommonControl::ContextEventUpdateWithoutStateEventButWithError(TInt aError) // from CDevCommonControl |
570 { |
592 { |
571 DP_CONTEXT(CDevCommonControl::ContextEvent, CtxDevSound, DPLOCAL); |
593 DP_CONTEXT(CDevCommonControl::ContextEventUpdateWithoutStateEventButWithError, CtxDevSound, DPLOCAL); |
572 DP_IN(); |
594 DP_IN(); |
573 |
595 |
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. |
596 // 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. |
597 // But just in case we are we will rewind the state before dealing with the error. |
578 switch (iDevAudio->iActiveState) |
598 switch (iDevAudio->iActiveState) |
579 { |
599 { |
580 case EDevSoundAdaptorInitialising: |
600 case EDevSoundAdaptorInitialising: |
655 } |
675 } |
656 |
676 |
657 |
677 |
658 void CDevCommonControl::ContextEventUpdateWithStateEventAndError(TInt aError) // from CDevCommonControl |
678 void CDevCommonControl::ContextEventUpdateWithStateEventAndError(TInt aError) // from CDevCommonControl |
659 { |
679 { |
660 DP_CONTEXT(CDevCommonControl::ContextEvent, CtxDevSound, DPLOCAL); |
680 DP_CONTEXT(CDevCommonControl::ContextEventUpdateWithStateEventAndError, CtxDevSound, DPLOCAL); |
661 DP_IN(); |
681 DP_IN(); |
662 |
682 |
663 DP1(DLERR,"ContextEvent error=%d", aError); |
683 DP1(DLERR,"ContextEventUpdateWithStateEventAndError error=%d", aError); |
664 |
684 |
665 switch(iDevAudio->iActiveState) |
685 switch(iDevAudio->iActiveState) |
666 { |
686 { |
667 case EDevSoundAdaptorInitialising: |
687 case EDevSoundAdaptorInitialising: |
668 iDevAudio->iActiveState = EDevSoundAdaptorCreated_Uninitialised; |
688 iDevAudio->iActiveState = EDevSoundAdaptorCreated_Uninitialised; |