os/mm/mmresourcemgmt/mmresctrl/src/mmrcserver/mmrcserversession.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
//
sl@0
    15
sl@0
    16
sl@0
    17
#include "mmrcserversession.h"
sl@0
    18
#include "mmrcerrorcodes.h"
sl@0
    19
#include "mmrcservercontroller.h"
sl@0
    20
#include "mmrcadaptationproxy.h"
sl@0
    21
sl@0
    22
#include <a3f/maudiocontext.h>
sl@0
    23
sl@0
    24
#include "mlogicalchain.h"
sl@0
    25
#include "logicalaudiostream.h"
sl@0
    26
#include "audiocontext.h"
sl@0
    27
sl@0
    28
#include <a3f/a3ffourcclookup.h>
sl@0
    29
sl@0
    30
sl@0
    31
//------------------------------------------------------------------------------------
sl@0
    32
//
sl@0
    33
//------------------------------------------------------------------------------------
sl@0
    34
/**
sl@0
    35
 * By default Symbian 2nd phase constructor is private.
sl@0
    36
 * @param CMMRCServerController& A reference on the MMRC Server controller
sl@0
    37
 */
sl@0
    38
CMMRCServerSession::CMMRCServerSession(CMMRCServerController& aServerController, 
sl@0
    39
									const CFourCCConvertor& aFourCCConvertor)
sl@0
    40
: iMMRCServerController(aServerController),
sl@0
    41
  iShutdown(0),
sl@0
    42
  iLogicalChainRequested(NULL),
sl@0
    43
  iLogicalChainLastCommited(NULL),
sl@0
    44
  iLogicalChainRequestResponse(NULL),
sl@0
    45
  iLogicalChainPreemptionNotification(NULL)
sl@0
    46
	{
sl@0
    47
	TRACE_CREATE();
sl@0
    48
	DP_CONTEXT(----> CMMRCServerSession::CMMRCServerSession *CD1*, CtxDevSound, DPLOCAL);
sl@0
    49
	DP_IN();
sl@0
    50
	iFourCCConvertor = &aFourCCConvertor;
sl@0
    51
	DP_OUT();
sl@0
    52
	}
sl@0
    53
sl@0
    54
/**
sl@0
    55
 * Destructor
sl@0
    56
 */
sl@0
    57
CMMRCServerSession::~CMMRCServerSession()
sl@0
    58
	{
sl@0
    59
 	DP_CONTEXT(----> CMMRCServerSession::~CMMRCServerSession *CD1*, CtxDevSound, DPLOCAL);
sl@0
    60
	DP_IN();
sl@0
    61
	//remove any request associated to this session from the controller
sl@0
    62
	iMMRCServerController.CloseSessionByContextId(iContextId);
sl@0
    63
	
sl@0
    64
	if (iMMRCServerSideAdaptationResponseAO)
sl@0
    65
		{
sl@0
    66
		delete iMMRCServerSideAdaptationResponseAO;
sl@0
    67
		iMMRCServerSideAdaptationResponseAO=0;
sl@0
    68
		};
sl@0
    69
	
sl@0
    70
 	if(	iLogicalChainLastCommited )
sl@0
    71
 		{
sl@0
    72
		iLogicalChainLastCommited->Release();
sl@0
    73
 		iLogicalChainLastCommited = NULL;
sl@0
    74
 		};
sl@0
    75
 	
sl@0
    76
 	if(	iLogicalChainRequested )
sl@0
    77
 		{
sl@0
    78
		iLogicalChainRequested->Release();
sl@0
    79
 		iLogicalChainRequested = NULL;
sl@0
    80
 		}
sl@0
    81
 	if(	iLogicalChainRequestResponse )
sl@0
    82
 		{
sl@0
    83
		iLogicalChainRequestResponse->Release();
sl@0
    84
		iLogicalChainRequestResponse = NULL;
sl@0
    85
 		};
sl@0
    86
 		
sl@0
    87
 	if(	iLogicalChainPreemptionNotification )
sl@0
    88
 		{
sl@0
    89
		iLogicalChainPreemptionNotification->Release();
sl@0
    90
		iLogicalChainPreemptionNotification = NULL;
sl@0
    91
 		};
sl@0
    92
sl@0
    93
	iMsgQueue.Close();	
sl@0
    94
	
sl@0
    95
	DP_OUT();
sl@0
    96
	}
sl@0
    97
sl@0
    98
/**
sl@0
    99
 * Constructs, and returns a pointer to, a new CMMRCServerSession object.
sl@0
   100
 * Leaves on failure.
sl@0
   101
 * @param CMMRCServerController& A reference on the MMRC Server controller
sl@0
   102
 * @param CFourCCConvertor& A reference to the Fourcc to format converter 
sl@0
   103
 * @return CMMRCServerSession* A pointer to newly created utlitly object.
sl@0
   104
 */
sl@0
   105
CMMRCServerSession* CMMRCServerSession::NewL(CMMRCServerController& aServerController, 
sl@0
   106
											const CFourCCConvertor& aFourCCConvertor)
sl@0
   107
	{
sl@0
   108
	DP_STATIC_CONTEXT(----> CMMRCServerSession::NewL *CD1*, CtxDevSound, DPLOCAL);
sl@0
   109
	DP_IN();
sl@0
   110
	
sl@0
   111
	CMMRCServerSession* self = NewLC(aServerController, aFourCCConvertor);
sl@0
   112
	CleanupStack::Pop(self);
sl@0
   113
	
sl@0
   114
    DP0_RET(self, "self=0x%x");
sl@0
   115
	}
sl@0
   116
sl@0
   117
/**
sl@0
   118
 * Constructs, leaves object on the cleanup stack, and returns a pointer
sl@0
   119
 * to, a new CMMRCServerSession object.
sl@0
   120
 * Leaves on failure.
sl@0
   121
 * @param CMMRCServerController& A reference on the MMRC Server controller
sl@0
   122
 * @param CFourCCConvertor& A reference to the Fourcc to format converter  
sl@0
   123
 * @return CMMRCServerSession* A pointer to newly created utlitly object.
sl@0
   124
 */
sl@0
   125
CMMRCServerSession* CMMRCServerSession::NewLC(CMMRCServerController& aServerController, 
sl@0
   126
											const CFourCCConvertor& aFourCCConvertor)
