TBool CMidiCustomCommandParser::DoSetPlaybackRateL(TMMFMessage& aMessage)
	{
	TPckgBuf<TMMFMidiConfig3> pckg;
	aMessage.ReadData1FromClientL(pckg);
	iImplementor.MmcSetPlaybackRateL(pckg().iPlayBackRate);
	return ETrue;
	}
TBool CMidiCustomCommandParser::DoNoteOffL(TMMFMessage& aMessage)
	{
	TPckgBuf<TMMFMidiConfig2> pckg;
	aMessage.ReadData1FromClientL(pckg);
	iImplementor.MmcNoteOffL(pckg().iChannel, pckg().iNote, pckg().iNoteOffVelocity);
	return ETrue;
	}
TBool CMidiCustomCommandParser::DoUnloadCustomInstrumentL(TMMFMessage& aMessage)
	{
	TPckgBuf<TMMFMidiConfig2> pckg;
	aMessage.ReadData1FromClientL(pckg);
	iImplementor.MmcUnloadCustomInstrumentL(pckg().iBankId, pckg().iInstrumentId);
	return ETrue;
	}
// ---------------------------------------------------------
// CIlbcEncoderIntfcMsgHdlr::DoSetVadModeL
// Handles the message from the proxy and calls the custom interface method.
// The data passed from the proxy is read from the message and passed to
// the custom interface.
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CIlbcEncoderIntfcMsgHdlr::DoSetVadModeL(TMMFMessage& aMessage)
	{
	TPckgBuf<TBool> pckgBuf;
	aMessage.ReadData1FromClientL(pckgBuf);
	TInt status = iIlbcEncoderIntfcCI->SetVadMode(pckgBuf());
    aMessage.Complete(status);
	}
TBool CMidiCustomCommandParser::DoSetRepeatsL(TMMFMessage& aMessage)
	{
	TPckgBuf<TMMFMidiConfig3> pckg;
	aMessage.ReadData1FromClientL(pckg);
	iImplementor.MmcSetRepeatsL(pckg().iRepeatNumberOfTimes, pckg().iTrailingSilence);
	return ETrue;
	}
TBool CMidiCustomCommandParser::DoStopL(TMMFMessage& aMessage)
	{
	TPckgBuf<TMMFMidiConfig1> pckg;
	aMessage.ReadData1FromClientL(pckg);
	iImplementor.MmcStopL(pckg().iFadeOutDuration);
	return ETrue;
	}
TBool CMidiCustomCommandParser::DoSetBankL(TMMFMessage& aMessage)
	{
	TPckgBuf<TMMFMidiConfig2> pckg;
	aMessage.ReadData1FromClientL(pckg);
	iImplementor.MmcSetBankL(pckg().iCustom);
	return ETrue;
	}
TBool CMidiCustomCommandParser::DoSetSyncUpdateCallbackIntervalL(TMMFMessage& aMessage)
	{
	TPckgBuf<TMMFMidiConfig3> pckg;
	aMessage.ReadData1FromClientL(pckg);
	iImplementor.MmcSetSyncUpdateCallbackIntervalL(pckg().iCallbackIntervalMicroSeconds, pckg().iCallbackIntervalMicroBeats);
	return ETrue;
	}
TBool CMidiCustomCommandParser::DoSetMaxPolyphonyL(TMMFMessage& aMessage)
	{
	TPckgBuf<TMMFMidiConfig1> pckg;
	aMessage.ReadData1FromClientL(pckg);
	iImplementor.MmcSetMaxPolyphonyL(pckg().iMaxNotes);
	return ETrue;
	}
TBool CMidiCustomCommandParser::DoPlayNoteWithStartTimeL(TMMFMessage& aMessage)
	{
	TPckgBuf<TMMFMidiConfig2> pckg;
	aMessage.ReadData1FromClientL(pckg);
	iImplementor.MmcPlayNoteL(pckg().iChannel, pckg().iNote, pckg().iStartTime, pckg().iDurationMicroSeconds, pckg().iNoteOnVelocity, pckg().iNoteOffVelocity);
	return ETrue;
	}
