devsound/a3fdevsound/src/mmfdevsoundserver/mmfdevsoundsession.cpp
changeset 15 c1e808730d6c
parent 13 efebd1779a59
child 24 2672ba96448e
equal deleted inserted replaced
13:efebd1779a59 15:c1e808730d6c
    24 #include "e32debug.h"
    24 #include "e32debug.h"
    25 
    25 
    26 #define SYMBIAN_DEBPRN0(str)                RDebug::Print(str, this)
    26 #define SYMBIAN_DEBPRN0(str)                RDebug::Print(str, this)
    27 #define SYMBIAN_DEBPRN1(str, val1)          RDebug::Print(str, this, val1)
    27 #define SYMBIAN_DEBPRN1(str, val1)          RDebug::Print(str, this, val1)
    28 #define SYMBIAN_DEBPRN2(str, val1, val2)    RDebug::Print(str, this, val1, val2)
    28 #define SYMBIAN_DEBPRN2(str, val1, val2)    RDebug::Print(str, this, val1, val2)
       
    29 #define SYMBIAN_DEBPRN3(str, val1, val2, val3)    RDebug::Print(str, this, val1, val2, val3)
    29 #else
    30 #else
    30 #define SYMBIAN_DEBPRN0(str)
    31 #define SYMBIAN_DEBPRN0(str)
    31 #define SYMBIAN_DEBPRN1(str, val1)
    32 #define SYMBIAN_DEBPRN1(str, val1)
    32 #define SYMBIAN_DEBPRN2(str, val1, val2)
    33 #define SYMBIAN_DEBPRN2(str, val1, val2)
       
    34 #define SYMBIAN_DEBPRN3(str, val1, val2, val3)
    33 #endif //_DEBUG
    35 #endif //_DEBUG
    34 
    36 
    35 //Assume that we can have two user request and one callback request
    37 const TInt KMaxQueueRequest = 6;
    36 //at the same time (maximum).
       
    37 const TInt KMaxQueueRequest = 3;
       
    38 
    38 
    39 //	MEMBER FUNCTIONS 
    39 //	MEMBER FUNCTIONS 
    40 
    40 
    41 TMMFDevSoundRequest::TMMFDevSoundRequest() 
    41 TMMFDevSoundRequest::TMMFDevSoundRequest() 
    42 	: iMessageCompleted(EFalse), 
    42 	: iMessageCompleted(EFalse), 
   220 	server.IncrementSessionId();
   220 	server.IncrementSessionId();
   221 	iDevSoundSessionId = server.DevSoundSessionId();
   221 	iDevSoundSessionId = server.DevSoundSessionId();
   222 	}
   222 	}
   223 
   223 
   224 //
   224 //
       
   225 // NeedToQueue - mid-commit cycle or async queue start AO is active
       
   226 //
       
   227 TBool CMMFDevSoundSession::NeedToQueue() const
       
   228     {
       
   229     return iOperationCompletePending || iAsyncQueueStart->IsActive();
       
   230     }
       
   231 
       
   232 //
   225 // CMMFDevSoundSession::ServiceL
   233 // CMMFDevSoundSession::ServiceL
   226 // (other items were commented in a header).
   234 // (other items were commented in a header).
   227 //
   235 //
   228 void CMMFDevSoundSession::ServiceL(const RMmfIpcMessage& aMessage)
   236 void CMMFDevSoundSession::ServiceL(const RMmfIpcMessage& aMessage)
   229 	{
   237 	{
   230 	SYMBIAN_DEBPRN2(_L("\nCMMFDevSoundSession[0x%x] NEW REQUEST %02x while pending=%d"),
   238 	SYMBIAN_DEBPRN2(_L("\nCMMFDevSoundSession[0x%x] NEW REQUEST %02x while pending=%d"),
   231 	        aMessage.Function(), iOperationCompletePending || iAsyncQueueStart->IsActive());
   239 	        aMessage.Function(), NeedToQueue());
   232 	if( iOperationCompletePending || iAsyncQueueStart->IsActive())
   240 	
       
   241 	if(NeedToQueue())
   233 		{
   242 		{
   234 		// if not possible to service now, then queue request
   243 		// if not possible to service now, then queue request
   235 		EnqueueRequest(aMessage);
   244 		EnqueueRequest(aMessage);
   236 		}
   245 		}
   237 	else
   246 	else
   254 // CMMFDevSoundSession::DoServiceL
   263 // CMMFDevSoundSession::DoServiceL
   255 // (other items were commented in a header).
   264 // (other items were commented in a header).
   256 //
   265 //
   257 void CMMFDevSoundSession::DoServiceRequestL(const RMmfIpcMessage& aMessage)
   266 void CMMFDevSoundSession::DoServiceRequestL(const RMmfIpcMessage& aMessage)
   258 	{
   267 	{
       
   268 	iRequestBeingServiced.SetMessage(aMessage);
   259 	iAsyncQueueStart->Cancel(); // just in case.
   269 	iAsyncQueueStart->Cancel(); // just in case.
   260 	TMMFMessageDestinationPckg destinationPckg;
   270     ResetNotifiedError();
       
   271 
       
   272     TMMFMessageDestinationPckg destinationPckg;
   261 	MmfMessageUtil::ReadL(aMessage, 0, destinationPckg);
   273 	MmfMessageUtil::ReadL(aMessage, 0, destinationPckg);
       
   274 	SYMBIAN_DEBPRN2(_L("CMMFDevSoundSession[0x%x]::DoServiceRequestL - DestinationHandle [%d] InterfaceId [%d] "), destinationPckg().DestinationHandle(), destinationPckg().InterfaceId());
   262 	if ((destinationPckg().DestinationHandle() == KMMFObjectHandleDevSound) &&
   275 	if ((destinationPckg().DestinationHandle() == KMMFObjectHandleDevSound) &&
   263 	    (destinationPckg().InterfaceId() == KUidInterfaceMMFDevSound))
   276 	    (destinationPckg().InterfaceId() == KUidInterfaceMMFDevSound))
   264 		{
   277 		{
       
   278         SYMBIAN_DEBPRN1(_L("CMMFDevSoundSession[0x%x]::DoServiceRequestL - Request [%d]"), aMessage.Function());
   265 		TBool complete = EFalse;
   279 		TBool complete = EFalse;
   266 		switch(aMessage.Function())
   280 		switch(aMessage.Function())
   267 			{
   281 			{
   268 			case EMMFDevSoundProxyPostOpen:
   282 			case EMMFDevSoundProxyPostOpen:
   269 				complete = DoPostOpenL(aMessage);
   283 				complete = DoPostOpenL(aMessage);
   435 		if (complete)
   449 		if (complete)
   436 			{
   450 			{
   437 			// Complete the message
   451 			// Complete the message
   438 			// Synchronous requests & Pseudo-asynchronous
   452 			// Synchronous requests & Pseudo-asynchronous
   439 			aMessage.Complete(KErrNone);
   453 			aMessage.Complete(KErrNone);
   440 			}
   454 
   441 		// Note: There are operations that not complete the message using the following flag
   455 			// Store function if we need to re-apply it again due to pre-emption clash
   442 		// So if the message is not completed, cannot be assumed that there is an operation pending
   456 			if(iRequestBeingServiced.Type() == TMMFDevSoundRequest::EAction_PseudoAsynchronous)
   443 		
   457 				{
   444 		if(iOperationCompletePending)
   458 				iRedoFunction = aMessage.Function();
   445 			{
   459 				}
   446 			// Keep a copy of the message for Asynchronous requests & Pseudo-asynchronous
   460 			}
   447 			iRequestBeingServiced.SetMessage(aMessage);
   461 		}
   448 			}
   462 	else if (aMessage.Function() == RMessage2::EDisConnect)
   449 		}
   463 	    {
       
   464         TBool complete = iAdapter->CloseDevSound();
       
   465         if(!complete)
       
   466             {
       
   467             iRequestBeingServiced.SetMessage(aMessage);
       
   468             iOperationCompletePending = ETrue;
       
   469             ResetNotifiedError();
       
   470             }
       
   471         else
       
   472             {
       
   473             // if we get here, iClosing wait will have been started and we'd be waiting
       
   474             iClosingWait->AsyncStop();
       
   475             }
       
   476 	    }
   450 	else
   477 	else
   451 		{
   478 		{
   452 		// If there's a CI extension, see if that handles this request
   479 		// If there's a CI extension, see if that handles this request
   453 		TInt err = KErrNotSupported;
   480 		TInt err = KErrNotSupported;
   454 		if (iCIExtension)
   481 		if (iCIExtension)
   455 			{
   482 			{
   456 			iOperationCompletePending = ETrue;
   483             SYMBIAN_DEBPRN1(_L("CMMFDevSoundSession[0x%x]::DoServiceRequestL - CIExtensionRequest [%d]"), aMessage.Function());
       
   484             iOperationCompletePending = ETrue;
   457 			iHandlingExtdCI = ETrue;
   485 			iHandlingExtdCI = ETrue;
   458 			TRAPD(err2, err = iCIExtension->HandleMessageL(aMessage));
   486 			TRAPD(err2, err = iCIExtension->HandleMessageL(aMessage));
   459 			if (err2)
   487 			if (err2)
   460 				{
   488 				{
   461 				err = err2;
   489 				err = err2;
   462 				}
   490 				}
   463 			iOperationCompletePending = EFalse;
   491 			iOperationCompletePending = EFalse;
   464 			iHandlingExtdCI = EFalse;
   492 			iHandlingExtdCI = EFalse;
       
   493 			SYMBIAN_DEBPRN2(_L("CMMFDevSoundSession[0x%x]::DoServiceRequestL - CIExtensionRequest[%d] - Exit with Error[%d] "), aMessage.Function(),err);
   465 			}
   494 			}
   466 
   495 
   467 		if (err != KErrNone)
   496 		if (err != KErrNone)
   468 			{
   497 			{
   469 			// Not been handled, the request is not supported
   498 			// Not been handled, the request is not supported
   470 			aMessage.Complete(KErrNotSupported);
   499 			aMessage.Complete(KErrNotSupported);
   471 			}
   500 			}
   472 		}
   501 		}
   473 	}
   502 	}
   474 
   503 
       
   504 void CMMFDevSoundSession::DoServiceAlreadyCompletedRequestL(const TInt aFunction)
       
   505 	{
       
   506     ResetNotifiedError();
       
   507 
       
   508 	switch(aFunction)
       
   509 		{
       
   510 		case EMMFDevSoundProxyInitialize1:
       
   511 			DoAlreadyCompletedInitialize1L();
       
   512 			break;
       
   513 		case EMMFDevSoundProxyInitialize2:
       
   514 			DoAlreadyCompletedInitialize2L();
       
   515 			break;
       
   516 		case EMMFDevSoundProxyInitialize4:
       
   517 			DoAlreadyCompletedInitialize4L();
       
   518 			break;
       
   519 		case EMMFDevSoundProxyPlayInit:
       
   520 			DoAlreadyCompletedPlayInitL();
       
   521 			break;
       
   522 		case EMMFDevSoundProxyRecordInit:
       
   523 			DoAlreadyCompletedRecordInitL();
       
   524 			break;
       
   525 		case EMMFDevSoundProxyPlayTone:
       
   526 			DoAlreadyCompletedPlayToneL();
       
   527 			break;
       
   528 		case EMMFDevSoundProxyPlayDualTone:
       
   529 			DoAlreadyCompletedPlayDualToneL();
       
   530 			break;
       
   531 		case EMMFDevSoundProxyPlayDTMFString:
       
   532 			DoAlreadyCompletedPlayDTMFStringL();
       
   533 			break;
       
   534 		case EMMFDevSoundProxyPlayToneSequence:
       
   535 			DoAlreadyCompletedPlayToneSequenceL();
       
   536 			break;
       
   537 		case EMMFDevSoundProxyPlayFixedSequence:
       
   538 			DoAlreadyCompletedPlayFixedSequenceL();
       
   539 			break;
       
   540 		default:
       
   541 			User::Leave(KErrNotSupported);
       
   542 			break;
       
   543 		}
       
   544 
       
   545 	}
       
   546 
       
   547 void CMMFDevSoundSession::HandleAlreadyCompletedRequest()
       
   548 	{
       
   549 	TRAPD(err,DoServiceAlreadyCompletedRequestL(iRedoFunction));
       
   550 
       
   551 	if (err != KErrNone)
       
   552 		{
       
   553 		switch(iRedoFunction)
       
   554 			{
       
   555 			case EMMFDevSoundProxyInitialize1:
       
   556 			case EMMFDevSoundProxyInitialize2:
       
   557 			case EMMFDevSoundProxyInitialize4:
       
   558 				InitializeComplete(err);
       
   559 				break;
       
   560 			case EMMFDevSoundProxyPlayInit:
       
   561 				PlayError(err);
       
   562 				break;
       
   563 			case EMMFDevSoundProxyRecordInit:
       
   564 				RecordError(err);
       
   565 				break;
       
   566 			case EMMFDevSoundProxyPlayTone:
       
   567 			case EMMFDevSoundProxyPlayDualTone:
       
   568 			case EMMFDevSoundProxyPlayDTMFString:
       
   569 			case EMMFDevSoundProxyPlayToneSequence:
       
   570 			case EMMFDevSoundProxyPlayFixedSequence:
       
   571 				ToneFinished(err);
       
   572 				break;
       
   573 			default:
       
   574 				break;
       
   575 			}
       
   576 		}
       
   577 	}
   475 
   578 
   476 void CMMFDevSoundSession::EnqueueRequest(const RMmfIpcMessage& aMessage)
   579 void CMMFDevSoundSession::EnqueueRequest(const RMmfIpcMessage& aMessage)
   477 	{
   580 	{
   478 	// Encapsule the request
   581 	// Encapsule the request
   479 	TMMFDevSoundRequest request;
   582 	TMMFDevSoundRequest request;
   497 // CMMFDevSoundSession::DoInitialize1L
   600 // CMMFDevSoundSession::DoInitialize1L
   498 // (other items were commented in a header).
   601 // (other items were commented in a header).
   499 //
   602 //
   500 TBool CMMFDevSoundSession::DoInitialize1L(const RMmfIpcMessage& aMessage)
   603 TBool CMMFDevSoundSession::DoInitialize1L(const RMmfIpcMessage& aMessage)
   501 	{
   604 	{
   502 	TInt err = iMsgQueue.Open(aMessage, 2); // a global queue.
   605     iMsgQueue.Close(); // close if already open
       
   606 	TInt err = iMsgQueue.Open(aMessage, 2, EOwnerThread); // a global queue but owned by thread
   503 	User::LeaveIfError(err);
   607 	User::LeaveIfError(err);
   504 	DoSetClientConfigL();// added here instead of the CreateL()
   608 	DoSetClientConfigL();// added here instead of the CreateL()
   505 	TMMFDevSoundProxySettingsPckg devSoundBuf;
   609 	TMMFDevSoundProxySettingsPckg devSoundBuf;
   506 	MmfMessageUtil::ReadL(aMessage,1,devSoundBuf);
   610 	MmfMessageUtil::ReadL(aMessage,1,devSoundBuf);
       
   611 	iCachedClientData = devSoundBuf;
   507 	TMMFState mode = devSoundBuf().iMode;
   612 	TMMFState mode = devSoundBuf().iMode;
   508 	iAdapter->InitializeL(mode);
   613 	iAdapter->InitializeL(mode);
   509 	iBufferPlay = NULL;
   614 	iBufferPlay = NULL;
   510 	iPlayErrorOccured = EFalse;
   615 	iPlayErrorOccured = EFalse;
   511 	// Flag to queue any further request 
   616 	// Flag to queue any further request 
   513 	iOperationCompletePending = ETrue;
   618 	iOperationCompletePending = ETrue;
   514 	return ETrue;
   619 	return ETrue;
   515 	}
   620 	}
   516 
   621 
   517 //
   622 //
       
   623 // CMMFDevSoundSession::DoAlreadyCompletedInitialize1L
       
   624 // (other items were commented in a header).
       
   625 //
       
   626 void CMMFDevSoundSession::DoAlreadyCompletedInitialize1L()
       
   627 	{
       
   628 	TMMFState mode = iCachedClientData().iMode;
       
   629 	iAdapter->InitializeL(mode);
       
   630 	iBufferPlay = NULL;
       
   631 	iPlayErrorOccured = EFalse;
       
   632 	// Flag to queue any further request
       
   633 	iOperationCompletePending = ETrue;
       
   634 	}
       
   635 
       
   636 //
   518 // CMMFDevSoundSession::DoInitialize2L
   637 // CMMFDevSoundSession::DoInitialize2L
   519 // (other items were commented in a header).
   638 // (other items were commented in a header).
   520 //
   639 //
   521 TBool CMMFDevSoundSession::DoInitialize2L(const RMmfIpcMessage& aMessage)
   640 TBool CMMFDevSoundSession::DoInitialize2L(const RMmfIpcMessage& aMessage)
   522 	{
   641 	{
   523 	TInt err = iMsgQueue.Open(aMessage, 2); // a global queue.
   642     iMsgQueue.Close(); // close if already open
       
   643 	TInt err = iMsgQueue.Open(aMessage, 2, EOwnerThread); // a global queue but owned by thread
   524 	User::LeaveIfError(err);
   644 	User::LeaveIfError(err);
   525 	DoSetClientConfigL();// added here instead of the CreateL()
   645 	DoSetClientConfigL();// added here instead of the CreateL()
   526 	TMMFDevSoundProxySettingsPckg devSoundBuf;
   646 	TMMFDevSoundProxySettingsPckg devSoundBuf;
   527 	MmfMessageUtil::ReadL(aMessage,1,devSoundBuf);
   647 	MmfMessageUtil::ReadL(aMessage,1,devSoundBuf);
       
   648 	iCachedClientData = devSoundBuf;
   528 	TUid HWDev = devSoundBuf().iHWDev;
   649 	TUid HWDev = devSoundBuf().iHWDev;
   529 	TMMFState mode = devSoundBuf().iMode;
   650 	TMMFState mode = devSoundBuf().iMode;
   530 	iAdapter->InitializeL(HWDev, mode);
   651 	iAdapter->InitializeL(HWDev, mode);
   531 	iBufferPlay = NULL;
   652 	iBufferPlay = NULL;
   532 	iPlayErrorOccured = EFalse;
   653 	iPlayErrorOccured = EFalse;
   533 	return ETrue;
   654 	return ETrue;
   534 	}
   655 	}
   535 
   656 
   536 //
   657 //
       
   658 // CMMFDevSoundSession::DoAlreadyCompletedInitialize2L
       
   659 // (other items were commented in a header).
       
   660 //
       
   661 void CMMFDevSoundSession::DoAlreadyCompletedInitialize2L()
       
   662 	{
       
   663 	TUid HWDev = iCachedClientData().iHWDev;
       
   664 	TMMFState mode = iCachedClientData().iMode;
       
   665 	iAdapter->InitializeL(HWDev, mode);
       
   666 	iBufferPlay = NULL;
       
   667 	iPlayErrorOccured = EFalse;
       
   668 	}
       
   669 
       
   670 //
   537 // CMMFDevSoundSession::DoInitialize4L
   671 // CMMFDevSoundSession::DoInitialize4L
   538 // (other items were commented in a header).
   672 // (other items were commented in a header).
   539 //
   673 //
   540 TBool CMMFDevSoundSession::DoInitialize4L(const RMmfIpcMessage& aMessage)
   674 TBool CMMFDevSoundSession::DoInitialize4L(const RMmfIpcMessage& aMessage)
   541 	{
   675 	{
   542 	TInt err = iMsgQueue.Open(aMessage, 2); // a global queue.
   676     iMsgQueue.Close();
       
   677 	TInt err = iMsgQueue.Open(aMessage, 2, EOwnerThread); // a global queue but owned by thread
   543 	User::LeaveIfError(err);
   678 	User::LeaveIfError(err);
   544 	DoSetClientConfigL();// added here instead of the CreateL()
   679 	DoSetClientConfigL();// added here instead of the CreateL()
   545 	TMMFDevSoundProxySettingsPckg devSoundBuf;
   680 	TMMFDevSoundProxySettingsPckg devSoundBuf;
   546 	aMessage.ReadL(TInt(1),devSoundBuf);
   681 	aMessage.ReadL(TInt(1),devSoundBuf);
       
   682 	iCachedClientData = devSoundBuf;
   547 	TFourCC desiredFourCC = devSoundBuf().iDesiredFourCC;
   683 	TFourCC desiredFourCC = devSoundBuf().iDesiredFourCC;
   548 	TMMFState mode = devSoundBuf().iMode;
   684 	TMMFState mode = devSoundBuf().iMode;
   549 	iAdapter->InitializeL(desiredFourCC, mode);
   685 	iAdapter->InitializeL(desiredFourCC, mode);
   550 	iBufferPlay = NULL;
   686 	iBufferPlay = NULL;
   551 	iPlayErrorOccured = EFalse;
   687 	iPlayErrorOccured = EFalse;
   554 	iOperationCompletePending = ETrue;
   690 	iOperationCompletePending = ETrue;
   555 	return ETrue;
   691 	return ETrue;
   556 	}
   692 	}
   557 
   693 
   558 //
   694 //
       
   695 // CMMFDevSoundSession::DoAlreadyCompletedInitialize4L
       
   696 // (other items were commented in a header).
       
   697 //
       
   698 void CMMFDevSoundSession::DoAlreadyCompletedInitialize4L()
       
   699 	{
       
   700 	TFourCC desiredFourCC = iCachedClientData().iDesiredFourCC;
       
   701 	TMMFState mode = iCachedClientData().iMode;
       
   702 	iAdapter->InitializeL(desiredFourCC, mode);
       
   703 	iBufferPlay = NULL;
       
   704 	iPlayErrorOccured = EFalse;
       
   705 	// Flag to queue any further request
       
   706 	iOperationCompletePending = ETrue;
       
   707 	}
       
   708 
       
   709 //
   559 // CMMFDevSoundSession::DoCancelInitialize
   710 // CMMFDevSoundSession::DoCancelInitialize
   560 // (other items were commented in a header).
   711 // (other items were commented in a header).
   561 //
   712 //
   562 TBool CMMFDevSoundSession::DoCancelInitializeL(const RMmfIpcMessage& aMessage)
   713 TBool CMMFDevSoundSession::DoCancelInitializeL(const RMmfIpcMessage& aMessage)
   563 	{
   714 	{
   772 	iOperationCompletePending = ETrue;
   923 	iOperationCompletePending = ETrue;
   773 	return ETrue;
   924 	return ETrue;
   774 	}
   925 	}
   775 
   926 
   776 //
   927 //
       
   928 // CMMFDevSoundSession::DoAlreadyCompletedPlayInitL
       
   929 // (other items were commented in a header).
       
   930 //
       
   931 void CMMFDevSoundSession::DoAlreadyCompletedPlayInitL()
       
   932 	{
       
   933 	iAdapter->PlayInitL();
       
   934 	iOperationCompletePending = ETrue;
       
   935 	}
       
   936 
       
   937 //
   777 // CMMFDevSoundSession::DoRecordInitL
   938 // CMMFDevSoundSession::DoRecordInitL
   778 // (other items were commented in a header).
   939 // (other items were commented in a header).
   779 //
   940 //
   780 TBool CMMFDevSoundSession::DoRecordInitL(const RMmfIpcMessage& /*aMessage*/)
   941 TBool CMMFDevSoundSession::DoRecordInitL(const RMmfIpcMessage& /*aMessage*/)
   781 	{
   942 	{
   782 	iAdapter->RecordInitL();
   943 	iAdapter->RecordInitL();
   783 	iOperationCompletePending = ETrue;
   944 	iOperationCompletePending = ETrue;
   784 	return ETrue;
   945 	return ETrue;
       
   946 	}
       
   947 
       
   948 //
       
   949 // CMMFDevSoundSession::DoAlreadyCompletedRecordInitL
       
   950 // (other items were commented in a header).
       
   951 //
       
   952 void CMMFDevSoundSession::DoAlreadyCompletedRecordInitL()
       
   953 	{
       
   954 	iAdapter->RecordInitL();
       
   955 	iOperationCompletePending = ETrue;
   785 	}
   956 	}
   786 
   957 
   787 //
   958 //
   788 // CMMFDevSoundSession::DoPlayDataL
   959 // CMMFDevSoundSession::DoPlayDataL
   789 // (other items were commented in a header).
   960 // (other items were commented in a header).
   824 // CMMFDevSoundSession::DoStopL
   995 // CMMFDevSoundSession::DoStopL
   825 // (other items were commented in a header).
   996 // (other items were commented in a header).
   826 //
   997 //
   827 TBool CMMFDevSoundSession::DoStopL(const RMmfIpcMessage& /*aMessage*/)
   998 TBool CMMFDevSoundSession::DoStopL(const RMmfIpcMessage& /*aMessage*/)
   828 	{
   999 	{
   829 	// Sometimes Stop is not involved on a commit cycle
  1000     SYMBIAN_DEBPRN0(_L("CMMFDevSoundSession[0x%x]::DoStopL - Enter"));
       
  1001     // Sometimes Stop is not involved on a commit cycle
   830 	TBool completed = iAdapter->Stop();
  1002 	TBool completed = iAdapter->Stop();
   831 	if (completed)
  1003 	if (completed)
   832 		{
  1004 		{
   833 		iQueuedRequests.Reset();
  1005 		iQueuedRequests.Reset();
   834 		FlushEventQueue(); // completed returned here means we were idle to start with. TODO could possibly skip this flush
  1006 		FlushEventQueue(); // completed returned here means we were idle to start with. TODO could possibly skip this flush
   835 		iChunk.Close();
  1007 		iChunk.Close();
   836 		}
  1008 		}
   837 	iOperationCompletePending = !completed;
  1009 	iOperationCompletePending = !completed;
       
  1010 	SYMBIAN_DEBPRN1(_L("CMMFDevSoundSession[0x%x]::DoStopL - Exit. Return value is [%d]"), completed);
   838 	return completed;
  1011 	return completed;
   839 	}
  1012 	}
   840 
  1013 
   841 //
  1014 //
   842 // CMMFDevSoundSession::DoPauseL
  1015 // CMMFDevSoundSession::DoPauseL
   853 // CMMFDevSoundSession::DoPlayToneL
  1026 // CMMFDevSoundSession::DoPlayToneL
   854 // (other items were commented in a header).
  1027 // (other items were commented in a header).
   855 //
  1028 //
   856 TBool CMMFDevSoundSession::DoPlayToneL(const RMmfIpcMessage& aMessage)
  1029 TBool CMMFDevSoundSession::DoPlayToneL(const RMmfIpcMessage& aMessage)
   857 	{
  1030 	{
   858 	TMMFDevSoundProxySettingsPckg devSoundBuf;
  1031     SYMBIAN_DEBPRN0(_L("CMMFDevSoundSession[0x%x]::DoPlayToneL - Enter"));
       
  1032     TMMFDevSoundProxySettingsPckg devSoundBuf;
   859 	aMessage.ReadL(TInt(1),devSoundBuf);
  1033 	aMessage.ReadL(TInt(1),devSoundBuf);
       
  1034 	iCachedClientData = devSoundBuf;
   860 	TInt frequency = devSoundBuf().iFrequencyOne;
  1035 	TInt frequency = devSoundBuf().iFrequencyOne;
   861 	TTimeIntervalMicroSeconds duration(devSoundBuf().iDuration);
  1036 	TTimeIntervalMicroSeconds duration(devSoundBuf().iDuration);
   862 	iAdapter->PlayToneL(frequency, duration);
  1037 	iAdapter->PlayToneL(frequency, duration);
   863 	iOperationCompletePending = ETrue;
  1038 	iOperationCompletePending = ETrue;
   864 	return ETrue;
  1039 	SYMBIAN_DEBPRN1(_L("CMMFDevSoundSession[0x%x]::DoPlayToneL - Exit. Return value is [%d]"), ETrue);
       
  1040 	return ETrue;
       
  1041 	}
       
  1042 
       
  1043 //
       
  1044 // CMMFDevSoundSession::DoAlreadyCompletedPlayToneL
       
  1045 // (other items were commented in a header).
       
  1046 //
       
  1047 void CMMFDevSoundSession::DoAlreadyCompletedPlayToneL()
       
  1048 	{
       
  1049 	TInt frequency = iCachedClientData().iFrequencyOne;
       
  1050 	TTimeIntervalMicroSeconds duration(iCachedClientData().iDuration);
       
  1051 	iAdapter->PlayToneL(frequency, duration);
       
  1052 	iOperationCompletePending = ETrue;
   865 	}
  1053 	}
   866 
  1054 
   867 //
  1055 //
   868 // CMMFDevSoundSession::DoPlayDualToneL
  1056 // CMMFDevSoundSession::DoPlayDualToneL
   869 // (other items were commented in a header).	
  1057 // (other items were commented in a header).	
   870 //
  1058 //
   871 TBool CMMFDevSoundSession::DoPlayDualToneL(const RMmfIpcMessage& aMessage)
  1059 TBool CMMFDevSoundSession::DoPlayDualToneL(const RMmfIpcMessage& aMessage)
   872 	{
  1060 	{
   873 	TMMFDevSoundProxySettingsPckg devSoundBuf;
  1061     SYMBIAN_DEBPRN0(_L("CMMFDevSoundSession[0x%x]::DoPlayDualToneL - Enter"));
       
  1062     TMMFDevSoundProxySettingsPckg devSoundBuf;
   874 	aMessage.ReadL(TInt(1),devSoundBuf);
  1063 	aMessage.ReadL(TInt(1),devSoundBuf);
       
  1064 	iCachedClientData = devSoundBuf;
   875 	TInt frequencyOne = devSoundBuf().iFrequencyOne;
  1065 	TInt frequencyOne = devSoundBuf().iFrequencyOne;
   876 	TInt frequencyTwo = devSoundBuf().iFrequencyTwo;
  1066 	TInt frequencyTwo = devSoundBuf().iFrequencyTwo;
   877 	TTimeIntervalMicroSeconds duration(devSoundBuf().iDuration);
  1067 	TTimeIntervalMicroSeconds duration(devSoundBuf().iDuration);
   878 	iAdapter->PlayDualToneL(frequencyOne, frequencyTwo, duration);
  1068 	iAdapter->PlayDualToneL(frequencyOne, frequencyTwo, duration);
   879 	iOperationCompletePending = ETrue;
  1069 	iOperationCompletePending = ETrue;
   880 	return ETrue;
  1070 	SYMBIAN_DEBPRN1(_L("CMMFDevSoundSession[0x%x]::DoPlayDualToneL - Exit. Return value is [%d]"), ETrue);
       
  1071 	return ETrue;
       
  1072 	}
       
  1073 
       
  1074 //
       
  1075 // CMMFDevSoundSession::DoAlreadyCompletedPlayDualToneL
       
  1076 // (other items were commented in a header).
       
  1077 //
       
  1078 void CMMFDevSoundSession::DoAlreadyCompletedPlayDualToneL()
       
  1079 	{
       
  1080 	TInt frequencyOne = iCachedClientData().iFrequencyOne;
       
  1081 	TInt frequencyTwo = iCachedClientData().iFrequencyTwo;
       
  1082 	TTimeIntervalMicroSeconds duration(iCachedClientData().iDuration);
       
  1083 	iAdapter->PlayDualToneL(frequencyOne, frequencyTwo, duration);
       
  1084 	iOperationCompletePending = ETrue;
   881 	}
  1085 	}
   882 
  1086 
   883 //
  1087 //
   884 // CMMFDevSoundSession::DoPlayDTMFStringL
  1088 // CMMFDevSoundSession::DoPlayDTMFStringL
   885 // (other items were commented in a header).
  1089 // (other items were commented in a header).
   886 //
  1090 //
   887 TBool CMMFDevSoundSession::DoPlayDTMFStringL(const RMmfIpcMessage& aMessage)
  1091 TBool CMMFDevSoundSession::DoPlayDTMFStringL(const RMmfIpcMessage& aMessage)
   888 	{
  1092 	{
   889 	TInt dtmfLength = aMessage.GetDesLength(2);
  1093     SYMBIAN_DEBPRN0(_L("CMMFDevSoundSession[0x%x]::DoPlayDTMFStringL - Enter"));
       
  1094     TInt dtmfLength = aMessage.GetDesLength(2);
   890 	
  1095 	
   891 	if(iDtmfString)
  1096 	if(iDtmfString)
   892 		{
  1097 		{
   893 		delete iDtmfString;
  1098 		delete iDtmfString;
   894 		iDtmfString = NULL;
  1099 		iDtmfString = NULL;
   898 	TPtr dtmfPtr = iDtmfString->Des();
  1103 	TPtr dtmfPtr = iDtmfString->Des();
   899 	aMessage.ReadL(TInt(2), dtmfPtr);
  1104 	aMessage.ReadL(TInt(2), dtmfPtr);
   900 
  1105 
   901 	iAdapter->PlayDTMFStringL(*iDtmfString);
  1106 	iAdapter->PlayDTMFStringL(*iDtmfString);
   902 	iOperationCompletePending = ETrue;
  1107 	iOperationCompletePending = ETrue;
   903 	return ETrue;
  1108 	SYMBIAN_DEBPRN1(_L("CMMFDevSoundSession[0x%x]::DoPlayDTMFStringL - Exit. Return value is [%d]"), ETrue);
       
  1109 	return ETrue;
       
  1110 	}
       
  1111 
       
  1112 //
       
  1113 // CMMFDevSoundSession::DoAlreadyCompletedPlayDTMFStringL
       
  1114 // (other items were commented in a header).
       
  1115 //
       
  1116 void CMMFDevSoundSession::DoAlreadyCompletedPlayDTMFStringL()
       
  1117 	{
       
  1118 	iAdapter->PlayDTMFStringL(*iDtmfString);
       
  1119 	iOperationCompletePending = ETrue;
   904 	}
  1120 	}
   905 
  1121 
   906 //
  1122 //
   907 // CMMFDevSoundSession::DoPlayToneSequenceL
  1123 // CMMFDevSoundSession::DoPlayToneSequenceL
   908 // (other items were commented in a header).
  1124 // (other items were commented in a header).
   909 //
  1125 //
   910 TBool CMMFDevSoundSession::DoPlayToneSequenceL(const RMmfIpcMessage& aMessage)
  1126 TBool CMMFDevSoundSession::DoPlayToneSequenceL(const RMmfIpcMessage& aMessage)
   911 	{
  1127 	{
   912 	TInt toneLength = aMessage.GetDesLength(1);
  1128     SYMBIAN_DEBPRN0(_L("CMMFDevSoundSession[0x%x]::DoPlayToneSequenceL - Enter"));
       
  1129     TInt toneLength = aMessage.GetDesLength(1);
   913 
  1130 
   914 	if(iToneSeqBuf)
  1131 	if(iToneSeqBuf)
   915 		{
  1132 		{
   916 		delete iToneSeqBuf;
  1133 		delete iToneSeqBuf;
   917 		iToneSeqBuf = NULL;
  1134 		iToneSeqBuf = NULL;
   921 	TPtr8 toneSeqPtr = iToneSeqBuf->Des();
  1138 	TPtr8 toneSeqPtr = iToneSeqBuf->Des();
   922 	aMessage.ReadL(TInt(1), toneSeqPtr);
  1139 	aMessage.ReadL(TInt(1), toneSeqPtr);
   923 
  1140 
   924 	iAdapter->PlayToneSequenceL(*iToneSeqBuf);
  1141 	iAdapter->PlayToneSequenceL(*iToneSeqBuf);
   925 	iOperationCompletePending = ETrue;
  1142 	iOperationCompletePending = ETrue;
   926 	return ETrue;
  1143 	SYMBIAN_DEBPRN1(_L("CMMFDevSoundSession[0x%x]::DoPlayToneSequenceL - Exit. Return value is [%d]"), ETrue);
       
  1144 	return ETrue;
       
  1145 	}
       
  1146 
       
  1147 //
       
  1148 // CMMFDevSoundSession::DoAlreadyCompletedPlayToneSequenceL
       
  1149 // (other items were commented in a header).
       
  1150 //
       
  1151 void CMMFDevSoundSession::DoAlreadyCompletedPlayToneSequenceL()
       
  1152 	{
       
  1153 	iAdapter->PlayToneSequenceL(*iToneSeqBuf);
       
  1154 	iOperationCompletePending = ETrue;
   927 	}
  1155 	}
   928 
  1156 
   929 //
  1157 //
   930 // CMMFDevSoundSession::DoPlayFixedSequenceL
  1158 // CMMFDevSoundSession::DoPlayFixedSequenceL
   931 // (other items were commented in a header).
  1159 // (other items were commented in a header).
   932 //
  1160 //
   933 TBool CMMFDevSoundSession::DoPlayFixedSequenceL(const RMmfIpcMessage& aMessage)
  1161 TBool CMMFDevSoundSession::DoPlayFixedSequenceL(const RMmfIpcMessage& aMessage)
   934 	{
  1162 	{
   935 	TPckgBuf<TInt> buf;
  1163     SYMBIAN_DEBPRN0(_L("CMMFDevSoundSession[0x%x]::DoPlayFixedSequenceL - Enter"));
       
  1164     TPckgBuf<TInt> buf;
   936 	aMessage.ReadL(TInt(1),buf);
  1165 	aMessage.ReadL(TInt(1),buf);
   937 	TInt seqNum = buf();
  1166 	TInt seqNum = buf();
   938 
  1167 	iSeqNum = seqNum;
   939 	iAdapter->PlayFixedSequenceL(seqNum);
  1168 	iAdapter->PlayFixedSequenceL(seqNum);
   940 	iOperationCompletePending = ETrue;
  1169 	iOperationCompletePending = ETrue;
   941 	return ETrue;
  1170 	SYMBIAN_DEBPRN1(_L("CMMFDevSoundSession[0x%x]::DoPlayFixedSequenceL - Exit. Return value is [%d]"), ETrue);
       
  1171 	return ETrue;
       
  1172 	}
       
  1173 
       
  1174 //
       
  1175 // CMMFDevSoundSession::DoAlreadyCompletedPlayFixedSequenceL
       
  1176 // (other items were commented in a header).
       
  1177 //
       
  1178 void CMMFDevSoundSession::DoAlreadyCompletedPlayFixedSequenceL()
       
  1179 	{
       
  1180 	iAdapter->PlayFixedSequenceL(iSeqNum);
       
  1181 	iOperationCompletePending = ETrue;
   942 	}
  1182 	}
   943 
  1183 
   944 //
  1184 //
   945 // CMMFDevSoundSession::DoSetDTMFLengthsL
  1185 // CMMFDevSoundSession::DoSetDTMFLengthsL
   946 // (other items were commented in a header).
  1186 // (other items were commented in a header).
   947 //
  1187 //
   948 TBool CMMFDevSoundSession::DoSetDTMFLengthsL(const RMmfIpcMessage& aMessage)
  1188 TBool CMMFDevSoundSession::DoSetDTMFLengthsL(const RMmfIpcMessage& aMessage)
   949 	{
  1189 	{
   950 	TMMFDevSoundProxySettingsPckg devSoundBuf;
  1190     SYMBIAN_DEBPRN0(_L("CMMFDevSoundSession[0x%x]::DoSetDTMFLengthsL - Enter"));
       
  1191     TMMFDevSoundProxySettingsPckg devSoundBuf;
   951 	aMessage.ReadL(TInt(1),devSoundBuf);
  1192 	aMessage.ReadL(TInt(1),devSoundBuf);
   952 	TTimeIntervalMicroSeconds32 toneOnLength = devSoundBuf().iToneOnLength;
  1193 	TTimeIntervalMicroSeconds32 toneOnLength = devSoundBuf().iToneOnLength;
   953 	TTimeIntervalMicroSeconds32 toneOffLength = devSoundBuf().iToneOffLength;
  1194 	TTimeIntervalMicroSeconds32 toneOffLength = devSoundBuf().iToneOffLength;
   954 	TTimeIntervalMicroSeconds32 pauseLength = devSoundBuf().iPauseLength;
  1195 	TTimeIntervalMicroSeconds32 pauseLength = devSoundBuf().iPauseLength;
   955 	User::LeaveIfError(iAdapter->SetDTMFLengths(toneOnLength, toneOffLength, pauseLength));
  1196 	User::LeaveIfError(iAdapter->SetDTMFLengths(toneOnLength, toneOffLength, pauseLength));
       
  1197     SYMBIAN_DEBPRN1(_L("CMMFDevSoundSession[0x%x]::DoSetDTMFLengthsL - Exit. Return value is [%d]"), ETrue);
   956 	return ETrue;
  1198 	return ETrue;
   957 	}
  1199 	}
   958 
  1200 
   959 //
  1201 //
   960 // CMMFDevSoundSession::DoSetVolumeRampL
  1202 // CMMFDevSoundSession::DoSetVolumeRampL
   961 // (other items were commented in a header).
  1203 // (other items were commented in a header).
   962 //
  1204 //
   963 TBool CMMFDevSoundSession::DoSetVolumeRampL(const RMmfIpcMessage& aMessage)
  1205 TBool CMMFDevSoundSession::DoSetVolumeRampL(const RMmfIpcMessage& aMessage)
   964 	{
  1206 	{
   965 	TMMFDevSoundProxySettingsPckg devSoundBuf;
  1207     SYMBIAN_DEBPRN0(_L("CMMFDevSoundSession[0x%x]::DoSetVolumeRampL - Enter"));
       
  1208     TMMFDevSoundProxySettingsPckg devSoundBuf;
   966 	aMessage.ReadL(TInt(1),devSoundBuf);
  1209 	aMessage.ReadL(TInt(1),devSoundBuf);
   967 	TTimeIntervalMicroSeconds duration = devSoundBuf().iDuration;
  1210 	TTimeIntervalMicroSeconds duration = devSoundBuf().iDuration;
   968 	User::LeaveIfError(iAdapter->SetVolumeRamp(duration));
  1211 	User::LeaveIfError(iAdapter->SetVolumeRamp(duration));
   969 	iOperationCompletePending = EFalse; // Volume ramp doesn't result on commit
  1212 	iOperationCompletePending = EFalse; // Volume ramp doesn't result on commit
       
  1213     SYMBIAN_DEBPRN1(_L("CMMFDevSoundSession[0x%x]::DoSetVolumeRampL - Exit. Return value is [%d]"), ETrue);
   970 	return ETrue; // operation complete
  1214 	return ETrue; // operation complete
   971 	}
  1215 	}
   972 
  1216 
   973 //
  1217 //
   974 // CMMFDevSoundSession::DoGetSupportedInputDataTypesL
  1218 // CMMFDevSoundSession::DoGetSupportedInputDataTypesL
  1042 // CMMFDevSoundSession::DoSetToneRepeatsL
  1286 // CMMFDevSoundSession::DoSetToneRepeatsL
  1043 // (other items were commented in a header).
  1287 // (other items were commented in a header).
  1044 //
  1288 //
  1045 TBool CMMFDevSoundSession::DoSetToneRepeatsL(const RMmfIpcMessage& aMessage)
  1289 TBool CMMFDevSoundSession::DoSetToneRepeatsL(const RMmfIpcMessage& aMessage)
  1046 	{
  1290 	{
  1047 	TPckgBuf<TInt> countRepeat;
  1291     SYMBIAN_DEBPRN0(_L("CMMFDevSoundSession[0x%x]::DoSetToneRepeatsL - Enter"));
       
  1292     TPckgBuf<TInt> countRepeat;
  1048 	aMessage.ReadL(TInt(1),countRepeat);
  1293 	aMessage.ReadL(TInt(1),countRepeat);
  1049 
  1294 
  1050 	TPckgBuf<TTimeIntervalMicroSeconds> repeatTS;
  1295 	TPckgBuf<TTimeIntervalMicroSeconds> repeatTS;
  1051 	aMessage.ReadL(TInt(2),repeatTS);
  1296 	aMessage.ReadL(TInt(2),repeatTS);
  1052 	User::LeaveIfError(iAdapter->SetToneRepeats(countRepeat(), repeatTS()));
  1297 	User::LeaveIfError(iAdapter->SetToneRepeats(countRepeat(), repeatTS()));
  1053 	
  1298     SYMBIAN_DEBPRN1(_L("CMMFDevSoundSession[0x%x]::DoSetToneRepeatsL - Exit. Return value is [%d]"), ETrue);
  1054 	return ETrue;
  1299 	return ETrue;
  1055 	}
  1300 	}
  1056 
  1301 
  1057 //
  1302 //
  1058 // CMMFDevSoundSession::DoSetPrioritySettingsL
  1303 // CMMFDevSoundSession::DoSetPrioritySettingsL
  1074 // (other items were commented in a header).
  1319 // (other items were commented in a header).
  1075 //
  1320 //
  1076 TBool CMMFDevSoundSession::DoFixedSequenceCountL(
  1321 TBool CMMFDevSoundSession::DoFixedSequenceCountL(
  1077 					const RMmfIpcMessage& aMessage)
  1322 					const RMmfIpcMessage& aMessage)
  1078 	{
  1323 	{
  1079 	TPckgBuf<TInt> fixSeqCountPckg;
  1324     SYMBIAN_DEBPRN0(_L("CMMFDevSoundSession[0x%x]::DoFixedSequenceCountL - Enter"));
       
  1325     TPckgBuf<TInt> fixSeqCountPckg;
  1080 	TInt fixSeqCount = iAdapter->FixedSequenceCount();
  1326 	TInt fixSeqCount = iAdapter->FixedSequenceCount();
  1081 	fixSeqCountPckg = fixSeqCount;
  1327 	fixSeqCountPckg = fixSeqCount;
  1082 
  1328 
  1083 	aMessage.WriteL(TInt(2),fixSeqCountPckg);
  1329 	aMessage.WriteL(TInt(2),fixSeqCountPckg);
       
  1330     SYMBIAN_DEBPRN1(_L("CMMFDevSoundSession[0x%x]::DoFixedSequenceCountL - Exit. Return value is [%d]"), ETrue);
  1084 	return ETrue;
  1331 	return ETrue;
  1085 	}
  1332 	}
  1086 
  1333 
  1087 
  1334 
  1088 //
  1335 //
  1337 //
  1584 //
  1338 // CMMFDevSoundSession::FlushEventQueue()
  1585 // CMMFDevSoundSession::FlushEventQueue()
  1339 //
  1586 //
  1340 void CMMFDevSoundSession::FlushEventQueue()
  1587 void CMMFDevSoundSession::FlushEventQueue()
  1341 	{
  1588 	{
  1342 	if(iMsgQueue.Handle() != 0)
  1589     SYMBIAN_DEBPRN0(_L("CMMFDevSoundSession[0x%x]::FlushEventQueue - Enter"));
       
  1590     if(iMsgQueue.Handle() != 0)
  1343 		{
  1591 		{
  1344 		TMMFDevSoundQueueItem queueItem;
  1592 		TMMFDevSoundQueueItem queueItem;
  1345 		TInt err = KErrNone;
  1593 		TInt err = KErrNone;
  1346 		while(err != KErrUnderflow)
  1594 		while(err != KErrUnderflow)
  1347 			{
  1595 			{
  1348 			err = iMsgQueue.Receive(queueItem);
  1596 			err = iMsgQueue.Receive(queueItem);
  1349 			}
  1597 			}
  1350 		}	
  1598 		}
       
  1599     SYMBIAN_DEBPRN0(_L("CMMFDevSoundSession[0x%x]::FlushEventQueue - Exit"));
  1351 	}
  1600 	}
  1352 
  1601 
  1353 void CMMFDevSoundSession::FilterQueueEvent(TMMFDevSoundProxyRequest aRequest)
  1602 void CMMFDevSoundSession::FilterQueueEvent(TMMFDevSoundProxyRequest aRequest)
  1354 	{
  1603 	{
  1355 	if(iMsgQueue.Handle() != 0)
  1604     SYMBIAN_DEBPRN0(_L("CMMFDevSoundSession[0x%x]::FilterQueueEvent - Enter"));
       
  1605     if(iMsgQueue.Handle() != 0)
  1356 		{
  1606 		{
  1357 		// Pop and push events result at the queue 
  1607 		// Pop and push events result at the queue 
  1358 		// can be seen as "circular list"
  1608 		// can be seen as "circular list"
  1359 		// set a mark to traverse it safely 
  1609 		// set a mark to traverse it safely 
  1360 		TMMFDevSoundQueueItem markItem;
  1610 		TMMFDevSoundQueueItem markItem;
  1378 				// assumes sufficient space in the queue
  1628 				// assumes sufficient space in the queue
  1379 				err = iMsgQueue.Send(queueItem);
  1629 				err = iMsgQueue.Send(queueItem);
  1380 				}
  1630 				}
  1381 			}
  1631 			}
  1382 		}
  1632 		}
       
  1633     SYMBIAN_DEBPRN0(_L("CMMFDevSoundSession[0x%x]::FilterQueueEvent - Exit"));
  1383 	}
  1634 	}
  1384 
  1635 
  1385 //
  1636 //
  1386 // CMMFDevSoundSession::Disconnect
  1637 // CMMFDevSoundSession::Disconnect
  1387 // (other items were commented in a header).
  1638 // (other items were commented in a header).
  1388 //
  1639 //
  1389 void CMMFDevSoundSession::Disconnect(const RMessage2& aMessage)
  1640 void CMMFDevSoundSession::Disconnect(const RMessage2& aMessage)
  1390 	{
  1641 	{
  1391 	TBool complete = iAdapter->CloseDevSound();
  1642     SYMBIAN_DEBPRN0(_L("CMMFDevSoundSession[0x%x]::Disconnect - Enter"));
  1392 	if(!complete)
  1643     if (NeedToQueue())
  1393 		{
  1644         {
  1394 		iRequestBeingServiced.SetMessage(aMessage);
  1645         // if we are in the middle of something, enqueue and wait
  1395 		iOperationCompletePending = ETrue;
  1646         SYMBIAN_DEBPRN0(_L("CMMFDevSoundSession[0x%x]::Disconnect - Add to queue"));
  1396 		iClosingWait->Start();
  1647         EnqueueRequest(aMessage);
  1397 		}
  1648         iClosingWait->Start();
       
  1649         }
       
  1650     else
       
  1651         {
       
  1652         // else do now. Enter ActiveSchedulerWait to wait for AsyncOpComplete
       
  1653         TBool complete = iAdapter->CloseDevSound();
       
  1654         if(!complete)
       
  1655             {
       
  1656             iRequestBeingServiced.SetMessage(aMessage);
       
  1657             iOperationCompletePending = ETrue;
       
  1658             ResetNotifiedError();
       
  1659             iClosingWait->Start();
       
  1660             }
       
  1661         }
  1398 	CSession2::Disconnect(aMessage);
  1662 	CSession2::Disconnect(aMessage);
       
  1663     SYMBIAN_DEBPRN0(_L("CMMFDevSoundSession[0x%x]::Disconnect - Exit"));
  1399 	}
  1664 	}
  1400 
  1665 
  1401 
  1666 
  1402 //
  1667 //
  1403 // CMMFDevSoundSession::NewL
  1668 // CMMFDevSoundSession::NewL
  1505 // CMMFDevSoundSession::ToneFinished
  1770 // CMMFDevSoundSession::ToneFinished
  1506 // (other items were commented in a header).
  1771 // (other items were commented in a header).
  1507 //
  1772 //
  1508 void CMMFDevSoundSession::ToneFinished(TInt aError)
  1773 void CMMFDevSoundSession::ToneFinished(TInt aError)
  1509 	{
  1774 	{
  1510 	TMMFDevSoundQueueItem item;
  1775     SYMBIAN_DEBPRN1(_L("CMMFDevSoundSession[0x%x]::ToneFinished - Enter. Error [%d]"), aError);
       
  1776     TMMFDevSoundQueueItem item;
  1511 	item.iRequest = EMMFDevSoundProxyTFEvent;
  1777 	item.iRequest = EMMFDevSoundProxyTFEvent;
  1512 	item.iErrorCode = aError;
  1778 	item.iErrorCode = aError;
  1513 	// assumes sufficient space in the queue so ignores the return value
  1779 	// assumes sufficient space in the queue so ignores the return value
  1514 	iMsgQueue.Send(item);
  1780 	iMsgQueue.Send(item);
       
  1781     SYMBIAN_DEBPRN0(_L("CMMFDevSoundSession[0x%x]::ToneFinished - Exit"));
  1515 	}
  1782 	}
  1516 
  1783 
  1517 //
  1784 //
  1518 // CMMFDevSoundSession::BufferToBeFilled
  1785 // CMMFDevSoundSession::BufferToBeFilled
  1519 // (other items were commented in a header).
  1786 // (other items were commented in a header).
  1551 // CMMFDevSoundSession::PlayError
  1818 // CMMFDevSoundSession::PlayError
  1552 // (other items were commented in a header).
  1819 // (other items were commented in a header).
  1553 //
  1820 //
  1554 void CMMFDevSoundSession::PlayError(TInt aError)
  1821 void CMMFDevSoundSession::PlayError(TInt aError)
  1555 	{
  1822 	{
  1556 	SYMBIAN_DEBPRN1(_L("CMMFDevSoundSession[0x%x]::PlayError [%d]"), aError);
  1823     SYMBIAN_DEBPRN1(_L("CMMFDevSoundSession[0x%x]::PlayError - Enter [%d]"), aError);
  1557 
  1824 
  1558 	// Set play error flag to ignore following PlayData requests
  1825 	// Set play error flag to ignore following PlayData requests
  1559 	iPlayErrorOccured = ETrue;
  1826 	iPlayErrorOccured = ETrue;
  1560 
  1827 
  1561 	TMMFDevSoundQueueItem item;
  1828 	TMMFDevSoundQueueItem item;
  1562 	item.iRequest = EMMFDevSoundProxyPEEvent;
  1829 	item.iRequest = EMMFDevSoundProxyPEEvent;
  1563 	item.iErrorCode = aError;
  1830 	item.iErrorCode = aError;
  1564 	iChunk.Close();
  1831 	iChunk.Close();
  1565 	// assumes sufficient space in the queue so ignores the return value
  1832 	// assumes sufficient space in the queue so ignores the return value
  1566 	iMsgQueue.Send(item);
  1833 	iMsgQueue.Send(item);
       
  1834     SYMBIAN_DEBPRN0(_L("CMMFDevSoundSession[0x%x]::PlayError - Exit"));
  1567 	}
  1835 	}
  1568 
  1836 
  1569 //
  1837 //
  1570 // CMMFDevSoundSession::BufferToBeEmptied
  1838 // CMMFDevSoundSession::BufferToBeEmptied
  1571 // (other items were commented in a header).
  1839 // (other items were commented in a header).
  1645 // CMMFDevSoundSession::CallbackFromAdaptorReceived
  1913 // CMMFDevSoundSession::CallbackFromAdaptorReceived
  1646 // (other items were commented in a header).
  1914 // (other items were commented in a header).
  1647 //
  1915 //
  1648 void CMMFDevSoundSession::CallbackFromAdaptorReceived(TInt aType, TInt aError)
  1916 void CMMFDevSoundSession::CallbackFromAdaptorReceived(TInt aType, TInt aError)
  1649 	{
  1917 	{
  1650 	
  1918     SYMBIAN_DEBPRN2(_L("CMMFDevSoundSession[0x%x]::CallbackFromAdaptorReceived - Enter. Type[%d] Error[%d]"), aType, aError);
  1651 	if(aType == KCallbackRecordPauseComplete)
  1919 	if(aType == KCallbackRecordPauseComplete)
  1652 		{
  1920 		{
  1653 		TMMFDevSoundQueueItem item;
  1921 		TMMFDevSoundQueueItem item;
  1654 		item.iRequest = EMMFDevSoundProxyPausedRecordCompleteEvent;
  1922 		item.iRequest = EMMFDevSoundProxyPausedRecordCompleteEvent;
  1655 		item.iErrorCode = KErrNone;
  1923 		item.iErrorCode = KErrNone;
  1664 		//coverity[uninit_use_in_call]
  1932 		//coverity[uninit_use_in_call]
  1665 		// Disabled Coverity warning, since it complains about iReserved1 member in TMMFEvent being uninitialised
  1933 		// Disabled Coverity warning, since it complains about iReserved1 member in TMMFEvent being uninitialised
  1666 		}
  1934 		}
  1667 	else if (aType == KCallbackFlushComplete)
  1935 	else if (aType == KCallbackFlushComplete)
  1668 		{
  1936 		{
  1669 		iRequestBeingServiced.Complete(aError);
  1937 		if(!iHandlingExtdCI && iRequestBeingServiced.Function()==EMMFDevSoundProxyEmptyBuffers)
  1670 		iOperationCompletePending = EFalse;
  1938 			{
       
  1939 			//If we come here then it is due to a EMMFDevSoundProxyEmptyBuffers request from client.
       
  1940 			SYMBIAN_DEBPRN0(_L("CMMFDevSoundSession[0x%x]::CallbackFromAdaptorReceived - Calling TMMFDevSoundRequest::Complete on iRequestBeingServiced"));
       
  1941 		    iRequestBeingServiced.Complete(aError);
       
  1942 		    iOperationCompletePending = EFalse;
       
  1943 			}
  1671 		}
  1944 		}
  1672 	else
  1945 	else
  1673 		{
  1946 		{
  1674 		if( iOperationCompletePending )
  1947 		if( NeedToQueue() )
  1675 			{
  1948 			{
  1676 			// If not possible to service now, then queue request
  1949 			// If not possible to service now, then queue request
  1677 			// Encapsule the request
  1950 			// Encapsule the request
  1678 			TMMFDevSoundRequest request(aType);
  1951 			TMMFDevSoundRequest request(aType);
  1679 			// assumes sufficient space in the queue so ignores the return value
  1952 			// assumes sufficient space in the queue so ignores the return value
  1690 				{
  1963 				{
  1691 				DoProcessingError();
  1964 				DoProcessingError();
  1692 				}
  1965 				}
  1693 			}
  1966 			}
  1694 		}
  1967 		}
       
  1968     SYMBIAN_DEBPRN0(_L("CMMFDevSoundSession[0x%x]::CallbackFromAdaptorReceived - Exit"));
  1695 	}
  1969 	}
  1696 
  1970 
  1697 
  1971 
  1698 //
  1972 //
  1699 // CMMFDevSoundSession::PreemptionStartedCallbackReceived
  1973 // CMMFDevSoundSession::PreemptionStartedCallbackReceived
  1700 // (other items were commented in a header).
  1974 // (other items were commented in a header).
  1701 //
  1975 //
  1702 void CMMFDevSoundSession::PreemptionStartedCallbackReceived()
  1976 void CMMFDevSoundSession::PreemptionStartedCallbackReceived()
  1703 	{
  1977 	{
  1704 	// Solution: Enqueue any request that arrives before preemption is completed
  1978     SYMBIAN_DEBPRN0(_L("CMMFDevSoundSession[0x%x]::PreemptionStartedCallbackReceived - Enter"));
       
  1979     // Solution: Enqueue any request that arrives before preemption is completed
  1705 	iOperationCompletePending = ETrue;
  1980 	iOperationCompletePending = ETrue;
       
  1981     SYMBIAN_DEBPRN0(_L("CMMFDevSoundSession[0x%x]::PreemptionStartedCallbackReceived - Exit"));
  1706 	}
  1982 	}
  1707 
  1983 
  1708 //
  1984 //
  1709 // CMMFDevSoundSession::PreemptionFinishedCallbackReceived
  1985 // CMMFDevSoundSession::PreemptionFinishedCallbackReceived
  1710 // (other items were commented in a header).
  1986 // (other items were commented in a header).
  1711 //
  1987 //
  1712 void CMMFDevSoundSession::PreemptionFinishedCallbackReceived(TBool aCanStartNewOperation)
  1988 void CMMFDevSoundSession::PreemptionFinishedCallbackReceived(TBool aCanStartNewOperation)
  1713 	{
  1989 	{
       
  1990     SYMBIAN_DEBPRN0(_L("CMMFDevSoundSession[0x%x]::PreemptionFinishedCallbackReceived - Enter"));
  1714     if (iHandlingExtdCI)
  1991     if (iHandlingExtdCI)
  1715         {
  1992         {
  1716         // we are in the middle of handling a CI, so ignore - will handle later when unwinding
  1993         // we are in the middle of handling a CI, so ignore - will handle later when unwinding
  1717         return;
  1994         SYMBIAN_DEBPRN0(_L("CMMFDevSoundSession[0x%x]::PreemptionFinishedCallbackReceived - Exit. Exiting from if block for CI"));
       
  1995 		return;
  1718         }
  1996         }
  1719 	iOperationCompletePending = EFalse;
  1997 	iOperationCompletePending = EFalse;
  1720 	if ( aCanStartNewOperation && iQueuedRequests.Count() != 0 )
  1998 	if ( aCanStartNewOperation && iQueuedRequests.Count() != 0 )
  1721 		{
  1999 		{
  1722 		DequeueRequest();
  2000 		DequeueRequest();
  1723 		}
  2001 		}
       
  2002     SYMBIAN_DEBPRN0(_L("CMMFDevSoundSession[0x%x]::PreemptionFinishedCallbackReceived - Exit"));
       
  2003 	}
       
  2004 
       
  2005 //
       
  2006 // CMMFDevSoundSession::PreemptionClash
       
  2007 // (other items were commented in a header).
       
  2008 //
       
  2009 void CMMFDevSoundSession::PreemptionClash()
       
  2010 	{
       
  2011 	//assumes sufficient space in the queue so ignore the return value
       
  2012 	iQueuedRequests.Insert(iRequestBeingServiced, 0);
       
  2013 	iPreemptionClash=ETrue;
       
  2014 	}
       
  2015 
       
  2016 //
       
  2017 // CMMFDevSoundSession::PreemptionClashWithStateChange
       
  2018 // (other items were commented in a header).
       
  2019 //
       
  2020 void CMMFDevSoundSession::PreemptionClashWithStateChange()
       
  2021 	{
       
  2022 	#ifdef _DEBUG
       
  2023 		TMMFDevSoundRequest msg = iQueuedRequests[0];
       
  2024 		// message being removed should be the one we previously pushed via PreemptionClash()
       
  2025 		__ASSERT_DEBUG(iRequestBeingServiced==msg, Panic(ERequestBeingServicedMismatch));
       
  2026 	#endif
       
  2027 	// remove without processing request with AsynchronousOperationComplete() completing the message
       
  2028 	iQueuedRequests.Remove(0);
       
  2029 	iPreemptionClash=EFalse;
  1724 	}
  2030 	}
  1725 
  2031 
  1726 //
  2032 //
  1727 // CMMFDevSoundSession::AdaptorControlsContext()
  2033 // CMMFDevSoundSession::AdaptorControlsContext()
  1728 //
  2034 //
  1752 // CMMFDevSoundSession::SendEventToClient
  2058 // CMMFDevSoundSession::SendEventToClient
  1753 // (other items were commented in a header).
  2059 // (other items were commented in a header).
  1754 //
  2060 //
  1755 void CMMFDevSoundSession::SendEventToClient(const TMMFEvent& aEvent)
  2061 void CMMFDevSoundSession::SendEventToClient(const TMMFEvent& aEvent)
  1756 	{
  2062 	{
  1757 	TMMFDevSoundQueueItem item;
  2063     SYMBIAN_DEBPRN0(_L("CMMFDevSoundSession[0x%x]::SendEventToClient - Enter"));
       
  2064     TMMFDevSoundQueueItem item;
  1758 	item.iRequest = EMMFDevSoundProxySETCEvent;
  2065 	item.iRequest = EMMFDevSoundProxySETCEvent;
  1759 	item.iErrorCode = KErrNone;
  2066 	item.iErrorCode = KErrNone;
  1760 	item.iEventPckg() = aEvent;
  2067 	item.iEventPckg() = aEvent;
  1761 	// assumes sufficient space in the queue so ignores the return value
  2068 	// assumes sufficient space in the queue so ignores the return value
  1762 	TInt err = iMsgQueue.Send(item);
  2069 	TInt err = iMsgQueue.Send(item);
  1763 	__ASSERT_DEBUG(err == KErrNone, Panic(EMsgQueueFailedToSendMsg));
  2070     __ASSERT_DEBUG(err == KErrNone, Panic(EMsgQueueFailedToSendMsg));
       
  2071     SYMBIAN_DEBPRN0(_L("CMMFDevSoundSession[0x%x]::SendEventToClient - Exit"));
  1764 	}
  2072 	}
  1765 
  2073 
  1766 void CMMFDevSoundSession::AsynchronousOperationComplete(TInt aError, TBool aCanStartNewOperation)
  2074 void CMMFDevSoundSession::AsynchronousOperationComplete(TInt aError, TBool aCanStartNewOperation)
  1767 	{
  2075 	{
  1768     __ASSERT_DEBUG(!iHandlingExtdCI, Panic(EUnexpectedAsyncOpCompleteHandlingCI));
  2076     __ASSERT_DEBUG(!iHandlingExtdCI, Panic(EUnexpectedAsyncOpCompleteHandlingCI));
  1769         // when handling CIs we should not reach here
  2077         // when handling CIs we should not reach here
       
  2078 
       
  2079     TInt error = aError;
       
  2080     if (!error)
       
  2081         {
       
  2082         // if have no error payload, use notified error. It will be KErrNone if not set, so just use.
       
  2083         error = NotifiedError();
       
  2084         }
  1770 
  2085 
  1771 	switch (iRequestBeingServiced.Type())
  2086 	switch (iRequestBeingServiced.Type())
  1772 		{
  2087 		{
  1773 		case TMMFDevSoundRequest::ESessionEvents:
  2088 		case TMMFDevSoundRequest::ESessionEvents:
  1774 			{
  2089 			{
  1807 				if(iRequestBeingServiced.Function()==EMMFDevSoundProxyCancelInitialize)
  2122 				if(iRequestBeingServiced.Function()==EMMFDevSoundProxyCancelInitialize)
  1808 					{
  2123 					{
  1809 					FlushEventQueue();
  2124 					FlushEventQueue();
  1810 					}
  2125 					}
  1811 				
  2126 				
  1812 				iRequestBeingServiced.Complete(aError);
  2127 				iRequestBeingServiced.Complete(error);
  1813 				iOperationCompletePending = EFalse;
  2128 				iOperationCompletePending = EFalse;
  1814 				}
  2129 				}
  1815 			}
  2130 			}
  1816 			break;
  2131 			break;
  1817 		case TMMFDevSoundRequest::EAction_PseudoAsynchronous:
  2132 		case TMMFDevSoundRequest::EAction_PseudoAsynchronous:
  1835 			}
  2150 			}
  1836 			break;
  2151 			break;
  1837 		default:
  2152 		default:
  1838 			break;
  2153 			break;
  1839 		}
  2154 		}
  1840 
  2155 	
  1841 	SYMBIAN_DEBPRN2(_L("CMMFDevSoundSession[0x%x] AsynchronousOperationComplete %x pending=%d"),iRequestBeingServiced.Function(), iOperationCompletePending );
  2156 	if(iRequestBeingServiced.Type() == TMMFDevSoundRequest::ECallBackType )
  1842 
  2157 	    {	    
       
  2158 	    SYMBIAN_DEBPRN2(_L("CMMFDevSoundSession[0x%x] AsynchronousOperationComplete CallbackPF=%d pending=%d"),
       
  2159 	            iRequestBeingServiced.IsCallBack(), iOperationCompletePending );
       
  2160 	    }
       
  2161 	else
       
  2162 	    {
       
  2163 	    SYMBIAN_DEBPRN3(_L("CMMFDevSoundSession[0x%x] AsynchronousOperationComplete %x pending=%d Requestype=%d"),
       
  2164 	            iRequestBeingServiced.Function(), iOperationCompletePending, iRequestBeingServiced.Type() );
       
  2165 	    }
       
  2166 
       
  2167 	    
  1843 	if ( aCanStartNewOperation && iQueuedRequests.Count() != 0 )
  2168 	if ( aCanStartNewOperation && iQueuedRequests.Count() != 0 )
  1844 		{
  2169 		{
  1845 		DequeueRequest();
  2170 		DequeueRequest();
  1846 		}
  2171 		}
  1847 	}
  2172 	}
  1848 
  2173 
  1849 void CMMFDevSoundSession::DequeueRequest()
  2174 void CMMFDevSoundSession::DequeueRequest()
  1850 	{
  2175 	{
       
  2176     SYMBIAN_DEBPRN0(_L("CMMFDevSoundSession[0x%x]::DequeueRequest - Enter"));
  1851     iAsyncQueueStart->Cancel(); // if we're in here cancel any background request
  2177     iAsyncQueueStart->Cancel(); // if we're in here cancel any background request
  1852 
  2178 
  1853 	TMMFDevSoundRequest msg = iQueuedRequests[0];
  2179 	TMMFDevSoundRequest msg = iQueuedRequests[0];
  1854 
  2180 
  1855 	if (msg.IsCallBack() > 0)
  2181 	if (msg.IsCallBack() > 0)
  1874 		{
  2200 		{
  1875 		// Some rules about what request can be followed
  2201 		// Some rules about what request can be followed
  1876 		SYMBIAN_DEBPRN0(_L("\n CMMFDevSoundSession[0x%x]======== Flag can service new request\n"));
  2202 		SYMBIAN_DEBPRN0(_L("\n CMMFDevSoundSession[0x%x]======== Flag can service new request\n"));
  1877 		iAsyncQueueStart->CallBack();
  2203 		iAsyncQueueStart->CallBack();
  1878 		}
  2204 		}
       
  2205 	SYMBIAN_DEBPRN0(_L("CMMFDevSoundSession[0x%x]::DequeueRequest - Exit"));
  1879 	}
  2206 	}
  1880 	
  2207 	
  1881 // 	AsyncQueueStartCallback
  2208 // 	AsyncQueueStartCallback
  1882 
  2209 
  1883 
  2210 
  1891 void CMMFDevSoundSession::AsyncQueueStartCallback()
  2218 void CMMFDevSoundSession::AsyncQueueStartCallback()
  1892 	{
  2219 	{
  1893 	SYMBIAN_DEBPRN0(_L("\n CMMFDevSoundSession[0x%x]======== Service a queued request\n"));
  2220 	SYMBIAN_DEBPRN0(_L("\n CMMFDevSoundSession[0x%x]======== Service a queued request\n"));
  1894 	TMMFDevSoundRequest msg = iQueuedRequests[0];
  2221 	TMMFDevSoundRequest msg = iQueuedRequests[0];
  1895 	iQueuedRequests.Remove(0);
  2222 	iQueuedRequests.Remove(0);
  1896 	TRAPD(err,DoServiceRequestL(msg.Message()));
  2223 	TInt err = KErrNone;
  1897     if(err != KErrNone)
  2224 	TBool doRequest = ETrue;
  1898         {
  2225 	if(iPreemptionClash)
  1899         msg.Complete(err);      
  2226 		{
  1900         }
  2227 		SYMBIAN_DEBPRN0(_L("CMMFDevSoundSession[0x%x]::AsyncQueueStartCallback - Re-applying client request due to Pre-emption clash"));
       
  2228 		iPreemptionClash=EFalse; // clear flag before reading next request in queue
       
  2229 		iAdapter->RollbackAdaptorActiveStateToBeforeCommit();
       
  2230 		if ((iRequestBeingServiced.Type() == TMMFDevSoundRequest::EAction_PseudoAsynchronous))
       
  2231 			{
       
  2232 		    doRequest = EFalse;
       
  2233 		    HandleAlreadyCompletedRequest();
       
  2234 			}
       
  2235 		}
       
  2236 
       
  2237 	if (doRequest)
       
  2238 		{
       
  2239 		TRAP(err,DoServiceRequestL(msg.Message()));
       
  2240 		if(err != KErrNone)
       
  2241 			{
       
  2242 			msg.Complete(err);
       
  2243 			}
       
  2244 		}
       
  2245 
  1901 	if (!iOperationCompletePending && iQueuedRequests.Count() != 0)
  2246 	if (!iOperationCompletePending && iQueuedRequests.Count() != 0)
  1902 		{
  2247 		{
  1903 		//dequeue next
  2248 		//dequeue next
  1904 		DequeueRequest();
  2249 		DequeueRequest();
  1905 		}
  2250 		}
  1924 //
  2269 //
  1925 // CMMFDevSoundSession::DoProcessingFinished()
  2270 // CMMFDevSoundSession::DoProcessingFinished()
  1926 //
  2271 //
  1927 void CMMFDevSoundSession::DoProcessingFinished()
  2272 void CMMFDevSoundSession::DoProcessingFinished()
  1928 	{
  2273 	{
       
  2274     ResetNotifiedError();
       
  2275 
  1929 	TBool asyncOperation = EFalse;
  2276 	TBool asyncOperation = EFalse;
  1930 	//ProcessingFinished should never fail
  2277 	//ProcessingFinished should never fail
  1931 	__ASSERT_ALWAYS(KErrNone, iAdapter->ProcessingFinishedReceived(asyncOperation));
  2278 	__ASSERT_ALWAYS(KErrNone, iAdapter->ProcessingFinishedReceived(asyncOperation));
  1932 	iOperationCompletePending = asyncOperation;
  2279 	iOperationCompletePending = asyncOperation;
  1933 	if (iOperationCompletePending)
  2280 	if (iOperationCompletePending)
  1939 //
  2286 //
  1940 // CMMFDevSoundSession::DoProcessingError()
  2287 // CMMFDevSoundSession::DoProcessingError()
  1941 //
  2288 //
  1942 void CMMFDevSoundSession::DoProcessingError()
  2289 void CMMFDevSoundSession::DoProcessingError()
  1943     {
  2290     {
       
  2291     ResetNotifiedError();
       
  2292 
  1944     TBool asyncOperation = EFalse;
  2293     TBool asyncOperation = EFalse;
  1945     //ProcessingFinished should never fail
  2294     //ProcessingFinished should never fail
  1946     __ASSERT_ALWAYS(KErrNone, iAdapter->ProcessingError(asyncOperation));
  2295     __ASSERT_ALWAYS(KErrNone, iAdapter->ProcessingError(asyncOperation));
  1947     iOperationCompletePending = asyncOperation;
  2296     iOperationCompletePending = asyncOperation;
  1948     if (iOperationCompletePending)
  2297     if (iOperationCompletePending)
  2023 		}
  2372 		}
  2024 	
  2373 	
  2025 	// Request kernel to create global RChunk if needed
  2374 	// Request kernel to create global RChunk if needed
  2026 	if ( !iChunk.Handle() )
  2375 	if ( !iChunk.Handle() )
  2027 		{
  2376 		{
  2028 		status = iChunk.CreateGlobal(KNullDesC, aRequestedSize, aRequestedSize);
  2377 		status = iChunk.CreateGlobal(KNullDesC, aRequestedSize, aRequestedSize, EOwnerThread);
  2029 		if ( status == KErrNone )
  2378 		if ( status == KErrNone )
  2030 			{
  2379 			{
  2031 			aBufPckg().iChunkOp = EOpen;
  2380 			aBufPckg().iChunkOp = EOpen;
  2032 			}
  2381 			}
  2033 		else
  2382 		else
  2271 	return ETrue;
  2620 	return ETrue;
  2272 	}
  2621 	}
  2273 	
  2622 	
  2274 void CMMFDevSoundSession::Panic(TMMFDevSoundSessionPanicCodes aCode)
  2623 void CMMFDevSoundSession::Panic(TMMFDevSoundSessionPanicCodes aCode)
  2275 	{
  2624 	{
  2276 	User::Panic(KMMFDevSoundSessionPanicCategory, aCode);
  2625     User::Panic(KMMFDevSoundSessionPanicCategory, aCode);
  2277 	}
  2626 	}
  2278 
  2627 
  2279 void CMMFDevSoundSession::BufferErrorEvent()
  2628 void CMMFDevSoundSession::BufferErrorEvent()
  2280 	{
  2629 	{
  2281 	// this will generate an processing error event and callback
  2630 	// this will generate an processing error event and callback
  2282 	iAdapter->BufferErrorEvent();
  2631 	iAdapter->BufferErrorEvent();
  2283 	}
  2632 	}
       
  2633 
       
  2634 void CMMFDevSoundSession::ResetNotifiedError()
       
  2635 // called at beginning of commit cycle, so any error will be from callbacks
       
  2636     {
       
  2637     SYMBIAN_DEBPRN0(_L("CMMFDevSoundSession[0x%x]::ResetNotifiedError"));
       
  2638     iNotifiedError = KErrNone;
       
  2639     }
       
  2640 
       
  2641 TInt CMMFDevSoundSession::NotifiedError() const
       
  2642 // NotifiedError property
       
  2643     {
       
  2644     SYMBIAN_DEBPRN1(_L("CMMFDevSoundSession[0x%x]::NotifiedError(%d)"), iNotifiedError);
       
  2645     return iNotifiedError;
       
  2646     }
       
  2647 
       
  2648 void CMMFDevSoundSession::NotifyError(TInt aError)
       
  2649 // cache notified error
       
  2650     {
       
  2651     SYMBIAN_DEBPRN1(_L("CMMFDevSoundSession[0x%x]::NotifyError(%d)"), aError);
       
  2652     iNotifiedError = aError;
       
  2653     }
       
  2654 
  2284 // End of file
  2655 // End of file