sl@0
   127
	{
sl@0
   128
	DP_STATIC_CONTEXT(----> CMMRCServerSession::NewLC *CD1*, CtxDevSound, DPLOCAL);
sl@0
   129
	DP_IN();
sl@0
   130
	
sl@0
   131
	CMMRCServerSession* self = new(ELeave) CMMRCServerSession(aServerController, aFourCCConvertor);
sl@0
   132
	CleanupStack::PushL( self );
sl@0
   133
	self->ConstructL();
sl@0
   134
	
sl@0
   135
	DP0_RET(self, "self=0x%x");
sl@0
   136
	}
sl@0
   137
sl@0
   138
/**
sl@0
   139
 	CMMRCServerSession::ConstructL
sl@0
   140
 	Symbian 2nd phase constructor can leave.
sl@0
   141
 */
sl@0
   142
void CMMRCServerSession::ConstructL()
sl@0
   143
	{
sl@0
   144
 	DP_CONTEXT(----> CMMRCServerSession::ConstructL *CD1*, CtxDevSound, DPLOCAL);
sl@0
   145
	DP_IN();
sl@0
   146
	
sl@0
   147
	iContextId = reinterpret_cast<TUint32>(this);
sl@0
   148
	iMMRCServerSideAdaptationResponseAO = CMMRCServerSideAdaptationResponseAO::NewL();
sl@0
   149
	iMMRCServerSideAdaptationResponseAO->Initialize(this, &iServerThread);
sl@0
   150
sl@0
   151
	DP_OUT();
sl@0
   152
	}
sl@0
   153
sl@0
   154
/**
sl@0
   155
 * from CSession2
sl@0
   156
 * @param aMessage - Function and data for the session
sl@0
   157
 */	
sl@0
   158
void CMMRCServerSession::ServiceL(const RMessage2& aMessage)
sl@0
   159
	{
sl@0
   160
 	DP_CONTEXT(----> CMMRCServerSession::ServiceL *CD1*, CtxDevSound, DPLOCAL);
sl@0
   161
	DP_IN();
sl@0
   162
sl@0
   163
	TRAPD( errL, DispatchMessageL(aMessage) );
sl@0
   164
sl@0
   165
	if( errL != KErrNone )
sl@0
   166
		{
sl@0
   167
		#ifdef SYMBIAN_MULTIMEDIA_ENABLE_LOGGING	
sl@0
   168
			RDebug::Print(_L("CMMRCServerSession::ServiceL - err %d"), errL);
sl@0
   169
		#endif
sl@0
   170
		}
sl@0
   171
	
sl@0
   172
	DP_OUT();
sl@0
   173
	}	
sl@0
   174
sl@0
   175
/**
sl@0
   176
 * Dispatch the message received from ServeL
sl@0
   177
 * EMMRCClientToServerSetMsgQueueHandle - Initialise the queue handler
sl@0
   178
 * EMMRCClientToServerMessage - Process a message from the client
sl@0
   179
 * EMMRCClientToServerMessageUpdate - Process a message update from the client
sl@0
   180
 * EMMRCClientToServerMessageAcknowledgement - Process the acknowldgement from the client
sl@0
   181
 * @param aMessage - Function and data for the session
sl@0
   182
 * @return error code
sl@0
   183
 * @leave in case of writeL leave or request leave
sl@0
   184
 */	
sl@0
   185
TInt CMMRCServerSession::DispatchMessageL(const RMessage2& aMessage)
sl@0
   186
	{
sl@0
   187
 	DP_CONTEXT(----> CMMRCServerSession::DispatchMessageL *CD1*, CtxDevSound, DPLOCAL);
sl@0
   188
	DP_IN();
sl@0
   189
	
sl@0
   190
	TInt error(KErrNone);
sl@0
   191
sl@0
   192
	TMMRCClientToServerMessages messageFunction = static_cast<TMMRCClientToServerMessages>(aMessage.Function());
sl@0
   193
	switch(messageFunction)
sl@0
   194
		{
sl@0
   195
		
sl@0
   196
		case EMMRCClientToServerSetClientThreadId:
sl@0
   197
			{
sl@0
   198
			TThreadId* id = static_cast<TThreadId*>(const_cast<TAny *>(aMessage.Ptr0()));
sl@0
   199
			iClientThread.Open(*id);
sl@0
   200
			RThread me;
sl@0
   201
			iServerThread.Open(me.Id());
sl@0
   202
			aMessage.Complete(error);  
sl@0
   203
			}
sl@0
   204
		break;
sl@0
   205
sl@0
   206
		case EMMRCClientToServerSetAdaptationProxy:
sl@0
   207
			{
sl@0
   208
			iMMRCClientSideServerRequestToAdaptationAO = static_cast<CMMRCClientSideServerRequestToAdaptationAO*>(const_cast<TAny *>(aMessage.Ptr0()));
sl@0
   209
sl@0
   210
			if(iMMRCClientSideServerRequestToAdaptationAO)
sl@0
   211
				{
sl@0
   212
				iMMRCClientSideServerRequestToAdaptationAO->Initialize(this, 
sl@0
   213
															iMMRCServerSideAdaptationResponseAO, 
sl@0
   214
															&iClientThread, 
sl@0
   215
															*iFourCCConvertor);
sl@0
   216
				}
sl@0
   217
			aMessage.Complete(error);  
sl@0
   218
			}
sl@0
   219
		break;
sl@0
   220
sl@0
   221
		case EMMRCClientToServerSetMsgQueueHandle:
sl@0
   222
			{
sl@0
   223
			error = iMsgQueue.Open( aMessage, 0 ); 
sl@0
   224
			aMessage.Complete(error);  
sl@0
   225
			}
sl@0
   226
		break;
sl@0
   227
sl@0
   228
		case EMMRCClientToServerCloseSession:
sl@0
   229
			{
sl@0
   230
			//set a flag so that any subsequent acknowledgment will be ignored...
sl@0
   231
			iShutdown=ETrue;
sl@0
   232
			aMessage.Complete(error);  
sl@0
   233
			}
sl@0
   234
		break;
sl@0
   235
		
sl@0
   236
		case EMMRCClientToServerRequestResource:
sl@0
   237
			{
sl@0
   238
			error = EnqueueRequestL(aMessage);
sl@0
   239
			// AM this is needed since the request is not asynchronous.
sl@0
   240
			// It is processed asynchronously which is different
sl@0
   241
			aMessage.Complete(error);
sl@0
   242
			}
sl@0
   243
		break;
sl@0
   244
sl@0
   245
		case EMMRCClientToServerRequestContextId:
sl@0
   246
			{
sl@0
   247
			// CDS This code does not appear to be handling PlatSec functionality well
sl@0
   248
sl@0
   249
			TProcessId PID;
sl@0
   250
			TPckg<TProcessId> processIdPckg(PID);
sl@0
   251
			TPckgBuf<TUint64> contextIdPckg;
sl@0
   252
						
sl@0
   253
			aMessage.ReadL( 0, processIdPckg );			
sl@0
   254
			
sl@0
   255
			RProcess client;
sl@0
   256
			TInt err = client.Open(PID);
sl@0
   257
			if(err == KErrNone)
sl@0
   258
				{
sl@0
   259
				iClientHasMMCapability = client.HasCapability(ECapabilityMultimediaDD, KSuppressPlatSecDiagnostic);
sl@0
   260
				iClientHasUECapability = client.HasCapability(ECapabilityUserEnvironment, KSuppressPlatSecDiagnostic);
sl@0
   261
				client.Close();
sl@0
   262
				}
sl@0
   263
			aMessage.WriteL( 1, contextIdPckg );
sl@0
   264
			aMessage.Complete(error);  
sl@0
   265
			}
sl@0
   266
		break;
sl@0
   267
		
sl@0
   268
		
sl@0
   269
		case EMMRCClientToServerRegisterAsClient:
sl@0
   270
			{
sl@0
   271
			// ignoring arguments
sl@0
   272
			error = iMMRCServerController.EnqueueRequestForAPRL(*this);
sl@0
   273
			aMessage.Complete(error);
sl@0
   274
			}
sl@0
   275
		break;
sl@0
   276
		
sl@0
   277
		case EMMRCClientToServerCancelRegisterAsClient:
sl@0
   278
			{
sl@0
   279
			// ignoring arguments
sl@0
   280
			error = iMMRCServerController.RemoveRequestForAPR(*this);
sl@0
   281
			aMessage.Complete(error);
sl@0
   282
			}
sl@0
   283
		break;
sl@0
   284
sl@0
   285
		case EMMRCClientToServerWillResumePlay:
sl@0
   286
			{
sl@0
   287
			error = iMMRCServerController.WillResumePlay();
sl@0
   288
			aMessage.Complete(error);  
sl@0
   289
			}
sl@0
   290
		break;		
sl@0
   291
		
sl@0
   292
		default:
sl@0
   293
			{
sl@0
   294
			#ifdef SYMBIAN_MULTIMEDIA_ENABLE_LOGGING	
sl@0
   295
				RDebug::Print(_L("!!!!CMMRCServerSession::DispatchMessageL - unknown message"));
sl@0
   296
			#endif
sl@0
   297
			// Unknown Message
sl@0
   298
			error = KErrNotSupported;
sl@0
   299
			}
sl@0
   300
		break;
sl@0
   301
		}
sl@0
   302
sl@0
   303
	DP0_RET(error, "err=%d");
sl@0
   304
	}	