TBool CMidiCustomCommandParser::DoPercussionKeyNameL(TMMFMessage& aMessage)
	{
	TPckgBuf<TMMFMidiConfig2> pckg;
	aMessage.ReadData1FromClientL(pckg);

	// Prevent memory leaks by deleting old key name - something must have gone wrong in the client
	// if it already exists
	delete iPercussionKeyName;
	iPercussionKeyName = NULL;

	const TDesC& percussionKeyName = iImplementor.MmcPercussionKeyNameL(pckg().iNote, pckg().iBankId, pckg().iCustom, pckg().iInstrumentId);

	iPercussionKeyName = CBufFlat::NewL(32);
	RBufWriteStream stream;
	stream.Open(*iPercussionKeyName);
	CleanupClosePushL(stream);
	stream << percussionKeyName;
	CleanupStack::PopAndDestroy();//s

	// Write the size of the descriptor back to the client
	TPckgBuf<TInt> descriptorSizePckg(iPercussionKeyName->Ptr(0).Length());	
	aMessage.WriteDataToClientL(descriptorSizePckg);	
	
	return ETrue;
	}
// ---------------------------------------------------------
// CErrorConcealmentIntfcMsgHdlr::DoSetFrameModeL
// Handles the message from the proxy and calls the custom interface method.
// The data passed from the proxy is read from the message and passed to
// the custom interface.
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CErrorConcealmentIntfcMsgHdlr::DoSetFrameModeL(TMMFMessage& aMessage)
    {
	TPckgBuf<TBool> pckg;
	aMessage.ReadData1FromClientL(pckg);
	TInt status = iErrorConcealmentIntfcCI->SetFrameMode(pckg());
    aMessage.Complete(status);
    }
// ---------------------------------------------------------
// CAacDecoderConfigMsgHdlr::DoSetAudioConfigL
// Handles the message from the proxy and calls the custom interface method.
// (other items were commented in a header).
// ---------------------------------------------------------
//
void CAacDecoderConfigMsgHdlr::DoSetAudioConfigL(TMMFMessage& aMessage)
    {
	TPckgBuf<TAudioConfig> pckg;
	aMessage.ReadData1FromClientL(pckg);
	TInt status = iAacDecoderConfigCI->SetAudioConfig(pckg());
    aMessage.Complete(status);
    }
TBool CMidiCustomCommandParser::DoIsChannelMuteL(TMMFMessage& aMessage)
	{
	TPckgBuf<TMMFMidiConfig2> pckg;
	aMessage.ReadData1FromClientL(pckg);
	TBool mute;
	iImplementor.MmcIsChannelMuteL(pckg().iChannel, mute);
	pckg().iMuted = mute;
	aMessage.WriteDataToClientL(pckg);
	return ETrue;
	}
TBool CMidiCustomCommandParser::DoGetInstrumentIdL(TMMFMessage& aMessage)
	{
	TPckgBuf<TMMFMidiConfig2> pckg;
	aMessage.ReadData1FromClientL(pckg);
	TInt instrumentId;
	iImplementor.MmcGetInstrumentIdL(pckg().iBankId, pckg().iCustom, pckg().iInstrumentIndex, instrumentId);
	pckg().iInstrumentId = instrumentId;
	aMessage.WriteDataToClientL(pckg);
	return ETrue;
	}
TBool CMidiCustomCommandParser::DoNumberOfInstrumentsL(TMMFMessage& aMessage)
	{
	TPckgBuf<TMMFMidiConfig2> pckg;
	aMessage.ReadData1FromClientL(pckg);
	TInt numInstruments;
	iImplementor.MmcNumberOfInstrumentsL(pckg().iBankId, pckg().iCustom, numInstruments);	
	pckg().iNumInstruments = numInstruments;
	aMessage.WriteDataToClientL(pckg);
	return ETrue;
	}
