sl@0: // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0: // All rights reserved.
sl@0: // This component and the accompanying materials are made available
sl@0: // under the terms of "Eclipse Public License v1.0"
sl@0: // which accompanies this distribution, and is available
sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0: //
sl@0: // Initial Contributors:
sl@0: // Nokia Corporation - initial contribution.
sl@0: //
sl@0: // Contributors:
sl@0: //
sl@0: // Description:
sl@0: // Implementation of Integraton test step classes for A3f DevSound Play test cases.
sl@0: // 
sl@0: //
sl@0: 
sl@0: #include "tsi_a3f_devsound_play.h"
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * RTestStepA3FDevSoundPlayBase - Test step constructor
sl@0:  *
sl@0:  */
sl@0: RTestStepA3FDevSoundPlayBase::RTestStepA3FDevSoundPlayBase(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType)
sl@0: :RAsyncTestStep(),
sl@0:  iMMFDevSound(NULL),
sl@0:  iBuffer(NULL),
sl@0:  iTimer(NULL),
sl@0:  iCallBack(NULL, NULL),
sl@0:  iInputDataType(aInputDataType),
sl@0:  iSectName(aSectName),
sl@0:  iFilename(KNullDesC),
sl@0:  iSampleRate(KNullDesC),
sl@0:  iMonoStereo(KNullDesC),
sl@0:  iPlayState(EStatePlayStart),
sl@0:  iBufferCount(0),
sl@0:  iConfig(EFalse),
sl@0:  iInvalidConfig(EFalse),
sl@0:  iUseFourCC(EFalse)
sl@0: 	{
sl@0: 	// From RTestStep
sl@0: 	iTestStepName = aTestName; // store the name of the test case
sl@0: 
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * RTestStepA3FDevSoundPlayBase - Test step constructor
sl@0:  *
sl@0:  */
sl@0: RTestStepA3FDevSoundPlayBase::RTestStepA3FDevSoundPlayBase(const TDesC& aTestName, const TDesC& aSectName)
sl@0: :RAsyncTestStep(),
sl@0:  iMMFDevSound(NULL),
sl@0:  iBuffer(NULL),
sl@0:  iTimer(NULL),
sl@0:  iCallBack(NULL, NULL),
sl@0:  iInputDataType(KMMFFourCCCodePCM16),
sl@0:  iSectName(aSectName),
sl@0:  iFilename(KNullDesC),
sl@0:  iSampleRate(KNullDesC),
sl@0:  iMonoStereo(KNullDesC),
sl@0:  iPlayState(EStatePlayStart),
sl@0:  iBufferCount(0),
sl@0:  iConfig(EFalse),
sl@0:  iInvalidConfig(EFalse),
sl@0:  iUseFourCC(EFalse)
sl@0: 	{
sl@0: 	// From RTestStep
sl@0: 	iTestStepName = aTestName; // store the name of the test case
sl@0: 
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * RTestStepA3FDevSoundPlayBase - Test step constructor
sl@0:  *
sl@0:  */
sl@0: RTestStepA3FDevSoundPlayBase::RTestStepA3FDevSoundPlayBase(const TDesC& aTestName, const TFourCC& aInputDataType)
sl@0: :RAsyncTestStep(),
sl@0:  iMMFDevSound(NULL),
sl@0:  iBuffer(NULL),
sl@0:  iTimer(NULL),
sl@0:  iCallBack(NULL, NULL),
sl@0:  iInputDataType(aInputDataType),
sl@0:  iSectName(KNullDesC),
sl@0:  iFilename(KNullDesC),
sl@0:  iSampleRate(KNullDesC),
sl@0:  iMonoStereo(KNullDesC),
sl@0:  iPlayState(EStatePlayStart),
sl@0:  iBufferCount(0),
sl@0:  iConfig(EFalse),
sl@0:  iInvalidConfig(EFalse),
sl@0:  iUseFourCC(EFalse)
sl@0: 	{
sl@0: 	// From RTestStep
sl@0: 	iTestStepName = aTestName; // store the name of the test case
sl@0: 
sl@0: 	}
sl@0: 
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * RTestStepA3FDevSoundPlayBase - Test step constructor
sl@0:  *
sl@0:  */
sl@0: RTestStepA3FDevSoundPlayBase::RTestStepA3FDevSoundPlayBase(const TDesC& aTestName)
sl@0: :RAsyncTestStep(),
sl@0:  iMMFDevSound(NULL),
sl@0:  iBuffer(NULL),
sl@0:  iTimer(NULL),
sl@0:  iCallBack(NULL, NULL),
sl@0:  iInputDataType(KMMFFourCCCodePCM16),
sl@0:  iSectName(KNullDesC),
sl@0:  iFilename(KNullDesC),
sl@0:  iSampleRate(KNullDesC),
sl@0:  iMonoStereo(KNullDesC),
sl@0:  iPlayState(EStatePlayStart),
sl@0:  iBufferCount(0),
sl@0:  iConfig(EFalse),
sl@0:  iInvalidConfig(EFalse),
sl@0:  iUseFourCC(EFalse)
sl@0: 	{
sl@0: 	// From RTestStep
sl@0: 	iTestStepName = aTestName; // store the name of the test case
sl@0: 
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * KickoffTestL
sl@0:  * - Starts the test
sl@0:  *
sl@0:  */
sl@0: void RTestStepA3FDevSoundPlayBase::KickoffTestL()
sl@0: 	{
sl@0: 	TInt err = iFs.Connect();
sl@0: 	if (err != KErrNone)
sl@0: 		{
sl@0: 		ERR_PRINTF2(_L("Could not connect to Filesystem. Error = %d"), err);
sl@0: 		StopTest(err);
sl@0: 		}
sl@0: 
sl@0: 	// Get the file name of the audio file to play
sl@0: 	#ifdef __WINS__
sl@0: 		if(!GetStringFromConfig(iSectName, _L("EmuPlayFile"), iFilename))
sl@0: 		{
sl@0: 		TPtrC keyName(_L("EmuPlayFile"));
sl@0: 		ERR_PRINTF3(_L("Error in getting file name from config file in %S section via the %S key field."), &iSectName, &keyName);
sl@0: 		StopTest(KErrPathNotFound);
sl@0: 		return;
sl@0: 		}
sl@0: 
sl@0: 	#elif __MARM__
sl@0: 		if(!GetStringFromConfig(iSectName, _L("HwPlayFile"), iFilename))
sl@0: 		{
sl@0: 		TPtrC keyName(_L("HwPlayFile"));
sl@0: 		ERR_PRINTF3(_L("Error in getting file name from config file in %S section via the %S key field."), &iSectName, &keyName);
sl@0: 		StopTest(KErrPathNotFound);
sl@0: 		return;
sl@0: 		}
sl@0: 	#endif
sl@0: 
sl@0: 	// Check if SetConfig and FourCC are to be used or not
sl@0: 	CheckConfigAndFourCCUsage();
sl@0: 
sl@0: 	INFO_PRINTF2(_L("Section Name is :%S"), &iSectName);
sl@0: 
sl@0: 	// Open using RFile for playback
sl@0: 	err = iFile.Open(iFs, iFilename, EFileRead);
sl@0: 	if (err != KErrNone)
sl@0: 		{
sl@0: 		ERR_PRINTF2(_L("Could not Open the File: Error = %d"), err);
sl@0: 		StopTest(err);
sl@0: 		}
sl@0: 
sl@0: 	// Create instance of CMMFDevSound
sl@0: 	iMMFDevSound = CMMFDevSound::NewL();
sl@0: 
sl@0: 	iTimer = CPeriodic::NewL(CActive::EPriorityHigh);
sl@0: 	iCallBack = TCallBack(TimerCallback, this);
sl@0: 
sl@0: 	DoKickoffTestL();
sl@0: 	Fsm(EEventPlayStart, KErrNone); // call to initialize DevSound
sl@0: 
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * DoKickoffTestL
sl@0:  *
sl@0:  */
sl@0: void RTestStepA3FDevSoundPlayBase::DoKickoffTestL()
sl@0: 	{
sl@0: 	INFO_PRINTF2(_L("File to be played -> %S"), &iFilename);
sl@0: 	DisplayCodecInfo();
sl@0: 
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  * ToneFinished
sl@0:  *
sl@0:  */
sl@0: void RTestStepA3FDevSoundPlayBase::ToneFinished(TInt /*aError*/)
sl@0: 	{
sl@0: 	__ASSERT_ALWAYS(0,Panic(_L("RTestStepA3FDevSoundPlayBase"),EInvalidCallbackCall));
sl@0: 
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * RecordError
sl@0:  *
sl@0:  */
sl@0: void RTestStepA3FDevSoundPlayBase::RecordError(TInt)
sl@0: 	{
sl@0: 	__ASSERT_ALWAYS(0,Panic(_L("RTestStepA3FDevSoundPlayBase"),EInvalidCallbackCall));
sl@0: 
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * BufferToBeEmptied
sl@0:  *
sl@0:  */
sl@0: void RTestStepA3FDevSoundPlayBase::BufferToBeEmptied(CMMFBuffer* /*aBuffer*/)
sl@0: 	{
sl@0: 	__ASSERT_ALWAYS(0,Panic(_L("RTestStepA3FDevSoundPlayBase"),EInvalidCallbackCall));
sl@0: 
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * ConvertError
sl@0:  *
sl@0:  */
sl@0: void RTestStepA3FDevSoundPlayBase::ConvertError(TInt /*aError*/)
sl@0: 	{
sl@0: 	__ASSERT_ALWAYS(0,Panic(_L("RTestStepA3FDevSoundPlayBase"),EInvalidCallbackCall));
sl@0: 
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * DeviceMessage
sl@0:  *
sl@0:  */
sl@0: void RTestStepA3FDevSoundPlayBase::DeviceMessage(TUid /*aMessageType*/, const TDesC8& /*aMsg*/)
sl@0: 	{
sl@0: 	__ASSERT_ALWAYS(0,Panic(_L("RTestStepA3FDevSoundPlayBase"),EInvalidCallbackCall));
sl@0: 
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * TimerCallback
sl@0:  *
sl@0:  */
sl@0: TInt RTestStepA3FDevSoundPlayBase::TimerCallback(TAny* aPtr)
sl@0: 	{
sl@0: 	static_cast<RTestStepA3FDevSoundPlayBase*>(aPtr)->DoTimerCallback();
sl@0: 	return KErrNone;
sl@0: 
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * DoTimerCallback
sl@0:  *
sl@0:  */
sl@0: void RTestStepA3FDevSoundPlayBase::DoTimerCallback()
sl@0: 	{
sl@0: 	// The derived classes may provide the implementation if needed
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * CallStopTest
sl@0:  *
sl@0:  */
sl@0: void RTestStepA3FDevSoundPlayBase::CloseTest()
sl@0: 	{
sl@0: 	if (iMMFDevSound)
sl@0: 		{
sl@0: 		INFO_PRINTF1(_L("Deleting DevSound object..."));
sl@0: 		delete iMMFDevSound;
sl@0: 		iMMFDevSound = NULL;
sl@0: 		}
sl@0: 
sl@0: 	if (iTimer)
sl@0: 		{
sl@0: 		delete iTimer;
sl@0: 		iTimer = NULL;
sl@0: 		}
sl@0: 
sl@0: 	iFile.Close();
sl@0: 	iFs.Close();
sl@0: 
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * InitializeComplete
sl@0:  *
sl@0:  */
sl@0: void RTestStepA3FDevSoundPlayBase::InitializeComplete(TInt aError)
sl@0: 	{
sl@0: 	if (iPlayState == EStatePlayInitializing)
sl@0: 		{
sl@0: 		Fsm(EEventInitCompletePlay,aError);
sl@0: 		}
sl@0: 
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * BufferToBeFilled
sl@0:  *
sl@0:  */
sl@0: void RTestStepA3FDevSoundPlayBase::BufferToBeFilled(CMMFBuffer* aBuffer)
sl@0: 	{
sl@0: 	if (!aBuffer)
sl@0: 		{
sl@0: 		ERR_PRINTF1(_L("BufferToBeFilled callback received a NULL CMMFBuffer!"));
sl@0: 		StopTest(KErrGeneral);
sl@0: 		return;
sl@0: 		}
sl@0: 
sl@0: 	iBuffer = aBuffer;
sl@0: 
sl@0: 	// Call to continue the Play process
sl@0: 	Fsm(EEventBTBF,KErrNone);
sl@0: 
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * PlayError
sl@0:  *
sl@0:  */
sl@0: void RTestStepA3FDevSoundPlayBase::PlayError(TInt aError)
sl@0: 	{
sl@0: 	INFO_PRINTF2(_L("DevSound called PlayError with error = %d"), aError);
sl@0: 	if ((iBuffer->LastBuffer()) && (aError == KErrUnderflow))
sl@0: 		{
sl@0: 		StopTest();
sl@0: 		}
sl@0: 	else
sl@0: 		{
sl@0: 		StopTest(aError, EFail);
sl@0: 		}
sl@0: 
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * Fsm
sl@0:  *	- Executes playing events of DevSound in sequence
sl@0:  *
sl@0:  */
sl@0: void RTestStepA3FDevSoundPlayBase::Fsm(TDevSoundPlayEvents aDevSoundEvent, TInt aError)
sl@0: 	{
sl@0: 	switch (iPlayState)
sl@0: 		{
sl@0: 		case EStatePlayStart:
sl@0: 			{
sl@0: 			__ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RTestStepA3FDevSoundPlayBase"),EFsmIncorrectErrorPassed));
sl@0: 			if (aDevSoundEvent == EEventPlayStart)
sl@0: 				{
sl@0: 				// Initializing DevSound object for playing mode to process audio data via desired FourCC code
sl@0: 				INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL"));
sl@0: 				TInt err;
sl@0: 				if(iUseFourCC)
sl@0: 					{
sl@0: 					TRAP(err, iMMFDevSound->InitializeL(*this, iInputDataType, EMMFStatePlaying));
sl@0: 					}
sl@0: 				else
sl@0: 					{
sl@0: 					TRAP(err, iMMFDevSound->InitializeL(*this, EMMFStatePlaying));
sl@0: 					}
sl@0: 				if (err != KErrNone)
sl@0: 					{
sl@0: 					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
sl@0: 					StopTest(err);
sl@0: 					break;
sl@0: 					}
sl@0: 
sl@0: 
sl@0: 				INFO_PRINTF1(_L("State: EStatePlayInitializing"));
sl@0: 				iPlayState = EStatePlayInitializing;
sl@0: 				}
sl@0: 			else
sl@0: 				{
sl@0: 				ERR_PRINTF2(_L("DevSound EEventPlayStart not received as expected. Received event: %d"), aDevSoundEvent);
sl@0: 				StopTest(aError, EFail);
sl@0: 				}
sl@0: 			break;
sl@0: 			}
sl@0: 
sl@0: 		case EStatePlayInitializing:
sl@0: 			{
sl@0: 			if (aDevSoundEvent == EEventInitCompletePlay && aError == KErrNone)
sl@0: 				{
sl@0: 				if(iConfig)
sl@0: 					{
sl@0: 					// Set Devsound capability settings using CMMFDevSound::SetConfigL
sl@0: 					SetSampleRateAndChannelMode();
sl@0: 					TMMFCapabilities capabilities;
sl@0: 					capabilities.iRate = ConvertDesToTMMFSampleRate(iSampleRate);
sl@0: 					capabilities.iChannels = ConvertDesToTMMFMonoStereo(iMonoStereo);
sl@0: 
sl@0: 					TRAPD(errConfig, iMMFDevSound->SetConfigL(capabilities));
sl@0: 					if (errConfig != KErrNone && !iInvalidConfig)
sl@0: 						{
sl@0: 						ERR_PRINTF2(_L("CMMFDevSound::SetConfigL() left with error = %d"), errConfig);
sl@0: 						StopTest(errConfig);
sl@0: 						return;
sl@0: 						}
sl@0: 					else if (errConfig == KErrArgument && iInvalidConfig)
sl@0: 						{
sl@0: 						ERR_PRINTF2(_L("CMMFDevSound::SetConfigL() left with expected error = %d"), errConfig);
sl@0: 						iInvalidConfig = EFalse;
sl@0: 						StopTest(errConfig, EPass);
sl@0: 						return;
sl@0: 						}
sl@0: 					}
sl@0: 
sl@0: 				// Initialize audio device and starts the playing process
sl@0: 				INFO_PRINTF1(_L("Calling CMMFDevSound::PlayInitL()"));
sl@0: 				TRAPD(errPlay, iMMFDevSound->PlayInitL());
sl@0: 				if (errPlay != KErrNone)
sl@0: 					{
sl@0: 					ERR_PRINTF2(_L("CMMFDevSound::PlayInitL() left with error = %d"), errPlay);
sl@0: 					StopTest(errPlay);
sl@0: 					break;
sl@0: 					}
sl@0: 				INFO_PRINTF1(_L("State: EStatePlaying"));
sl@0: 				iPlayState = EStatePlaying;
sl@0: 				}
sl@0: 			else if (aDevSoundEvent == EEventInitCompletePlay && aError != KErrNone)
sl@0: 				{
sl@0: 				ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError);
sl@0: 				StopTest(aError);
sl@0: 				}
sl@0: 			else
sl@0: 				{
sl@0: 				ERR_PRINTF2(_L("DevSound EEventInitCompletePlay not received as expected. Received event: %d"), aDevSoundEvent);
sl@0: 				StopTest(aError, EFail);
sl@0: 				}
sl@0: 			break;
sl@0: 			}
sl@0: 
sl@0: 		case EStatePlaying:
sl@0: 			{
sl@0: 			__ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RTestStepA3FDevSoundPlayBase"),EFsmIncorrectErrorPassed));
sl@0: 			if (aDevSoundEvent == EEventBTBF)
sl@0: 				{
sl@0: 				// Fill the buffer with audio data and play the data in the buffer
sl@0: 				CMMFDataBuffer* buffer = static_cast <CMMFDataBuffer*> (iBuffer);
sl@0: 				TInt err = iFile.Read(buffer->Data());
sl@0: 				if (err != KErrNone)
sl@0: 					{
sl@0: 					ERR_PRINTF2(_L("ERROR : iFile.Read() failed with %d"), err);
sl@0: 					StopTest(err);
sl@0: 					break;
sl@0: 					}
sl@0: 				if (buffer->Data().Length() != buffer->RequestSize())
sl@0: 					{
sl@0: 					INFO_PRINTF3(_L("Data length copied from file = %d. Expected = %d. Must be EOF."), buffer->Data().Length(), buffer->RequestSize());
sl@0: 					iBuffer->SetLastBuffer(ETrue);
sl@0: 					}
sl@0: 
sl@0: 				// Playing data in the buffer at the current volume
sl@0: 				iMMFDevSound->PlayData();
sl@0: 				iBufferCount++;
sl@0: 				}
sl@0: 			else
sl@0: 				{
sl@0: 				ERR_PRINTF2(_L("DevSound EEventBTBF not received as expected. Received event: %d"), aDevSoundEvent);
sl@0: 				StopTest(aError, EFail);
sl@0: 				}
sl@0: 
sl@0: 			break;
sl@0: 			}
sl@0: 
sl@0: 		default:
sl@0: 			{
sl@0: 			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iPlayState);
sl@0: 			StopTest(KErrGeneral);
sl@0: 			}
sl@0: 		}
sl@0: 
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * DisplayCodecInfo
sl@0:  *
sl@0:  */
sl@0: void RTestStepA3FDevSoundPlayBase::DisplayCodecInfo()
sl@0: 	{
sl@0: 	// Display trace about codec under test
sl@0: 	TUint32 fourCC = iInputDataType.FourCC();
sl@0: 	INFO_PRINTF5(_L("Codec under test -> %c%c%c%c"), fourCC, fourCC>>8, fourCC>>16, fourCC>>24);
sl@0: 
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * ConvertDesToTMMFSampleRate
sl@0:  *
sl@0:  */
sl@0: TUint RTestStepA3FDevSoundPlayBase::ConvertDesToTMMFSampleRate(const TDesC& aSampleRateString)
sl@0: 	{
sl@0: 	TUint rate = 0;
sl@0: 
sl@0: 	STR_SWITCH(aSampleRateString)
sl@0: 
sl@0: 	STR_CASE(_L("EMMFSampleRate8000Hz"))
sl@0: 		{
sl@0: 		rate = EMMFSampleRate8000Hz;
sl@0: 		break;
sl@0: 		}
sl@0: 	STR_CASE(_L("EMMFSampleRate11025Hz"))
sl@0: 		{
sl@0: 		rate = EMMFSampleRate11025Hz;
sl@0: 		break;
sl@0: 		}
sl@0: 	STR_CASE(_L("EMMFSampleRate12000Hz"))
sl@0: 		{
sl@0: 		rate = EMMFSampleRate12000Hz;
sl@0: 		break;
sl@0: 		}
sl@0: 	STR_CASE(_L("EMMFSampleRate16000Hz"))
sl@0: 		{
sl@0: 		rate = EMMFSampleRate16000Hz;
sl@0: 		break;
sl@0: 		}
sl@0: 	STR_CASE(_L("EMMFSampleRate22050Hz"))
sl@0: 		{
sl@0: 		rate = EMMFSampleRate22050Hz;
sl@0: 		break;
sl@0: 		}
sl@0: 	STR_CASE(_L("EMMFSampleRate24000Hz"))
sl@0: 		{
sl@0: 		rate = EMMFSampleRate24000Hz;
sl@0: 		break;
sl@0: 		}
sl@0: 	STR_CASE(_L("EMMFSampleRate32000Hz"))
sl@0: 		{
sl@0: 		rate = EMMFSampleRate32000Hz;
sl@0: 		break;
sl@0: 		}
sl@0: 	STR_CASE(_L("EMMFSampleRate44100Hz"))
sl@0: 		{
sl@0: 		rate = EMMFSampleRate44100Hz;
sl@0: 		break;
sl@0: 		}
sl@0: 	STR_CASE(_L("EMMFSampleRate48000Hz"))
sl@0: 		{
sl@0: 		rate = EMMFSampleRate48000Hz;
sl@0: 		break;
sl@0: 		}
sl@0: 	STR_CASE(_L("EMMFSampleRate64000Hz"))
sl@0: 		{
sl@0: 		rate = EMMFSampleRate64000Hz;
sl@0: 		break;
sl@0: 		}
sl@0: 	STR_CASE(_L("EMMFSampleRate88200Hz"))
sl@0: 		{
sl@0: 		rate = EMMFSampleRate88200Hz;
sl@0: 		break;
sl@0: 		}
sl@0: 	STR_CASE(_L("EMMFSampleRate96000Hz"))
sl@0: 		{
sl@0: 		rate = EMMFSampleRate96000Hz;
sl@0: 		break;
sl@0: 		}
sl@0: 	STR_CASE(_L("InvalidRate"))
sl@0: 		{
sl@0: 		rate = 0x90000000;
sl@0: 		break;
sl@0: 		}
sl@0: 
sl@0: 	DEFAULT_CASE()
sl@0: 		{
sl@0: 		ERR_PRINTF1(_L("Attempt to convert invalid sample rate"));
sl@0: 		StopTest(KErrGeneral);
sl@0: 		}
sl@0: 
sl@0: 	STR_SWITCH_END()
sl@0: 
sl@0: 	INFO_PRINTF2(_L("Sample Rate = %S"), &iSampleRate);
sl@0: 	return rate;
sl@0: 
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * ConvertDesToTMMFMonoStereo
sl@0:  *
sl@0:  */
sl@0: TUint RTestStepA3FDevSoundPlayBase::ConvertDesToTMMFMonoStereo(const TDesC& aMonoStereoString)
sl@0: 	{
sl@0: 	TUint channelMode = 0;
sl@0: 
sl@0: 	STR_SWITCH(aMonoStereoString)
sl@0: 
sl@0: 	STR_CASE(_L("EMMFMono"))
sl@0: 		{
sl@0: 		channelMode = EMMFMono;
sl@0: 		break;
sl@0: 		}
sl@0: 	STR_CASE(_L("EMMFStereo"))
sl@0: 		{
sl@0: 		channelMode = EMMFStereo;
sl@0: 		break;
sl@0: 		}
sl@0: 	STR_CASE(_L("InvalidMode"))
sl@0: 		{
sl@0: 		channelMode = 0x90000000;
sl@0: 		break;
sl@0: 		}
sl@0: 	DEFAULT_CASE()
sl@0: 		{
sl@0: 		ERR_PRINTF1(_L("Attempt to convert invalid channel mode"));
sl@0: 		StopTest(KErrGeneral);
sl@0: 		}
sl@0: 
sl@0: 	STR_SWITCH_END()
sl@0: 
sl@0: 	INFO_PRINTF2(_L("Channel = %S"), &iMonoStereo);
sl@0: 	return channelMode;
sl@0: 
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * SetSampleRateAndChannelMode
sl@0:  *
sl@0:  */
sl@0: void RTestStepA3FDevSoundPlayBase::SetSampleRateAndChannelMode()
sl@0: 	{
sl@0: 	if(!GetStringFromConfig(iSectName, _L("SampleRate"), iSampleRate))
sl@0: 		{
sl@0: 		TPtrC keyName(_L("SampleRate"));
sl@0: 		ERR_PRINTF3(_L("Error in getting sample rate from config file in %S section via the %S key field."), &iSectName, &keyName);
sl@0: 		StopTest(KErrPathNotFound);
sl@0: 		return;
sl@0: 		}
sl@0: 
sl@0: 	if(!GetStringFromConfig(iSectName, _L("MonoStereo"), iMonoStereo))
sl@0: 		{
sl@0: 		TPtrC keyName(_L("MonoStereo"));
sl@0: 		ERR_PRINTF3(_L("Error in getting channel mode from config file in %S section via the %S key field."), &iSectName, &keyName);
sl@0: 		StopTest(KErrPathNotFound);
sl@0: 		return;
sl@0: 		}
sl@0: 
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * CheckConfigAndFourCCUsage
sl@0:  *
sl@0:  */
sl@0: void RTestStepA3FDevSoundPlayBase::CheckConfigAndFourCCUsage()
sl@0: 	{
sl@0: 	if(!GetBoolFromConfig(iSectName, _L("SetConfig"), iConfig))
sl@0: 		{
sl@0: 		TPtrC keyName(_L("SetConfig"));
sl@0: 		ERR_PRINTF3(_L("Error in getting SetConfig flag value from config file in %S section via the %S key field."), &iSectName, &keyName);
sl@0: 		StopTest(KErrPathNotFound);
sl@0: 		return;
sl@0: 		}
sl@0: 	if(!GetBoolFromConfig(iSectName, _L("UseFourCC"), iUseFourCC))
sl@0: 		{
sl@0: 		TPtrC keyName(_L("UseFourCC"));
sl@0: 		ERR_PRINTF3(_L("Error in getting UseFourCC flag value from config file in %S section via the %S key field."), &iSectName, &keyName);
sl@0: 		StopTest(KErrPathNotFound);
sl@0: 		return;
sl@0: 		}
sl@0: 
sl@0: 	}
sl@0: 
sl@0: //
sl@0: // RStepA3FDevSoundPlaySimple
sl@0: //
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * RStepA3FDevSoundPlaySimple - Test step constructor
sl@0:  *
sl@0:  */
sl@0: RStepA3FDevSoundPlaySimple::RStepA3FDevSoundPlaySimple(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType)
sl@0: :RTestStepA3FDevSoundPlayBase(aTestName, aSectName, aInputDataType)
sl@0: 	{
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * RStepA3FDevSoundPlaySimple - Test step constructor
sl@0:  *
sl@0:  */
sl@0: RStepA3FDevSoundPlaySimple::RStepA3FDevSoundPlaySimple(const TDesC& aTestName, const TDesC& aSectName)
sl@0: :RTestStepA3FDevSoundPlayBase(aTestName, aSectName)
sl@0: 	{
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * NewL
sl@0:  *
sl@0:  */
sl@0: RStepA3FDevSoundPlaySimple* RStepA3FDevSoundPlaySimple::NewL(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType)
sl@0: 	{
sl@0: 	RStepA3FDevSoundPlaySimple* self = new (ELeave) RStepA3FDevSoundPlaySimple(aTestName, aSectName, aInputDataType);
sl@0: 	return self;
sl@0: 
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * NewL
sl@0:  *
sl@0:  */
sl@0: RStepA3FDevSoundPlaySimple* RStepA3FDevSoundPlaySimple::NewL(const TDesC& aTestName, const TDesC& aSectName)
sl@0: 	{
sl@0: 	RStepA3FDevSoundPlaySimple* self = new (ELeave) RStepA3FDevSoundPlaySimple(aTestName, aSectName);
sl@0: 	return self;
sl@0: 
sl@0: 	}
sl@0: 
sl@0: //
sl@0: // RStepA3FDevSoundPlayEmpty
sl@0: //
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * RStepA3FDevSoundPlayEmpty - Test step constructor
sl@0:  *
sl@0:  */
sl@0: RStepA3FDevSoundPlayEmpty::RStepA3FDevSoundPlayEmpty(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType)
sl@0: :RTestStepA3FDevSoundPlayBase(aTestName, aSectName, aInputDataType)
sl@0: 	{
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * NewL
sl@0:  *
sl@0:  */
sl@0: RStepA3FDevSoundPlayEmpty* RStepA3FDevSoundPlayEmpty::NewL(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType)
sl@0: 	{
sl@0: 	RStepA3FDevSoundPlayEmpty* self = new (ELeave) RStepA3FDevSoundPlayEmpty(aTestName, aSectName, aInputDataType);
sl@0: 	return self;
sl@0: 
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * Fsm
sl@0:  *	- Executes playing events of DevSound in sequence
sl@0:  *
sl@0:  */
sl@0: void RStepA3FDevSoundPlayEmpty::Fsm(TDevSoundPlayEvents aDevSoundEvent, TInt aError)
sl@0: 	{
sl@0: 	switch (iPlayState)
sl@0: 		{
sl@0: 		case EStatePlayStart:
sl@0: 			{
sl@0: 			__ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundPlayEmpty"),EFsmIncorrectErrorPassed));
sl@0: 			if (aDevSoundEvent == EEventPlayStart)
sl@0: 				{
sl@0: 				// Initializing DevSound object for playing mode to process audio data via desired FourCC code
sl@0: 				INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL"));
sl@0: 				TInt err;
sl@0: 				if(iUseFourCC)
sl@0: 					{
sl@0: 					TRAP(err, iMMFDevSound->InitializeL(*this, iInputDataType, EMMFStatePlaying));
sl@0: 					}
sl@0: 				else
sl@0: 					{
sl@0: 					TRAP(err, iMMFDevSound->InitializeL(*this, EMMFStatePlaying));
sl@0: 					}
sl@0: 				if (err != KErrNone)
sl@0: 					{
sl@0: 					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
sl@0: 					StopTest(err);
sl@0: 					break;
sl@0: 					}
sl@0: 				INFO_PRINTF1(_L("State: EStatePlayInitializing"));
sl@0: 				iPlayState = EStatePlayInitializing;
sl@0: 				}
sl@0: 			else
sl@0: 				{
sl@0: 				ERR_PRINTF2(_L("DevSound EEventPlayStart not received as expected. Received event: %d"), aDevSoundEvent);
sl@0: 				StopTest(aError, EFail);
sl@0: 				}
sl@0: 			break;
sl@0: 			}
sl@0: 
sl@0: 		case EStatePlayInitializing:
sl@0: 			{
sl@0: 			if (aDevSoundEvent == EEventInitCompletePlay && aError == KErrNone)
sl@0: 				{
sl@0: 				if(iConfig)
sl@0: 					{
sl@0: 					// Set Devsound capability settings using CMMFDevSound::SetConfigL
sl@0: 					SetSampleRateAndChannelMode();
sl@0: 					TMMFCapabilities capabilities;
sl@0: 					capabilities.iRate = ConvertDesToTMMFSampleRate(iSampleRate);
sl@0: 					capabilities.iChannels = ConvertDesToTMMFMonoStereo(iMonoStereo);
sl@0: 
sl@0: 					TRAPD(errConfig, iMMFDevSound->SetConfigL(capabilities));
sl@0: 					if (errConfig != KErrNone)
sl@0: 						{
sl@0: 						ERR_PRINTF2(_L("CMMFDevSound::SetConfigL() left with error = %d"), errConfig);
sl@0: 						StopTest(errConfig);
sl@0: 						return;
sl@0: 						}
sl@0: 					}
sl@0: 
sl@0: 				// Initialize audio device and starts the playing process
sl@0: 				INFO_PRINTF1(_L("Calling CMMFDevSound::PlayInitL()"));
sl@0: 				TRAPD(errPlay, iMMFDevSound->PlayInitL());
sl@0: 				if (errPlay != KErrNone)
sl@0: 					{
sl@0: 					ERR_PRINTF2(_L("CMMFDevSound::PlayInitL() left with error = %d"), errPlay);
sl@0: 					StopTest(errPlay);
sl@0: 					break;
sl@0: 					}
sl@0: 				INFO_PRINTF1(_L("State: EStatePlaying"));
sl@0: 				iPlayState = EStatePlaying;
sl@0: 				}
sl@0: 			else if (aDevSoundEvent == EEventInitCompletePlay && aError != KErrNone)
sl@0: 				{
sl@0: 				ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError);
sl@0: 				StopTest(aError);
sl@0: 				}
sl@0: 			else
sl@0: 				{
sl@0: 				ERR_PRINTF2(_L("DevSound EEventInitCompletePlay not received as expected. Received event: %d"), aDevSoundEvent);
sl@0: 				StopTest(aError, EFail);
sl@0: 				}
sl@0: 			break;
sl@0: 			}
sl@0: 
sl@0: 		case EStatePlaying:
sl@0: 			{
sl@0: 			__ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundPlayEmpty"),EFsmIncorrectErrorPassed));
sl@0: 			if (aDevSoundEvent == EEventBTBF)
sl@0: 				{
sl@0: 				// Fill the buffer with audio data and play the data in the buffer
sl@0: 				CMMFDataBuffer* buffer = static_cast <CMMFDataBuffer*> (iBuffer);
sl@0: 				TInt err = iFile.Read(buffer->Data());
sl@0: 				if (err != KErrNone)
sl@0: 					{
sl@0: 					ERR_PRINTF2(_L("ERROR : iFile.Read() failed with %d"), err);
sl@0: 					StopTest(err);
sl@0: 					break;
sl@0: 					}
sl@0: 				if (buffer->Data().Length() != buffer->RequestSize())
sl@0: 					{
sl@0: 					iBuffer->SetLastBuffer(ETrue);
sl@0: 					INFO_PRINTF3(_L("Data length copied from file = %d. Expected = %d. Must be EOF."), buffer->Data().Length(), buffer->RequestSize());
sl@0: 					// Playing empty data
sl@0: 					iMMFDevSound->PlayData();
sl@0: 
sl@0: 					}
sl@0: 				iBufferCount++;
sl@0: 				}
sl@0: 			else
sl@0: 				{
sl@0: 				ERR_PRINTF2(_L("DevSound EEventBTBF not received as expected. Received event: %d"), aDevSoundEvent);
sl@0: 				StopTest(aError, EFail);
sl@0: 				}
sl@0: 
sl@0: 			break;
sl@0: 			}
sl@0: 
sl@0: 		default:
sl@0: 			{
sl@0: 			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iPlayState);
sl@0: 			StopTest(KErrGeneral);
sl@0: 			}
sl@0: 		}
sl@0: 
sl@0: 	}
sl@0: 
sl@0: //
sl@0: // RStepA3FDevSoundPlayInvalidFourCC
sl@0: //
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * RStepA3FDevSoundPlayInvalidFourCC - Test step constructor
sl@0:  *
sl@0:  */
sl@0: RStepA3FDevSoundPlayInvalidFourCC::RStepA3FDevSoundPlayInvalidFourCC(const TDesC& aTestName, const TFourCC& aInputDataType)
sl@0: :RTestStepA3FDevSoundPlayBase(aTestName, aInputDataType)
sl@0: 	{
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * NewL
sl@0:  *
sl@0:  */
sl@0: RStepA3FDevSoundPlayInvalidFourCC* RStepA3FDevSoundPlayInvalidFourCC::NewL(const TDesC& aTestName, const TFourCC& aInputDataType)
sl@0: 	{
sl@0: 	RStepA3FDevSoundPlayInvalidFourCC* self = new (ELeave) RStepA3FDevSoundPlayInvalidFourCC(aTestName, aInputDataType);
sl@0: 	return self;
sl@0: 
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * KickoffTestL
sl@0:  * - Starts the test
sl@0:  *
sl@0:  */
sl@0: void RStepA3FDevSoundPlayInvalidFourCC::KickoffTestL()
sl@0: 	{
sl@0: 	// Create instance of CMMFDevSound
sl@0: 	INFO_PRINTF1(_L("--- Creating DevSound object..."));
sl@0: 	iMMFDevSound = CMMFDevSound::NewL();
sl@0: 
sl@0: 	//Display the name of Codec being used
sl@0: 	DisplayCodecInfo();
sl@0: 	Fsm(EEventPlayStart,KErrNone); // call to start the DevSound finite state machine for playing
sl@0: 
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * Fsm
sl@0:  *	- Executes playing events of DevSound in sequence
sl@0:  *
sl@0:  */
sl@0: void RStepA3FDevSoundPlayInvalidFourCC::Fsm(TDevSoundPlayEvents aDevSoundEvent, TInt aError)
sl@0: 	{
sl@0: 	switch (iPlayState)
sl@0: 		{
sl@0: 		case EStatePlayStart:
sl@0: 			{
sl@0: 			__ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundPlayInvalidFourCC"),EFsmIncorrectErrorPassed));
sl@0: 			if (aDevSoundEvent == EEventPlayStart)
sl@0: 				{
sl@0: 				// Initializing DevSound object for playing mode to process audio data via desired FourCC code
sl@0: 				INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL"));
sl@0: 				TInt err;
sl@0: 				TRAP(err, iMMFDevSound->InitializeL(*this, iInputDataType, EMMFStatePlaying));
sl@0: 				if (err == KErrNotSupported)
sl@0: 					{
sl@0: 					INFO_PRINTF2(_L("CMMFDevSound::InitializeL left with expected error = %d"), err);
sl@0: 					StopTest(err, EPass);
sl@0: 					}
sl@0: 				else
sl@0: 					{
sl@0: 					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
sl@0: 					INFO_PRINTF2(_L("Expected error = %d"), KErrNotSupported);
sl@0: 					StopTest(err, EFail);
sl@0: 					}
sl@0: 				}
sl@0: 			else
sl@0: 				{
sl@0: 				ERR_PRINTF2(_L("DevSound EEventPlayStart not received as expected. Received event: %d"), aDevSoundEvent);
sl@0: 				StopTest(aError, EFail);
sl@0: 				}
sl@0: 			break;
sl@0: 			}
sl@0: 		default:
sl@0: 			{
sl@0: 			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iPlayState);
sl@0: 			StopTest(KErrGeneral);
sl@0: 			}
sl@0: 		}
sl@0: 
sl@0: 	}
sl@0: 
sl@0: 
sl@0: 
sl@0: 
sl@0: //
sl@0: // RStepA3FDevSoundInitializeWithHwDeviceUID
sl@0: //
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * RStepA3FDevSoundInitializeWithHwDeviceUID - Test step constructor
sl@0:  *
sl@0:  */
sl@0: RStepA3FDevSoundInitializeWithHwDeviceUID::RStepA3FDevSoundInitializeWithHwDeviceUID(const TDesC& aTestName)
sl@0: :RTestStepA3FDevSoundPlayBase(aTestName)
sl@0: 	{
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * NewL
sl@0:  *
sl@0:  */
sl@0: RStepA3FDevSoundInitializeWithHwDeviceUID* RStepA3FDevSoundInitializeWithHwDeviceUID::NewL(const TDesC& aTestName)
sl@0: 	{
sl@0: 	RStepA3FDevSoundInitializeWithHwDeviceUID* self = new (ELeave) RStepA3FDevSoundInitializeWithHwDeviceUID(aTestName);
sl@0: 	return self;
sl@0: 
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * KickoffTestL
sl@0:  * - Starts the test
sl@0:  *
sl@0:  */
sl@0: void RStepA3FDevSoundInitializeWithHwDeviceUID::KickoffTestL()
sl@0: 	{
sl@0: 	// Create instance of CMMFDevSound
sl@0: 	INFO_PRINTF1(_L("--- Creating DevSound object..."));
sl@0: 	iMMFDevSound = CMMFDevSound::NewL();
sl@0: 
sl@0: 	//Display the name of Codec being used.
sl@0: 	DisplayCodecInfo();
sl@0: 	Fsm(EEventPlayStart,KErrNone); // call to start the DevSound finite state machine for playing
sl@0: 
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * Fsm
sl@0:  *	- Executes playing events of DevSound in sequence
sl@0:  *
sl@0:  */
sl@0: void RStepA3FDevSoundInitializeWithHwDeviceUID::Fsm(TDevSoundPlayEvents aDevSoundEvent, TInt aError)
sl@0: 	{
sl@0: 	switch (iPlayState)
sl@0: 		{
sl@0: 		case EStatePlayStart:
sl@0: 			{
sl@0: 			__ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundInitializeWithHwDeviceUID"),EFsmIncorrectErrorPassed));
sl@0: 			if (aDevSoundEvent == EEventPlayStart)
sl@0: 				{
sl@0: 				// Initializing DevSound object for playing mode to process audio data via HwDeviceUID
sl@0: 				INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL with KMmfUidHwDevicePCM16ToPCM16"));
sl@0: 				TInt err;
sl@0: 				TRAP(err, iMMFDevSound->InitializeL(*this, 0x101F9F00 , EMMFStatePlaying)); //KMmfUidHwDevicePCM16ToPCM16
sl@0: 				if (err == KErrNotSupported)
sl@0: 					{
sl@0: 					INFO_PRINTF2(_L("CMMFDevSound::InitializeL left with expected error = %d"), err);
sl@0: 					StopTest(err, EPass);
sl@0: 					}
sl@0: 				else
sl@0: 					{
sl@0: 					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
sl@0: 					INFO_PRINTF2(_L("Expected error = %d"), KErrNotSupported);
sl@0: 					StopTest(err, EFail);
sl@0: 					}
sl@0: 				}
sl@0: 			else
sl@0: 				{
sl@0: 				ERR_PRINTF2(_L("DevSound EEventPlayStart not received as expected. Received event: %d"), aDevSoundEvent);
sl@0: 				StopTest(aError, EFail);
sl@0: 				}
sl@0: 			break;
sl@0: 			}
sl@0: 		default:
sl@0: 			{
sl@0: 			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iPlayState);
sl@0: 			StopTest(KErrGeneral);
sl@0: 			}
sl@0: 		}
sl@0: 
sl@0: 	}
sl@0: 
sl@0: //
sl@0: // RStepA3FDevSoundPlayInvalidConfig
sl@0: //
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * RStepA3FDevSoundPlayInvalidConfig - Test step constructor
sl@0:  *
sl@0:  */
sl@0: RStepA3FDevSoundPlayInvalidConfig::RStepA3FDevSoundPlayInvalidConfig(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType)
sl@0: :RTestStepA3FDevSoundPlayBase(aTestName, aSectName, aInputDataType)
sl@0: 	{
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * NewL
sl@0:  *
sl@0:  */
sl@0: RStepA3FDevSoundPlayInvalidConfig* RStepA3FDevSoundPlayInvalidConfig::NewL(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType)
sl@0: 	{
sl@0: 	RStepA3FDevSoundPlayInvalidConfig* self = new (ELeave) RStepA3FDevSoundPlayInvalidConfig(aTestName, aSectName, aInputDataType);
sl@0: 	return self;
sl@0: 
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * KickoffTestL
sl@0:  * - Starts the test
sl@0:  *
sl@0:  */
sl@0: void RStepA3FDevSoundPlayInvalidConfig::KickoffTestL()
sl@0: 	{
sl@0: 	// Create instance of CMMFDevSound
sl@0: 	INFO_PRINTF1(_L("--- Creating DevSound object..."));
sl@0: 	iMMFDevSound = CMMFDevSound::NewL();
sl@0: 	
sl@0: 	iInvalidConfig = ETrue;
sl@0: 	//Display the name of Codec being used
sl@0: 	DisplayCodecInfo();
sl@0: 	CheckConfigAndFourCCUsage();
sl@0: 	Fsm(EEventPlayStart,KErrNone); // call to start the DevSound finite state machine for playing
sl@0: 
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * PlayError
sl@0:  *
sl@0:  */
sl@0: void RStepA3FDevSoundPlayInvalidConfig::PlayError(TInt aError)
sl@0: 	{
sl@0: 	if ((iPlayState == EStatePlaying) && (aError == KErrArgument))
sl@0: 		{
sl@0: 		INFO_PRINTF2(_L("DevSound called PlayError with expected error = %d"), aError);
sl@0: 		StopTest(aError, EPass);
sl@0: 		}
sl@0: 	else
sl@0: 		{
sl@0: 		INFO_PRINTF1(_L("Expected error = -6"));
sl@0: 		ERR_PRINTF2(_L("DevSound called PlayError with error = %d"), aError);
sl@0: 		StopTest(aError, EFail);
sl@0: 		}
sl@0: 
sl@0: 	}
sl@0: 
sl@0: //
sl@0: // RStepA3FDevSoundReadConfigDuringPlay
sl@0: //
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * RStepA3FDevSoundReadConfigDuringPlay - Test step constructor
sl@0:  *
sl@0:  */
sl@0: RStepA3FDevSoundReadConfigDuringPlay::RStepA3FDevSoundReadConfigDuringPlay(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType)
sl@0: :RTestStepA3FDevSoundPlayBase(aTestName, aSectName, aInputDataType)
sl@0: 	{
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * NewL
sl@0:  *
sl@0:  */
sl@0: RStepA3FDevSoundReadConfigDuringPlay* RStepA3FDevSoundReadConfigDuringPlay::NewL(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType)
sl@0: 	{
sl@0: 	RStepA3FDevSoundReadConfigDuringPlay* self = new (ELeave) RStepA3FDevSoundReadConfigDuringPlay(aTestName, aSectName, aInputDataType);
sl@0: 	return self;
sl@0: 
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * PlayError
sl@0:  *
sl@0:  */
sl@0: void RStepA3FDevSoundReadConfigDuringPlay::BufferToBeFilled(CMMFBuffer* aBuffer)
sl@0: 	{
sl@0: 	if (!aBuffer)
sl@0: 		{
sl@0: 		ERR_PRINTF1(_L("BufferToBeFilled callback received a NULL CMMFBuffer!"));
sl@0: 		StopTest(KErrGeneral);
sl@0: 		return;
sl@0: 		}
sl@0: 
sl@0: 	iBuffer = aBuffer;
sl@0: 
sl@0: 	if (iPlayState == EStatePlaying)
sl@0: 		{
sl@0: 		TMMFCapabilities capabilities;
sl@0: 		capabilities = iMMFDevSound->Config();
sl@0: 		INFO_PRINTF1(_L("Config values during Play: "));
sl@0: 		if (capabilities.iRate == ConvertDesToTMMFSampleRate(iSampleRate) && capabilities.iChannels == ConvertDesToTMMFMonoStereo(iMonoStereo))
sl@0: 			{
sl@0: 			INFO_PRINTF1(_L("Config values before and during playback are same."));
sl@0: 			StopTest(KErrNone);
sl@0: 			}
sl@0: 		else
sl@0: 			{
sl@0: 			ERR_PRINTF1(_L("Config values before and during playback are different."));
sl@0: 			StopTest(KErrGeneral);
sl@0: 			}
sl@0: 		}
sl@0: 
sl@0: 	}
sl@0: 
sl@0: //
sl@0: // RStepA3FDevSoundSetVolPlayStopGetVol
sl@0: //
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * RStepA3FDevSoundSetVolPlayStopGetVol - Test step constructor
sl@0:  *
sl@0:  */
sl@0: RStepA3FDevSoundSetVolPlayStopGetVol::RStepA3FDevSoundSetVolPlayStopGetVol(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType)
sl@0: :RTestStepA3FDevSoundPlayBase(aTestName, aSectName, aInputDataType),
sl@0:  iSetVolume(0),
sl@0:  iVolDuringStopped(0),
sl@0:  iCheckTimer(ETrue)
sl@0: 	{
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * NewL
sl@0:  *
sl@0:  */
sl@0: RStepA3FDevSoundSetVolPlayStopGetVol* RStepA3FDevSoundSetVolPlayStopGetVol::NewL(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType)
sl@0: 	{
sl@0: 	RStepA3FDevSoundSetVolPlayStopGetVol* self = new (ELeave) RStepA3FDevSoundSetVolPlayStopGetVol(aTestName, aSectName, aInputDataType);
sl@0: 	return self;
sl@0: 
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * DoKickoffTestL
sl@0:  *
sl@0:  */
sl@0: void RStepA3FDevSoundSetVolPlayStopGetVol::DoKickoffTestL()
sl@0: 	{
sl@0: 	INFO_PRINTF2(_L("File to be played -> %S"), &iFilename);
sl@0: 	DisplayCodecInfo();
sl@0: 	CheckConfigAndFourCCUsage();
sl@0: 
sl@0: 	TBool vol = GetIntFromConfig(iSectName,_L("Setvolume"),iSetVolume);
sl@0: 	if (vol)
sl@0: 		{
sl@0: 		INFO_PRINTF2(_L("SetVolume = %d"), iSetVolume );
sl@0: 		}
sl@0: 	else
sl@0: 		{
sl@0: 		TPtrC keyName(_L("Setvolume"));
sl@0: 		ERR_PRINTF3(_L("Error in getting volume to be set from config file in %S section via the %S key field."), &iSectName, &keyName);
sl@0: 		StopTest(KErrPathNotFound);
sl@0: 		return;
sl@0: 		}
sl@0: 
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * Fsm
sl@0:  *	- Executes playing events of DevSound in sequence
sl@0:  *
sl@0:  */
sl@0: void RStepA3FDevSoundSetVolPlayStopGetVol::Fsm(TDevSoundPlayEvents aDevSoundEvent, TInt aError)
sl@0: 	{
sl@0: 	switch (iPlayState)
sl@0: 		{
sl@0: 		case EStatePlayStart:
sl@0: 			{
sl@0: 			__ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundSetVolPlayStopGetVol"),EFsmIncorrectErrorPassed));
sl@0: 			if (aDevSoundEvent == EEventPlayStart)
sl@0: 				{
sl@0: 				// Initializing DevSound object for playing mode to process audio data via desired FourCC code
sl@0: 				INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL"));
sl@0: 				TInt err;
sl@0: 				if(iUseFourCC)
sl@0: 					{
sl@0: 					TRAP(err, iMMFDevSound->InitializeL(*this, iInputDataType, EMMFStatePlaying));
sl@0: 					}
sl@0: 				else
sl@0: 					{
sl@0: 					TRAP(err, iMMFDevSound->InitializeL(*this, EMMFStatePlaying));
sl@0: 					}
sl@0: 				if (err != KErrNone)
sl@0: 					{
sl@0: 					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
sl@0: 					StopTest(err);
sl@0: 					break;
sl@0: 					}
sl@0: 				INFO_PRINTF1(_L("State: EStatePlayInitializing"));
sl@0: 				iPlayState = EStatePlayInitializing;
sl@0: 				}
sl@0: 			else
sl@0: 				{
sl@0: 				ERR_PRINTF2(_L("DevSound EEventPlayStart not received as expected. Received event: %d"), aDevSoundEvent);
sl@0: 				StopTest(aError, EFail);
sl@0: 				}
sl@0: 			break;
sl@0: 			}
sl@0: 
sl@0: 		case EStatePlayInitializing:
sl@0: 			{
sl@0: 			if (aDevSoundEvent == EEventInitCompletePlay && aError == KErrNone)
sl@0: 				{
sl@0: 				if(iConfig)
sl@0: 					{
sl@0: 					// Set Devsound capability settings using CMMFDevSound::SetConfigL
sl@0: 					SetSampleRateAndChannelMode();
sl@0: 					TMMFCapabilities capabilities;
sl@0: 					capabilities.iRate = ConvertDesToTMMFSampleRate(iSampleRate);
sl@0: 					capabilities.iChannels = ConvertDesToTMMFMonoStereo(iMonoStereo);
sl@0: 
sl@0: 					TRAPD(errConfig, iMMFDevSound->SetConfigL(capabilities));
sl@0: 					if (errConfig != KErrNone)
sl@0: 						{
sl@0: 						ERR_PRINTF2(_L("CMMFDevSound::SetConfigL() left with error = %d"), errConfig);
sl@0: 						StopTest(errConfig);
sl@0: 						break;
sl@0: 						}
sl@0: 					}
sl@0: 				// Setting Volume Before Playback
sl@0: 				iMMFDevSound->SetVolume(iSetVolume);
sl@0: 				INFO_PRINTF2(_L("Volume before playback = %d"), iSetVolume);
sl@0: 				// Initialize audio device and starts the playing process
sl@0: 				INFO_PRINTF1(_L("Calling CMMFDevSound::PlayInitL()"));
sl@0: 				TRAPD(errPlay, iMMFDevSound->PlayInitL());
sl@0: 				if (errPlay != KErrNone)
sl@0: 					{
sl@0: 					ERR_PRINTF2(_L("CMMFDevSound::PlayInitL() left with error = %d"), errPlay);
sl@0: 					StopTest(errPlay);
sl@0: 					break;
sl@0: 					}
sl@0: 				INFO_PRINTF1(_L("State: EStatePlaying"));
sl@0: 				iPlayState = EStatePlaying;
sl@0: 				}
sl@0: 			else if (aDevSoundEvent == EEventInitCompletePlay && aError != KErrNone)
sl@0: 				{
sl@0: 				ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError);
sl@0: 				StopTest(aError);
sl@0: 				}
sl@0: 			else
sl@0: 				{
sl@0: 				ERR_PRINTF2(_L("DevSound EEventInitCompletePlay not received as expected. Received event: %d"), aDevSoundEvent);
sl@0: 				StopTest(aError, EFail);
sl@0: 				}
sl@0: 			break;
sl@0: 			}
sl@0: 
sl@0: 		case EStatePlaying:
sl@0: 			{
sl@0: 			__ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundSetVolPlayStopGetVol"),EFsmIncorrectErrorPassed));
sl@0: 			if (aDevSoundEvent == EEventBTBF)
sl@0: 				{
sl@0: 				// Fill the buffer with audio data and play the data in the buffer
sl@0: 				CMMFDataBuffer* buffer = static_cast <CMMFDataBuffer*> (iBuffer);
sl@0: 				TInt err = iFile.Read(buffer->Data());
sl@0: 				if (err != KErrNone)
sl@0: 					{
sl@0: 					ERR_PRINTF2(_L("ERROR : iFile.Read() failed with %d"), err);
sl@0: 					StopTest(err);
sl@0: 					}
sl@0: 				if (buffer->Data().Length() != buffer->RequestSize())
sl@0: 					{
sl@0: 					INFO_PRINTF3(_L("Data length copied from file = %d. Expected = %d. Must be EOF."), buffer->Data().Length(), buffer->RequestSize());
sl@0: 					iBuffer->SetLastBuffer(ETrue);
sl@0: 					}
sl@0: 
sl@0: 				if (iCheckTimer)
sl@0: 					{
sl@0: 					iTimer->Start(KMicroSecsInTenSecs, 0, iCallBack);
sl@0: 					}
sl@0: 				iCheckTimer = EFalse;
sl@0: 				// Playing data in the buffer at the current volume
sl@0: 				iMMFDevSound->PlayData();
sl@0: 				iBufferCount++;
sl@0: 				}
sl@0: 			else if (aDevSoundEvent == EEventPlayTimerComplete)
sl@0: 				{
sl@0: 				iMMFDevSound->Stop();
sl@0: 				iPlayState = EStatePlayStopped;
sl@0: 				INFO_PRINTF1(_L("State: EStatePlayStopped"));
sl@0: 				}
sl@0: 			else
sl@0: 				{
sl@0: 				ERR_PRINTF2(_L("DevSound EEventBTBF not received as expected. Received event: %d"), aDevSoundEvent);
sl@0: 				StopTest(aError, EFail);
sl@0: 				}
sl@0: 			break;
sl@0: 			}
sl@0: 
sl@0: 		case EStatePlayStopped:
sl@0: 			{
sl@0: 			__ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundSetVolPlayStopGetVol"),EFsmIncorrectErrorPassed));
sl@0: 			if (aDevSoundEvent == EEventPlayStopped)
sl@0: 				{
sl@0: 				iVolDuringStopped = iMMFDevSound->Volume();
sl@0: 				INFO_PRINTF2(_L("Volume when play is stopped: %d"), iVolDuringStopped);
sl@0: 				if (iVolDuringStopped == iSetVolume)
sl@0: 					{
sl@0: 					INFO_PRINTF1(_L("Volume set before the playback is same as volume during playback stopped"));
sl@0: 					StopTest(KErrNone);
sl@0: 					}
sl@0: 				else
sl@0: 					{
sl@0: 					ERR_PRINTF1(_L("Volume set before the playback is not the same as volume during playback stopped"));
sl@0: 					StopTest(KErrGeneral);
sl@0: 					}					
sl@0: 				}
sl@0: 			else
sl@0: 				{
sl@0: 				ERR_PRINTF1(_L("EStatePlayStopped event not received in EStatePlayStopped state"));
sl@0: 				StopTest(KErrGeneral);
sl@0: 				break;
sl@0: 				}
sl@0: 			}
sl@0: 			break;
sl@0: 
sl@0: 		default:
sl@0: 			{
sl@0: 			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iPlayState);
sl@0: 			StopTest(KErrGeneral);
sl@0: 			}
sl@0: 		}
sl@0: 
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * DoTimerCallback
sl@0:  *
sl@0:  */
sl@0: void RStepA3FDevSoundSetVolPlayStopGetVol::DoTimerCallback()
sl@0: 	{
sl@0: 	iTimer->Cancel(); // only really wanted a one-shot
sl@0: 	if(!iCheckTimer)
sl@0: 		{
sl@0: 		Fsm(EEventPlayTimerComplete, KErrNone);
sl@0: 		Fsm(EEventPlayStopped, KErrNone);
sl@0: 		}
sl@0: 
sl@0: 	}
sl@0: 
sl@0: //
sl@0: // RStepA3FDevSoundFlushBuffersPaused
sl@0: //
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * RStepA3FDevSoundFlushBuffersPaused - Test step constructor
sl@0:  *
sl@0:  */
sl@0: RStepA3FDevSoundFlushBuffersPaused::RStepA3FDevSoundFlushBuffersPaused(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType)
sl@0: :RTestStepA3FDevSoundPlayBase(aTestName, aSectName, aInputDataType),
sl@0:  iCheckTimer(ETrue)
sl@0: 	{
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * NewL
sl@0:  *
sl@0:  */
sl@0: RStepA3FDevSoundFlushBuffersPaused* RStepA3FDevSoundFlushBuffersPaused::NewL(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType)
sl@0: 	{
sl@0: 	RStepA3FDevSoundFlushBuffersPaused* self = new (ELeave) RStepA3FDevSoundFlushBuffersPaused(aTestName, aSectName, aInputDataType);
sl@0: 	return self;
sl@0: 
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * Fsm
sl@0:  *	- Executes playing events of DevSound in sequence
sl@0:  *
sl@0:  */
sl@0: void RStepA3FDevSoundFlushBuffersPaused::Fsm(TDevSoundPlayEvents aDevSoundEvent, TInt aError)
sl@0: 	{
sl@0: 	switch (iPlayState)
sl@0: 		{
sl@0: 		case EStatePlayStart:
sl@0: 			{
sl@0: 			__ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundFlushBuffersPaused"),EFsmIncorrectErrorPassed));
sl@0: 			if (aDevSoundEvent == EEventPlayStart)
sl@0: 				{
sl@0: 				// Initializing DevSound object for playing mode to process audio data via desired FourCC code
sl@0: 				INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL"));
sl@0: 				TInt err;
sl@0: 				if(iUseFourCC)
sl@0: 					{
sl@0: 					TRAP(err, iMMFDevSound->InitializeL(*this, iInputDataType, EMMFStatePlaying));
sl@0: 					}
sl@0: 				else
sl@0: 					{
sl@0: 					TRAP(err, iMMFDevSound->InitializeL(*this, EMMFStatePlaying));
sl@0: 					}
sl@0: 				if (err != KErrNone)
sl@0: 					{
sl@0: 					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
sl@0: 					StopTest(err);
sl@0: 					break;
sl@0: 					}
sl@0: 				INFO_PRINTF1(_L("State: EStatePlayInitializing"));
sl@0: 				iPlayState = EStatePlayInitializing;
sl@0: 				}
sl@0: 			else
sl@0: 				{
sl@0: 				ERR_PRINTF2(_L("DevSound EEventPlayStart not received as expected. Received event: %d"), aDevSoundEvent);
sl@0: 				StopTest(aError, EFail);
sl@0: 				}
sl@0: 			break;
sl@0: 			}
sl@0: 
sl@0: 		case EStatePlayInitializing:
sl@0: 			{
sl@0: 			if (aDevSoundEvent == EEventInitCompletePlay && aError == KErrNone)
sl@0: 				{
sl@0: 				if(iConfig)
sl@0: 					{
sl@0: 					// Set Devsound capability settings using CMMFDevSound::SetConfigL
sl@0: 					SetSampleRateAndChannelMode();
sl@0: 					TMMFCapabilities capabilities;
sl@0: 					capabilities.iRate = ConvertDesToTMMFSampleRate(iSampleRate);
sl@0: 					capabilities.iChannels = ConvertDesToTMMFMonoStereo(iMonoStereo);
sl@0: 
sl@0: 					TRAPD(errConfig, iMMFDevSound->SetConfigL(capabilities));
sl@0: 					if (errConfig != KErrNone)
sl@0: 						{
sl@0: 						ERR_PRINTF2(_L("CMMFDevSound::SetConfigL() left with error = %d"), errConfig);
sl@0: 						StopTest(errConfig);
sl@0: 						return;
sl@0: 						}
sl@0: 					}
sl@0: 				// Initialize audio device and starts the playing process
sl@0: 				INFO_PRINTF1(_L("Calling CMMFDevSound::PlayInitL()"));
sl@0: 				TRAPD(errPlay, iMMFDevSound->PlayInitL());
sl@0: 				if (errPlay != KErrNone)
sl@0: 					{
sl@0: 					ERR_PRINTF2(_L("CMMFDevSound::PlayInitL() left with error = %d"), errPlay);
sl@0: 					StopTest(errPlay);
sl@0: 					break;
sl@0: 					}
sl@0: 				INFO_PRINTF1(_L("State: EStatePlaying"));
sl@0: 				iPlayState = EStatePlaying;
sl@0: 				}
sl@0: 			else if (aDevSoundEvent == EEventInitCompletePlay && aError != KErrNone)
sl@0: 				{
sl@0: 				ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError);
sl@0: 				StopTest(aError);
sl@0: 				}
sl@0: 			else
sl@0: 				{
sl@0: 				ERR_PRINTF2(_L("DevSound EEventInitCompletePlay not received as expected. Received event: %d"), aDevSoundEvent);
sl@0: 				StopTest(aError, EFail);
sl@0: 				}
sl@0: 			break;
sl@0: 			}
sl@0: 
sl@0: 		case EStatePlaying:
sl@0: 			{
sl@0: 			__ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundFlushBuffersPaused"),EFsmIncorrectErrorPassed));
sl@0: 			if (aDevSoundEvent == EEventBTBF)
sl@0: 				{
sl@0: 				// Fill the buffer with audio data and play the data in the buffer
sl@0: 				CMMFDataBuffer* buffer = static_cast <CMMFDataBuffer*> (iBuffer);
sl@0: 				TInt err = iFile.Read(buffer->Data());
sl@0: 				if (err != KErrNone)
sl@0: 					{
sl@0: 					ERR_PRINTF2(_L("ERROR : iFile.Read() failed with %d"), err);
sl@0: 					StopTest(err);
sl@0: 					break;
sl@0: 					}
sl@0: 				if (buffer->Data().Length() != buffer->RequestSize())
sl@0: 					{
sl@0: 					INFO_PRINTF3(_L("Data length copied from file = %d. Expected = %d. Must be EOF."), buffer->Data().Length(), buffer->RequestSize());
sl@0: 					iBuffer->SetLastBuffer(ETrue);
sl@0: 					}
sl@0: 				if (iCheckTimer)
sl@0: 					{
sl@0: 					iTimer->Start(KMicroSecsInTenSecs, 0, iCallBack);
sl@0: 					}
sl@0: 				// Playing data in the buffer at the current volume
sl@0: 				iMMFDevSound->PlayData();
sl@0: 				iBufferCount++;
sl@0: 				iCheckTimer = EFalse;
sl@0: 				}
sl@0: 			else if (aDevSoundEvent == EEventPlayTimerComplete)
sl@0: 				{
sl@0: 				INFO_PRINTF1(_L("Calling CMMFDevSound::Pause()"));
sl@0: 				iMMFDevSound->Pause();
sl@0: 				iPlayState = EStatePlayPaused;
sl@0: 				INFO_PRINTF1(_L("State: EStatePlayPaused"));
sl@0: 				}
sl@0: 			else
sl@0: 				{
sl@0: 				ERR_PRINTF2(_L("DevSound EEventBTBF not received as expected. Received event: %d"), aDevSoundEvent);
sl@0: 				StopTest(aError, EFail);
sl@0: 				}
sl@0: 
sl@0: 			break;
sl@0: 			}
sl@0: 
sl@0: 		case EStatePlayPaused:
sl@0: 			{
sl@0: 			__ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundFlushBuffersPaused"),EFsmIncorrectErrorPassed));
sl@0: 			TInt err;
sl@0: 			if (aDevSoundEvent == EEventPlayPaused)
sl@0: 				{
sl@0: 				err = iMMFDevSound->EmptyBuffers();
sl@0: 				INFO_PRINTF2(_L("EmptyBuffers in paused state returned with %d"), err);
sl@0: 				INFO_PRINTF2(_L("Expected to return with %d"), KErrNone);
sl@0: 				StopTest(err);
sl@0: 				}
sl@0: 			break;
sl@0: 			}
sl@0: 
sl@0: 		default:
sl@0: 			{
sl@0: 			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iPlayState);
sl@0: 			StopTest(KErrGeneral);
sl@0: 			}
sl@0: 		}
sl@0: 
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * BufferToBeFilled
sl@0:  *
sl@0:  */
sl@0: void RStepA3FDevSoundFlushBuffersPaused::BufferToBeFilled(CMMFBuffer* aBuffer)
sl@0: 	{
sl@0: 	if (!aBuffer)
sl@0: 		{
sl@0: 		ERR_PRINTF1(_L("BufferToBeFilled callback received a NULL CMMFBuffer!"));
sl@0: 		StopTest(KErrGeneral);
sl@0: 		return;
sl@0: 		}
sl@0: 
sl@0: 	iBuffer = aBuffer;
sl@0: 
sl@0: 	if(iPlayState != EStatePlayPaused)
sl@0: 		{
sl@0: 		Fsm(EEventBTBF, KErrNone);
sl@0: 		}
sl@0: 
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * DoTimerCallback
sl@0:  *
sl@0:  */
sl@0: void RStepA3FDevSoundFlushBuffersPaused::DoTimerCallback()
sl@0: 	{
sl@0: 	iTimer->Cancel(); // only really wanted a one-shot
sl@0: 	if(!iCheckTimer)
sl@0: 		{
sl@0: 		Fsm(EEventPlayTimerComplete, KErrNone);
sl@0: 		Fsm(EEventPlayPaused, KErrNone);
sl@0: 		}
sl@0: 	else
sl@0: 		{
sl@0: 		StopTest(KErrGeneral);
sl@0: 		}
sl@0: 
sl@0: 	}
sl@0: 
sl@0: //
sl@0: // RStepA3FDevSoundInvalidStatePlay
sl@0: //
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * RStepA3FDevSoundInvalidStatePlay - Test step constructor
sl@0:  *
sl@0:  */
sl@0: RStepA3FDevSoundInvalidStatePlay::RStepA3FDevSoundInvalidStatePlay(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType)
sl@0: :RTestStepA3FDevSoundPlayBase(aTestName, aSectName, aInputDataType)
sl@0: 	{
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * NewL
sl@0:  *
sl@0:  */
sl@0: RStepA3FDevSoundInvalidStatePlay* RStepA3FDevSoundInvalidStatePlay::NewL(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType)
sl@0: 	{
sl@0: 	RStepA3FDevSoundInvalidStatePlay* self = new (ELeave) RStepA3FDevSoundInvalidStatePlay(aTestName, aSectName, aInputDataType);
sl@0: 	return self;
sl@0: 
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * KickoffTestL
sl@0:  * - Starts the test
sl@0:  *
sl@0:  */
sl@0: void RStepA3FDevSoundInvalidStatePlay::KickoffTestL()
sl@0: 	{
sl@0: 	// Create instance of CMMFDevSound
sl@0: 	INFO_PRINTF1(_L("--- Creating DevSound object..."));
sl@0: 	iMMFDevSound = CMMFDevSound::NewL();
sl@0: 
sl@0: 	//Display the name of Codec being used
sl@0: 	DisplayCodecInfo();
sl@0: 	if(!GetBoolFromConfig(iSectName, _L("UseFourCC"), iUseFourCC))
sl@0: 		{
sl@0: 		TPtrC keyName(_L("UseFourCC"));
sl@0: 		ERR_PRINTF3(_L("Error in getting UseFourCC flag value from config file in %S section via the %S key field."), &iSectName, &keyName);
sl@0: 		StopTest(KErrPathNotFound);
sl@0: 		return;
sl@0: 		}
sl@0: 
sl@0: 	Fsm(EEventPlayStart,KErrNone); // call to start the DevSound finite state machine for playing
sl@0: 
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * Fsm
sl@0:  *	- Executes playing events of DevSound in sequence
sl@0:  *
sl@0:  */
sl@0: void RStepA3FDevSoundInvalidStatePlay::Fsm(TDevSoundPlayEvents aDevSoundEvent, TInt aError)
sl@0: 	{
sl@0: 	switch (iPlayState)
sl@0: 		{
sl@0: 		case EStatePlayStart:
sl@0: 			{
sl@0: 			__ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundInvalidStatePlay"),EFsmIncorrectErrorPassed));
sl@0: 			if (aDevSoundEvent == EEventPlayStart)
sl@0: 				{
sl@0: 				// Initializing DevSound object for playing mode to process audio data via desired FourCC code
sl@0: 				INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL"));
sl@0: 				TInt err;
sl@0: 				INFO_PRINTF1(_L("Initializing DevSound in EMMFStateRecording"));
sl@0: 				if(iUseFourCC)
sl@0: 					{
sl@0: 					TRAP(err, iMMFDevSound->InitializeL(*this, iInputDataType, EMMFStateRecording));
sl@0: 					}
sl@0: 				else
sl@0: 					{
sl@0: 					TRAP(err, iMMFDevSound->InitializeL(*this, EMMFStateRecording));
sl@0: 					}
sl@0: 				if (err != KErrNone)
sl@0: 					{
sl@0: 					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
sl@0: 					StopTest(err, EFail);
sl@0: 					break;
sl@0: 					}
sl@0: 				INFO_PRINTF1(_L("State: EStatePlayInitializing"));
sl@0: 				iPlayState = EStatePlayInitializing;
sl@0: 				}
sl@0: 			else
sl@0: 				{
sl@0: 				ERR_PRINTF2(_L("DevSound EEventPlayStart not received as expected. Received event: %d"), aDevSoundEvent);
sl@0: 				StopTest(aError, EFail);
sl@0: 				}
sl@0: 			break;
sl@0: 			}
sl@0: 
sl@0: 		case EStatePlayInitializing:
sl@0: 			{
sl@0: 			if (aDevSoundEvent == EEventInitCompletePlay && aError == KErrNone)
sl@0: 				{
sl@0: 				// Initialize audio device and start the playing process
sl@0: 				// Calling CMMFDevSound::PlayInitL() when DevSound initialized for record mode!
sl@0: 				INFO_PRINTF1(_L("Calling CMMFDevSound::PlayInitL()"));
sl@0: 				TRAPD(errPlay, iMMFDevSound->PlayInitL());
sl@0: 				if (errPlay == KErrNotReady)
sl@0: 					{
sl@0: 					ERR_PRINTF2(_L("CMMFDevSound::PlayInitL() left as expected with error = %d"), errPlay);
sl@0: 					StopTest(errPlay,EPass);
sl@0: 					}
sl@0: 				else
sl@0: 					{
sl@0: 					ERR_PRINTF2(_L("CMMFDevSound::PlayInitL did NOT leave with KErrNotReady as expected. Error = %d"), errPlay);
sl@0: 					StopTest(KErrUnknown);
sl@0: 					}
sl@0: 				}
sl@0: 			else if (aDevSoundEvent == EEventInitCompletePlay && aError != KErrNone)
sl@0: 				{
sl@0: 				ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError);
sl@0: 				StopTest(aError);
sl@0: 				}
sl@0: 			else
sl@0: 				{
sl@0: 				ERR_PRINTF2(_L("DevSound EEventInitCompletePlay not received as expected. Received event: %d"), aDevSoundEvent);
sl@0: 				StopTest(aError, EFail);
sl@0: 				}
sl@0: 
sl@0: 			break;
sl@0: 
sl@0: 			}
sl@0: 		default:
sl@0: 			{
sl@0: 			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iPlayState);
sl@0: 			StopTest(KErrGeneral);
sl@0: 			}
sl@0: 		}
sl@0: 
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * BufferToBeFilled
sl@0:  *
sl@0:  */
sl@0: void RStepA3FDevSoundInvalidStatePlay::BufferToBeFilled(CMMFBuffer* aBuffer)
sl@0: 	{
sl@0: 	if (!aBuffer)
sl@0: 		{
sl@0: 		ERR_PRINTF1(_L("BufferToBeFilled callback received a NULL CMMFBuffer!"));
sl@0: 		StopTest(KErrGeneral);
sl@0: 		return;
sl@0: 		}
sl@0: 
sl@0: 	iBuffer = aBuffer;
sl@0: 
sl@0: 	// Call to continue the Play process
sl@0: 	Fsm(EEventBTBF,KErrNone);
sl@0: 
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * PlayError
sl@0:  *
sl@0:  */
sl@0: void RStepA3FDevSoundInvalidStatePlay::PlayError(TInt aError)
sl@0: 	{
sl@0: 	if ((iPlayState == EStatePlaying) && (aError == KErrNotSupported))
sl@0: 		{
sl@0: 		INFO_PRINTF2(_L("DevSound called PlayError with expected error = %d"), aError);
sl@0: 		StopTest(aError, EPass);
sl@0: 		}
sl@0: 	else
sl@0: 		{
sl@0: 		INFO_PRINTF1(_L("Expected error = -5"));
sl@0: 		ERR_PRINTF2(_L("DevSound called PlayError with error = %d"), aError);
sl@0: 		StopTest(aError, EFail);
sl@0: 		}
sl@0: 
sl@0: 	}
sl@0: 
sl@0: //
sl@0: // RStepA3FDevSoundFlushBuffersPlaying
sl@0: //
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * RStepA3FDevSoundFlushBuffersPlaying - Test step constructor
sl@0:  *
sl@0:  */
sl@0: RStepA3FDevSoundFlushBuffersPlaying::RStepA3FDevSoundFlushBuffersPlaying(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType)
sl@0: :RTestStepA3FDevSoundPlayBase(aTestName, aSectName, aInputDataType)
sl@0: 	{
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * NewL
sl@0:  *
sl@0:  */
sl@0: RStepA3FDevSoundFlushBuffersPlaying* RStepA3FDevSoundFlushBuffersPlaying::NewL(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType)
sl@0: 	{
sl@0: 	RStepA3FDevSoundFlushBuffersPlaying* self = new (ELeave) RStepA3FDevSoundFlushBuffersPlaying(aTestName, aSectName, aInputDataType);
sl@0: 	return self;
sl@0: 
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * Fsm
sl@0:  *	- Executes playing events of DevSound in sequence
sl@0:  *
sl@0:  */
sl@0: void RStepA3FDevSoundFlushBuffersPlaying::Fsm(TDevSoundPlayEvents aDevSoundEvent, TInt aError)
sl@0: 	{
sl@0: 	switch (iPlayState)
sl@0: 		{
sl@0: 		case EStatePlayStart:
sl@0: 			{
sl@0: 			__ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundFlushBuffersPlaying"),EFsmIncorrectErrorPassed));
sl@0: 			if (aDevSoundEvent == EEventPlayStart)
sl@0: 				{
sl@0: 				// Initializing DevSound object for playing mode to process audio data via desired FourCC code
sl@0: 				INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL"));
sl@0: 				TInt err;
sl@0: 				if(iUseFourCC)
sl@0: 					{
sl@0: 					TRAP(err, iMMFDevSound->InitializeL(*this, iInputDataType, EMMFStatePlaying));
sl@0: 					}
sl@0: 				else
sl@0: 					{
sl@0: 					TRAP(err, iMMFDevSound->InitializeL(*this, EMMFStatePlaying));
sl@0: 					}
sl@0: 				if (err != KErrNone)
sl@0: 					{
sl@0: 					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
sl@0: 					StopTest(err);
sl@0: 					break;
sl@0: 					}
sl@0: 				INFO_PRINTF1(_L("State: EStatePlayInitializing"));
sl@0: 				iPlayState = EStatePlayInitializing;
sl@0: 				}
sl@0: 			else
sl@0: 				{
sl@0: 				ERR_PRINTF2(_L("DevSound EEventPlayStart not received as expected. Received event: %d"), aDevSoundEvent);
sl@0: 				StopTest(aError, EFail);
sl@0: 				}
sl@0: 			break;
sl@0: 			}
sl@0: 
sl@0: 		case EStatePlayInitializing:
sl@0: 			{
sl@0: 			if (aDevSoundEvent == EEventInitCompletePlay && aError == KErrNone)
sl@0: 				{
sl@0: 				if(iConfig)
sl@0: 					{
sl@0: 					// Set Devsound capability settings using CMMFDevSound::SetConfigL
sl@0: 					SetSampleRateAndChannelMode();
sl@0: 					TMMFCapabilities capabilities;
sl@0: 					capabilities.iRate = ConvertDesToTMMFSampleRate(iSampleRate);
sl@0: 					capabilities.iChannels = ConvertDesToTMMFMonoStereo(iMonoStereo);
sl@0: 
sl@0: 					TRAPD(errConfig, iMMFDevSound->SetConfigL(capabilities));
sl@0: 					if (errConfig != KErrNone)
sl@0: 						{
sl@0: 						ERR_PRINTF2(_L("CMMFDevSound::SetConfigL() left with error = %d"), errConfig);
sl@0: 						StopTest(errConfig);
sl@0: 						break;
sl@0: 						}
sl@0: 					}
sl@0: 				// Initialize audio device and starts the playing process
sl@0: 				INFO_PRINTF1(_L("Calling CMMFDevSound::PlayInitL()"));
sl@0: 				TRAPD(errPlay, iMMFDevSound->PlayInitL());
sl@0: 				if (errPlay != KErrNone)
sl@0: 					{
sl@0: 					ERR_PRINTF2(_L("CMMFDevSound::PlayInitL() left with error = %d"), errPlay);
sl@0: 					StopTest(errPlay);
sl@0: 					break;
sl@0: 					}
sl@0: 				INFO_PRINTF1(_L("State: EStatePlaying"));
sl@0: 				iPlayState = EStatePlaying;
sl@0: 				}
sl@0: 			else if (aDevSoundEvent == EEventInitCompletePlay && aError != KErrNone)
sl@0: 				{
sl@0: 				ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError);
sl@0: 				StopTest(aError);
sl@0: 				}
sl@0: 			else
sl@0: 				{
sl@0: 				ERR_PRINTF2(_L("DevSound EEventInitCompletePlay not received as expected. Received event: %d"), aDevSoundEvent);
sl@0: 				StopTest(aError, EFail);
sl@0: 				}
sl@0: 			break;
sl@0: 			}
sl@0: 
sl@0: 		case EStatePlaying:
sl@0: 			{
sl@0: 			__ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundFlushBuffersPlaying"),EFsmIncorrectErrorPassed));
sl@0: 			if (aDevSoundEvent == EEventBTBF)
sl@0: 				{
sl@0: 				// Fill the buffer with audio data and play the data in the buffer
sl@0: 				CMMFDataBuffer* buffer = static_cast <CMMFDataBuffer*> (iBuffer);
sl@0: 				TInt err = iFile.Read(buffer->Data());
sl@0: 				if (err != KErrNone)
sl@0: 					{
sl@0: 					ERR_PRINTF2(_L("ERROR : iFile.Read() failed with %d"), err);
sl@0: 					StopTest(err);
sl@0: 					break;
sl@0: 					}
sl@0: 				if (buffer->Data().Length() != buffer->RequestSize())
sl@0: 					{
sl@0: 					INFO_PRINTF3(_L("Data length copied from file = %d. Expected = %d. Must be EOF."), buffer->Data().Length(), buffer->RequestSize());
sl@0: 					iBuffer->SetLastBuffer(ETrue);
sl@0: 					}
sl@0: 
sl@0: 				INFO_PRINTF1(_L("Calling CMMFDevSound::EmptyBuffers() during playing"));
sl@0: 				err = iMMFDevSound->EmptyBuffers();
sl@0: 				INFO_PRINTF2(_L("CMMFDevSound::EmptyBuffers() left with error = %d"), err);
sl@0: 				if(err == KErrNone)
sl@0: 					{
sl@0: 					StopTest(err, EPass);
sl@0: 					}
sl@0: 				else
sl@0: 					{
sl@0: 					StopTest(err, EFail);
sl@0: 					}
sl@0: 				}
sl@0: 			else
sl@0: 				{
sl@0: 				ERR_PRINTF2(_L("DevSound EEventBTBF not received as expected. Received event: %d"), aDevSoundEvent);
sl@0: 				StopTest(aError, EFail);
sl@0: 				}
sl@0: 			break;
sl@0: 			}
sl@0: 
sl@0: 		default:
sl@0: 			{
sl@0: 			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iPlayState);
sl@0: 			StopTest(KErrGeneral);
sl@0: 			}
sl@0: 		}
sl@0: 
sl@0: 	}
sl@0: 
sl@0: //
sl@0: // RStepA3FDevSoundInitializeWhilePlaying
sl@0: //
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * RStepA3FDevSoundInitializeWhilePlaying - Test step constructor
sl@0:  *
sl@0:  */
sl@0: RStepA3FDevSoundInitializeWhilePlaying::RStepA3FDevSoundInitializeWhilePlaying(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType)
sl@0: :RTestStepA3FDevSoundPlayBase(aTestName, aSectName, aInputDataType),
sl@0:  iCheckTimer(ETrue)
sl@0: 	{
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * NewL
sl@0:  *
sl@0:  */
sl@0: RStepA3FDevSoundInitializeWhilePlaying* RStepA3FDevSoundInitializeWhilePlaying::NewL(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType)
sl@0: 	{
sl@0: 	RStepA3FDevSoundInitializeWhilePlaying* self = new (ELeave) RStepA3FDevSoundInitializeWhilePlaying(aTestName, aSectName, aInputDataType);
sl@0: 	return self;
sl@0: 
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * Fsm
sl@0:  *	- Executes playing events of DevSound in sequence
sl@0:  *
sl@0:  */
sl@0: void RStepA3FDevSoundInitializeWhilePlaying::Fsm(TDevSoundPlayEvents aDevSoundEvent, TInt aError)
sl@0: 	{
sl@0: 	switch (iPlayState)
sl@0: 		{
sl@0: 		case EStatePlayStart:
sl@0: 			{
sl@0: 			__ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundInitializeWhilePlaying"),EFsmIncorrectErrorPassed));
sl@0: 			if (aDevSoundEvent == EEventPlayStart)
sl@0: 				{
sl@0: 				// Initializing DevSound object for playing mode to process audio data via desired FourCC code
sl@0: 				INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL"));
sl@0: 				TInt err;
sl@0: 				if(iUseFourCC)
sl@0: 					{
sl@0: 					TRAP(err, iMMFDevSound->InitializeL(*this, iInputDataType, EMMFStatePlaying));
sl@0: 					}
sl@0: 				else
sl@0: 					{
sl@0: 					TRAP(err, iMMFDevSound->InitializeL(*this, EMMFStatePlaying));
sl@0: 					}
sl@0: 				if (err != KErrNone)
sl@0: 					{
sl@0: 					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
sl@0: 					StopTest(err);
sl@0: 					break;
sl@0: 					}
sl@0: 				INFO_PRINTF1(_L("State: EStatePlayInitializing"));
sl@0: 				iPlayState = EStatePlayInitializing;
sl@0: 				}
sl@0: 			else
sl@0: 				{
sl@0: 				ERR_PRINTF2(_L("DevSound EEventPlayStart not received as expected. Received event: %d"), aDevSoundEvent);
sl@0: 				StopTest(aError, EFail);
sl@0: 				}
sl@0: 			break;
sl@0: 			}
sl@0: 
sl@0: 		case EStatePlayInitializing:
sl@0: 			{
sl@0: 			if (aDevSoundEvent == EEventInitCompletePlay && aError == KErrNone)
sl@0: 				{
sl@0: 				if(iConfig)
sl@0: 					{
sl@0: 					// Set Devsound capability settings using CMMFDevSound::SetConfigL
sl@0: 					SetSampleRateAndChannelMode();
sl@0: 					TMMFCapabilities capabilities;
sl@0: 					capabilities.iRate = ConvertDesToTMMFSampleRate(iSampleRate);
sl@0: 					capabilities.iChannels = ConvertDesToTMMFMonoStereo(iMonoStereo);
sl@0: 
sl@0: 					TRAPD(errConfig, iMMFDevSound->SetConfigL(capabilities));
sl@0: 					if (errConfig != KErrNone)
sl@0: 						{
sl@0: 						ERR_PRINTF2(_L("CMMFDevSound::SetConfigL() left with error = %d"), errConfig);
sl@0: 						StopTest(errConfig);
sl@0: 						break;
sl@0: 						}
sl@0: 					}
sl@0: 				// Initialize audio device and starts the playing process
sl@0: 				INFO_PRINTF1(_L("Calling CMMFDevSound::PlayInitL()"));
sl@0: 				TRAPD(errPlay, iMMFDevSound->PlayInitL());
sl@0: 				if (errPlay != KErrNone)
sl@0: 					{
sl@0: 					ERR_PRINTF2(_L("CMMFDevSound::PlayInitL() left with error = %d"), errPlay);
sl@0: 					StopTest(errPlay);
sl@0: 					break;
sl@0: 					}
sl@0: 				INFO_PRINTF1(_L("State: EStatePlaying"));
sl@0: 				iPlayState = EStatePlaying;
sl@0: 				}
sl@0: 			else if (aDevSoundEvent == EEventInitCompletePlay && aError != KErrNone)
sl@0: 				{
sl@0: 				ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError);
sl@0: 				StopTest(aError);
sl@0: 				}
sl@0: 			else
sl@0: 				{
sl@0: 				ERR_PRINTF2(_L("DevSound EEventInitCompletePlay not received as expected. Received event: %d"), aDevSoundEvent);
sl@0: 				StopTest(aError, EFail);
sl@0: 				}
sl@0: 			break;
sl@0: 			}
sl@0: 
sl@0: 		case EStatePlaying:
sl@0: 			{
sl@0: 			__ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundInitializeWhilePlaying"),EFsmIncorrectErrorPassed));
sl@0: 			if (aDevSoundEvent == EEventBTBF)
sl@0: 				{
sl@0: 				// Fill the buffer with audio data and play the data in the buffer
sl@0: 				CMMFDataBuffer* buffer = static_cast <CMMFDataBuffer*> (iBuffer);
sl@0: 				TInt err = iFile.Read(buffer->Data());
sl@0: 				if (err != KErrNone)
sl@0: 					{
sl@0: 					ERR_PRINTF2(_L("ERROR : iFile.Read() failed with %d"), err);
sl@0: 					StopTest(err);
sl@0: 					break;
sl@0: 					}
sl@0: 				if (buffer->Data().Length() != buffer->RequestSize())
sl@0: 					{
sl@0: 					INFO_PRINTF3(_L("Data length copied from file = %d. Expected = %d. Must be EOF."), buffer->Data().Length(), buffer->RequestSize());
sl@0: 					iBuffer->SetLastBuffer(ETrue);
sl@0: 					}
sl@0: 
sl@0: 				if (iCheckTimer)
sl@0: 					{
sl@0: 					iTimer->Start(KMicroSecsInTenSecs, 0, iCallBack);
sl@0: 					}
sl@0: 				iCheckTimer = EFalse;
sl@0: 				}
sl@0: 			else
sl@0: 				{
sl@0: 				ERR_PRINTF2(_L("DevSound EEventBTBF not received as expected. Received event: %d"), aDevSoundEvent);
sl@0: 				StopTest(aError, EFail);
sl@0: 				}
sl@0: 			break;
sl@0: 			}
sl@0: 
sl@0: 		default:
sl@0: 			{
sl@0: 			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iPlayState);
sl@0: 			StopTest(KErrGeneral);
sl@0: 			}
sl@0: 		}
sl@0: 
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * DoTimerCallback
sl@0:  *
sl@0:  */
sl@0: void RStepA3FDevSoundInitializeWhilePlaying::DoTimerCallback()
sl@0: 	{
sl@0: 	iTimer->Cancel(); // only really wanted a one-shot
sl@0: 	if(!iCheckTimer)
sl@0: 		{
sl@0: 		INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL() during playing"));
sl@0: 		TRAPD(errInit, iMMFDevSound->InitializeL(*this, iInputDataType, EMMFStatePlaying));
sl@0: 		INFO_PRINTF2(_L("CMMFDevSound::InitializeL() left with error = %d"), errInit);
sl@0: 		INFO_PRINTF2(_L("Expected error = %d"), KErrNotReady);
sl@0: 		if(errInit == KErrNotReady)
sl@0: 			{
sl@0: 			StopTest(errInit, EPass);
sl@0: 			}
sl@0: 			else
sl@0: 			{
sl@0: 			StopTest(errInit, EFail);
sl@0: 			}
sl@0: 		}
sl@0: 
sl@0: 	}
sl@0: 
sl@0: //
sl@0: // RStepA3FDevSoundSetBalanceDuringPlay
sl@0: //
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * RStepA3FDevSoundSetBalanceDuringPlay - Test step constructor
sl@0:  *
sl@0:  */
sl@0: RStepA3FDevSoundSetBalanceDuringPlay::RStepA3FDevSoundSetBalanceDuringPlay(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType)
sl@0: :RTestStepA3FDevSoundPlayBase(aTestName, aSectName, aInputDataType),
sl@0:  iPlaybalanceLeft(0),
sl@0:  iPlaybalanceRight(0)
sl@0: 	{
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * NewL
sl@0:  *
sl@0:  */
sl@0: RStepA3FDevSoundSetBalanceDuringPlay* RStepA3FDevSoundSetBalanceDuringPlay::NewL(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType)
sl@0: 	{
sl@0: 	RStepA3FDevSoundSetBalanceDuringPlay* self = new (ELeave) RStepA3FDevSoundSetBalanceDuringPlay(aTestName, aSectName, aInputDataType);
sl@0: 	return self;
sl@0: 
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * DoKickoffTestL
sl@0:  *
sl@0:  */
sl@0: void RStepA3FDevSoundSetBalanceDuringPlay::DoKickoffTestL()
sl@0: 	{
sl@0: 	INFO_PRINTF2(_L("File to be played -> %S"), &iFilename);
sl@0: 	DisplayCodecInfo();
sl@0: 	CheckConfigAndFourCCUsage();
sl@0: 
sl@0: 	TBool balance = GetIntFromConfig(iSectName,_L("PlaybalanceLeft"),iPlaybalanceLeft );
sl@0: 	if (balance)
sl@0: 		{
sl@0: 		// Getting the Left balance from Config file
sl@0: 		INFO_PRINTF2(_L("Left Percentage Playbalance = %d"),iPlaybalanceLeft);
sl@0: 		}
sl@0: 	else
sl@0: 		{
sl@0: 		TPtrC keyName(_L("PlaybalanceLeft"));
sl@0: 		ERR_PRINTF3(_L("Error in getting left pc playbalance from config file in %S section via the %S key field."), &iSectName, &keyName);
sl@0: 		StopTest(KErrPathNotFound);
sl@0: 		return;
sl@0: 		}
sl@0: 	balance = GetIntFromConfig(iSectName,_L("PlaybalanceRight"),iPlaybalanceRight );
sl@0: 	if (balance)
sl@0: 		{
sl@0: 		// Getting the Right balance from Config file
sl@0: 		INFO_PRINTF2(_L("Right Percentage Playbalance = %d"),iPlaybalanceRight);
sl@0: 		}
sl@0: 	else
sl@0: 		{
sl@0: 		TPtrC keyName(_L("PlaybalanceRight"));
sl@0: 		ERR_PRINTF3(_L("Error in getting right pc playbalance from config file in %S section via the %S key field."), &iSectName, &keyName);
sl@0: 		StopTest(KErrPathNotFound);
sl@0: 		return;
sl@0: 		}
sl@0: 
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * BufferToBeFilled
sl@0:  *
sl@0:  */
sl@0: void RStepA3FDevSoundSetBalanceDuringPlay::BufferToBeFilled(CMMFBuffer* aBuffer)
sl@0: 	{
sl@0: 	if (!aBuffer)
sl@0: 		{
sl@0: 		ERR_PRINTF1(_L("BufferToBeFilled callback received a NULL CMMFBuffer!"));
sl@0: 		StopTest(KErrGeneral);
sl@0: 		return;
sl@0: 		}
sl@0: 
sl@0: 	iBuffer = aBuffer;
sl@0: 
sl@0: 	INFO_PRINTF3(_L("Setting left and right playbalance. left = %d right = %d"), iPlaybalanceLeft, iPlaybalanceRight );
sl@0: 	TRAPD(setErr, iMMFDevSound->SetPlayBalanceL(iPlaybalanceLeft, iPlaybalanceRight));
sl@0: 	if (setErr == KErrNone)
sl@0: 		{
sl@0: 		TInt getLeft = 0;
sl@0: 		TInt getRight = 0;
sl@0: 		INFO_PRINTF1(_L("Getting left and right playbalance"));
sl@0: 		TRAPD(getErr, iMMFDevSound->GetPlayBalanceL(getLeft, getRight));
sl@0: 		INFO_PRINTF3(_L("Got left and right playbalance. left = %d right = %d"), getLeft, getRight);
sl@0: 		if (getErr == KErrNone)
sl@0: 			{
sl@0: 			if ((getLeft == iPlaybalanceLeft) && (getRight == iPlaybalanceRight ))
sl@0: 				{
sl@0: 				INFO_PRINTF1(_L("Left and Right playbalanace values are same as the ones that were set"));
sl@0: 				StopTest(getErr);
sl@0: 				}
sl@0: 			else
sl@0: 				{
sl@0: 				ERR_PRINTF1(_L("Let and right playbalanace values are not the same as the ones that were set"));
sl@0: 				StopTest(KErrGeneral);
sl@0: 				}
sl@0: 			}
sl@0: 		else
sl@0: 			{
sl@0: 			ERR_PRINTF1(_L("Error in getting left and right play balance."));
sl@0: 			StopTest(getErr);
sl@0: 			}
sl@0: 		}
sl@0: 	else
sl@0: 		{
sl@0: 		ERR_PRINTF1(_L("Error in setting left and right play balance."));
sl@0: 		StopTest(setErr);
sl@0: 		}
sl@0: 
sl@0: 	}
sl@0: 
sl@0: //
sl@0: // RStepA3FDevSoundPlayStopMultipleTimes
sl@0: //
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * RStepA3FDevSoundPlayStopMultipleTimes - Test step constructor
sl@0:  *
sl@0:  */
sl@0: RStepA3FDevSoundPlayStopMultipleTimes::RStepA3FDevSoundPlayStopMultipleTimes(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType)
sl@0: :RTestStepA3FDevSoundPlayBase(aTestName, aSectName, aInputDataType),
sl@0: iRepeatCount(0),
sl@0: iRepeatCounter(0),
sl@0: iCheckTimer(ETrue)
sl@0: 	{
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * NewL
sl@0:  *
sl@0:  */
sl@0: RStepA3FDevSoundPlayStopMultipleTimes* RStepA3FDevSoundPlayStopMultipleTimes::NewL(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType)
sl@0: 	{
sl@0: 	RStepA3FDevSoundPlayStopMultipleTimes* self = new (ELeave) RStepA3FDevSoundPlayStopMultipleTimes(aTestName, aSectName, aInputDataType);
sl@0: 	return self;
sl@0: 
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * DoKickoffTestL
sl@0:  *
sl@0:  */
sl@0: void RStepA3FDevSoundPlayStopMultipleTimes::DoKickoffTestL()
sl@0: 	{
sl@0: 	INFO_PRINTF2(_L("File to be played -> %S"), &iFilename);
sl@0: 	DisplayCodecInfo();
sl@0: 	CheckConfigAndFourCCUsage();
sl@0: 
sl@0: 	TBool repeatCount = GetIntFromConfig(iSectName,_L("Repeat"),iRepeatCount);
sl@0: 	if (repeatCount)
sl@0: 		{
sl@0: 		INFO_PRINTF2(_L("No. of times to Repeat = %d"), iRepeatCount);
sl@0: 		}
sl@0: 	else
sl@0: 		{
sl@0: 		TPtrC keyName(_L("Repeat"));
sl@0: 		ERR_PRINTF3(_L("Error in getting number of times to repeat stop from config file in %S section via the %S key field."), &iSectName, &keyName);
sl@0: 		StopTest(KErrPathNotFound);
sl@0: 		return;
sl@0: 		}
sl@0: 
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * Fsm
sl@0:  *	- Executes playing events of DevSound in sequence
sl@0:  *
sl@0:  */
sl@0: void RStepA3FDevSoundPlayStopMultipleTimes::Fsm(TDevSoundPlayEvents aDevSoundEvent, TInt aError)
sl@0: 	{
sl@0: 	switch (iPlayState)
sl@0: 		{
sl@0: 		case EStatePlayStart:
sl@0: 			{
sl@0: 			__ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundPlayStopMultipleTimes"),EFsmIncorrectErrorPassed));
sl@0: 			if (aDevSoundEvent == EEventPlayStart)
sl@0: 				{
sl@0: 				// Initializing DevSound object for playing mode to process audio data via desired FourCC code
sl@0: 				INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL"));
sl@0: 				TInt err;
sl@0: 				if(iUseFourCC)
sl@0: 					{
sl@0: 					TRAP(err, iMMFDevSound->InitializeL(*this, iInputDataType, EMMFStatePlaying));
sl@0: 					}
sl@0: 				else
sl@0: 					{
sl@0: 					TRAP(err, iMMFDevSound->InitializeL(*this, EMMFStatePlaying));
sl@0: 					}
sl@0: 				if (err != KErrNone)
sl@0: 					{
sl@0: 					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
sl@0: 					StopTest(err);
sl@0: 					break;
sl@0: 					}
sl@0: 				INFO_PRINTF1(_L("State: EStatePlayInitializing"));
sl@0: 				iPlayState = EStatePlayInitializing;
sl@0: 				}
sl@0: 			else
sl@0: 				{
sl@0: 				ERR_PRINTF2(_L("DevSound EEventPlayStart not received as expected. Received event: %d"), aDevSoundEvent);
sl@0: 				StopTest(aError, EFail);
sl@0: 				}
sl@0: 			break;
sl@0: 			}
sl@0: 
sl@0: 		case EStatePlayInitializing:
sl@0: 			{
sl@0: 			if (aDevSoundEvent == EEventInitCompletePlay && aError == KErrNone)
sl@0: 				{
sl@0: 				if(iConfig)
sl@0: 					{
sl@0: 					// Set Devsound capability settings using CMMFDevSound::SetConfigL
sl@0: 					SetSampleRateAndChannelMode();
sl@0: 					TMMFCapabilities capabilities;
sl@0: 					capabilities.iRate = ConvertDesToTMMFSampleRate(iSampleRate);
sl@0: 					capabilities.iChannels = ConvertDesToTMMFMonoStereo(iMonoStereo);
sl@0: 
sl@0: 					TRAPD(errConfig, iMMFDevSound->SetConfigL(capabilities));
sl@0: 					if (errConfig != KErrNone)
sl@0: 						{
sl@0: 						ERR_PRINTF2(_L("CMMFDevSound::SetConfigL() left with error = %d"), errConfig);
sl@0: 						StopTest(errConfig);
sl@0: 						break;
sl@0: 						}
sl@0: 					}
sl@0: 				// Initialize audio device and starts the playing process
sl@0: 				INFO_PRINTF1(_L("Calling CMMFDevSound::PlayInitL()"));
sl@0: 				TRAPD(errPlay, iMMFDevSound->PlayInitL());
sl@0: 				if (errPlay != KErrNone)
sl@0: 					{
sl@0: 					ERR_PRINTF2(_L("CMMFDevSound::PlayInitL() left with error = %d"), errPlay);
sl@0: 					StopTest(errPlay);
sl@0: 					break;
sl@0: 					}
sl@0: 				INFO_PRINTF1(_L("State: EStatePlaying"));
sl@0: 				iPlayState = EStatePlaying;
sl@0: 				}
sl@0: 			else if (aDevSoundEvent == EEventInitCompletePlay && aError != KErrNone)
sl@0: 				{
sl@0: 				ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError);
sl@0: 				StopTest(aError);
sl@0: 				}
sl@0: 			else
sl@0: 				{
sl@0: 				ERR_PRINTF2(_L("DevSound EEventInitCompletePlay not received as expected. Received event: %d"), aDevSoundEvent);
sl@0: 				StopTest(aError, EFail);
sl@0: 				}
sl@0: 			break;
sl@0: 			}
sl@0: 
sl@0: 		case EStatePlaying:
sl@0: 			{
sl@0: 			__ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundPlayStopMultipleTimes"),EFsmIncorrectErrorPassed));
sl@0: 			if (aDevSoundEvent == EEventBTBF)
sl@0: 				{
sl@0: 				// Fill the buffer with audio data and play the data in the buffer
sl@0: 				CMMFDataBuffer* buffer = static_cast <CMMFDataBuffer*> (iBuffer);
sl@0: 				TInt err = iFile.Read(buffer->Data());
sl@0: 				if (err != KErrNone)
sl@0: 					{
sl@0: 					ERR_PRINTF2(_L("ERROR : iFile.Read() failed with %d"), err);
sl@0: 					StopTest(err);
sl@0: 					break;
sl@0: 					}
sl@0: 				if (buffer->Data().Length() != buffer->RequestSize())
sl@0: 					{
sl@0: 					INFO_PRINTF3(_L("Data length copied from file = %d. Expected = %d. Must be EOF."), buffer->Data().Length(), buffer->RequestSize());
sl@0: 					iBuffer->SetLastBuffer(ETrue);
sl@0: 					}
sl@0: 
sl@0: 				if ((iCheckTimer) && (iRepeatCounter < iRepeatCount))
sl@0: 					{
sl@0: 					iTimer->Start(KMicroSecsInTenSecs, 0, iCallBack);
sl@0: 					}
sl@0: 				iCheckTimer = EFalse;
sl@0: 				// Playing data in the buffer at the current volume
sl@0: 				iMMFDevSound->PlayData();
sl@0: 				iBufferCount++;
sl@0: 				}
sl@0: 			else if (aDevSoundEvent == EEventPlayTimerComplete)
sl@0: 				{
sl@0: 				while(iRepeatCounter <= iRepeatCount)
sl@0: 					{
sl@0: 					INFO_PRINTF1(_L("Calling iMMFDevSound->Stop()"));
sl@0: 					iMMFDevSound->Stop();
sl@0: 					iRepeatCounter++;
sl@0: 					INFO_PRINTF2(_L("Playback Stopped. Count = %d"), iRepeatCounter);
sl@0: 					INFO_PRINTF1(_L("Changing the state to: EStatePlaying "));
sl@0: 					iPlayState = EStatePlayInitializing;
sl@0: 					break;
sl@0: 					}
sl@0: 				}
sl@0: 			else
sl@0: 				{
sl@0: 				ERR_PRINTF2(_L("DevSound EEventBTBF not received as expected. Received event: %d"), aDevSoundEvent);
sl@0: 				StopTest(aError, EFail);
sl@0: 				}
sl@0: 			break;
sl@0: 			}
sl@0: 
sl@0: 		default:
sl@0: 			{
sl@0: 			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iPlayState);
sl@0: 			StopTest(KErrGeneral);
sl@0: 			}
sl@0: 		}
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * DoTimerCallback
sl@0:  *
sl@0:  */
sl@0: void RStepA3FDevSoundPlayStopMultipleTimes::DoTimerCallback()
sl@0: 	{
sl@0: 	iTimer->Cancel(); // only really wanted a one-shot
sl@0: 	if(!iCheckTimer)
sl@0: 		{
sl@0: 		iCheckTimer = ETrue;
sl@0: 		Fsm(EEventPlayTimerComplete, KErrNone);
sl@0: 		if (iRepeatCounter <= iRepeatCount)
sl@0: 			{
sl@0: 			Fsm(EEventInitCompletePlay, KErrNone);
sl@0: 			}
sl@0: 		}
sl@0: 
sl@0: 	}
sl@0: 
sl@0: //
sl@0: // RStepA3FDevSoundPlayEOFPlayMultipleTimes
sl@0: //
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * RStepA3FDevSoundPlayEOFPlayMultipleTimes - Test step constructor
sl@0:  *
sl@0:  */
sl@0: RStepA3FDevSoundPlayEOFPlayMultipleTimes::RStepA3FDevSoundPlayEOFPlayMultipleTimes(const TDesC& aTestName, const TDesC& aSectName)
sl@0: :RTestStepA3FDevSoundPlayBase(aTestName, aSectName),
sl@0:  iRepeatCount(0),
sl@0:  iRepeatCounter(1)
sl@0: 	{
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * NewL
sl@0:  *
sl@0:  */
sl@0: RStepA3FDevSoundPlayEOFPlayMultipleTimes* RStepA3FDevSoundPlayEOFPlayMultipleTimes::NewL(const TDesC& aTestName, const TDesC& aSectName)
sl@0: 	{
sl@0: 	RStepA3FDevSoundPlayEOFPlayMultipleTimes* self = new (ELeave) RStepA3FDevSoundPlayEOFPlayMultipleTimes(aTestName, aSectName);
sl@0: 	return self;
sl@0: 
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * DoKickoffTestL
sl@0:  *
sl@0:  */
sl@0: void RStepA3FDevSoundPlayEOFPlayMultipleTimes::DoKickoffTestL()
sl@0: 	{
sl@0: 	INFO_PRINTF2(_L("File to be played -> %S"), &iFilename);
sl@0: 	DisplayCodecInfo();
sl@0: 	CheckConfigAndFourCCUsage();
sl@0: 
sl@0: 	TBool repeatCount = GetIntFromConfig(iSectName,_L("Repeat"),iRepeatCount);
sl@0: 	if (repeatCount)
sl@0: 		{
sl@0: 		INFO_PRINTF2(_L("No. of times to Repeat = %d"), iRepeatCount);
sl@0: 		}
sl@0: 	else
sl@0: 		{
sl@0: 		TPtrC keyName(_L("Repeat"));
sl@0: 		ERR_PRINTF3(_L("Error in getting number of times to repeat playback from config file in %S section via the %S key field."), &iSectName, &keyName);
sl@0: 		StopTest(KErrPathNotFound);
sl@0: 		return;
sl@0: 		}
sl@0: 
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * PlayError
sl@0:  *
sl@0:  */
sl@0: void RStepA3FDevSoundPlayEOFPlayMultipleTimes::PlayError(TInt aError)
sl@0: 	{
sl@0: 	INFO_PRINTF2(_L("DevSound called PlayError with error = %d"), aError);
sl@0: 	if ((iBuffer->LastBuffer()) && (aError == KErrUnderflow))
sl@0: 		{
sl@0: 		INFO_PRINTF2(_L("Finished playing. Playback Count = %d"), iRepeatCounter);
sl@0: 		if (iRepeatCounter < iRepeatCount)
sl@0: 			{
sl@0: 			iRepeatCounter++;
sl@0: 			INFO_PRINTF1(_L("Starting to Play again"));
sl@0: 			iFile.Close();
sl@0: 			TInt err = iFile.Open(iFs, iFilename, EFileRead);
sl@0: 			if (err != KErrNone)
sl@0: 				{
sl@0: 				ERR_PRINTF2(_L("Could not Open the File: Error = %d"), err);
sl@0: 				StopTest(err);
sl@0: 				}
sl@0: 			iPlayState = EStatePlayInitializing;
sl@0: 			Fsm(EEventInitCompletePlay, KErrNone);
sl@0: 			}
sl@0: 		else
sl@0: 			{
sl@0: 			INFO_PRINTF2(_L("Finished playing %d number of times."), iRepeatCounter);
sl@0: 			StopTest(KErrNone);
sl@0: 			}
sl@0: 		}
sl@0: 	else
sl@0: 		{
sl@0: 		StopTest(aError, EFail);
sl@0: 		}
sl@0: 
sl@0: 	}
sl@0: 
sl@0: //
sl@0: // RStepA3FDevSoundInititalizeDuringInitialize
sl@0: //
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * RStepA3FDevSoundInititalizeDuringInitialize - Test step constructor
sl@0:  *
sl@0:  */
sl@0: RStepA3FDevSoundInititalizeDuringInitialize::RStepA3FDevSoundInititalizeDuringInitialize(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType)
sl@0: :RTestStepA3FDevSoundPlayBase(aTestName, aSectName, aInputDataType),
sl@0:  iSecondInitErr(0)
sl@0: 	{
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * NewL
sl@0:  *
sl@0:  */
sl@0: RStepA3FDevSoundInititalizeDuringInitialize* RStepA3FDevSoundInititalizeDuringInitialize::NewL(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType)
sl@0: 	{
sl@0: 	RStepA3FDevSoundInititalizeDuringInitialize* self = new (ELeave) RStepA3FDevSoundInititalizeDuringInitialize(aTestName, aSectName, aInputDataType);
sl@0: 	return self;
sl@0: 
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * KickoffTestL
sl@0:  * - Starts the test
sl@0:  *
sl@0:  */
sl@0: void RStepA3FDevSoundInititalizeDuringInitialize::KickoffTestL()
sl@0: 	{
sl@0: 	// Create instance of CMMFDevSound
sl@0: 	INFO_PRINTF1(_L("--- Creating DevSound object..."));
sl@0: 	iMMFDevSound = CMMFDevSound::NewL();
sl@0: 
sl@0: 	//Display the name of Codec being used
sl@0: 	DisplayCodecInfo();
sl@0: 
sl@0: 	if(!GetBoolFromConfig(iSectName, _L("UseFourCC"), iUseFourCC))
sl@0: 		{
sl@0: 		TPtrC keyName(_L("UseFourCC"));
sl@0: 		ERR_PRINTF3(_L("Error in getting UseFourCC flag value from config file in %S section via the %S key field."), &iSectName, &keyName);
sl@0: 		StopTest(KErrPathNotFound);
sl@0: 		return;
sl@0: 		}
sl@0: 
sl@0: 	Fsm(EEventPlayStart,KErrNone); // call to start the DevSound finite state machine for playing
sl@0: 
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * Fsm
sl@0:  *	- Executes playing events of DevSound in sequence
sl@0:  *
sl@0:  */
sl@0: void RStepA3FDevSoundInititalizeDuringInitialize::Fsm(TDevSoundPlayEvents aDevSoundEvent, TInt aError)
sl@0: 	{
sl@0: 	switch (iPlayState)
sl@0: 		{
sl@0: 		case EStatePlayStart:
sl@0: 			{
sl@0: 			__ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundInititalizeDuringInitialize"),EFsmIncorrectErrorPassed));
sl@0: 			if (aDevSoundEvent == EEventPlayStart)
sl@0: 				{
sl@0: 				// Initializing DevSound object for playing mode to process audio data via desired FourCC code
sl@0: 				INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL"));
sl@0: 				TInt err;
sl@0: 				if(iUseFourCC)
sl@0: 					{
sl@0: 					INFO_PRINTF1(_L("Calling first InitializeL()"));
sl@0: 					TRAP(err, iMMFDevSound->InitializeL(*this, iInputDataType, EMMFStatePlaying));
sl@0: 					if (err != KErrNone)
sl@0: 						{
sl@0: 						ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
sl@0: 						StopTest(err);
sl@0: 						break;
sl@0: 						}
sl@0: 					else
sl@0: 						{
sl@0: 						INFO_PRINTF1(_L("Calling second InitializeL() beofre first InitializeL() returns."));
sl@0: 						TRAP(iSecondInitErr, iMMFDevSound->InitializeL(*this, iInputDataType, EMMFStatePlaying));
sl@0: 						}
sl@0: 					}
sl@0: 				else
sl@0: 					{
sl@0: 					INFO_PRINTF1(_L("Calling first InitializeL()"));
sl@0: 					TRAP(err, iMMFDevSound->InitializeL(*this, EMMFStatePlaying));
sl@0: 					if (err != KErrNone)
sl@0: 						{
sl@0: 						ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
sl@0: 						StopTest(err);
sl@0: 						break;
sl@0: 						}
sl@0: 					else
sl@0: 						{
sl@0: 						INFO_PRINTF1(_L("Calling second InitializeL() beofre first InitializeL() returns."));
sl@0: 						TRAP(iSecondInitErr, iMMFDevSound->InitializeL(*this, EMMFStatePlaying));
sl@0: 						}
sl@0: 					}
sl@0: 				INFO_PRINTF1(_L("State: EStatePlayInitializing"));
sl@0: 				iPlayState = EStatePlayInitializing;
sl@0: 				}
sl@0: 			else
sl@0: 				{
sl@0: 				ERR_PRINTF2(_L("DevSound EEventPlayStart not received as expected. Received event: %d"), aDevSoundEvent);
sl@0: 				StopTest(aError, EFail);
sl@0: 				}
sl@0: 			break;
sl@0: 			}
sl@0: 
sl@0: 		default:
sl@0: 			{
sl@0: 			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iPlayState);
sl@0: 			StopTest(KErrGeneral);
sl@0: 			}
sl@0: 		}
sl@0: 
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * InitializeComplete
sl@0:  *
sl@0:  */
sl@0: void RStepA3FDevSoundInititalizeDuringInitialize::InitializeComplete(TInt aError)
sl@0: 	{
sl@0: 	INFO_PRINTF2(_L("First Initialize returned with = %d"), aError);
sl@0: 	INFO_PRINTF2(_L("Second Initialize left with = %d"), iSecondInitErr);
sl@0: 
sl@0: 	if ((aError == KErrNone) && (iSecondInitErr == KErrNotReady))
sl@0: 		{
sl@0: 		INFO_PRINTF1(_L("This is expected"));
sl@0: 		StopTest(aError);
sl@0: 		}
sl@0: 	else
sl@0: 		{
sl@0: 		INFO_PRINTF2(_L("This is not expected. Second InitializeL should fail with %d"), KErrNotReady);
sl@0: 		StopTest(aError, EFail);
sl@0: 		}
sl@0: 
sl@0: 	}
sl@0: 
sl@0: //
sl@0: // RStepA3FDevSoundPlayInitDuringPlayInit
sl@0: //
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * RStepA3FDevSoundPlayInitDuringPlayInit - Test step constructor
sl@0:  *
sl@0:  */
sl@0: RStepA3FDevSoundPlayInitDuringPlayInit::RStepA3FDevSoundPlayInitDuringPlayInit(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType)
sl@0: :RTestStepA3FDevSoundPlayBase(aTestName, aSectName, aInputDataType),
sl@0:  iFirstPlayInitErr(0),
sl@0:  iSecondPlayInitErr(0)
sl@0: 	{
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * NewL
sl@0:  *
sl@0:  */
sl@0: RStepA3FDevSoundPlayInitDuringPlayInit* RStepA3FDevSoundPlayInitDuringPlayInit::NewL(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType)
sl@0: 	{
sl@0: 	RStepA3FDevSoundPlayInitDuringPlayInit* self = new (ELeave) RStepA3FDevSoundPlayInitDuringPlayInit(aTestName, aSectName, aInputDataType);
sl@0: 	return self;
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * KickoffTestL
sl@0:  * - Starts the test
sl@0:  *
sl@0:  */
sl@0: void RStepA3FDevSoundPlayInitDuringPlayInit::KickoffTestL()
sl@0: 	{
sl@0: 	// Create instance of CMMFDevSound
sl@0: 	INFO_PRINTF1(_L("--- Creating DevSound object..."));
sl@0: 	iMMFDevSound = CMMFDevSound::NewL();
sl@0: 
sl@0: 	//Display the name of Codec being used
sl@0: 	DisplayCodecInfo();
sl@0: 	CheckConfigAndFourCCUsage();
sl@0: 	Fsm(EEventPlayStart,KErrNone); // call to start the DevSound finite state machine for playing
sl@0: 
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * Fsm
sl@0:  *	- Executes playing events of DevSound in sequence
sl@0:  *
sl@0:  */
sl@0: void RStepA3FDevSoundPlayInitDuringPlayInit::Fsm(TDevSoundPlayEvents aDevSoundEvent, TInt aError)
sl@0: 	{
sl@0: 	switch (iPlayState)
sl@0: 		{
sl@0: 		case EStatePlayStart:
sl@0: 			{
sl@0: 			__ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundPlayInitDuringPlayInit"),EFsmIncorrectErrorPassed));
sl@0: 			if (aDevSoundEvent == EEventPlayStart)
sl@0: 				{
sl@0: 				// Initializing DevSound object for playing mode to process audio data via desired FourCC code
sl@0: 				INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL"));
sl@0: 				TInt err;
sl@0: 				if(iUseFourCC)
sl@0: 					{
sl@0: 					TRAP(err, iMMFDevSound->InitializeL(*this, iInputDataType, EMMFStatePlaying));
sl@0: 					}
sl@0: 				else
sl@0: 					{
sl@0: 					TRAP(err, iMMFDevSound->InitializeL(*this, EMMFStatePlaying));
sl@0: 					}
sl@0: 				if (err != KErrNone)
sl@0: 					{
sl@0: 					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
sl@0: 					StopTest(err);
sl@0: 					break;
sl@0: 					}
sl@0: 				INFO_PRINTF1(_L("State: EStatePlayInitializing"));
sl@0: 				iPlayState = EStatePlayInitializing;
sl@0: 				}
sl@0: 			else
sl@0: 				{
sl@0: 				ERR_PRINTF2(_L("DevSound EEventPlayStart not received as expected. Received event: %d"), aDevSoundEvent);
sl@0: 				StopTest(aError, EFail);
sl@0: 				}
sl@0: 			break;
sl@0: 			}
sl@0: 
sl@0: 		case EStatePlayInitializing:
sl@0: 			{
sl@0: 			if (aDevSoundEvent == EEventInitCompletePlay && aError == KErrNone)
sl@0: 				{
sl@0: 				if(iConfig)
sl@0: 					{
sl@0: 					// Set Devsound capability settings using CMMFDevSound::SetConfigL
sl@0: 					SetSampleRateAndChannelMode();
sl@0: 					TMMFCapabilities capabilities;
sl@0: 					capabilities.iRate = ConvertDesToTMMFSampleRate(iSampleRate);
sl@0: 					capabilities.iChannels = ConvertDesToTMMFMonoStereo(iMonoStereo);
sl@0: 
sl@0: 					TRAPD(errConfig, iMMFDevSound->SetConfigL(capabilities));
sl@0: 					if (errConfig != KErrNone)
sl@0: 						{
sl@0: 						ERR_PRINTF2(_L("CMMFDevSound::SetConfigL() left with error = %d"), errConfig);
sl@0: 						StopTest(errConfig);
sl@0: 						break;
sl@0: 						}
sl@0: 					}
sl@0: 
sl@0: 				// Initialize audio device and starts the playing process
sl@0: 				INFO_PRINTF1(_L("Calling First CMMFDevSound::PlayInitL()"));
sl@0: 				TRAPD(iFirstPlayInitErr, iMMFDevSound->PlayInitL());
sl@0: 				TRAP(iSecondPlayInitErr, iMMFDevSound->PlayInitL());
sl@0: 				if (iFirstPlayInitErr != KErrNone)
sl@0: 					{
sl@0: 					ERR_PRINTF2(_L("First CMMFDevSound::PlayInitL() left with error = %d"), iFirstPlayInitErr);
sl@0: 					StopTest(iFirstPlayInitErr);
sl@0: 					break;
sl@0: 					}
sl@0: 				INFO_PRINTF1(_L("State: EStatePlaying"));
sl@0: 				iPlayState = EStatePlaying;
sl@0: 				}
sl@0: 			else if (aDevSoundEvent == EEventInitCompletePlay && aError != KErrNone)
sl@0: 				{
sl@0: 				ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError);
sl@0: 				StopTest(aError);
sl@0: 				}
sl@0: 			else
sl@0: 				{
sl@0: 				ERR_PRINTF2(_L("DevSound EEventInitCompletePlay not received as expected. Received event: %d"), aDevSoundEvent);
sl@0: 				StopTest(aError, EFail);
sl@0: 				}
sl@0: 			break;
sl@0: 			}
sl@0: 
sl@0: 		default:
sl@0: 			{
sl@0: 			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iPlayState);
sl@0: 			StopTest(KErrGeneral);
sl@0: 			}
sl@0: 		}
sl@0: 
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * BufferToBeFilled
sl@0:  *
sl@0:  */
sl@0: void RStepA3FDevSoundPlayInitDuringPlayInit::BufferToBeFilled(CMMFBuffer* aBuffer)
sl@0: 	{
sl@0: 	if (!aBuffer)
sl@0: 		{
sl@0: 		ERR_PRINTF1(_L("BufferToBeFilled callback received a NULL CMMFBuffer!"));
sl@0: 		StopTest(KErrGeneral);
sl@0: 		return;
sl@0: 		}
sl@0: 	iBuffer = aBuffer;
sl@0: 
sl@0: 	INFO_PRINTF2(_L("First PlayInit left with = %d"), iFirstPlayInitErr);
sl@0: 	INFO_PRINTF2(_L("Second PlayInit left with = %d"), iSecondPlayInitErr);
sl@0: 
sl@0: 	if ((iFirstPlayInitErr == KErrNone) && (iSecondPlayInitErr == KErrNotReady))
sl@0: 		{
sl@0: 		INFO_PRINTF1(_L("This is expected"));
sl@0: 		StopTest(KErrNone);
sl@0: 		}
sl@0: 	else
sl@0: 		{
sl@0: 		INFO_PRINTF2(_L("This is not expected. Second PlayInit should fail with  %d"), KErrNotReady);
sl@0: 		StopTest(iFirstPlayInitErr, EFail);
sl@0: 		}
sl@0: 
sl@0: 	}
sl@0: 
sl@0: //
sl@0: // RStepA3FDevSoundVolumeCrop
sl@0: //
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * RStepA3FDevSoundVolumeCrop - Test step constructor
sl@0:  *
sl@0:  */
sl@0: RStepA3FDevSoundVolumeCrop::RStepA3FDevSoundVolumeCrop(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType)
sl@0: :RTestStepA3FDevSoundPlayBase(aTestName, aSectName, aInputDataType),
sl@0:  iIncreaseMaxVolume(0),
sl@0:  iMinVolume(0)
sl@0: 	{
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * NewL
sl@0:  *
sl@0:  */
sl@0: RStepA3FDevSoundVolumeCrop* RStepA3FDevSoundVolumeCrop::NewL(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType)
sl@0: 	{
sl@0: 	RStepA3FDevSoundVolumeCrop* self = new (ELeave) RStepA3FDevSoundVolumeCrop(aTestName, aSectName, aInputDataType);
sl@0: 	return self;
sl@0: 
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * KickoffTestL
sl@0:  *
sl@0:  */
sl@0: void RStepA3FDevSoundVolumeCrop::KickoffTestL()
sl@0: 	{
sl@0: 	//Create instance of CMMFDevSound
sl@0: 	iMMFDevSound = CMMFDevSound::NewL();
sl@0: 	//Display the name of Codec being used
sl@0: 	DisplayCodecInfo();
sl@0: 
sl@0: 	if(!GetBoolFromConfig(iSectName, _L("UseFourCC"), iUseFourCC))
sl@0: 		{
sl@0: 		TPtrC keyName(_L("UseFourCC"));
sl@0: 		ERR_PRINTF3(_L("Error in getting UseFourCC flag from config file in %S section via the %S key field."), &iSectName, &keyName);
sl@0: 		StopTest(KErrPathNotFound);
sl@0: 		return;
sl@0: 		}
sl@0: 
sl@0: 	TBool maxVol = GetIntFromConfig(iSectName,_L("IncreaseMaxVolume"),iIncreaseMaxVolume);
sl@0: 	if (maxVol)
sl@0: 		{
sl@0: 		INFO_PRINTF2(_L("Volume to be added to the MaxVolume supported by device = %d"), iIncreaseMaxVolume);
sl@0: 		}
sl@0: 	else
sl@0: 		{
sl@0: 		TPtrC keyName(_L("IncreaseMaxVolume"));
sl@0: 		ERR_PRINTF3(_L("Error in getting the volume to increase maxvolume by from config file in %S section via the %S key field."), &iSectName, &keyName);
sl@0: 		StopTest(KErrPathNotFound);
sl@0: 		return;
sl@0: 		}
sl@0: 
sl@0: 	TBool minVol = GetIntFromConfig(iSectName,_L("SetMinVolume"),iMinVolume);
sl@0: 	if (minVol)
sl@0: 		{
sl@0: 		INFO_PRINTF2(_L("Seting MinVolume value = %d"), iMinVolume);
sl@0: 		}
sl@0: 	else
sl@0: 		{
sl@0: 		TPtrC keyName(_L("SetMinVolume"));
sl@0: 		ERR_PRINTF3(_L("Error in getting volume below zero from config file in %S section via the %S key field."), &iSectName, &keyName);
sl@0: 		return;
sl@0: 		}
sl@0: 
sl@0: 	Fsm(EEventPlayStart,KErrNone); // call to start the DevSound finite state machine for playing
sl@0: 
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * Fsm
sl@0:  *	- Executes playing events of DevSound in sequence
sl@0:  *
sl@0:  */
sl@0: void RStepA3FDevSoundVolumeCrop::Fsm(TDevSoundPlayEvents aDevSoundEvent, TInt aError)
sl@0: 	{
sl@0: 	switch (iPlayState)
sl@0: 		{
sl@0: 		case EStatePlayStart:
sl@0: 			{
sl@0: 			__ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundVolumeCrop"),EFsmIncorrectErrorPassed));
sl@0: 			if (aDevSoundEvent == EEventPlayStart)
sl@0: 				{
sl@0: 				// Initializing DevSound object for playing mode to process audio data via desired FourCC code
sl@0: 				INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL"));
sl@0: 				TInt err;
sl@0: 				if(iUseFourCC)
sl@0: 					{
sl@0: 					TRAP(err, iMMFDevSound->InitializeL(*this, iInputDataType, EMMFStatePlaying));
sl@0: 					}
sl@0: 				else
sl@0: 					{
sl@0: 					TRAP(err, iMMFDevSound->InitializeL(*this, EMMFStatePlaying));
sl@0: 					}
sl@0: 				if (err != KErrNone)
sl@0: 					{
sl@0: 					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
sl@0: 					StopTest(err);
sl@0: 					break;
sl@0: 					}
sl@0: 				else
sl@0: 					{
sl@0: 					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
sl@0: 					TInt deviceMaxVol = iMMFDevSound->MaxVolume();
sl@0: 					INFO_PRINTF2(_L("Maximum volume supported by the device is %d"), deviceMaxVol);
sl@0: 					INFO_PRINTF2(_L("Setting the volume beyond the maximum volume supported by the device: %d"), deviceMaxVol + iIncreaseMaxVolume);
sl@0: 					iMMFDevSound->SetVolume(deviceMaxVol + iIncreaseMaxVolume);
sl@0: 					INFO_PRINTF1(_L("Getting the volume set"));
sl@0: 					TInt maxVolumeObtained = iMMFDevSound->Volume();
sl@0: 					INFO_PRINTF2(_L("iMMFDevSound->Volume(): %d"), maxVolumeObtained);
sl@0: 					if (maxVolumeObtained != deviceMaxVol)
sl@0: 						{
sl@0: 						ERR_PRINTF1(_L("Volume was not cropped to equal to maximum volume supported by device"));
sl@0: 						StopTest(KErrGeneral);
sl@0: 						}
sl@0: 					else
sl@0: 						{
sl@0: 						INFO_PRINTF1(_L("Volume was cropped to equal to maximum volume supported by device"));
sl@0: 						INFO_PRINTF2(_L("Setting volume to less than zero: %d"), iMinVolume);
sl@0: 						iMMFDevSound->SetVolume(iMinVolume);
sl@0: 						INFO_PRINTF1(_L("Getting the volume set"));
sl@0: 						TInt minVolumeObtained = iMMFDevSound->Volume();
sl@0: 						INFO_PRINTF2(_L("iMMFDevSound->Volume(): %d"), minVolumeObtained);
sl@0: 						if (minVolumeObtained != KNULLVolume)
sl@0: 							{
sl@0: 							ERR_PRINTF1(_L("Volume was not cropped to equal to minimum volume supported by device"));
sl@0: 							StopTest(KErrGeneral);
sl@0: 							}
sl@0: 						else
sl@0: 							{
sl@0: 							INFO_PRINTF1(_L("Volume was cropped to equal to minimum volume supported by device"));
sl@0: 							StopTest(KErrNone);
sl@0: 							}
sl@0: 						}
sl@0: 					}
sl@0: 				}
sl@0: 			else
sl@0: 				{
sl@0: 				ERR_PRINTF2(_L("DevSound EEventPlayStart not received as expected. Received event: %d"), aDevSoundEvent);
sl@0: 				StopTest(aError, EFail);
sl@0: 				}
sl@0: 		break;
sl@0: 		}
sl@0: 		default:
sl@0: 			{
sl@0: 			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iPlayState);
sl@0: 			StopTest(KErrGeneral);
sl@0: 			}
sl@0: 		}
sl@0: 
sl@0: 	}
sl@0: 
sl@0: //
sl@0: // RStepA3FDevSoundInitializeForConverting
sl@0: //
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * RStepA3FDevSoundInitializeForConverting - Test step constructor
sl@0:  *
sl@0:  */
sl@0: RStepA3FDevSoundInitializeForConverting::RStepA3FDevSoundInitializeForConverting(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType)
sl@0: :RTestStepA3FDevSoundPlayBase(aTestName, aSectName, aInputDataType)
sl@0: 	{
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * NewL
sl@0:  *
sl@0:  */
sl@0: RStepA3FDevSoundInitializeForConverting* RStepA3FDevSoundInitializeForConverting::NewL(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType)
sl@0: 	{
sl@0: 	RStepA3FDevSoundInitializeForConverting* self = new (ELeave) RStepA3FDevSoundInitializeForConverting(aTestName, aSectName, aInputDataType);
sl@0: 	return self;
sl@0: 
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * KickoffTestL
sl@0:  * - Starts the test
sl@0:  *
sl@0:  */
sl@0: void RStepA3FDevSoundInitializeForConverting::KickoffTestL()
sl@0: 	{
sl@0: 	// Create instance of CMMFDevSound
sl@0: 	INFO_PRINTF1(_L("--- Creating DevSound object..."));
sl@0: 	iMMFDevSound = CMMFDevSound::NewL();
sl@0: 
sl@0: 	//Display the name of Codec being used
sl@0: 	DisplayCodecInfo();
sl@0: 
sl@0: 	if(!GetBoolFromConfig(iSectName, _L("UseFourCC"), iUseFourCC))
sl@0: 		{
sl@0: 		TPtrC keyName(_L("UseFourCC"));
sl@0: 		ERR_PRINTF3(_L("Error in getting UseFourCC flag value from config file in %S section via the %S key field."), &iSectName, &keyName);
sl@0: 		StopTest(KErrPathNotFound);
sl@0: 		return;
sl@0: 		}
sl@0: 
sl@0: 	Fsm(EEventPlayStart,KErrNone); // call to start the DevSound finite state machine for playing
sl@0: 
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * Fsm
sl@0:  *	- Executes playing events of DevSound in sequence
sl@0:  *
sl@0:  */
sl@0: void RStepA3FDevSoundInitializeForConverting::Fsm(TDevSoundPlayEvents aDevSoundEvent, TInt aError)
sl@0: 	{
sl@0: 	switch (iPlayState)
sl@0: 		{
sl@0: 		case EStatePlayStart:
sl@0: 			{
sl@0: 			__ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundInitializeForConverting"),EFsmIncorrectErrorPassed));
sl@0: 			if (aDevSoundEvent == EEventPlayStart)
sl@0: 				{
sl@0: 				// Initializing DevSound object for playing mode to process audio data via desired FourCC code
sl@0: 				INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL"));
sl@0: 				TInt err;
sl@0: 				if(iUseFourCC)
sl@0: 					{
sl@0: 					TRAP(err, iMMFDevSound->InitializeL(*this, iInputDataType, EMMFStateConverting));
sl@0: 					}
sl@0: 				else
sl@0: 					{
sl@0: 					TRAP(err, iMMFDevSound->InitializeL(*this, EMMFStateConverting));
sl@0: 					}
sl@0: 				if (err == KErrNotSupported)
sl@0: 					{
sl@0: 					INFO_PRINTF2(_L("CMMFDevSound::InitializeL left with expected error = %d for EMMFStateConverting"), err);
sl@0: 					StopTest(err, EPass);
sl@0: 					}
sl@0: 				else
sl@0: 					{
sl@0: 					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d for EMMFStateConverting"), err);
sl@0: 					StopTest(err, EFail);
sl@0: 					}
sl@0: 				}
sl@0: 			else
sl@0: 				{
sl@0: 				ERR_PRINTF2(_L("DevSound EEventPlayStart not received as expected. Received event: %d"), aDevSoundEvent);
sl@0: 				StopTest(aError, EFail);
sl@0: 				}
sl@0: 			break;
sl@0: 			}
sl@0: 		}
sl@0: 
sl@0: 	}
sl@0: 
sl@0: //
sl@0: // RStepA3FDevSoundGetSampleNumsAfterStop
sl@0: //
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * RStepA3FDevSoundGetSampleNumsAfterStop - Test step constructor
sl@0:  *
sl@0:  */
sl@0: RStepA3FDevSoundGetSampleNumsAfterStop::RStepA3FDevSoundGetSampleNumsAfterStop(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType)
sl@0: :RTestStepA3FDevSoundPlayBase(aTestName, aSectName, aInputDataType),
sl@0:  iCheckTimer(ETrue)
sl@0: 	{
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * NewL
sl@0:  *
sl@0:  */
sl@0: RStepA3FDevSoundGetSampleNumsAfterStop* RStepA3FDevSoundGetSampleNumsAfterStop::NewL(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType)
sl@0: 	{
sl@0: 	RStepA3FDevSoundGetSampleNumsAfterStop* self = new (ELeave) RStepA3FDevSoundGetSampleNumsAfterStop(aTestName, aSectName, aInputDataType);
sl@0: 	return self;
sl@0: 
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * Fsm
sl@0:  *	- Executes playing events of DevSound in sequence
sl@0:  *
sl@0:  */
sl@0: void RStepA3FDevSoundGetSampleNumsAfterStop::Fsm(TDevSoundPlayEvents aDevSoundEvent, TInt aError)
sl@0: 	{
sl@0: 	switch (iPlayState)
sl@0: 		{
sl@0: 		case EStatePlayStart:
sl@0: 			{
sl@0: 			__ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundGetSampleNumsAfterStop"),EFsmIncorrectErrorPassed));
sl@0: 			if (aDevSoundEvent == EEventPlayStart)
sl@0: 				{
sl@0: 				// Initializing DevSound object for playing mode to process audio data via desired FourCC code
sl@0: 				INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL"));
sl@0: 				TInt err;
sl@0: 				if(iUseFourCC)
sl@0: 					{
sl@0: 					TRAP(err, iMMFDevSound->InitializeL(*this, iInputDataType, EMMFStatePlaying));
sl@0: 					}
sl@0: 				else
sl@0: 					{
sl@0: 					TRAP(err, iMMFDevSound->InitializeL(*this, EMMFStatePlaying));
sl@0: 					}
sl@0: 				if (err != KErrNone)
sl@0: 					{
sl@0: 					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
sl@0: 					StopTest(err);
sl@0: 					break;
sl@0: 					}
sl@0: 				INFO_PRINTF1(_L("State: EStatePlayInitializing"));
sl@0: 				iPlayState = EStatePlayInitializing;
sl@0: 				}
sl@0: 			else
sl@0: 				{
sl@0: 				ERR_PRINTF2(_L("DevSound EEventPlayStart not received as expected. Received event: %d"), aDevSoundEvent);
sl@0: 				StopTest(aError, EFail);
sl@0: 				}
sl@0: 			break;
sl@0: 			}
sl@0: 
sl@0: 		case EStatePlayInitializing:
sl@0: 			{
sl@0: 			if (aDevSoundEvent == EEventInitCompletePlay && aError == KErrNone)
sl@0: 				{
sl@0: 				if(iConfig)
sl@0: 					{
sl@0: 					// Set Devsound capability settings using CMMFDevSound::SetConfigL
sl@0: 					SetSampleRateAndChannelMode();
sl@0: 					TMMFCapabilities capabilities;
sl@0: 					capabilities.iRate = ConvertDesToTMMFSampleRate(iSampleRate);
sl@0: 					capabilities.iChannels = ConvertDesToTMMFMonoStereo(iMonoStereo);
sl@0: 
sl@0: 					TRAPD(errConfig, iMMFDevSound->SetConfigL(capabilities));
sl@0: 					if (errConfig != KErrNone)
sl@0: 						{
sl@0: 						ERR_PRINTF2(_L("CMMFDevSound::SetConfigL() left with error = %d"), errConfig);
sl@0: 						StopTest(errConfig);
sl@0: 						break;
sl@0: 						}
sl@0: 					}
sl@0: 				// Initialize audio device and starts the playing process
sl@0: 				INFO_PRINTF1(_L("Calling CMMFDevSound::PlayInitL()"));
sl@0: 				TRAPD(errPlay, iMMFDevSound->PlayInitL());
sl@0: 				if (errPlay != KErrNone)
sl@0: 					{
sl@0: 					ERR_PRINTF2(_L("CMMFDevSound::PlayInitL() left with error = %d"), errPlay);
sl@0: 					StopTest(errPlay);
sl@0: 					break;
sl@0: 					}
sl@0: 				INFO_PRINTF1(_L("State: EStatePlaying"));
sl@0: 				iPlayState = EStatePlaying;
sl@0: 				}
sl@0: 			else if (aDevSoundEvent == EEventInitCompletePlay && aError != KErrNone)
sl@0: 				{
sl@0: 				ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError);
sl@0: 				StopTest(aError);
sl@0: 				}
sl@0: 			else
sl@0: 				{
sl@0: 				ERR_PRINTF2(_L("DevSound EEventInitCompletePlay not received as expected. Received event: %d"), aDevSoundEvent);
sl@0: 				StopTest(aError, EFail);
sl@0: 				}
sl@0: 
sl@0: 			break;
sl@0: 
sl@0: 			}
sl@0: 
sl@0: 		case EStatePlaying:
sl@0: 			{
sl@0: 			__ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundGetSampleNumsAfterStop"),EFsmIncorrectErrorPassed));
sl@0: 			if (aDevSoundEvent == EEventBTBF)
sl@0: 				{
sl@0: 				// Fill the buffer with audio data and play the data in the buffer
sl@0: 				CMMFDataBuffer* buffer = static_cast <CMMFDataBuffer*> (iBuffer);
sl@0: 				TInt err = iFile.Read(buffer->Data());
sl@0: 				if (err != KErrNone)
sl@0: 					{
sl@0: 					ERR_PRINTF2(_L("ERROR : iFile.Read() failed with %d"), err);
sl@0: 					StopTest(err);
sl@0: 					break;
sl@0: 					}
sl@0: 				if (buffer->Data().Length() != buffer->RequestSize())
sl@0: 					{
sl@0: 					INFO_PRINTF3(_L("Data length copied from file = %d. Expected = %d. Must be EOF."), buffer->Data().Length(), buffer->RequestSize());
sl@0: 					iBuffer->SetLastBuffer(ETrue);
sl@0: 					}
sl@0: 
sl@0: 				if (iCheckTimer)
sl@0: 					{
sl@0: 					iTimer->Start(KMicroSecsInTenSecs, 0, iCallBack);
sl@0: 					}
sl@0: 				iCheckTimer = EFalse;
sl@0: 				// Playing data in the buffer at the current volume
sl@0: 				iMMFDevSound->PlayData();
sl@0: 				iBufferCount++;
sl@0: 				}
sl@0: 			else if (aDevSoundEvent == EEventPlayTimerComplete)
sl@0: 				{
sl@0: 				iMMFDevSound->Stop();
sl@0: 				iPlayState = EStatePlayStopped;
sl@0: 				INFO_PRINTF1(_L("EStatePlayStopped"));
sl@0: 				}
sl@0: 			else
sl@0: 				{
sl@0: 				ERR_PRINTF2(_L("DevSound EEventBTBF not received as expected. Received event: %d"), aDevSoundEvent);
sl@0: 				StopTest(aError, EFail);
sl@0: 				}
sl@0: 			break;
sl@0: 			}
sl@0: 
sl@0: 		case EStatePlayStopped:
sl@0: 			{
sl@0: 			__ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundGetSampleNumsAfterStop"),EFsmIncorrectErrorPassed));
sl@0: 			if (aDevSoundEvent == EEventPlayStopped)
sl@0: 				{
sl@0: 				INFO_PRINTF1(_L("Getting SamplesPlayed after Stop"));
sl@0: 				TInt numSamplesStop = iMMFDevSound->SamplesPlayed();
sl@0: 				INFO_PRINTF2(_L("SamplesPlayed after Stop: %d"), numSamplesStop);
sl@0: 				if (numSamplesStop == KNULLSamples)
sl@0: 					{
sl@0: 					ERR_PRINTF2(_L("Number of samples played after stop should not be %d"), KNULLSamples );
sl@0: 					StopTest(KErrGeneral);
sl@0: 					}
sl@0: 				else
sl@0: 					{
sl@0: 					INFO_PRINTF2(_L("Number of samples played after stop is greater than %d"), KNULLSamples );
sl@0: 					StopTest(KErrNone);
sl@0: 					}
sl@0: 				}
sl@0: 			else
sl@0: 				{
sl@0: 				ERR_PRINTF2(_L("Invalid DevSound event received: %d"), aDevSoundEvent);
sl@0: 				StopTest(KErrGeneral);
sl@0: 				}
sl@0: 			}
sl@0: 			break;
sl@0: 
sl@0: 		default:
sl@0: 			{
sl@0: 			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iPlayState);
sl@0: 			StopTest(KErrGeneral);
sl@0: 			}
sl@0: 		}
sl@0: 
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * DoTimerCallback
sl@0:  *
sl@0:  */
sl@0: void RStepA3FDevSoundGetSampleNumsAfterStop::DoTimerCallback()
sl@0: 	{
sl@0: 	iTimer->Cancel(); // only really wanted a one-shot
sl@0: 	if(!iCheckTimer)
sl@0: 		{
sl@0: 		Fsm(EEventPlayTimerComplete, KErrNone);
sl@0: 		Fsm(EEventPlayStopped, KErrNone);
sl@0: 		}
sl@0: 
sl@0: 	}
sl@0: 
sl@0: //
sl@0: // RStepA3FDevSoundCancelInitializePlay
sl@0: //
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * RStepA3FDevSoundCancelInitializePlay - Test step constructor
sl@0:  *
sl@0:  */
sl@0: RStepA3FDevSoundCancelInitializePlay::RStepA3FDevSoundCancelInitializePlay(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType)
sl@0: :RTestStepA3FDevSoundPlayBase(aTestName, aSectName, aInputDataType)
sl@0: 	{
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * NewL
sl@0:  *
sl@0:  */
sl@0: RStepA3FDevSoundCancelInitializePlay* RStepA3FDevSoundCancelInitializePlay::NewL(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType)
sl@0: 	{
sl@0: 	RStepA3FDevSoundCancelInitializePlay* self = new (ELeave) RStepA3FDevSoundCancelInitializePlay(aTestName, aSectName, aInputDataType);
sl@0: 	return self;
sl@0: 
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * KickoffTestL
sl@0:  * - Starts the test
sl@0:  *
sl@0:  */
sl@0: void RStepA3FDevSoundCancelInitializePlay::KickoffTestL()
sl@0: 	{
sl@0: 	// Create instance of CMMFDevSound
sl@0: 	INFO_PRINTF1(_L("--- Creating DevSound object..."));
sl@0: 	iMMFDevSound = CMMFDevSound::NewL();
sl@0: 
sl@0: 	iTimer = CPeriodic::NewL(CActive::EPriorityHigh);
sl@0: 	iCallBack = TCallBack(TimerCallback, this);
sl@0: 	
sl@0: 	//Display the name of Codec being used
sl@0: 	DisplayCodecInfo();
sl@0: 	CheckConfigAndFourCCUsage();
sl@0: 
sl@0: 	Fsm(EEventPlayStart,KErrNone); // call to start the DevSound finite state machine for playing
sl@0: 
sl@0: 	}
sl@0: 	
sl@0: /*
sl@0:  *
sl@0:  * InitializeComplete
sl@0:  *
sl@0:  */
sl@0: void RStepA3FDevSoundCancelInitializePlay::InitializeComplete(TInt aError)
sl@0: 	{
sl@0: 	INFO_PRINTF1(_L("InitializeComplete callback was received. This is not the expected behaviour"));
sl@0: 	INFO_PRINTF1(_L("InitializeL was not cancelled"));
sl@0: 	StopTest(aError, EFail);
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * DoTimerCallback
sl@0:  *
sl@0:  */
sl@0: void RStepA3FDevSoundCancelInitializePlay::DoTimerCallback()
sl@0: 	{
sl@0: 	iTimer->Cancel(); // only really wanted a one-shot
sl@0: 	INFO_PRINTF1(_L("InitializeComplete callback was not received. This is the expected behaviour"));
sl@0: 	INFO_PRINTF1(_L("Use SetConfigL to verify that DevSound has not been initialised"));
sl@0: 	SetSampleRateAndChannelMode();
sl@0: 	TMMFCapabilities capabilities;
sl@0: 	capabilities.iRate = ConvertDesToTMMFSampleRate(iSampleRate);
sl@0: 	capabilities.iChannels = ConvertDesToTMMFMonoStereo(iMonoStereo);
sl@0: 
sl@0: 	TRAPD(errConfig, iMMFDevSound->SetConfigL(capabilities));	
sl@0: 	if(errConfig == KErrNotReady)
sl@0: 		{
sl@0: 		INFO_PRINTF2(_L("SetConfigL returned with %d as expected"), errConfig);
sl@0: 		INFO_PRINTF1(_L("InitializeL was cancelled successfully"));
sl@0: 		StopTest(KErrNone);
sl@0: 		}
sl@0: 	else if (errConfig == KErrNone)
sl@0: 		{
sl@0: 		INFO_PRINTF2(_L("SetConfigL returned with KErrNone %d"), errConfig);
sl@0: 		INFO_PRINTF1(_L("InitializeL was not cancelled successfully"));
sl@0: 		StopTest(errConfig, EFail);
sl@0: 		}
sl@0: 	else
sl@0: 		{
sl@0: 		INFO_PRINTF2(_L("SetConfigL returned with unexpected error %d"), errConfig);
sl@0: 		StopTest(errConfig, EFail);
sl@0: 		}
sl@0: 	}
sl@0: 	
sl@0: /*
sl@0:  *
sl@0:  * Fsm
sl@0:  *	- Executes playing events of DevSound in sequence
sl@0:  *
sl@0:  */
sl@0: void RStepA3FDevSoundCancelInitializePlay::Fsm(TDevSoundPlayEvents aDevSoundEvent, TInt aError)
sl@0: 	{
sl@0: 	switch (iPlayState)
sl@0: 		{
sl@0: 		case EStatePlayStart:
sl@0: 			{
sl@0: 			__ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundCancelInitializePlay"),EFsmIncorrectErrorPassed));
sl@0: 			if (aDevSoundEvent == EEventPlayStart)
sl@0: 				{
sl@0: 				// Initializing DevSound object for playing mode to process audio data via desired FourCC code
sl@0: 				INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL"));
sl@0: 				TInt err;
sl@0: 				if(iUseFourCC)
sl@0: 					{
sl@0: 					TRAP(err, iMMFDevSound->InitializeL(*this, iInputDataType, EMMFStatePlaying));
sl@0: 					}
sl@0: 				else
sl@0: 					{
sl@0: 					TRAP(err, iMMFDevSound->InitializeL(*this, EMMFStatePlaying));
sl@0: 					}
sl@0: 				if (err != KErrNone)
sl@0: 					{
sl@0: 					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
sl@0: 					StopTest(err);
sl@0: 					break;
sl@0: 					}
sl@0: 				else
sl@0: 					{
sl@0: 					INFO_PRINTF1(_L("State: EStatePlayInitializing"));
sl@0: 					iPlayState = EStatePlayInitializing;					
sl@0: 					INFO_PRINTF1(_L("Calling CMMFDevSound::CancelInitialize()"));
sl@0: 					iMMFDevSound->CancelInitialize();
sl@0: 					}
sl@0: 					INFO_PRINTF1(_L("Start timer to wait for InitializeComplete"));
sl@0: 					iTimer->Start(KMicroSecsInTenSecs, 0, iCallBack);	
sl@0: 				}
sl@0: 			else
sl@0: 				{
sl@0: 				ERR_PRINTF2(_L("DevSound EEventPlayStart not received as expected. Received event: %d"), aDevSoundEvent);
sl@0: 				StopTest(aError, EFail);
sl@0: 				}
sl@0: 			break;
sl@0: 			}
sl@0: 		default:
sl@0: 			{
sl@0: 			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iPlayState);
sl@0: 			StopTest(KErrGeneral);
sl@0: 			}
sl@0: 		}
sl@0: 
sl@0: 	}
sl@0: 
sl@0: //
sl@0: // RStepA3FDevSoundNegCancelInitializePlay
sl@0: //
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * RStepA3FDevSoundNegCancelInitializePlay - Test step constructor
sl@0:  *
sl@0:  */
sl@0: RStepA3FDevSoundNegCancelInitializePlay::RStepA3FDevSoundNegCancelInitializePlay(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType)
sl@0: :RTestStepA3FDevSoundPlayBase(aTestName, aSectName, aInputDataType)
sl@0: 	{
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * NewL
sl@0:  *
sl@0:  */
sl@0: RStepA3FDevSoundNegCancelInitializePlay* RStepA3FDevSoundNegCancelInitializePlay::NewL(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType)
sl@0: 	{
sl@0: 	RStepA3FDevSoundNegCancelInitializePlay* self = new (ELeave) RStepA3FDevSoundNegCancelInitializePlay(aTestName, aSectName, aInputDataType);
sl@0: 	return self;
sl@0: 
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * KickoffTestL
sl@0:  * - Starts the test
sl@0:  *
sl@0:  */
sl@0: void RStepA3FDevSoundNegCancelInitializePlay::KickoffTestL()
sl@0: 	{
sl@0: 	// Create instance of CMMFDevSound
sl@0: 	INFO_PRINTF1(_L("--- Creating DevSound object..."));
sl@0: 	iMMFDevSound = CMMFDevSound::NewL();
sl@0: 
sl@0: 	//Display the name of Codec being used
sl@0: 	DisplayCodecInfo();
sl@0: 	if(!GetBoolFromConfig(iSectName, _L("UseFourCC"), iUseFourCC))
sl@0: 		{
sl@0: 		TPtrC keyName(_L("UseFourCC"));
sl@0: 		ERR_PRINTF3(_L("Error in getting UseFourCC flag value from config file in %S section via the %S key field."), &iSectName, &keyName);
sl@0: 		StopTest(KErrPathNotFound);
sl@0: 		return;
sl@0: 		}
sl@0: 
sl@0: 	Fsm(EEventPlayStart,KErrNone); // call to start the DevSound finite state machine for playing
sl@0: 
sl@0: 	}
sl@0: 	
sl@0: /*
sl@0:  *
sl@0:  * InitializeComplete
sl@0:  *
sl@0:  */
sl@0: void RStepA3FDevSoundNegCancelInitializePlay::InitializeComplete(TInt aError)
sl@0: 	{
sl@0: 	if (aError == KErrNone)
sl@0: 		{
sl@0: 		INFO_PRINTF1(_L("InitializeComplete returned with KErrNone"));
sl@0: 		INFO_PRINTF1(_L("Calling CancelInitialize after InitializeComplete"));
sl@0: 		TInt err;
sl@0: 		err = iMMFDevSound->CancelInitialize();
sl@0: 		if (err == KErrNotReady)
sl@0: 			{
sl@0: 			INFO_PRINTF1(_L("CancelInitialize returned with KErrNotReady as expected"));
sl@0: 			StopTest(aError);
sl@0: 			}
sl@0: 		else
sl@0: 			{
sl@0: 			INFO_PRINTF2(_L("CancelInitialize return with error %d instead of KErrNotReady as expected"), aError);
sl@0: 			StopTest(aError, EFail);
sl@0: 			}
sl@0: 		}
sl@0: 	else
sl@0: 		{
sl@0: 		INFO_PRINTF2(_L("InitializeComplete returned with error %d"), aError);
sl@0: 		StopTest(aError, EFail);
sl@0: 		}
sl@0: 	
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * Fsm
sl@0:  *	- Executes playing events of DevSound in sequence
sl@0:  *
sl@0:  */
sl@0: void RStepA3FDevSoundNegCancelInitializePlay::Fsm(TDevSoundPlayEvents aDevSoundEvent, TInt aError)
sl@0: 	{
sl@0: 	switch (iPlayState)
sl@0: 		{
sl@0: 		case EStatePlayStart:
sl@0: 			{
sl@0: 			__ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundNegCancelInitializePlay"),EFsmIncorrectErrorPassed));
sl@0: 			if (aDevSoundEvent == EEventPlayStart)
sl@0: 				{
sl@0: 				// Initializing DevSound object for playing mode to process audio data via desired FourCC code
sl@0: 				INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL"));
sl@0: 				TInt err;
sl@0: 				if(iUseFourCC)
sl@0: 					{
sl@0: 					TRAP(err, iMMFDevSound->InitializeL(*this, iInputDataType, EMMFStatePlaying));
sl@0: 					}
sl@0: 				else
sl@0: 					{
sl@0: 					TRAP(err, iMMFDevSound->InitializeL(*this, EMMFStatePlaying));
sl@0: 					}
sl@0: 				if (err != KErrNone)
sl@0: 					{
sl@0: 					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
sl@0: 					StopTest(err);
sl@0: 					break;
sl@0: 					}
sl@0: 				INFO_PRINTF1(_L("State: EStatePlayInitializing"));
sl@0: 				iPlayState = EStatePlayInitializing;					
sl@0: 				}
sl@0: 			else
sl@0: 				{
sl@0: 				ERR_PRINTF2(_L("DevSound EEventPlayStart not received as expected. Received event: %d"), aDevSoundEvent);
sl@0: 				StopTest(aError, EFail);
sl@0: 				}
sl@0: 			break;
sl@0: 			}
sl@0: 
sl@0: 		default:
sl@0: 			{
sl@0: 			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iPlayState);
sl@0: 			StopTest(KErrGeneral);
sl@0: 			}
sl@0: 		}
sl@0: 
sl@0: 	}
sl@0: 
sl@0: //
sl@0: // RStepA3FDevSoundEmptyBuffersInCreatedState
sl@0: //
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * RStepA3FDevSoundEmptyBuffersInCreatedState - Test step constructor
sl@0:  *
sl@0:  */
sl@0: RStepA3FDevSoundEmptyBuffersInCreatedState::RStepA3FDevSoundEmptyBuffersInCreatedState(const TDesC& aTestName)
sl@0: :RTestStepA3FDevSoundPlayBase(aTestName)
sl@0: 	{
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * NewL
sl@0:  *
sl@0:  */
sl@0: RStepA3FDevSoundEmptyBuffersInCreatedState* RStepA3FDevSoundEmptyBuffersInCreatedState::NewL(const TDesC& aTestName)
sl@0: 	{
sl@0: 	RStepA3FDevSoundEmptyBuffersInCreatedState* self = new (ELeave) RStepA3FDevSoundEmptyBuffersInCreatedState(aTestName);
sl@0: 	return self;
sl@0: 
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * KickoffTestL
sl@0:  * - Starts the test
sl@0:  *
sl@0:  */
sl@0: void RStepA3FDevSoundEmptyBuffersInCreatedState::KickoffTestL()
sl@0: 	{
sl@0: 	// Create instance of CMMFDevSound
sl@0: 	INFO_PRINTF1(_L("--- Creating DevSound object..."));
sl@0: 	iMMFDevSound = CMMFDevSound::NewL();
sl@0: 	
sl@0: 	//Display the name of Codec being used
sl@0: 	DisplayCodecInfo();
sl@0: 
sl@0: 	Fsm(EEventPlayStart,KErrNone); // call to start the DevSound finite state machine for playing
sl@0: 
sl@0: 	}
sl@0: 	
sl@0: /*
sl@0:  *
sl@0:  * Fsm
sl@0:  *	- Executes playing events of DevSound in sequence
sl@0:  *
sl@0:  */
sl@0: void RStepA3FDevSoundEmptyBuffersInCreatedState::Fsm(TDevSoundPlayEvents aDevSoundEvent, TInt aError)
sl@0: 	{
sl@0: 	switch (iPlayState)
sl@0: 		{
sl@0: 		case EStatePlayStart:
sl@0: 			{
sl@0: 			__ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundEmptyBuffersInCreatedState"),EFsmIncorrectErrorPassed));
sl@0: 			if (aDevSoundEvent == EEventPlayStart)
sl@0: 				{
sl@0: 				// Calling EmptyBuffers
sl@0: 				INFO_PRINTF1(_L("Calling CMMFDevSound::EmptyBuffers()"));
sl@0: 				TInt err;
sl@0: 				err = iMMFDevSound->EmptyBuffers();
sl@0: 				if (err == KErrNotReady)
sl@0: 					{
sl@0: 					ERR_PRINTF2(_L("CMMFDevSound::EmptyBuffers() returned expected error = %d"), err);
sl@0: 					StopTest();
sl@0: 					}
sl@0: 				else
sl@0: 					{
sl@0: 					ERR_PRINTF2(_L("CMMFDevSound::EmptyBuffers() did not return KErrNotReady as expected. Returned with unexpected error = %d"), err);
sl@0: 					StopTest(err);
sl@0: 					}
sl@0: 				}
sl@0: 			else
sl@0: 				{
sl@0: 				ERR_PRINTF2(_L("DevSound EEventPlayStart not received as expected. Received event: %d"), aDevSoundEvent);
sl@0: 				StopTest(aError, EFail);
sl@0: 				}
sl@0: 			break;
sl@0: 			}
sl@0: 		default:
sl@0: 			{
sl@0: 			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iPlayState);
sl@0: 			StopTest(KErrGeneral);
sl@0: 			}
sl@0: 		}
sl@0: 
sl@0: 	}
sl@0: 
sl@0: //
sl@0: // RStepA3FDevSoundEmptyBuffersInInitializedState
sl@0: //
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * RStepA3FDevSoundEmptyBuffersInCreatedState - Test step constructor
sl@0:  *
sl@0:  */
sl@0: RStepA3FDevSoundEmptyBuffersInInitializedState::RStepA3FDevSoundEmptyBuffersInInitializedState(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType)
sl@0: :RTestStepA3FDevSoundPlayBase(aTestName, aSectName, aInputDataType)
sl@0: 	{
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * NewL
sl@0:  *
sl@0:  */
sl@0: RStepA3FDevSoundEmptyBuffersInInitializedState* RStepA3FDevSoundEmptyBuffersInInitializedState::NewL(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType)
sl@0: 	{
sl@0: 	RStepA3FDevSoundEmptyBuffersInInitializedState* self = new (ELeave) RStepA3FDevSoundEmptyBuffersInInitializedState(aTestName, aSectName, aInputDataType);
sl@0: 	return self;
sl@0: 
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * KickoffTestL
sl@0:  * - Starts the test
sl@0:  *
sl@0:  */
sl@0: void RStepA3FDevSoundEmptyBuffersInInitializedState::KickoffTestL()
sl@0: 	{
sl@0: 	// Create instance of CMMFDevSound
sl@0: 	INFO_PRINTF1(_L("--- Creating DevSound object..."));
sl@0: 	iMMFDevSound = CMMFDevSound::NewL();
sl@0: 	
sl@0: 	//Display the name of Codec being used
sl@0: 	DisplayCodecInfo();
sl@0: 	CheckConfigAndFourCCUsage();
sl@0: 
sl@0: 	Fsm(EEventPlayStart,KErrNone); // call to start the DevSound finite state machine for playing
sl@0: 
sl@0: 	}
sl@0: 	
sl@0: /*
sl@0:  *
sl@0:  * Fsm
sl@0:  *	- Executes playing events of DevSound in sequence
sl@0:  *
sl@0:  */
sl@0: void RStepA3FDevSoundEmptyBuffersInInitializedState::Fsm(TDevSoundPlayEvents aDevSoundEvent, TInt aError)
sl@0: 	{
sl@0: 	switch (iPlayState)
sl@0: 		{
sl@0: 		case EStatePlayStart:
sl@0: 			{
sl@0: 			__ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundEmptyBuffersInCreatedState"),EFsmIncorrectErrorPassed));
sl@0: 			if (aDevSoundEvent == EEventPlayStart)
sl@0: 				{
sl@0: 				// Initializing DevSound object for playing mode to process audio data via desired FourCC code
sl@0: 				INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL"));
sl@0: 				TInt err;
sl@0: 				if(iUseFourCC)
sl@0: 					{
sl@0: 					TRAP(err, iMMFDevSound->InitializeL(*this, iInputDataType, EMMFStatePlaying));
sl@0: 					}
sl@0: 				else
sl@0: 					{
sl@0: 					TRAP(err, iMMFDevSound->InitializeL(*this, EMMFStatePlaying));
sl@0: 					}
sl@0: 				if (err != KErrNone)
sl@0: 					{
sl@0: 					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
sl@0: 					StopTest(err);
sl@0: 					break;
sl@0: 					}
sl@0: 				INFO_PRINTF1(_L("State: EStatePlayInitializing"));
sl@0: 				iPlayState = EStatePlayInitializing;
sl@0: 				}
sl@0: 			else
sl@0: 				{
sl@0: 				ERR_PRINTF2(_L("DevSound EEventPlayStart not received as expected. Received event: %d"), aDevSoundEvent);
sl@0: 				StopTest(aError, EFail);
sl@0: 				}
sl@0: 			break;
sl@0: 			}
sl@0: 		case EStatePlayInitializing:
sl@0: 			{
sl@0: 			if (aDevSoundEvent == EEventInitCompletePlay && aError == KErrNone)
sl@0: 				{
sl@0: 				// Calling EmptyBuffers
sl@0: 				INFO_PRINTF1(_L("Calling CMMFDevSound::EmptyBuffers()"));
sl@0: 				TInt err;
sl@0: 				err = iMMFDevSound->EmptyBuffers();
sl@0: 				if (err == KErrNotReady)
sl@0: 					{
sl@0: 					ERR_PRINTF2(_L("CMMFDevSound::EmptyBuffers() returned expected error = %d"), err);
sl@0: 					StopTest();
sl@0: 					}
sl@0: 				else
sl@0: 					{
sl@0: 					ERR_PRINTF2(_L("CMMFDevSound::EmptyBuffers() did not return KErrNotReady as expected. Returned with unexpected error = %d"), err);
sl@0: 					StopTest(err);
sl@0: 					}
sl@0: 				}
sl@0: 			else if (aDevSoundEvent == EEventInitCompletePlay && aError != KErrNone)
sl@0: 				{
sl@0: 				ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError);
sl@0: 				StopTest(aError);
sl@0: 				}
sl@0: 			else
sl@0: 				{
sl@0: 				ERR_PRINTF2(_L("DevSound EEventInitCompletePlay not received as expected. Received event: %d"), aDevSoundEvent);
sl@0: 				StopTest(aError, EFail);
sl@0: 				}
sl@0: 			break;
sl@0: 			}
sl@0: 		default:
sl@0: 			{
sl@0: 			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iPlayState);
sl@0: 			StopTest(KErrGeneral);
sl@0: 			}
sl@0: 		}
sl@0: 	}
sl@0: 
sl@0: //
sl@0: // RStepA3FDevSoundEmptyBuffersInInitializingState
sl@0: //
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * RStepA3FDevSoundCancelInitializePlay - Test step constructor
sl@0:  *
sl@0:  */
sl@0: RStepA3FDevSoundEmptyBuffersInInitializingState::RStepA3FDevSoundEmptyBuffersInInitializingState(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType)
sl@0: :RTestStepA3FDevSoundPlayBase(aTestName, aSectName, aInputDataType)
sl@0: 	{
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * NewL
sl@0:  *
sl@0:  */
sl@0: RStepA3FDevSoundEmptyBuffersInInitializingState* RStepA3FDevSoundEmptyBuffersInInitializingState::NewL(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType)
sl@0: 	{
sl@0: 	RStepA3FDevSoundEmptyBuffersInInitializingState* self = new (ELeave) RStepA3FDevSoundEmptyBuffersInInitializingState(aTestName, aSectName, aInputDataType);
sl@0: 	return self;
sl@0: 
sl@0: 	}
sl@0: 
sl@0: /*
sl@0:  *
sl@0:  * KickoffTestL
sl@0:  * - Starts the test
sl@0:  *
sl@0:  */
sl@0: void RStepA3FDevSoundEmptyBuffersInInitializingState::KickoffTestL()
sl@0: 	{
sl@0: 	// Create instance of CMMFDevSound
sl@0: 	INFO_PRINTF1(_L("--- Creating DevSound object..."));
sl@0: 	iMMFDevSound = CMMFDevSound::NewL();
sl@0: 	
sl@0: 	//Display the name of Codec being used
sl@0: 	DisplayCodecInfo();
sl@0: 	CheckConfigAndFourCCUsage();
sl@0: 
sl@0: 	Fsm(EEventPlayStart,KErrNone); // call to start the DevSound finite state machine for playing
sl@0: 
sl@0: 	}
sl@0: 	
sl@0: /*
sl@0:  *
sl@0:  * InitializeComplete
sl@0:  *
sl@0:  */
sl@0: void RStepA3FDevSoundEmptyBuffersInInitializingState::InitializeComplete(TInt aError)
sl@0: 	{
sl@0: 	INFO_PRINTF1(_L("InitializeComplete callback was received. This is not the expected behaviour"));
sl@0: 	INFO_PRINTF1(_L("EmptyBuffers was not called before InitializeComplete "));
sl@0: 	StopTest(aError, EFail);
sl@0: 	}
sl@0: 	
sl@0: /*
sl@0:  *
sl@0:  * Fsm
sl@0:  *	- Executes playing events of DevSound in sequence
sl@0:  *
sl@0:  */
sl@0: void RStepA3FDevSoundEmptyBuffersInInitializingState::Fsm(TDevSoundPlayEvents aDevSoundEvent, TInt aError)
sl@0: 	{
sl@0: 	switch (iPlayState)
sl@0: 		{
sl@0: 		case EStatePlayStart:
sl@0: 			{
sl@0: 			__ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundCancelInitializePlay"),EFsmIncorrectErrorPassed));
sl@0: 			if (aDevSoundEvent == EEventPlayStart)
sl@0: 				{
sl@0: 				// Initializing DevSound object for playing mode to process audio data via desired FourCC code
sl@0: 				INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL"));
sl@0: 				TInt err;
sl@0: 				if(iUseFourCC)
sl@0: 					{
sl@0: 					TRAP(err, iMMFDevSound->InitializeL(*this, iInputDataType, EMMFStatePlaying));
sl@0: 					}
sl@0: 				else
sl@0: 					{
sl@0: 					TRAP(err, iMMFDevSound->InitializeL(*this, EMMFStatePlaying));
sl@0: 					}
sl@0: 				if (err != KErrNone)
sl@0: 					{
sl@0: 					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
sl@0: 					StopTest(err);
sl@0: 					break;
sl@0: 					}
sl@0: 				else
sl@0: 					{
sl@0: 					INFO_PRINTF1(_L("State: EStatePlayInitializing"));
sl@0: 					iPlayState = EStatePlayInitializing;					
sl@0: 					INFO_PRINTF1(_L("Calling CMMFDevSound::EmptyBuffers()"));
sl@0: 					TInt err;
sl@0: 					err = iMMFDevSound->EmptyBuffers();
sl@0: 					if (err == KErrNotReady)
sl@0: 						{
sl@0: 						ERR_PRINTF2(_L("CMMFDevSound::EmptyBuffers() returned expected error = %d"), err);
sl@0: 						StopTest();
sl@0: 						}
sl@0: 					else
sl@0: 						{
sl@0: 						ERR_PRINTF2(_L("CMMFDevSound::EmptyBuffers() did not return KErrNotReady as expected. Returned with unexpected error = %d"), err);
sl@0: 						StopTest(err);
sl@0: 						}
sl@0: 					}
sl@0: 				}
sl@0: 			else
sl@0: 				{
sl@0: 				ERR_PRINTF2(_L("DevSound EEventPlayStart not received as expected. Received event: %d"), aDevSoundEvent);
sl@0: 				StopTest(aError, EFail);
sl@0: 				}
sl@0: 			break;
sl@0: 			}
sl@0: 		default:
sl@0: 			{
sl@0: 			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iPlayState);
sl@0: 			StopTest(KErrGeneral);
sl@0: 			}
sl@0: 		}
sl@0: 	}