sl@0
   305
sl@0
   306
/**
sl@0
   307
 * Process a message that can be
sl@0
   308
 *     EMMRCMessageStateAffecting a state-effecting message
sl@0
   309
 *     EMMRCMessageCommit a resource request
sl@0
   310
 * @param const RMessage2& aMessage
sl@0
   311
 */	
sl@0
   312
void CMMRCServerSession::PreProcessRequestL(const RMessage2& aMessage)
sl@0
   313
 	{
sl@0
   314
 	DP_CONTEXT(----> CMMRCServerSession::PreprocessMessageL *CD1*, CtxDevSound, DPLOCAL);
sl@0
   315
	DP_IN();
sl@0
   316
	
sl@0
   317
	MLogicalChain* logicalChainRequested = static_cast<MLogicalChain*>(const_cast<TAny *>(aMessage.Ptr1()));
sl@0
   318
	if( logicalChainRequested == NULL )
sl@0
   319
		{
sl@0
   320
		#ifdef _DEBUG	
sl@0
   321
			RDebug::Print(_L("!!!!CMMRCServerSession::PreProcessRequestL - logicalChainRequested NULL"));
sl@0
   322
			ASSERT(0);
sl@0
   323
		#endif
sl@0
   324
		User::Leave(KErrArgument);	
sl@0
   325
		}
sl@0
   326
	
sl@0
   327
	TInt err1 = KErrNone, err2 = KErrNone;
sl@0
   328
	iAudioContext = static_cast<CAudioContext*>(const_cast<TAny *>(aMessage.Ptr2()));
sl@0
   329
	MLogicalChain* logicalChainLastCommited = static_cast<MLogicalChain*>(const_cast<TAny *>(aMessage.Ptr0()));
sl@0
   330
	
sl@0
   331
	if(iLogicalChainLastCommitedStack)
sl@0
   332
		{
sl@0
   333
		iLogicalChainLastCommitedStack->Release();
sl@0
   334
		iLogicalChainLastCommitedStack = NULL;
sl@0
   335
		}
sl@0
   336
	if(iLogicalChainRequestedStack)
sl@0
   337
		{
sl@0
   338
		iLogicalChainRequestedStack->Release();
sl@0
   339
		iLogicalChainRequestedStack = NULL;
sl@0
   340
		}
sl@0
   341
	
sl@0
   342
	iAudioContext->CriticalSection().Wait();
sl@0
   343
	TInt msgVersion = iAudioContext->MsgVersion();
sl@0
   344
	if(msgVersion == aMessage.Int3())
sl@0
   345
		{
sl@0
   346
		if(logicalChainLastCommited)
sl@0
   347
			{
sl@0
   348
			TRAP(err1, iLogicalChainLastCommitedStack = logicalChainLastCommited->CloneL());
sl@0
   349
			}
sl@0
   350
	
sl@0
   351
		if(logicalChainRequested)
sl@0
   352
			{
sl@0
   353
			TRAP(err2, iLogicalChainRequestedStack = logicalChainRequested->CloneL());
sl@0
   354
			}
sl@0
   355
		}
sl@0
   356
	iAudioContext->CriticalSection().Signal();
sl@0
   357
	
sl@0
   358
	if(msgVersion != aMessage.Int3())
sl@0
   359
		{
sl@0
   360
		User::Leave(KErrCompletion);
sl@0
   361
		}
sl@0
   362
	
sl@0
   363
	if(err1!=KErrNone)
sl@0
   364
		{
sl@0
   365
		#ifdef SYMBIAN_MULTIMEDIA_ENABLE_LOGGING
sl@0
   366
			RDebug::Print(_L("!!!!CMMRCServerSession::PreProcessRequestL - logicalChainLastCommited->CloneL - error = %d"), err1);
sl@0
   367
		#endif
sl@0
   368
		ASSERT(0);
sl@0
   369
		User::Leave(err1);
sl@0
   370
		}
sl@0
   371
		
sl@0
   372
	if(err2!=KErrNone)
sl@0
   373
		{
sl@0
   374
		#ifdef SYMBIAN_MULTIMEDIA_ENABLE_LOGGING	
sl@0
   375
			RDebug::Print(_L("!!!!CMMRCServerSession::PreProcessRequestL - logicalChainRequested->CloneL - error = %d"), err2);
sl@0
   376
		#endif
sl@0
   377
		if(iLogicalChainLastCommitedStack)
sl@0
   378
			{
sl@0
   379
			iLogicalChainRequestedStack->Release();
sl@0
   380
			iLogicalChainRequestedStack = NULL;
sl@0
   381
			}
sl@0
   382
		ASSERT(0);
sl@0
   383
		User::Leave(err2);
sl@0
   384
		}
sl@0
   385
		
sl@0
   386
	DP_OUT();
sl@0
   387
	}
