2010wk34_03
authorhgs
Thu, 16 Sep 2010 18:39:58 +0100
changeset 57 1cbb0d5bf7f2
parent 56 b6488ac24ddc
child 58 b6dbf97aba93
2010wk34_03
devsound/a3fdevsound/src/mmfdevsoundserver/mmfdevsoundsession.cpp
devsound/a3fdevsound/src/mmfdevsoundserver/mmfdevsoundsession.h
mm_plat/global_audio_settings_api/inc/GlobalAudioSettings.h
mm_pub/drm_audio_player_api/tsrc/data/mmc/drm/test3gp.dcf
mm_pub/drm_audio_player_api/tsrc/data/mmc/drm/testmp3.dcf
mmlibs/mmfw/src/Client/Video/VideoPlayerBody.h
mmlibs/mmfw/src/Client/Video/mediaclientpolicyserverclient.cpp
mmlibs/mmfw/src/Client/Video/mediaclientvideodisplay.cpp
mmlibs/mmfw/src/Client/Video/mediaclientvideodisplaybody.cpp
mmlibs/mmfw/src/Client/Video/mediaclientvideodisplaybody.h
mmlibs/mmfw/src/Client/Video/mmfclientvideoplayer2.cpp
mmlibs/mmfw/src/Client/Video/mmfclientvideoplayerbody.cpp
mmlibs/mmfw/tsrc/mmfintegrationtest/vclntavi/src/testvideoplayer.cpp
--- a/devsound/a3fdevsound/src/mmfdevsoundserver/mmfdevsoundsession.cpp	Wed Sep 08 17:15:23 2010 +0100
+++ b/devsound/a3fdevsound/src/mmfdevsoundserver/mmfdevsoundsession.cpp	Thu Sep 16 18:39:58 2010 +0100
@@ -269,8 +269,25 @@
 	iAsyncQueueStart->Cancel(); // just in case.
     ResetNotifiedError();
 
+    if (aMessage.Function() == RMessage2::EDisConnect)
+        {
+        TBool complete = iAdapter->CloseDevSound();
+        if(!complete)
+            {
+            iRequestBeingServiced.SetMessage(aMessage);
+            iOperationCompletePending = ETrue;
+            ResetNotifiedError();
+            }
+        else
+            {
+            // if we get here, iClosing wait will have been started and we'd be waiting
+            iClosingWait->AsyncStop();
+            }
+        return;
+        }
+    
     TMMFMessageDestinationPckg destinationPckg;
-	MmfMessageUtil::ReadL(aMessage, 0, destinationPckg);
+	User::LeaveIfError(MessageRead(aMessage, 0, destinationPckg));
 	SYMBIAN_DEBPRN2(_L("CMMFDevSoundSession[0x%x]::DoServiceRequestL - DestinationHandle [%d] InterfaceId [%d] "), destinationPckg().DestinationHandle(), destinationPckg().InterfaceId());
 	if ((destinationPckg().DestinationHandle() == KMMFObjectHandleDevSound) &&
 	    (destinationPckg().InterfaceId() == KUidInterfaceMMFDevSound))
@@ -459,21 +476,6 @@
 				}
 			}
 		}
-	else if (aMessage.Function() == RMessage2::EDisConnect)
-	    {
-        TBool complete = iAdapter->CloseDevSound();
-        if(!complete)
-            {
-            iRequestBeingServiced.SetMessage(aMessage);
-            iOperationCompletePending = ETrue;
-            ResetNotifiedError();
-            }
-        else
-            {
-            // if we get here, iClosing wait will have been started and we'd be waiting
-            iClosingWait->AsyncStop();
-            }
-	    }
 	else
 		{
 		// If there's a CI extension, see if that handles this request
@@ -578,12 +580,14 @@
 
 void CMMFDevSoundSession::EnqueueRequest(const RMmfIpcMessage& aMessage)
 	{
+    SYMBIAN_DEBPRN0(_L("CMMFDevSoundSession[0x%x]::EnqueueRequest - Enter"));
 	// Encapsule the request
 	TMMFDevSoundRequest request;
 	request.SetMessage(aMessage);
 	// Append
 	TInt error = iQueuedRequests.Append(request);
-	__ASSERT_DEBUG(error == KErrNone, Panic(EQueueRequestsFailedToAppend)); 
+	__ASSERT_DEBUG(error == KErrNone, Panic(EQueueRequestsFailedToAppend));
+	SYMBIAN_DEBPRN0(_L("CMMFDevSoundSession[0x%x]::EnqueueRequest - Exit"));
 	}
 
 //
@@ -607,7 +611,7 @@
 	User::LeaveIfError(err);
 	DoSetClientConfigL();// added here instead of the CreateL()
 	TMMFDevSoundProxySettingsPckg devSoundBuf;
-	MmfMessageUtil::ReadL(aMessage,1,devSoundBuf);
+	User::LeaveIfError(MessageRead(aMessage,1,devSoundBuf));
 	iCachedClientData = devSoundBuf;
 	TMMFState mode = devSoundBuf().iMode;
 	iAdapter->InitializeL(mode);
@@ -644,7 +648,7 @@
 	User::LeaveIfError(err);
 	DoSetClientConfigL();// added here instead of the CreateL()
 	TMMFDevSoundProxySettingsPckg devSoundBuf;
-	MmfMessageUtil::ReadL(aMessage,1,devSoundBuf);
+	User::LeaveIfError(MessageRead(aMessage,1,devSoundBuf));
 	iCachedClientData = devSoundBuf;
 	TUid HWDev = devSoundBuf().iHWDev;
 	TMMFState mode = devSoundBuf().iMode;
@@ -678,7 +682,7 @@
 	User::LeaveIfError(err);
 	DoSetClientConfigL();// added here instead of the CreateL()
 	TMMFDevSoundProxySettingsPckg devSoundBuf;
-	aMessage.ReadL(TInt(1),devSoundBuf);
+	User::LeaveIfError(MessageRead(aMessage, TInt(1), devSoundBuf));
 	iCachedClientData = devSoundBuf;
 	TFourCC desiredFourCC = devSoundBuf().iDesiredFourCC;
 	TMMFState mode = devSoundBuf().iMode;
@@ -755,7 +759,7 @@
 	TMMFDevSoundProxySettings devSoundSet;
 	devSoundSet.iConfig = iAdapter->Config();
 	TMMFDevSoundProxySettingsPckg pckg(devSoundSet);
-	aMessage.WriteL(TInt(2),pckg);
+	User::LeaveIfError(MessageWrite(aMessage,TInt(2),pckg));
 	return ETrue;
 	}
 