TBool CMidiCustomCommandParser::DoCustomBankLoadedL(TMMFMessage& aMessage)
	{
	TPckgBuf<TMMFMidiConfig2> pckg;
	aMessage.ReadData1FromClientL(pckg);
	TBool bankLoaded;
	iImplementor.MmcCustomBankLoadedL(pckg().iBankId, bankLoaded);
	pckg().iBankLoaded = bankLoaded;
	aMessage.WriteDataToClientL(pckg);
	return ETrue;
	}
TBool CMidiCustomCommandParser::DoLoadCustomBankDataL(TMMFMessage& aMessage)
	{
	TPckgBuf<TMMFMidiConfig2> pckg;
	aMessage.ReadData1FromClientL(pckg);
	TInt bankId;
	iImplementor.MmcLoadCustomBankDataL(*(pckg().iBankData), bankId);
	pckg().iBankId = bankId;
	aMessage.WriteDataToClientL(pckg);
	return ETrue;
	}
TBool CMidiCustomCommandParser::DoSendMessageWithTimeStampL(TMMFMessage& aMessage)
	{
	TPckgBuf<TMMFMidiConfig3> pckg;
	aMessage.ReadData1FromClientL(pckg);
	TInt bytesProcessed;
	iImplementor.MmcSendMessageL(*(pckg().iMidiMessage), pckg().iTimeStamp, bytesProcessed);
	pckg().iBytesProcessed = bytesProcessed;
	aMessage.WriteDataToClientL(pckg);
	return ETrue;
	}
TBool CMidiCustomCommandParser::DoChannelVolumeL(TMMFMessage& aMessage)
	{
	TPckgBuf<TMMFMidiConfig2> pckg;
	aMessage.ReadData1FromClientL(pckg);
	TReal32 channelVol;
	iImplementor.MmcChannelVolumeL(pckg().iChannel, channelVol);
	pckg().iChannelVol = channelVol;
	aMessage.WriteDataToClientL(pckg);
	return ETrue;
	}
TBool CMidiCustomCommandParser::DoSetPitchTranspositionL(TMMFMessage& aMessage)
	{
	TPckgBuf<TMMFMidiConfig1> pckg;
	aMessage.ReadData1FromClientL(pckg);
	TInt centsApplied;
	iImplementor.MmcSetPitchTranspositionL(pckg().iPitch, centsApplied);
	pckg().iPitch = centsApplied;
	aMessage.WriteDataToClientL(pckg);
	return ETrue;
	}
// -----------------------------------------------------------------------------
// CRa8CustomInterfaceMsgHdlr::DoSetInitStringL
// Handles the message from the proxy and calls the custom interface method.
// The data passed from the proxy is read from the message and passed to
// the custom interface.
// (other items were commented in a header).
// -----------------------------------------------------------------------------
//
void CRa8CustomInterfaceMsgHdlr::DoSetInitStringL(TMMFMessage& aMessage)
    {
	TInt size = aMessage.SizeOfData1FromClient();
	HBufC8* dataBuf = HBufC8::NewL(size);
	CleanupStack::PushL( dataBuf );
	TPtr8 dataPtr = dataBuf->Des();
    aMessage.ReadData1FromClientL(dataPtr);
	TInt status = iRa8CustomInterface->SetInitString(dataPtr);
	CleanupStack::Pop(dataBuf);
	delete dataBuf;
    aMessage.Complete(status);
    }
TInt CStreamControlCustomCommandParser::DoEnableEvents(TMMFMessage& aMessage)
    {
    TInt status;
    TPckgBuf<TBool> pckg;
    TRAPD(err, aMessage.ReadData1FromClientL(pckg));
    if(!err)
        {
        status = iImplementor.MscEnableEvents(pckg());
        }
    else
        status = err;        
    
    return status;
    }