sl@0
   388
sl@0
   389
/**
sl@0
   390
 * Process a message that can be
sl@0
   391
 *     EMMRCMessageStateAffecting a state-effecting message
sl@0
   392
 *     EMMRCMessageCommit a resource request
sl@0
   393
 * @param const RMessage2& aMessage
sl@0
   394
 */	
sl@0
   395
TInt CMMRCServerSession::EnqueueRequestL(const RMessage2& aMessage)
sl@0
   396
 	{
sl@0
   397
 	DP_CONTEXT(----####> CMMRCServerSession::ProcessRequestL *CD1*, CtxDevSound, DPLOCAL);
sl@0
   398
	DP_IN();
sl@0
   399
	
sl@0
   400
	TInt err = KErrNone;
sl@0
   401
	TRAP(err, PreProcessRequestL(aMessage));
sl@0
   402
	if( err == KErrNone )
sl@0
   403
		{
sl@0
   404
		err = iMMRCServerController.EnqueueRequestL(*this);
sl@0
   405
		}
sl@0
   406
	
sl@0
   407
	DP0_RET(err, "err = %d");
sl@0
   408
	}
sl@0
   409
sl@0
   410
/*
sl@0
   411
 * 
sl@0
   412
 */
sl@0
   413
void CMMRCServerSession::StartProcessL()
sl@0
   414
	{
sl@0
   415
 	DP_CONTEXT(----> CMMRCServerSession::StartProcessL *CD1*, CtxDevSound, DPLOCAL);
sl@0
   416
	DP_IN();
sl@0
   417
sl@0
   418
 	if( iLogicalChainLastCommited )
sl@0
   419
		{
sl@0
   420
		//jjpy TODO should compare with iLogicalChainRequestedStack
sl@0
   421
		iLogicalChainLastCommited->Release();
sl@0
   422
		}
sl@0
   423
		
sl@0
   424
	if(iLogicalChainRequested)
sl@0
   425
		{
sl@0
   426
		#ifdef _DEBUG	
sl@0
   427
			RDebug::Print(_L("!!!!CMMRCServerSession::StartProcessL - iLogicalChainRequested not NULL"));
sl@0
   428
			ASSERT(0);
sl@0
   429
		#endif
sl@0
   430
		iLogicalChainRequested->Release();
sl@0
   431
		}
sl@0
   432
		
sl@0
   433
	iLogicalChainLastCommited = iLogicalChainLastCommitedStack;
sl@0
   434
	iLogicalChainRequested = iLogicalChainRequestedStack;
sl@0
   435
	
sl@0
   436
	iLogicalChainLastCommitedStack = 0;
sl@0
   437
	iLogicalChainRequestedStack = 0;
sl@0
   438
	
sl@0
   439
	//Send the CommitUpdate to the client
sl@0
   440
 	TMMRCQueueItem messageItem;
sl@0
   441
 	messageItem.iRequestType = EMMRCRequestCommitUpdate;
sl@0
   442
	messageItem.iResult = EMMRCServerToClientCommitUpdate;
sl@0
   443
	messageItem.iErrorCode = KErrNone;
sl@0
   444
 	TInt errSend = iMsgQueue.Send(messageItem);
sl@0
   445
	#ifdef _DEBUG	
sl@0
   446
		if(errSend!=KErrNone)
sl@0
   447
 		{
sl@0
   448
		RDebug::Print(_L("!!!!CMMRCServerSession::PreProcessRequestL - error = %d"), errSend);
sl@0
   449
		ASSERT(0);
sl@0
   450
 		}
sl@0
   451
	#endif
sl@0
   452
	User::LeaveIfError(errSend);
sl@0
   453
	
sl@0
   454
	DP_OUT();
sl@0
   455
	}
sl@0
   456
sl@0
   457
/*
sl@0
   458
 * 
sl@0
   459
 */
sl@0
   460
void CMMRCServerSession::StartPreemptionL()
sl@0
   461
	{
sl@0
   462
 	DP_CONTEXT(----> CMMRCServerSession::StartPreemptionL *CD1*, CtxDevSound, DPLOCAL);
sl@0
   463
	DP_IN();
sl@0
   464
sl@0
   465
	//Should be NULL
sl@0
   466
	if(iLogicalChainRequested)
sl@0
   467
		{
sl@0
   468
		#ifdef _DEBUG	
sl@0
   469
			RDebug::Print(_L("!!!!CMMRCServerSession::StartPreemptionL - iLogicalChainRequested not NULL"));
sl@0
   470
			ASSERT(0);
sl@0
   471
		#endif
sl@0
   472
		iLogicalChainRequested->Release();
sl@0
   473
		}
sl@0
   474
sl@0
   475
	//Should NOT be NULL.
sl@0
   476
	if( iLogicalChainLastCommited )
sl@0
   477
		{
sl@0
   478
		iLogicalChainRequested = iLogicalChainLastCommited->CloneL();
sl@0
   479
		CLogicalAudioStream* audiostream = static_cast<CLogicalAudioStream*>(iLogicalChainRequested);
sl@0
   480
		TAudioState state = audiostream->StreamState();
sl@0
   481
		
sl@0
   482
		// MMRC wont't support demote to EIdle anymore
sl@0
   483
		// All stream are demote to EInitialised
sl@0
   484
		switch(state)
sl@0
   485
			{
sl@0
   486
			case EIdle:
sl@0
   487
				{
sl@0
   488
				audiostream->Unload();
sl@0
   489
				}
sl@0
   490
				break;
sl@0
   491
				
sl@0
   492
			case EPrimed:
sl@0
   493
			case EActive:
sl@0
   494
				{
sl@0
   495
				User::LeaveIfError(audiostream->Stop());
sl@0
   496
				audiostream->Unload();
sl@0
   497
				}
sl@0
   498
				break;
sl@0
   499
			default:
sl@0
   500
				#ifdef _DEBUG	
sl@0
   501
					RDebug::Print(_L("!!!!CMMRCServerSession::StartPreemptionL - wrong state "));
sl@0
   502
					ASSERT(0);
sl@0
   503
				#endif
sl@0
   504
				break;
sl@0
   505
			}
sl@0
   506
		}
sl@0
   507
	
sl@0
   508
	DP_OUT();
sl@0
   509
	}
sl@0
   510
sl@0
   511
/**
sl@0
   512
 * Callback on a resource request
sl@0
   513
 * @param TMMRCServerToClientMessageResults aResult the result on the request
sl@0
   514
 * @leave
sl@0
   515
 */
sl@0
   516
void CMMRCServerSession::AdaptationRequestAcknowledgment(TMMRCAdaptationToServerRequestResults aResult, TInt aError)
sl@0
   517
 	{
sl@0
   518
 	DP_CONTEXT(----@@@@> CMMRCServerSession::AdaptationRequestAcknowledgment *CD1*, CtxDevSound, DPLOCAL);
sl@0
   519
	DP_IN();
sl@0
   520
	
sl@0
   521
 	TMMRCQueueItem messageItem;
sl@0
   522
 	messageItem.iRequestType = EMMRCRequestCommitResponse;
sl@0
   523
 	
sl@0
   524
 	switch(aResult)
sl@0
   525
 		{
sl@0
   526
  		case EMMRCAdaptationToServerResourceComplete:
sl@0
   527
 			{
sl@0
   528
 			TUint64 contextId;
sl@0
   529
 			TMMRCServerState serverState;
sl@0
   530
 			iMMRCServerController.ServerState(serverState, contextId);
sl@0
   531
			switch(serverState)
sl@0
   532
				{
sl@0
   533
 				case EMMRCServerStateWaitResourceResponseFromAdaptation: // here we process the response
sl@0
   534
		 	  		{
sl@0
   535
		 	  		messageItem.iResult = EMMRCServerToClientResourceAgreed;
sl@0
   536
		 	 	 	messageItem.iErrorCode = aError;
sl@0
   537
		 	 		iMMRCServerController.AdaptationRequestAcknowledgment(*this, aResult, aError);
sl@0
   538
		 	 		SendRequestResponseToClient(messageItem);
sl@0
   539
 					} //end case EMMRCServerStateWaitResourceResponseFromAdaptation
sl@0
   540
 	 				break;
sl@0
   541
				case EMMRCServerStateWaitPreemptionResponse: // here we process the response
sl@0
   542
					{
sl@0
   543
			 	 	messageItem.iResult = EMMRCServerToClientResourcePreempt;
sl@0
   544
		 	 	 	messageItem.iErrorCode = KErrCompletion;
sl@0
   545
					iMMRCServerController.AdaptationRequestAcknowledgment(*this, aResult, KErrCompletion);
sl@0
   546
					SendPreemptionNotificationToClient(messageItem);
sl@0
   547
					}
sl@0
   548
					break;
sl@0
   549
				default:
sl@0
   550
					{
sl@0
   551
					#ifdef _DEBUG	
sl@0
   552
						RDebug::Print(_L("!!!!CMMRCServerSession::AdaptationRequestAcknowledgment - Unknown message"));
sl@0
   553
						ASSERT(0);
sl@0
   554
					#endif
sl@0
   555
					}
sl@0
   556
					break;
sl@0
   557
				} //end case EMMRCServerStateWaitPreemptionRespons
sl@0
   558
			}
sl@0
   559
 			break;
sl@0
   560
 			
sl@0
   561
 		case EMMRCAdaptationToServerResourceIncomplete:
sl@0
   562
 			{
sl@0
   563
	 	  		messageItem.iResult = EMMRCServerToClientResourceDenied;
sl@0
   564
	 	 	 	messageItem.iErrorCode = aError;
sl@0
   565
	 	 		iMMRCServerController.AdaptationRequestAcknowledgment(*this, aResult, aError);
sl@0
   566
	 	 		SendRequestResponseToClient(messageItem);
sl@0
   567
			}
sl@0
   568
 			break;
sl@0
   569
 			
sl@0
   570
 		case EMMRCAdaptationToServerResourceTimeout:
sl@0
   571
 			{
sl@0
   572
 	 	 	messageItem.iResult = EMMRCServerToClientRequestError;
sl@0
   573
 	 	 	messageItem.iErrorCode = KErrCompletion;
sl@0
   574
			iMMRCServerController.AdaptationRequestAcknowledgment(*this, EMMRCAdaptationToServerResourceTimeout, KErrCompletion);
sl@0
   575
			SendRequestResponseToClient(messageItem);
sl@0
   576
 			}
sl@0
   577
 			break;
sl@0
   578
 			
sl@0
   579
		default:
sl@0
   580
 			break;
sl@0
   581
 		}
sl@0
   582
 	
sl@0
   583
  	DP_OUT();
sl@0
   584
  	}
sl@0
   585
sl@0
   586
/**
sl@0
   587
 * 
sl@0
   588
 * 
sl@0
   589
 */	
sl@0
   590
void CMMRCServerSession::SendRequestResponseToClient(TMMRCQueueItem& messageItem)
sl@0
   591
	{
sl@0
   592
 	DP_CONTEXT(----====> CMMRCServerSession::SendRequestResponseToClient *CD1*, CtxDevSound, DPLOCAL);
sl@0
   593
	DP_IN();
sl@0
   594
	if(messageItem.iErrorCode == KErrNone)
sl@0
   595
		{
sl@0
   596
		//1) Set the iLogicalChainRequestResponse
sl@0
   597
		if(iLogicalChainRequestResponse)
sl@0
   598
			{
sl@0
   599
			iLogicalChainRequestResponse->Release();
sl@0
   600
			iLogicalChainRequestResponse = NULL;
sl@0
   601
			}
sl@0
   602
		if(iLogicalChainRequested)
sl@0
   603
			{
sl@0
   604
			TInt errT;
sl@0
   605
			TRAP(errT, iLogicalChainRequestResponse = iLogicalChainRequested->CloneL());
sl@0
   606
			DP1(DLERR,"ECloneLeftWhenSendingResponseToClient %d", errT);
sl@0
   607
			__ASSERT_DEBUG(errT == KErrNone, Panic(ECloneLeftWhenSendingResponseToClient));
sl@0
   608
			}
sl@0
   609
		//2) Set the last commited chain et set the desired one to NULL
sl@0
   610
		if( iLogicalChainLastCommited )
sl@0
   611
			{
sl@0
   612
			iLogicalChainLastCommited->Release();
sl@0
   613
			iLogicalChainLastCommited = NULL;
sl@0
   614
			}
sl@0
   615
		iLogicalChainLastCommited = iLogicalChainRequested;
sl@0
   616
		iLogicalChainRequested = NULL;
sl@0
   617
		}
sl@0
   618
	else //In case of ERROR
sl@0
   619
		{
sl@0
   620
		//1) Set the iLogicalChainRequestResponse
sl@0
   621
		if(iLogicalChainRequestResponse)
sl@0
   622
			{
sl@0
   623
			iLogicalChainRequestResponse->Release();
sl@0
   624
			iLogicalChainRequestResponse = NULL;
sl@0
   625
			}
sl@0
   626
		if(iLogicalChainRequested)
sl@0
   627
			{
sl@0
   628
			TInt errT;
sl@0
   629
			TRAP(errT, iLogicalChainRequestResponse = iLogicalChainLastCommited->CloneL());
sl@0
   630
			DP1(DLERR,"ECloneLeftWhenSendingResponseToClient %d", errT);
sl@0
   631
			__ASSERT_DEBUG(errT == KErrNone, Panic(ECloneLeftWhenSendingResponseToClient));
sl@0
   632
			}
sl@0
   633
		//2) Set the last commited chain et set the desired one to NULL
sl@0
   634
		if( iLogicalChainRequested )
sl@0
   635
			{
sl@0
   636
			iLogicalChainRequested->Release();
sl@0
   637
			iLogicalChainRequested = NULL;
sl@0
   638
			}
sl@0
   639
			
sl@0
   640
		if(iLogicalChainRequestedStack)
sl@0
   641
			{
sl@0
   642
			CLogicalAudioStream* lChain = static_cast <CLogicalAudioStream*>(iLogicalChainLastCommited);
sl@0
   643
			TAudioTypeSettings settings;	
sl@0
   644
			settings.iPriority = iLogicalChainRequestedStack->Priority();
sl@0
   645
			settings.iPref = 0;
sl@0
   646
			lChain->SetAudioType(settings);
sl@0
   647
			}
sl@0
   648
		}
sl@0
   649
	// Set the data for the client
sl@0
   650
	messageItem.iData = iLogicalChainRequestResponse;
sl@0
   651
sl@0
   652
 	//send the response to the client
sl@0
   653
 	TInt errSend = iMsgQueue.Send(messageItem);
sl@0
   654
	DP1(DLERR,"EMsgQueueFailedToSendMsg %d", errSend);
sl@0
   655
	__ASSERT_DEBUG(errSend == KErrNone, Panic(EMsgQueueFailedToSendMsg));
sl@0
   656
	
sl@0
   657
  	DP_OUT();
sl@0
   658
	}
sl@0
   659
sl@0
   660
/**
sl@0
   661
 * 
sl@0
   662
 * 
sl@0
   663
 */	
sl@0
   664
void CMMRCServerSession::SendPreemptionNotificationToClient(TMMRCQueueItem& messageItem)
sl@0
   665
	{
sl@0
   666
 	DP_CONTEXT(----~~~~> CMMRCServerSession::SendRequestResponseToClient *CD1*, CtxDevSound, DPLOCAL);
sl@0
   667
	DP_IN();
sl@0
   668
	//1) Set the iLogicalChainPreemptionNotification
sl@0
   669
	if(iLogicalChainPreemptionNotification)
sl@0
   670
		{
sl@0
   671
		iLogicalChainPreemptionNotification->Release();
sl@0
   672
		iLogicalChainPreemptionNotification = NULL;
sl@0
   673
		}
sl@0
   674
	if(iLogicalChainRequested)
sl@0
   675
		{
sl@0
   676
		TInt errT;
sl@0
   677
		TRAP(errT, iLogicalChainPreemptionNotification = iLogicalChainRequested->CloneL());
sl@0
   678
		DP1(DLERR,"ECloneLeftWhenSendingResponseToClient %d", errT);
sl@0
   679
		__ASSERT_DEBUG(errT == KErrNone, Panic(ECloneLeftWhenSendingResponseToClient));
sl@0
   680
sl@0
   681
		iLogicalChainRequested->Release();
sl@0
   682
		iLogicalChainRequested = NULL;
sl@0
   683
		}
sl@0
   684
sl@0
   685
	messageItem.iData = iLogicalChainPreemptionNotification;
sl@0
   686
sl@0
   687
 	//send the response to the client
sl@0
   688
 	TInt errSend = iMsgQueue.Send(messageItem);
sl@0
   689
	DP1(DLERR,"EMsgQueueFailedToSendMsg %d", errSend);
sl@0
   690
	__ASSERT_DEBUG(errSend == KErrNone, Panic(EMsgQueueFailedToSendMsg));
sl@0
   691
	
sl@0
   692
  	DP_OUT();
sl@0
   693
	}
sl@0
   694
sl@0
   695
/**
sl@0
   696
 * Notify all the paused client that a resource has been unallocated
sl@0
   697
 */
sl@0
   698
void CMMRCServerSession::NotifyClientResourceUnallocated()
sl@0
   699
	{
sl@0
   700
	DP_CONTEXT(----****> CMMRCServerSession::NotifyClientsResourceUnallocated *CD1*, CtxDevSound, DPLOCAL);
sl@0
   701
	DP_IN();
sl@0
   702
	
sl@0
   703
 	TMMRCQueueItem messageItem;
sl@0
   704
 	messageItem.iRequestType = EMMRCRequestResourceUnallocated;
sl@0
   705
 	TInt errSend = iMsgQueue.Send(messageItem);
sl@0
   706
	DP1(DLERR,"EMsgQueueFailedToSendMsg %d", errSend);
sl@0
   707
	__ASSERT_DEBUG(errSend == KErrNone, Panic(EMsgQueueFailedToSendMsg));
sl@0
   708
	
sl@0
   709
	DP_OUT();
sl@0
   710
	}
sl@0
   711
sl@0
   712
sl@0
   713
/**
sl@0
   714
 * return the current committed chain (const)
sl@0
   715
 * @return the current committed chain
sl@0
   716
 */
sl@0
   717
const MLogicalChain* CMMRCServerSession::LogicalChainRequested() const
sl@0
   718
 	{
sl@0
   719
 	DP_CONTEXT(----> CMMRCServerSession::LogicalChainRequested const *CD1*, CtxDevSound, DPLOCAL);
sl@0
   720
	DP_IN();
sl@0
   721
	
sl@0
   722
	DP0_RET(iLogicalChainRequested, "iLogicalChainRequested=0x%x");
sl@0
   723
	}
sl@0
   724
sl@0
   725
/**
sl@0
   726
 * return the current committed chain (const)
sl@0
   727
 * @return the current committed chain
sl@0
   728
 */
sl@0
   729
const MLogicalChain* CMMRCServerSession::LogicalChainRequestedStack() const
sl@0
   730
 	{
sl@0
   731
 	DP_CONTEXT(----> CMMRCServerSession::LogicalChainRequestedStack const *CD1*, CtxDevSound, DPLOCAL);
sl@0
   732
	DP_IN();
sl@0
   733
	
sl@0
   734
	DP0_RET(iLogicalChainRequestedStack, "iLogicalChainRequestedStack=0x%x");
sl@0
   735
	}
sl@0
   736
sl@0
   737
sl@0
   738
/**
sl@0
   739
 * return the last committed chain (const)
sl@0
   740
 * @return the last committed chain
sl@0
   741
 */
sl@0
   742
const MLogicalChain* CMMRCServerSession::LogicalChainLastCommited() const
sl@0
   743
 	{
sl@0
   744
 	DP_CONTEXT(----> CMMRCServerSession::LogicalChainLastCommited const *CD1*, CtxDevSound, DPLOCAL);
sl@0
   745
	DP_IN();
sl@0
   746
	
sl@0
   747
    DP0_RET(iLogicalChainLastCommited, "iLogicalChainLastCommited=0x%x");
sl@0
   748
 	}
sl@0
   749
sl@0
   750
/**
sl@0
   751
 * return the Audio Context (const)
sl@0
   752
 * @return the Audio Context
sl@0
   753
 */
sl@0
   754
const MAudioContext* CMMRCServerSession::AudioContext() const
sl@0
   755
	{
sl@0
   756
 	DP_CONTEXT(----> CMMRCServerSession::AudioContext *CD1*, CtxDevSound, DPLOCAL);
sl@0
   757
	DP_IN();
sl@0
   758
	
sl@0
   759
    DP0_RET(iAudioContext, "iAudioContext=0x%x");
sl@0
   760
	}
sl@0
   761
 	
sl@0
   762
/**
sl@0
   763
 * return the current committed chain
sl@0
   764
 * @return the current committed chain
sl@0
   765
 */
sl@0
   766
MLogicalChain* CMMRCServerSession::LogicalChainRequested()
sl@0
   767
  	{
sl@0
   768
 	DP_CONTEXT(----> CMMRCServerSession::LogicalChainRequested *CD1*, CtxDevSound, DPLOCAL);
sl@0
   769
	DP_IN();
sl@0
   770
	
sl@0
   771
    DP0_RET(iLogicalChainRequested, "iLogicalChainRequested=0x%x");
sl@0
   772
 	}
sl@0
   773
sl@0
   774
/**
sl@0
   775
 * return the current committed chain
sl@0
   776
 * @return the current committed chain
sl@0
   777
 */
sl@0
   778
MLogicalChain* CMMRCServerSession::LogicalChainRequestedStack()
sl@0
   779
  	{
sl@0
   780
 	DP_CONTEXT(----> CMMRCServerSession::LogicalChainRequestedStack *CD1*, CtxDevSound, DPLOCAL);
sl@0
   781
	DP_IN();
sl@0
   782
	
sl@0
   783
    DP0_RET(iLogicalChainRequestedStack, "iLogicalChainRequestedStack=0x%x");
sl@0
   784
 	}
sl@0
   785
sl@0
   786
/**
sl@0
   787
 * return the last committed chain
sl@0
   788
 * @return the last committed chain
sl@0
   789
 */
sl@0
   790
MLogicalChain* CMMRCServerSession::LogicalChainLastCommited()
sl@0
   791
  	{
sl@0
   792
 	DP_CONTEXT(----> CMMRCServerSession::LogicalChainLastCommited *CD1*, CtxDevSound, DPLOCAL);
sl@0
   793
	DP_IN();
sl@0
   794
	
sl@0
   795
	DP0_RET(iLogicalChainLastCommited, "iLogicalChainLastCommited=0x%x");
sl@0
   796
 	}
sl@0
   797
sl@0
   798
/**
sl@0
   799
 * 
sl@0
   800
 * @param 
sl@0
   801
 * @return
sl@0
   802
 */
sl@0
   803
CMMRCClientSideServerRequestToAdaptationAO* CMMRCServerSession::AdaptationProxy()
sl@0
   804
{
sl@0
   805
	DP_CONTEXT(----> CMMRCServerSession::AdaptationProxy *CD1*, CtxDevSound, DPLOCAL);
sl@0
   806
	DP_IN();
sl@0
   807
	
sl@0
   808
    DP0_RET(iMMRCClientSideServerRequestToAdaptationAO, "iMMRCServerAdaptationProxy=0x%x");
sl@0
   809
}
sl@0
   810
sl@0
   811
/**
sl@0
   812
 * 
sl@0
   813
 * @param 
sl@0
   814
 * @return
sl@0
   815
 */
sl@0
   816
TUint64 CMMRCServerSession::ContextId()
sl@0
   817
	{
sl@0
   818
	DP_CONTEXT(----> CMMRCServerSession::ContextId *CD1*, CtxDevSound, DPLOCAL);
sl@0
   819
	DP_IN();
sl@0
   820
	
sl@0
   821
    DP0_RET(iContextId, "iContextId=%d");
sl@0
   822
	}
sl@0
   823
sl@0
   824
/**
sl@0
   825
 * 
sl@0
   826
 */
sl@0
   827
TBool CMMRCServerSession::HasMultimediaCapability() const
sl@0
   828
	{
sl@0
   829
	return iClientHasMMCapability;
sl@0
   830
	}
sl@0
   831
sl@0
   832
sl@0
   833
/**
sl@0
   834
 * 
sl@0
   835
 */
sl@0
   836
void CMMRCServerSession::Clean()
sl@0
   837
	{
sl@0
   838
	DP_CONTEXT(----> CMMRCServerSession::Clean *CD1*, CtxDevSound, DPLOCAL);
sl@0
   839
	DP_IN();
sl@0
   840
	DP_OUT();
sl@0
   841
	}
sl@0
   842
sl@0
   843
/**
sl@0
   844
 * 
sl@0
   845
 * @param 
sl@0
   846
 */
sl@0
   847
void CMMRCServerSession::Disconnect(const RMessage2& aMessage)
sl@0
   848
	{
sl@0
   849
	DP_CONTEXT(----> CMMRCServerSession::Disconnect *CD1*, CtxDevSound, DPLOCAL);
sl@0
   850
	DP_IN();
sl@0
   851
sl@0
   852
	CSession2::Disconnect(aMessage);
sl@0
   853
	
sl@0
   854
	DP_OUT();
sl@0
   855
	}
sl@0
   856
sl@0
   857
/**
sl@0
   858
 * 
sl@0
   859
 * @return 
sl@0
   860
 */
sl@0
   861
TBool CMMRCServerSession::IsServerShuttingDown()
sl@0
   862
	{
sl@0
   863
	DP_CONTEXT(----> CMMRCServerSession::IsServerShuttingDown *CD1*, CtxDevSound, DPLOCAL);
sl@0
   864
	DP_IN();
sl@0
   865
sl@0
   866
	DP0_RET(iShutdown, "state(bool) = %d");
sl@0
   867
	}
sl@0
   868
sl@0
   869
TInt CMMRCServerSession::RequestsSent()
sl@0
   870
	{
sl@0
   871
	return iRequestsSent;
sl@0
   872
	};
sl@0
   873
sl@0
   874
void CMMRCServerSession::IncrementRequestsSent()
sl@0
   875
	{
sl@0
   876
	iRequestsSent++;
sl@0
   877
	};
sl@0
   878
	
sl@0
   879
CMMRCServerSideAdaptationResponseAO* CMMRCServerSession::ServerProxy()
sl@0
   880
	{
sl@0
   881
	return iMMRCServerSideAdaptationResponseAO;
sl@0
   882
	};
sl@0
   883
	
sl@0
   884
TInt CMMRCServerSession::SendRequestToAdaptation(TMMRCServerSessionRequestType aRequestType)
sl@0
   885
	{
sl@0
   886
	TInt err=KErrNone;
sl@0
   887
	if (!IsServerShuttingDown())
sl@0
   888
		{
sl@0
   889
		IncrementRequestsSent();
sl@0
   890
		ServerProxy()->StartAdaptationListening();
sl@0
   891
		AdaptationProxy()->Service(aRequestType);
sl@0
   892
		}
sl@0
   893
	else
sl@0
   894
		{
sl@0
   895
// send some server shutting down error code.		
sl@0
   896
		}
sl@0
   897
	return err;
sl@0
   898
	};	
sl@0
   899
sl@0
   900
TInt CMMRCServerSession::GetPriority() const
sl@0
   901
	{
sl@0
   902
	DP_CONTEXT(----> CMMRCServerSession::GetPriority *CD1*, CtxDevSound, DPLOCAL);
sl@0
   903
	DP_IN();
sl@0
   904
	TInt priority = 0;
sl@0
   905
	if(LogicalChainLastCommited() != NULL)
sl@0
   906
		{
sl@0
   907
		priority = const_cast<MLogicalChain*>( LogicalChainLastCommited() )->Priority();
sl@0
   908
		}
sl@0
   909
	DP0_RET(priority, "priority = %d");
sl@0
   910
	}
sl@0
   911
sl@0
   912
void CMMRCServerSession::Panic(TMMRCServerSessionPanicCodes aCode)
sl@0
   913
	{
sl@0
   914
	User::Panic(KMMRCServerSessionPanicCategory, aCode);
sl@0
   915
	}
sl@0
   916
sl@0
   917
/**
sl@0
   918
 * @ return Boolean value specifying whether Client has UserEnvironment Capability.
sl@0
   919
 */
sl@0
   920
TBool CMMRCServerSession::HasUserEnvironmentCapability()
sl@0
   921
	{
sl@0
   922
	return iClientHasUECapability;
sl@0
   923
	}
sl@0
   924
sl@0
   925
/**
sl@0
   926
 * @ param Error Value to send
sl@0
   927
 * @ return Error Value specifying any error in adding the message to the message queue.
sl@0
   928
 */
sl@0
   929
sl@0
   930
TInt CMMRCServerSession::NotifyClientOfError(TInt aError)
sl@0
   931
	{
sl@0
   932
	// Create message and send to Client
sl@0
   933
	TMMRCQueueItem messageItem;
sl@0
   934
 	messageItem.iRequestType = EMMRCRequestCommitUpdate;
sl@0
   935
	messageItem.iResult = EMMRCServerToClientCommitUpdate;
sl@0
   936
	messageItem.iErrorCode = KErrNone;
sl@0
   937
 	TInt errSend = iMsgQueue.Send(messageItem);
sl@0
   938
	
sl@0
   939
	// Create a message with the Error and send to Client
sl@0
   940
 	messageItem.iRequestType = EMMRCRequestCommitResponse;
sl@0
   941
	messageItem.iResult = EMMRCServerToClientResourceAgreed;
sl@0
   942
 	messageItem.iErrorCode = aError;
sl@0
   943
 	TInt errSend2 = iMsgQueue.Send(messageItem);
sl@0
   944
 	if (errSend!=KErrNone)
sl@0
   945
 		{
sl@0
   946
 		return errSend;
sl@0
   947
 		}
sl@0
   948
 	else
sl@0
   949
 		{
sl@0
   950
 		return errSend2;
sl@0
   951
 		}
sl@0
   952
	}
sl@0
   953
//EOF