@@ -766,7 +770,7 @@
 TBool CMMFDevSoundSession::DoSetConfigL(const RMmfIpcMessage& aMessage)
 	{
 	TMMFDevSoundProxySettingsPckg devSoundBuf;
-	aMessage.ReadL(TInt(1),devSoundBuf);
+	User::LeaveIfError(MessageRead(aMessage,TInt(1),devSoundBuf));
 	TMMFCapabilities config = devSoundBuf().iConfig;
 	iAdapter->SetConfigL(config);
 	iOperationCompletePending = ETrue;
@@ -782,7 +786,7 @@
 	TMMFDevSoundProxySettings devSoundSet;
 	devSoundSet.iMaxVolume = iAdapter->MaxVolume();
 	TMMFDevSoundProxySettingsPckg pckg(devSoundSet);
-	aMessage.WriteL(TInt(2),pckg);
+	User::LeaveIfError(MessageWrite(aMessage,TInt(2),pckg));
 	return ETrue;
 	}
 
@@ -795,7 +799,7 @@
 	TMMFDevSoundProxySettings devSoundSet;
 	devSoundSet.iVolume = iAdapter->Volume();
 	TMMFDevSoundProxySettingsPckg pckg(devSoundSet);
-	aMessage.WriteL(TInt(2),pckg);
+	User::LeaveIfError(MessageWrite(aMessage,TInt(2),pckg));
 	return ETrue;
 	}
 
@@ -806,7 +810,7 @@
 TBool CMMFDevSoundSession::DoSetVolumeL(const RMmfIpcMessage& aMessage)
 	{
 	TMMFDevSoundProxySettingsPckg devSoundBuf;
-	aMessage.ReadL(TInt(1),devSoundBuf);
+	User::LeaveIfError(MessageRead(aMessage, TInt(1),devSoundBuf));
 	TInt volume = devSoundBuf().iVolume;
 	TBool asyncOperation;
 	User::LeaveIfError(iAdapter->SetVolume(volume, asyncOperation));
@@ -823,7 +827,7 @@
 	TMMFDevSoundProxySettings devSoundSet;
 	devSoundSet.iMaxGain = iAdapter->MaxGain();
 	TMMFDevSoundProxySettingsPckg pckg(devSoundSet);
-	aMessage.WriteL(TInt(2),pckg);
+	User::LeaveIfError(MessageWrite(aMessage,TInt(2),pckg));
 	return ETrue;
 	}
 
@@ -836,7 +840,7 @@
 	TMMFDevSoundProxySettings devSoundSet;
 	devSoundSet.iGain = iAdapter->Gain();
 	TMMFDevSoundProxySettingsPckg pckg(devSoundSet);
-	aMessage.WriteL(TInt(2),pckg);
+	User::LeaveIfError(MessageWrite(aMessage,TInt(2),pckg));
 	return ETrue;
 	}
 
@@ -847,7 +851,7 @@
 TBool CMMFDevSoundSession::DoSetGainL(const RMmfIpcMessage& aMessage)
 	{
 	TMMFDevSoundProxySettingsPckg devSoundBuf;
-	aMessage.ReadL(TInt(1),devSoundBuf);
+	User::LeaveIfError(MessageRead(aMessage,TInt(1),devSoundBuf));
 	TInt gain = devSoundBuf().iGain;
 	TBool asyncOperation;
 	User::LeaveIfError(iAdapter->SetGain(gain, asyncOperation));
@@ -864,7 +868,7 @@
 	TMMFDevSoundProxySettings devSoundSet;
 	iAdapter->GetPlayBalanceL(devSoundSet.iLeftPercentage, devSoundSet.iRightPercentage);
 	TMMFDevSoundProxySettingsPckg pckg(devSoundSet);
-	aMessage.WriteL(TInt(2),pckg);
+	User::LeaveIfError(MessageWrite(aMessage,TInt(2),pckg));
 	return ETrue;
 	}
 
@@ -875,7 +879,7 @@
 TBool CMMFDevSoundSession::DoSetPlayBalanceL(const RMmfIpcMessage& aMessage)
 	{
 	TMMFDevSoundProxySettingsPckg devSoundBuf;
-	aMessage.ReadL(TInt(1),devSoundBuf);
+    User::LeaveIfError(MessageRead(aMessage,TInt(1),devSoundBuf));
 	TInt leftPercentage = devSoundBuf().iLeftPercentage;
 	TInt rightPercentage = devSoundBuf().iRightPercentage;
 	TBool asyncOperation;
@@ -893,7 +897,7 @@
 	TMMFDevSoundProxySettings devSoundSet;
 	iAdapter->GetRecordBalanceL(devSoundSet.iLeftPercentage, devSoundSet.iRightPercentage);
 	TMMFDevSoundProxySettingsPckg pckg(devSoundSet);
-	aMessage.WriteL(TInt(2),pckg);
+	User::LeaveIfError(MessageWrite(aMessage,TInt(2),pckg));
 	return ETrue;
 	}
 
@@ -904,7 +908,7 @@
 TBool CMMFDevSoundSession::DoSetRecordBalanceL(const RMmfIpcMessage& aMessage)
 	{
 	TMMFDevSoundProxySettingsPckg devSoundBuf;
-	aMessage.ReadL(TInt(1),devSoundBuf);
+	User::LeaveIfError(MessageRead(aMessage,TInt(1),devSoundBuf));
 	TInt leftPercentage = devSoundBuf().iLeftPercentage;
 	TInt rightPercentage = devSoundBuf().iRightPercentage;
 	TBool asyncOperation;
@@ -970,7 +974,7 @@
 		}
 
 	TMMFDevSoundProxyHwBufPckg devSoundBuf;
-	aMessage.ReadL(TInt(1),devSoundBuf);
+	User::LeaveIfError(MessageRead(aMessage,TInt(1),devSoundBuf));
 	iBufferPlay->SetLastBuffer(devSoundBuf().iLastBuffer);
 
 	TPtr8 dataPtr(iChunk.Base(), devSoundBuf().iBufferSize, devSoundBuf().iBufferSize);
@@ -1002,7 +1006,7 @@
 	TBool completed = iAdapter->Stop();
 	if (completed)
 		{
-		iQueuedRequests.Reset();
+        FlushQueuedRequests();
 		FlushEventQueue(); // completed returned here means we were idle to start with. TODO could possibly skip this flush
 		iChunk.Close();
 		}
@@ -1030,7 +1034,7 @@
 	{
     SYMBIAN_DEBPRN0(_L("CMMFDevSoundSession[0x%x]::DoPlayToneL - Enter"));
     TMMFDevSoundProxySettingsPckg devSoundBuf;
-	aMessage.ReadL(TInt(1),devSoundBuf);
+	User::LeaveIfError(MessageRead(aMessage,TInt(1),devSoundBuf));
 	iCachedClientData = devSoundBuf;
 	TInt frequency = devSoundBuf().iFrequencyOne;
 	TTimeIntervalMicroSeconds duration(devSoundBuf().iDuration);
@@ -1060,7 +1064,7 @@
 	{
     SYMBIAN_DEBPRN0(_L("CMMFDevSoundSession[0x%x]::DoPlayDualToneL - Enter"));
     TMMFDevSoundProxySettingsPckg devSoundBuf;
-	aMessage.ReadL(TInt(1),devSoundBuf);
+	User::LeaveIfError(MessageRead(aMessage,TInt(1),devSoundBuf));
 	iCachedClientData = devSoundBuf;
 	TInt frequencyOne = devSoundBuf().iFrequencyOne;
 	TInt frequencyTwo = devSoundBuf().iFrequencyTwo;
@@ -1101,8 +1105,7 @@
 
 	iDtmfString = HBufC::NewL(dtmfLength);
 	TPtr dtmfPtr = iDtmfString->Des();
-	aMessage.ReadL(TInt(2), dtmfPtr);
-
+    User::LeaveIfError(MessageRead(aMessage, TInt(2), dtmfPtr));
 	iAdapter->PlayDTMFStringL(*iDtmfString);
 	iOperationCompletePending = ETrue;
 	SYMBIAN_DEBPRN1(_L("CMMFDevSoundSession[0x%x]::DoPlayDTMFStringL - Exit. Return value is [%d]"), ETrue);
@@ -1136,7 +1139,7 @@
 
 	iToneSeqBuf = HBufC8::NewL(toneLength);
 	TPtr8 toneSeqPtr = iToneSeqBuf->Des();
-	aMessage.ReadL(TInt(1), toneSeqPtr);
+	User::LeaveIfError(MessageRead(aMessage,TInt(1), toneSeqPtr));
 
 	iAdapter->PlayToneSequenceL(*iToneSeqBuf);
 	iOperationCompletePending = ETrue;
@@ -1162,7 +1165,7 @@
 	{
     SYMBIAN_DEBPRN0(_L("CMMFDevSoundSession[0x%x]::DoPlayFixedSequenceL - Enter"));
     TPckgBuf<TInt> buf;
-	aMessage.ReadL(TInt(1),buf);
+	User::LeaveIfError(MessageRead(aMessage,TInt(1),buf));
 	TInt seqNum = buf();
 	iSeqNum = seqNum;
 	iAdapter->PlayFixedSequenceL(seqNum);
@@ -1189,7 +1192,7 @@
 	{
     SYMBIAN_DEBPRN0(_L("CMMFDevSoundSession[0x%x]::DoSetDTMFLengthsL - Enter"));
     TMMFDevSoundProxySettingsPckg devSoundBuf;
-	aMessage.ReadL(TInt(1),devSoundBuf);
+	User::LeaveIfError(MessageRead(aMessage,TInt(1),devSoundBuf));
 	TTimeIntervalMicroSeconds32 toneOnLength = devSoundBuf().iToneOnLength;
 	TTimeIntervalMicroSeconds32 toneOffLength = devSoundBuf().iToneOffLength;
 	TTimeIntervalMicroSeconds32 pauseLength = devSoundBuf().iPauseLength;
@@ -1206,7 +1209,7 @@
 	{
     SYMBIAN_DEBPRN0(_L("CMMFDevSoundSession[0x%x]::DoSetVolumeRampL - Enter"));
     TMMFDevSoundProxySettingsPckg devSoundBuf;
-	aMessage.ReadL(TInt(1),devSoundBuf);
+	User::LeaveIfError(MessageRead(aMessage,TInt(1),devSoundBuf));
 	TTimeIntervalMicroSeconds duration = devSoundBuf().iDuration;
 	User::LeaveIfError(iAdapter->SetVolumeRamp(duration));
 	iOperationCompletePending = EFalse; // Volume ramp doesn't result on commit
@@ -1224,14 +1227,14 @@
 	iArray.Reset();
 
 	TMMFPrioritySettingsPckg prioritySetBuf;
-	aMessage.ReadL(TInt(1),prioritySetBuf);
+	User::LeaveIfError(MessageRead(aMessage,TInt(1),prioritySetBuf));
 	TMMFPrioritySettings prioritySet = prioritySetBuf();
 
 	iAdapter->GetSupportedInputDataTypesL(iArray, prioritySet);
 
 	TPckgBuf<TInt> pckg;
 	pckg() = iArray.Count();
-	aMessage.WriteL(TInt(2),pckg);
+	User::LeaveIfError(MessageWrite(aMessage,TInt(2),pckg));
 
 	return ETrue;
 	}
@@ -1246,14 +1249,14 @@
 	iArray.Reset();
 
 	TMMFPrioritySettingsPckg prioritySetBuf;
-	aMessage.ReadL(TInt(1),prioritySetBuf);
+	User::LeaveIfError(MessageRead(aMessage,TInt(1),prioritySetBuf));
 	TMMFPrioritySettings prioritySet = prioritySetBuf();
 
 	iAdapter->GetSupportedOutputDataTypesL(iArray, prioritySet);
 
 	TPckgBuf<TInt> pckg;
 	pckg() = iArray.Count();
-	aMessage.WriteL(TInt(2),pckg);
+	User::LeaveIfError(MessageWrite(aMessage,TInt(2),pckg));
 
 	return ETrue;
 	}
@@ -1266,7 +1269,7 @@
 	{
 	TPckgBuf<TInt> pckg;
 	pckg() = iAdapter->SamplesRecorded();
-	aMessage.WriteL(TInt(2),pckg);
+	User::LeaveIfError(MessageWrite(aMessage,TInt(2),pckg));
 	return ETrue;
 	}
 
@@ -1278,7 +1281,7 @@
 	{
 	TPckgBuf<TInt> pckg;
 	pckg() = iAdapter->SamplesPlayed();
-	aMessage.WriteL(TInt(2),pckg);
+	User::LeaveIfError(MessageWrite(aMessage,TInt(2),pckg));
 	return ETrue;
 	}
 
@@ -1290,10 +1293,10 @@
 	{
     SYMBIAN_DEBPRN0(_L("CMMFDevSoundSession[0x%x]::DoSetToneRepeatsL - Enter"));
     TPckgBuf<TInt> countRepeat;
-	aMessage.ReadL(TInt(1),countRepeat);
+	User::LeaveIfError(MessageRead(aMessage,TInt(1),countRepeat));
 
 	TPckgBuf<TTimeIntervalMicroSeconds> repeatTS;
-	aMessage.ReadL(TInt(2),repeatTS);
+	User::LeaveIfError(MessageRead(aMessage,TInt(2),repeatTS));
 	User::LeaveIfError(iAdapter->SetToneRepeats(countRepeat(), repeatTS()));
     SYMBIAN_DEBPRN1(_L("CMMFDevSoundSession[0x%x]::DoSetToneRepeatsL - Exit. Return value is [%d]"), ETrue);
 	return ETrue;
@@ -1307,7 +1310,7 @@
 						const RMmfIpcMessage& aMessage)
 	{
 	TPckgBuf<TMMFPrioritySettings> prioritySet;
-	aMessage.ReadL(TInt(1),prioritySet);
+	User::LeaveIfError(MessageRead(aMessage,TInt(1),prioritySet));
 
 	User::LeaveIfError(iAdapter->SetPrioritySettings(prioritySet()));
 	iOperationCompletePending = EFalse;
@@ -1326,7 +1329,7 @@
 	TInt fixSeqCount = iAdapter->FixedSequenceCount();
 	fixSeqCountPckg = fixSeqCount;
 
-	aMessage.WriteL(TInt(2),fixSeqCountPckg);
+	User::LeaveIfError(MessageWrite(aMessage,TInt(2),fixSeqCountPckg));
     SYMBIAN_DEBPRN1(_L("CMMFDevSoundSession[0x%x]::DoFixedSequenceCountL - Exit. Return value is [%d]"), ETrue);
 	return ETrue;
 	}
@@ -1354,7 +1357,7 @@
 		stream.WriteInt32L(iArray[i].FourCC());
 		i++;
 		}
-	aMessage.WriteL(TInt(2), dataCopyBuffer->Ptr(0));
+	User::LeaveIfError(MessageWrite(aMessage, TInt(2), dataCopyBuffer->Ptr(0)));
 	stream.Close();
 	CleanupStack::PopAndDestroy(&stream);
 	CleanupStack::PopAndDestroy(dataCopyBuffer);
@@ -1377,14 +1380,14 @@
 		return EFalse;	
 		}
 	TPckgBuf<TInt> requestChunkBuf;
-	MmfMessageUtil::Read(aMessage, TInt(1), requestChunkBuf);
+	User::LeaveIfError(MessageRead(aMessage, TInt(1), requestChunkBuf));
 	TBool requestChunk = requestChunkBuf();
 	if (requestChunk)
 		{
 		// if the client requests, always do EOpen
 		iHwBufPckgFill().iChunkOp = EOpen;
 		}
-	TInt err = MmfMessageUtil::Write(aMessage, TInt(2), iHwBufPckgFill);
+	TInt err = MessageWrite(aMessage, TInt(2), iHwBufPckgFill);
 	if ( (err == KErrNone) && (iHwBufPckgFill().iChunkOp == EOpen) )
 		{
 		aMessage.Complete(iChunk);
@@ -1410,7 +1413,7 @@
 		return EFalse;	
 		}
 	
-	TInt err = MmfMessageUtil::Write(aMessage, TInt(2), iHwBufPckgEmpty);
+	TInt err = MessageWrite(aMessage, TInt(2), iHwBufPckgEmpty);
 	if ( (err == KErrNone) && (iHwBufPckgEmpty().iChunkOp == EOpen) )
 		{
 		aMessage.Complete(iChunk);
@@ -1456,7 +1459,7 @@
 		aMessage.Complete(err);
 		return EFalse;		
 		}
-	aMessage.WriteL(TInt(2),timePckg);
+	User::LeaveIfError(MessageWrite(aMessage,TInt(2),timePckg));
 	return ETrue;
 	}
 
@@ -1465,7 +1468,7 @@
 	TBool isSupported = EFalse;
 	TPckgBuf<TBool> isSupportedPckg(isSupported);
 	isSupportedPckg() = iAdapter->IsResumeSupported();
-	aMessage.WriteL(TInt(2),isSupportedPckg);
+	User::LeaveIfError(MessageWrite(aMessage,TInt(2),isSupportedPckg));
 	return ETrue;
 	}
 
@@ -1522,7 +1525,8 @@
 // (other items were commented in a header).
 //
 CMMFDevSoundSession::CMMFDevSoundSession() :
-	iSetClientConfigApplied (EFalse)
+	iSetClientConfigApplied (EFalse),
+	iDisconnecting (EFalse)
 	{
 	}
 
@@ -1640,6 +1644,8 @@
 void CMMFDevSoundSession::Disconnect(const RMessage2& aMessage)
 	{
     SYMBIAN_DEBPRN0(_L("CMMFDevSoundSession[0x%x]::Disconnect - Enter"));
+    iDisconnecting = ETrue;
+	
     if (NeedToQueue())
         {
         // if we are in the middle of something, enqueue and wait
@@ -2106,7 +2112,7 @@
 				if (iRequestBeingServiced.Function()==EMMFDevSoundProxyStop)
 					{
 					// flush the queue - will have removed any stale items added between initial call and MMRC's reaction
-					iQueuedRequests.Reset();
+                    FlushQueuedRequests();
 					FlushEventQueue();
 					iChunk.Close();
 					}
@@ -2116,7 +2122,7 @@
 					TMMFDevSoundProxySettings devSoundSet;
 					devSoundSet.iCaps = iDevSoundCapabilities;
 					TMMFDevSoundProxySettingsPckg pckg(devSoundSet);
-					iRequestBeingServiced.Message().Write(TInt(2),pckg);
+					MessageWrite(iRequestBeingServiced.Message(),TInt(2),pckg);
 					}
 				
 				if(iRequestBeingServiced.Function()==EMMFDevSoundProxyCancelInitialize)
@@ -2541,11 +2547,11 @@
 TBool CMMFDevSoundSession::DoRegisterAsClientL(const RMmfIpcMessage& aMessage)
 	{
 	TMMFDevSoundProxySettingsPckg buf;
-	aMessage.ReadL(0,buf);
+	User::LeaveIfError(MessageRead(aMessage,0,buf));
 	HBufC8* notificationRegistrationData = NULL;
 	notificationRegistrationData = HBufC8::NewLC(User::LeaveIfError(aMessage.GetDesLengthL(1)));
 	TPtr8 dataPtr(notificationRegistrationData->Des());  	
-	aMessage.ReadL(1,dataPtr);
+	User::LeaveIfError(MessageRead(aMessage,1,dataPtr));
 	DoSetClientConfigL();// added here instead of the CreateL()
 	TInt err = KErrNone;
 	err = iAdapter->RegisterAsClient(buf().iNotificationEventUid,dataPtr);
@@ -2561,7 +2567,7 @@
 TBool CMMFDevSoundSession::DoCancelRegisterAsClientL(const RMmfIpcMessage& aMessage)
 	{
 	TMMFDevSoundProxySettingsPckg buf;
-	aMessage.ReadL(0,buf);
+	User::LeaveIfError(MessageRead(aMessage,0,buf));
 	TInt err = KErrNone;
 	err = iAdapter->CancelRegisterAsClient(buf().iNotificationEventUid);
 	if (err != KErrNone)
@@ -2575,14 +2581,14 @@
 TBool CMMFDevSoundSession::DoGetResourceNotificationDataL(const RMmfIpcMessage& aMessage)
 	{
 	TMMFDevSoundProxySettingsPckg buf;
-	aMessage.ReadL(0,buf);
+	User::LeaveIfError(MessageRead(aMessage,0,buf));
 	HBufC8* notificationData = NULL;
 	notificationData = HBufC8::NewLC(User::LeaveIfError(aMessage.GetDesMaxLengthL(2)));
 	TPtr8 dataPtr(notificationData->Des());  	
-	aMessage.ReadL(2,dataPtr);
+	User::LeaveIfError(MessageRead(aMessage,2,dataPtr));
 	TInt err = KErrNone;
 	err = iAdapter->GetResourceNotificationData(buf().iNotificationEventUid,dataPtr);
-	aMessage.WriteL(2,*notificationData);
+	User::LeaveIfError(MessageWrite(aMessage,2,*notificationData));
 	CleanupStack::PopAndDestroy(1); // Notification data
 	if (err != KErrNone)
 		{
@@ -2611,7 +2617,7 @@
 		if (aMessage.HasCapability(ECapabilityMultimediaDD) && aMessage.HasCapability(ECapabilityUserEnvironment))
 			{
 			TPckgBuf<TThreadId> threadId;
-			aMessage.ReadL(1, threadId);
+			User::LeaveIfError(MessageRead(aMessage, 1, threadId));
 			
 			CMMFDevSoundServer* server = 
 				const_cast<CMMFDevSoundServer*>(static_cast<const CMMFDevSoundServer*>(Server()));
@@ -2640,6 +2646,46 @@
 	iAdapter->BufferErrorEvent();
 	}
 
+void CMMFDevSoundSession::FlushQueuedRequests()
+    {
+    for (TInt queueIndex = (iQueuedRequests.Count() - 1); queueIndex >= 0; --queueIndex)
+        {
+        if ((iQueuedRequests[queueIndex].Type() == TMMFDevSoundRequest::ESessionEvents) && 
+                (iQueuedRequests[queueIndex].Function() == RMessage2::EDisConnect))
+            {
+            continue;
+            }
+        iQueuedRequests.Remove(queueIndex);
+        }    
+    }
+
+TInt CMMFDevSoundSession::MessageRead(const RMmfIpcMessage& aMessage, TInt aParam, TDes8& aResult)
+    {
+    if (!iDisconnecting)
+        {
+        return MmfMessageUtil::Read(aMessage, aParam, aResult);    
+        }
+    return KErrBadHandle;
+    }
+
+TInt CMMFDevSoundSession::MessageRead(const RMmfIpcMessage& aMessage, TInt aParam, TDes16& aResult)
+    {
+    if (!iDisconnecting)
+        {
+        return aMessage.Read(aParam, aResult);    
+        }
+    return KErrBadHandle;
+    }
+
+TInt CMMFDevSoundSession::MessageWrite(const RMmfIpcMessage& aMessage, TInt aParam, const TDesC8& aValue)
+    {
+    if (!iDisconnecting)
+        {
+        return MmfMessageUtil::Write(aMessage, aParam, aValue);
+        }
+    return KErrBadHandle;
+    }
+
 void CMMFDevSoundSession::ResetNotifiedError()
 // called at beginning of commit cycle, so any error will be from callbacks
     {
--- a/devsound/a3fdevsound/src/mmfdevsoundserver/mmfdevsoundsession.h	Wed Sep 08 17:15:23 2010 +0100
+++ b/devsound/a3fdevsound/src/mmfdevsoundserver/mmfdevsoundsession.h	Thu Sep 16 18:39:58 2010 +0100
@@ -1534,6 +1534,22 @@
 	*/
 	void BufferErrorEvent();
 
+	/*
+	 Removes all entries from iQueuedRequests except for
+	 disconnect requests.
+	 */
+	void FlushQueuedRequests();
+	
+	/*
+	 Helper functions, used to guard against accessing the equivalent
+	 functions on bad message handles during a disconnection. These
+	 methods should be used whenever a Read or Write is made outside the 
+	 context of DoServiceRequestL().
+	 */
+	TInt MessageRead(const RMmfIpcMessage& aMessage, TInt aParam, TDes8& aResult);
+	TInt MessageRead(const RMmfIpcMessage& aMessage, TInt aParam, TDes16& aResult);
+	TInt MessageWrite(const RMmfIpcMessage& aMessage, TInt aParam, const TDesC8& aValue);
+
 protected:
 
 	/**
@@ -1614,6 +1630,7 @@
 	TInt iSeqNum;
 	TBool iPreemptionClash;
 	TInt iNotifiedError;
+	TBool iDisconnecting;
 
 	};
 
--- a/mm_plat/global_audio_settings_api/inc/GlobalAudioSettings.h	Wed Sep 08 17:15:23 2010 +0100
+++ b/mm_plat/global_audio_settings_api/inc/GlobalAudioSettings.h	Thu Sep 16 18:39:58 2010 +0100
@@ -63,6 +63,7 @@
             */
             EGASRingingTypeBeepOnce     = 3,
             /** The phone is silent.
+            * This Ringing type is set when the phone is in silence mode.
             */
             EGASRingingTypeSilent       = 4
             };
@@ -309,6 +310,7 @@
         *
         * 
         * @return TBool aEnable. ETrue if the silent mode is enabled else EFalse.
+        * Ringingtype is set to EGASRingingTypeSilent when silence mode is enabled
         */
         
         IMPORT_C TBool IsSilenceModeEnabled();
--- a/mmlibs/mmfw/src/Client/Video/VideoPlayerBody.h	Wed Sep 08 17:15:23 2010 +0100
+++ b/mmlibs/mmfw/src/Client/Video/VideoPlayerBody.h	Thu Sep 16 18:39:58 2010 +0100
@@ -229,6 +229,8 @@
 	TBool RectContains(const TRect& aLeft, const TRect& aRight);
 	void DoAddDisplayWindowL(RWsSession& aWs, TInt aDisplay, RWindowBase& aWindow,
 								const TRect& aClipRect, const TRect& aVideoExtent, RWindow* aWindow2);
+	void DoUpdateDisplayWindowL(RWsSession& aWs, RWindowBase& aWindow,
+	              const TRect& aClipRect, const TRect& aVideoExtent, RWindow* aWindow2);
 	TInt SurfaceCreated();
 	TInt SurfaceParametersChanged();
 	TInt RemoveSurface(TBool aControllerEvent);
--- a/mmlibs/mmfw/src/Client/Video/mediaclientpolicyserverclient.cpp	Wed Sep 08 17:15:23 2010 +0100
+++ b/mmlibs/mmfw/src/Client/Video/mediaclientpolicyserverclient.cpp	Thu Sep 16 18:39:58 2010 +0100
@@ -88,7 +88,8 @@
     TBool ignore = (
             (aId == 0x10281EF2) ||  // aknnfysrv
             (aId == 0x10207218) ||  // akncapserver
-            (aId == 0x10003a4a)     // eiksrvs
+            (aId == 0x10003a4a) ||  // eiksrvs
+			(aId == 0x20022FC5)     // Hbdevicedialogappserver
             );
     
     DEBUG_PRINTF2("CMediaClientPolicyServerClient::IgnoreProcess --- return %d", ignore);
--- a/mmlibs/mmfw/src/Client/Video/mediaclientvideodisplay.cpp	Wed Sep 08 17:15:23 2010 +0100
+++ b/mmlibs/mmfw/src/Client/Video/mediaclientvideodisplay.cpp	Thu Sep 16 18:39:58 2010 +0100
@@ -149,9 +149,12 @@
 	}
 
 /**
-Removes a window that is currently being used to display the video picture. The window must 
+Removes a window that is currently being used to display the video picture. The window must
 have previously been added with AddDisplayWindowL(). 
 
+Note Depending on underlying implementation it may also remove any graphics resources associated
+with video playback on this window. 
+
 Note removing the last window on a display will deregister the display
 	
 @param  aWindow
--- a/mmlibs/mmfw/src/Client/Video/mediaclientvideodisplaybody.cpp	Wed Sep 08 17:15:23 2010 +0100
+++ b/mmlibs/mmfw/src/Client/Video/mediaclientvideodisplaybody.cpp	Thu Sep 16 18:39:58 2010 +0100
@@ -239,6 +239,60 @@
 	DEBUG_PRINTF("CMediaClientVideoDisplayBody::AddDisplayWindowL ---");
 	}
 
+void CMediaClientVideoDisplayBody::UpdateDisplayWindowL(const RWindowBase* aWindow, const TRect& aClipRect, const TRect& aCropRegion, const TRect& aVideoExtent, 
+                                                            TReal32 aScaleWidth, TReal32 aScaleHeight, TVideoRotation aRotation, 
+                                                            TAutoScaleType aAutoScaleType, TInt aHorizPos, TInt aVertPos, RWindow* aWindow2)
+    {   
+    DEBUG_PRINTF("CMediaClientVideoDisplayBody::UpdateDisplayWindowL +++");
+    DEBUG_PRINTF2("CMediaClientVideoDisplayBody::UpdateDisplayWindowL - aWindow WsHandle 0x%X", aWindow->WsHandle());
+    DEBUG_PRINTF5("CMediaClientVideoDisplayBody::UpdateDisplayWindowL - aClipRect %d,%d - %d,%d", aClipRect.iTl.iX, aClipRect.iTl.iY, aClipRect.iBr.iX, aClipRect.iBr.iY);
+    DEBUG_PRINTF5("CMediaClientVideoDisplayBody::UpdateDisplayWindowL - aCropRegion %d,%d - %d,%d", aCropRegion.iTl.iX, aCropRegion.iTl.iY, aCropRegion.iBr.iX, aCropRegion.iBr.iY);
+    DEBUG_PRINTF5("CMediaClientVideoDisplayBody::UpdateDisplayWindowL - aVideoExtent %d,%d - %d,%d", aVideoExtent.iTl.iX, aVideoExtent.iTl.iY, aVideoExtent.iBr.iX, aVideoExtent.iBr.iY);
+    DEBUG_PRINTF3("CMediaClientVideoDisplayBody::UpdateDisplayWindowL - aScaleWidth %f, aScaleHeight %f", aScaleWidth, aScaleHeight);
+    DEBUG_PRINTF2("CMediaClientVideoDisplayBody::UpdateDisplayWindowL - aRotation %d", aRotation);
+    DEBUG_PRINTF2("CMediaClientVideoDisplayBody::UpdateDisplayWindowL - aAutoScaleType %d", aAutoScaleType);
+    DEBUG_PRINTF3("CMediaClientVideoDisplayBody::UpdateDisplayWindowL - aHorizPos %d, aVertPos %d", aHorizPos, aVertPos);
+
+    if (!IsRotationValid(aRotation))
+        {
+        User::Leave(KErrArgument);
+        }
+
+    if (!IsAutoScaleTypeValid(aAutoScaleType))
+        {
+        User::Leave(KErrArgument);
+        }
+
+    TInt pos = iClientWindows.Find(aWindow->WsHandle(), TWindowData::CompareByWsHandle);
+    User::LeaveIfError(pos);
+    iClientWindows.Remove(pos);
+    
+    TWindowData winData(aWindow, aClipRect, aVideoExtent, aScaleWidth, aScaleHeight, aRotation, aAutoScaleType, aHorizPos, aVertPos, aWindow2);
+    iClientWindows.AppendL(winData);
+    
+    TRect prevCropRegion = iCropRegion;
+    iCropRegion = aCropRegion;
+    
+    if (IsSurfaceCreated())
+        {
+        if(ClientCropRegionChangeRequiresRedraw(prevCropRegion, aCropRegion, iCropRect))
+            {
+            // all windows need to be redrawn
+            User::LeaveIfError(RedrawWindows(aCropRegion));
+            }
+        else
+            {
+            // only redraw affected window as other window data may have changed
+            if(!iSwitchedToExternalDisplay)
+                {
+                User::LeaveIfError(SetBackgroundSurface(winData, aCropRegion));
+                }
+            }
+        }
+
+    DEBUG_PRINTF("CMediaClientVideoDisplayBody::UpdateDisplayWindowL ---");
+    }
+
 void CMediaClientVideoDisplayBody::RemoveDisplay()
 	{
 	DEBUG_PRINTF("CMediaClientVideoDisplayBody::RemoveDisplay +++");
--- a/mmlibs/mmfw/src/Client/Video/mediaclientvideodisplaybody.h	Wed Sep 08 17:15:23 2010 +0100
+++ b/mmlibs/mmfw/src/Client/Video/mediaclientvideodisplaybody.h	Thu Sep 16 18:39:58 2010 +0100
@@ -104,6 +104,9 @@
 	void AddDisplayWindowL(const RWindowBase* aWindow, const TRect& aClipRect, const TRect& aCropRegion, const TRect& aVideoExtent,
 							TReal32 aScaleWidth, TReal32 aScaleHeight, TVideoRotation aRotation,
 							TAutoScaleType aAutoScaleType, TInt aHorizPos, TInt aVertPos, RWindow* aWindow2);
+	void UpdateDisplayWindowL(const RWindowBase* aWindow, const TRect& aClipRect, const TRect& aCropRegion, const TRect& aVideoExtent, 
+                            TReal32 aScaleWidth, TReal32 aScaleHeight, TVideoRotation aRotation, 
+                            TAutoScaleType aAutoScaleType, TInt aHorizPos, TInt aVertPos, RWindow* aWindow2);
 	void RemoveDisplay();
 	TInt RemoveDisplayWindow(const RWindowBase& aWindow);
 	
--- a/mmlibs/mmfw/src/Client/Video/mmfclientvideoplayer2.cpp	Wed Sep 08 17:15:23 2010 +0100
+++ b/mmlibs/mmfw/src/Client/Video/mmfclientvideoplayer2.cpp	Thu Sep 16 18:39:58 2010 +0100
@@ -1,4 +1,4 @@
-// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies).
 // All rights reserved.
 // This component and the accompanying materials are made available
 // under the terms of "Eclipse Public License v1.0"
@@ -119,9 +119,12 @@
 	}
 
 /**
-Removes a window that is currently being used to display the video picture. The window must 
+Removes a window that is currently being used to display the video picture. The window must
 have previously been added with AddDisplayWindowL(). 
 
+Note Depending on underlying implementation it may also remove any graphics resources associated
+with video playback on this window. 
+
 This method cannot fail. If the window has not been added with AddDisplayWindowL(), the 
 method call will be ignored. 
 	
--- a/mmlibs/mmfw/src/Client/Video/mmfclientvideoplayerbody.cpp	Wed Sep 08 17:15:23 2010 +0100
+++ b/mmlibs/mmfw/src/Client/Video/mmfclientvideoplayerbody.cpp	Thu Sep 16 18:39:58 2010 +0100
@@ -657,10 +657,6 @@
  			iDirectScreenAccess->Cancel();
   			AbortNow(RDirectScreenAccess::ETerminateCancel);
  			}
-
-		// try to remove the display window first no matter it is active or not.
-		// This method won't leave
-		RemoveDisplayWindow(aWindow);
 		
 		// When using surfaces for CVPU we use DoAddDisplayWindowL() which requires clip rectangle and video extent
 		// as arguments. Video extent is not supported by CVPU so aWindowRect is used instead. This function
@@ -670,7 +666,16 @@
 		TRect clipRectRelativeToWindow;		
 		ConvertFromRelativeToDisplayToRelativeToWindow(aWindow, aWindowRect, aClipRect, windowRectRelativeToWindow, clipRectRelativeToWindow);
 
-        DoAddDisplayWindowL(aWs, aScreenDevice.GetScreenNumber(), aWindow, clipRectRelativeToWindow, windowRectRelativeToWindow, NULL);
+		// check if display for window already exists and if so do an update else create a new display
+		TRAPD(err, CMediaClientVideoDisplayBody::FindDisplayWithWindowL(iActiveDisplays, aWindow));
+		if (err == KErrNone)
+		    {
+		    DoUpdateDisplayWindowL(aWs, aWindow, clipRectRelativeToWindow, windowRectRelativeToWindow, NULL);
+		    }
+		else
+		    {
+		    DoAddDisplayWindowL(aWs, aScreenDevice.GetScreenNumber(), aWindow, clipRectRelativeToWindow, windowRectRelativeToWindow, NULL);
+		    }
 		}
 #else
 	PrepareDSAL(aWs, aScreenDevice, aWindow);
@@ -1594,6 +1599,38 @@
 #endif //SYMBIAN_MULTIMEDIA_SUBTITLE_SUPPORT
 	}
 
+void CVideoPlayerUtility::CBody::DoUpdateDisplayWindowL(RWsSession& aWs, RWindowBase& aWindow,
+                                const TRect& aClipRect, const TRect& aVideoExtent, RWindow* aWindow2)
+    {
+    iWs = &aWs;
+
+    // check opening the source is complete and the client has been recieved an MvpuoOpenComplete() callback
+    if (!iControllerOpen)
+        {
+        User::Leave(KErrNotReady);
+        }
+
+    CMediaClientVideoDisplayBody* display = NULL;
+    TRAPD(err, display = CMediaClientVideoDisplayBody::FindDisplayWithWindowL(iActiveDisplays, aWindow));
+    User::LeaveIfError(err);
+
+    display->UpdateDisplayWindowL(&aWindow, aClipRect, iCropRegion, aVideoExtent, iGlobalScaleWidth, iGlobalScaleHeight,
+                                iGlobalRotation, iGlobalAutoScaleType, iGlobalHorizPos, iGlobalVertPos, aWindow2);
+
+#ifdef SYMBIAN_MULTIMEDIA_SUBTITLE_SUPPORT
+    if (iSubtitleUtility)
+        {
+        // subtitles were enabled already, so update subtitles on this window
+        TMMFSubtitleWindowConfig config;
+        config.iWindowId = aWindow.WsHandle();
+        config.iWindowClipRect = aClipRect;
+        config.iDisplayMode = aWindow.DisplayMode();
+        config.iRotation = iGlobalRotation;
+        iSubtitleUtility->UpdateSubtitleConfig(config); // ignore error from add subtitle config because the window can still display video properly
+        }
+#endif //SYMBIAN_MULTIMEDIA_SUBTITLE_SUPPORT
+    }
+
 void CVideoPlayerUtility::CBody::RemoveDisplayWindow(RWindowBase& aWindow)
 	{
     DEBUG_PRINTF("CVideoPlayerUtility::CBody::RemoveDisplayWindow++");
--- a/mmlibs/mmfw/tsrc/mmfintegrationtest/vclntavi/src/testvideoplayer.cpp	Wed Sep 08 17:15:23 2010 +0100
+++ b/mmlibs/mmfw/tsrc/mmfintegrationtest/vclntavi/src/testvideoplayer.cpp	Thu Sep 16 18:39:58 2010 +0100
@@ -1,4 +1,4 @@
-// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
+// Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies).
 // All rights reserved.
 // This component and the accompanying materials are made available
 // under the terms of "Eclipse Public License v1.0"
@@ -1131,10 +1131,22 @@
     TSize clipSize(176, 144);
     TRect clipRect(clipOrigin, clipSize);
     
+    // first call tests creation of display instance
     TRAPD(err, aPlayer->SetDisplayWindowL(iWs, *iScreen, *iWindow, rect, clipRect));
+    INFO_PRINTF1(_L("Test : Made first call to SetDisplayWindowL()"));
     if(err)
         {
-        ERR_PRINTF2(_L("SetDisplayWindowL() failed, error %d"), err);
+        ERR_PRINTF2(_L("First call to SetDisplayWindowL() failed, error %d"), err);
+        CActiveScheduler::Stop();
+        return EFail;
+        }
+
+    // second call tests update of display instance
+    TRAP(err, aPlayer->SetDisplayWindowL(iWs, *iScreen, *iWindow, rect, clipRect));
+    INFO_PRINTF1(_L("Test : Made second call to SetDisplayWindowL()"));
+    if(err)
+        {
+        ERR_PRINTF2(_L("Second call to SetDisplayWindowL() failed, error %d"), err);
         ret = EFail;
         }
     else
@@ -1143,7 +1155,6 @@
         }
 
     CActiveScheduler::Stop();
-        
     return ret;
     }