os/mm/devsound/a3fintegrationtest/src/tsi_a3f_devsound_play.cpp
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
// Implementation of Integraton test step classes for A3f DevSound Play test cases.
sl@0
    15
// 
sl@0
    16
//
sl@0
    17
sl@0
    18
#include "tsi_a3f_devsound_play.h"
sl@0
    19
sl@0
    20
/*
sl@0
    21
 *
sl@0
    22
 * RTestStepA3FDevSoundPlayBase - Test step constructor
sl@0
    23
 *
sl@0
    24
 */
sl@0
    25
RTestStepA3FDevSoundPlayBase::RTestStepA3FDevSoundPlayBase(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType)
sl@0
    26
:RAsyncTestStep(),
sl@0
    27
 iMMFDevSound(NULL),
sl@0
    28
 iBuffer(NULL),
sl@0
    29
 iTimer(NULL),
sl@0
    30
 iCallBack(NULL, NULL),
sl@0
    31
 iInputDataType(aInputDataType),
sl@0
    32
 iSectName(aSectName),
sl@0
    33
 iFilename(KNullDesC),
sl@0
    34
 iSampleRate(KNullDesC),
sl@0
    35
 iMonoStereo(KNullDesC),
sl@0
    36
 iPlayState(EStatePlayStart),
sl@0
    37
 iBufferCount(0),
sl@0
    38
 iConfig(EFalse),
sl@0
    39
 iInvalidConfig(EFalse),
sl@0
    40
 iUseFourCC(EFalse)
sl@0
    41
	{
sl@0
    42
	// From RTestStep
sl@0
    43
	iTestStepName = aTestName; // store the name of the test case
sl@0
    44
sl@0
    45
	}
sl@0
    46
sl@0
    47
/*
sl@0
    48
 *
sl@0
    49
 * RTestStepA3FDevSoundPlayBase - Test step constructor
sl@0
    50
 *
sl@0
    51
 */
sl@0
    52
RTestStepA3FDevSoundPlayBase::RTestStepA3FDevSoundPlayBase(const TDesC& aTestName, const TDesC& aSectName)
sl@0
    53
:RAsyncTestStep(),
sl@0
    54
 iMMFDevSound(NULL),
sl@0
    55
 iBuffer(NULL),
sl@0
    56
 iTimer(NULL),
sl@0
    57
 iCallBack(NULL, NULL),
sl@0
    58
 iInputDataType(KMMFFourCCCodePCM16),
sl@0
    59
 iSectName(aSectName),
sl@0
    60
 iFilename(KNullDesC),
sl@0
    61
 iSampleRate(KNullDesC),
sl@0
    62
 iMonoStereo(KNullDesC),
sl@0
    63
 iPlayState(EStatePlayStart),
sl@0
    64
 iBufferCount(0),
sl@0
    65
 iConfig(EFalse),
sl@0
    66
 iInvalidConfig(EFalse),
sl@0
    67
 iUseFourCC(EFalse)
sl@0
    68
	{
sl@0
    69
	// From RTestStep
sl@0
    70
	iTestStepName = aTestName; // store the name of the test case
sl@0
    71
sl@0
    72
	}
sl@0
    73
sl@0
    74
/*
sl@0
    75
 *
sl@0
    76
 * RTestStepA3FDevSoundPlayBase - Test step constructor
sl@0
    77
 *
sl@0
    78
 */
sl@0
    79
RTestStepA3FDevSoundPlayBase::RTestStepA3FDevSoundPlayBase(const TDesC& aTestName, const TFourCC& aInputDataType)
sl@0
    80
:RAsyncTestStep(),
sl@0
    81
 iMMFDevSound(NULL),
sl@0
    82
 iBuffer(NULL),
sl@0
    83
 iTimer(NULL),
sl@0
    84
 iCallBack(NULL, NULL),
sl@0
    85
 iInputDataType(aInputDataType),
sl@0
    86
 iSectName(KNullDesC),
sl@0
    87
 iFilename(KNullDesC),
sl@0
    88
 iSampleRate(KNullDesC),
sl@0
    89
 iMonoStereo(KNullDesC),
sl@0
    90
 iPlayState(EStatePlayStart),
sl@0
    91
 iBufferCount(0),
sl@0
    92
 iConfig(EFalse),
sl@0
    93
 iInvalidConfig(EFalse),
sl@0
    94
 iUseFourCC(EFalse)
sl@0
    95
	{
sl@0
    96
	// From RTestStep
sl@0
    97
	iTestStepName = aTestName; // store the name of the test case
sl@0
    98
sl@0
    99
	}
sl@0
   100
sl@0
   101
sl@0
   102
/*
sl@0
   103
 *
sl@0
   104
 * RTestStepA3FDevSoundPlayBase - Test step constructor
sl@0
   105
 *
sl@0
   106
 */
sl@0
   107
RTestStepA3FDevSoundPlayBase::RTestStepA3FDevSoundPlayBase(const TDesC& aTestName)
sl@0
   108
:RAsyncTestStep(),
sl@0
   109
 iMMFDevSound(NULL),
sl@0
   110
 iBuffer(NULL),
sl@0
   111
 iTimer(NULL),
sl@0
   112
 iCallBack(NULL, NULL),
sl@0
   113
 iInputDataType(KMMFFourCCCodePCM16),
sl@0
   114
 iSectName(KNullDesC),
sl@0
   115
 iFilename(KNullDesC),
sl@0
   116
 iSampleRate(KNullDesC),
sl@0
   117
 iMonoStereo(KNullDesC),
sl@0
   118
 iPlayState(EStatePlayStart),
sl@0
   119
 iBufferCount(0),
sl@0
   120
 iConfig(EFalse),
sl@0
   121
 iInvalidConfig(EFalse),
sl@0
   122
 iUseFourCC(EFalse)
sl@0
   123
	{
sl@0
   124
	// From RTestStep
sl@0
   125
	iTestStepName = aTestName; // store the name of the test case
sl@0
   126
sl@0
   127
	}
sl@0
   128
sl@0
   129
/*
sl@0
   130
 *
sl@0
   131
 * KickoffTestL
sl@0
   132
 * - Starts the test
sl@0
   133
 *
sl@0
   134
 */
sl@0
   135
void RTestStepA3FDevSoundPlayBase::KickoffTestL()
sl@0
   136
	{
sl@0
   137
	TInt err = iFs.Connect();
sl@0
   138
	if (err != KErrNone)
sl@0
   139
		{
sl@0
   140
		ERR_PRINTF2(_L("Could not connect to Filesystem. Error = %d"), err);
sl@0
   141
		StopTest(err);
sl@0
   142
		}
sl@0
   143
sl@0
   144
	// Get the file name of the audio file to play
sl@0
   145
	#ifdef __WINS__
sl@0
   146
		if(!GetStringFromConfig(iSectName, _L("EmuPlayFile"), iFilename))
sl@0
   147
		{
sl@0
   148
		TPtrC keyName(_L("EmuPlayFile"));
sl@0
   149
		ERR_PRINTF3(_L("Error in getting file name from config file in %S section via the %S key field."), &iSectName, &keyName);
sl@0
   150
		StopTest(KErrPathNotFound);
sl@0
   151
		return;
sl@0
   152
		}
sl@0
   153
sl@0
   154
	#elif __MARM__
sl@0
   155
		if(!GetStringFromConfig(iSectName, _L("HwPlayFile"), iFilename))
sl@0
   156
		{
sl@0
   157
		TPtrC keyName(_L("HwPlayFile"));
sl@0
   158
		ERR_PRINTF3(_L("Error in getting file name from config file in %S section via the %S key field."), &iSectName, &keyName);
sl@0
   159
		StopTest(KErrPathNotFound);
sl@0
   160
		return;
sl@0
   161
		}
sl@0
   162
	#endif
sl@0
   163
sl@0
   164
	// Check if SetConfig and FourCC are to be used or not
sl@0
   165
	CheckConfigAndFourCCUsage();
sl@0
   166
sl@0
   167
	INFO_PRINTF2(_L("Section Name is :%S"), &iSectName);
sl@0
   168
sl@0
   169
	// Open using RFile for playback
sl@0
   170
	err = iFile.Open(iFs, iFilename, EFileRead);
sl@0
   171
	if (err != KErrNone)
sl@0
   172
		{
sl@0
   173
		ERR_PRINTF2(_L("Could not Open the File: Error = %d"), err);
sl@0
   174
		StopTest(err);
sl@0
   175
		}
sl@0
   176
sl@0
   177
	// Create instance of CMMFDevSound
sl@0
   178
	iMMFDevSound = CMMFDevSound::NewL();
sl@0
   179
sl@0
   180
	iTimer = CPeriodic::NewL(CActive::EPriorityHigh);
sl@0
   181
	iCallBack = TCallBack(TimerCallback, this);
sl@0
   182
sl@0
   183
	DoKickoffTestL();
sl@0
   184
	Fsm(EEventPlayStart, KErrNone); // call to initialize DevSound
sl@0
   185
sl@0
   186
	}
sl@0
   187
sl@0
   188
/*
sl@0
   189
 *
sl@0
   190
 * DoKickoffTestL
sl@0
   191
 *
sl@0
   192
 */
sl@0
   193
void RTestStepA3FDevSoundPlayBase::DoKickoffTestL()
sl@0
   194
	{
sl@0
   195
	INFO_PRINTF2(_L("File to be played -> %S"), &iFilename);
sl@0
   196
	DisplayCodecInfo();
sl@0
   197
sl@0
   198
	}
sl@0
   199
sl@0
   200
/*
sl@0
   201
 * ToneFinished
sl@0
   202
 *
sl@0
   203
 */
sl@0
   204
void RTestStepA3FDevSoundPlayBase::ToneFinished(TInt /*aError*/)
sl@0
   205
	{
sl@0
   206
	__ASSERT_ALWAYS(0,Panic(_L("RTestStepA3FDevSoundPlayBase"),EInvalidCallbackCall));
sl@0
   207
sl@0
   208
	}
sl@0
   209
sl@0
   210
/*
sl@0
   211
 *
sl@0
   212
 * RecordError
sl@0
   213
 *
sl@0
   214
 */
sl@0
   215
void RTestStepA3FDevSoundPlayBase::RecordError(TInt)
sl@0
   216
	{
sl@0
   217
	__ASSERT_ALWAYS(0,Panic(_L("RTestStepA3FDevSoundPlayBase"),EInvalidCallbackCall));
sl@0
   218
sl@0
   219
	}
sl@0
   220
sl@0
   221
/*
sl@0
   222
 *
sl@0
   223
 * BufferToBeEmptied
sl@0
   224
 *
sl@0
   225
 */
sl@0
   226
void RTestStepA3FDevSoundPlayBase::BufferToBeEmptied(CMMFBuffer* /*aBuffer*/)
sl@0
   227
	{
sl@0
   228
	__ASSERT_ALWAYS(0,Panic(_L("RTestStepA3FDevSoundPlayBase"),EInvalidCallbackCall));
sl@0
   229
sl@0
   230
	}
sl@0
   231
sl@0
   232
/*
sl@0
   233
 *
sl@0
   234
 * ConvertError
sl@0
   235
 *
sl@0
   236
 */
sl@0
   237
void RTestStepA3FDevSoundPlayBase::ConvertError(TInt /*aError*/)
sl@0
   238
	{
sl@0
   239
	__ASSERT_ALWAYS(0,Panic(_L("RTestStepA3FDevSoundPlayBase"),EInvalidCallbackCall));
sl@0
   240
sl@0
   241
	}
sl@0
   242
sl@0
   243
/*
sl@0
   244
 *
sl@0
   245
 * DeviceMessage
sl@0
   246
 *
sl@0
   247
 */
sl@0
   248
void RTestStepA3FDevSoundPlayBase::DeviceMessage(TUid /*aMessageType*/, const TDesC8& /*aMsg*/)
sl@0
   249
	{
sl@0
   250
	__ASSERT_ALWAYS(0,Panic(_L("RTestStepA3FDevSoundPlayBase"),EInvalidCallbackCall));
sl@0
   251
sl@0
   252
	}
sl@0
   253
sl@0
   254
/*
sl@0
   255
 *
sl@0
   256
 * TimerCallback
sl@0
   257
 *
sl@0
   258
 */
sl@0
   259
TInt RTestStepA3FDevSoundPlayBase::TimerCallback(TAny* aPtr)
sl@0
   260
	{
sl@0
   261
	static_cast<RTestStepA3FDevSoundPlayBase*>(aPtr)->DoTimerCallback();
sl@0
   262
	return KErrNone;
sl@0
   263
sl@0
   264
	}
sl@0
   265
sl@0
   266
/*
sl@0
   267
 *
sl@0
   268
 * DoTimerCallback
sl@0
   269
 *
sl@0
   270
 */
sl@0
   271
void RTestStepA3FDevSoundPlayBase::DoTimerCallback()
sl@0
   272
	{
sl@0
   273
	// The derived classes may provide the implementation if needed
sl@0
   274
	}
sl@0
   275
sl@0
   276
/*
sl@0
   277
 *
sl@0
   278
 * CallStopTest
sl@0
   279
 *
sl@0
   280
 */
sl@0
   281
void RTestStepA3FDevSoundPlayBase::CloseTest()
sl@0
   282
	{
sl@0
   283
	if (iMMFDevSound)
sl@0
   284
		{
sl@0
   285
		INFO_PRINTF1(_L("Deleting DevSound object..."));
sl@0
   286
		delete iMMFDevSound;
sl@0
   287
		iMMFDevSound = NULL;
sl@0
   288
		}
sl@0
   289
sl@0
   290
	if (iTimer)
sl@0
   291
		{
sl@0
   292
		delete iTimer;
sl@0
   293
		iTimer = NULL;
sl@0
   294
		}
sl@0
   295
sl@0
   296
	iFile.Close();
sl@0
   297
	iFs.Close();
sl@0
   298
sl@0
   299
	}
sl@0
   300
sl@0
   301
/*
sl@0
   302
 *
sl@0
   303
 * InitializeComplete
sl@0
   304
 *
sl@0
   305
 */
sl@0
   306
void RTestStepA3FDevSoundPlayBase::InitializeComplete(TInt aError)
sl@0
   307
	{
sl@0
   308
	if (iPlayState == EStatePlayInitializing)
sl@0
   309
		{
sl@0
   310
		Fsm(EEventInitCompletePlay,aError);
sl@0
   311
		}
sl@0
   312
sl@0
   313
	}
sl@0
   314
sl@0
   315
/*
sl@0
   316
 *
sl@0
   317
 * BufferToBeFilled
sl@0
   318
 *
sl@0
   319
 */
sl@0
   320
void RTestStepA3FDevSoundPlayBase::BufferToBeFilled(CMMFBuffer* aBuffer)
sl@0
   321
	{
sl@0
   322
	if (!aBuffer)
sl@0
   323
		{
sl@0
   324
		ERR_PRINTF1(_L("BufferToBeFilled callback received a NULL CMMFBuffer!"));
sl@0
   325
		StopTest(KErrGeneral);
sl@0
   326
		return;
sl@0
   327
		}
sl@0
   328
sl@0
   329
	iBuffer = aBuffer;
sl@0
   330
sl@0
   331
	// Call to continue the Play process
sl@0
   332
	Fsm(EEventBTBF,KErrNone);
sl@0
   333
sl@0
   334
	}
sl@0
   335
sl@0
   336
/*
sl@0
   337
 *
sl@0
   338
 * PlayError
sl@0
   339
 *
sl@0
   340
 */
sl@0
   341
void RTestStepA3FDevSoundPlayBase::PlayError(TInt aError)
sl@0
   342
	{
sl@0
   343
	INFO_PRINTF2(_L("DevSound called PlayError with error = %d"), aError);
sl@0
   344
	if ((iBuffer->LastBuffer()) && (aError == KErrUnderflow))
sl@0
   345
		{
sl@0
   346
		StopTest();
sl@0
   347
		}
sl@0
   348
	else
sl@0
   349
		{
sl@0
   350
		StopTest(aError, EFail);
sl@0
   351
		}
sl@0
   352
sl@0
   353
	}
sl@0
   354
sl@0
   355
/*
sl@0
   356
 *
sl@0
   357
 * Fsm
sl@0
   358
 *	- Executes playing events of DevSound in sequence
sl@0
   359
 *
sl@0
   360
 */
sl@0
   361
void RTestStepA3FDevSoundPlayBase::Fsm(TDevSoundPlayEvents aDevSoundEvent, TInt aError)
sl@0
   362
	{
sl@0
   363
	switch (iPlayState)
sl@0
   364
		{
sl@0
   365
		case EStatePlayStart:
sl@0
   366
			{
sl@0
   367
			__ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RTestStepA3FDevSoundPlayBase"),EFsmIncorrectErrorPassed));
sl@0
   368
			if (aDevSoundEvent == EEventPlayStart)
sl@0
   369
				{
sl@0
   370
				// Initializing DevSound object for playing mode to process audio data via desired FourCC code
sl@0
   371
				INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL"));
sl@0
   372
				TInt err;
sl@0
   373
				if(iUseFourCC)
sl@0
   374
					{
sl@0
   375
					TRAP(err, iMMFDevSound->InitializeL(*this, iInputDataType, EMMFStatePlaying));
sl@0
   376
					}
sl@0
   377
				else
sl@0
   378
					{
sl@0
   379
					TRAP(err, iMMFDevSound->InitializeL(*this, EMMFStatePlaying));
sl@0
   380
					}
sl@0
   381
				if (err != KErrNone)
sl@0
   382
					{
sl@0
   383
					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
sl@0
   384
					StopTest(err);
sl@0
   385
					break;
sl@0
   386
					}
sl@0
   387
sl@0
   388
sl@0
   389
				INFO_PRINTF1(_L("State: EStatePlayInitializing"));
sl@0
   390
				iPlayState = EStatePlayInitializing;
sl@0
   391
				}
sl@0
   392
			else
sl@0
   393
				{
sl@0
   394
				ERR_PRINTF2(_L("DevSound EEventPlayStart not received as expected. Received event: %d"), aDevSoundEvent);
sl@0
   395
				StopTest(aError, EFail);
sl@0
   396
				}
sl@0
   397
			break;
sl@0
   398
			}
sl@0
   399
sl@0
   400
		case EStatePlayInitializing:
sl@0
   401
			{
sl@0
   402
			if (aDevSoundEvent == EEventInitCompletePlay && aError == KErrNone)
sl@0
   403
				{
sl@0
   404
				if(iConfig)
sl@0
   405
					{
sl@0
   406
					// Set Devsound capability settings using CMMFDevSound::SetConfigL
sl@0
   407
					SetSampleRateAndChannelMode();
sl@0
   408
					TMMFCapabilities capabilities;
sl@0
   409
					capabilities.iRate = ConvertDesToTMMFSampleRate(iSampleRate);
sl@0
   410
					capabilities.iChannels = ConvertDesToTMMFMonoStereo(iMonoStereo);
sl@0
   411
sl@0
   412
					TRAPD(errConfig, iMMFDevSound->SetConfigL(capabilities));
sl@0
   413
					if (errConfig != KErrNone && !iInvalidConfig)
sl@0
   414
						{
sl@0
   415
						ERR_PRINTF2(_L("CMMFDevSound::SetConfigL() left with error = %d"), errConfig);
sl@0
   416
						StopTest(errConfig);
sl@0
   417
						return;
sl@0
   418
						}
sl@0
   419
					else if (errConfig == KErrArgument && iInvalidConfig)
sl@0
   420
						{
sl@0
   421
						ERR_PRINTF2(_L("CMMFDevSound::SetConfigL() left with expected error = %d"), errConfig);
sl@0
   422
						iInvalidConfig = EFalse;
sl@0
   423
						StopTest(errConfig, EPass);
sl@0
   424
						return;
sl@0
   425
						}
sl@0
   426
					}
sl@0
   427
sl@0
   428
				// Initialize audio device and starts the playing process
sl@0
   429
				INFO_PRINTF1(_L("Calling CMMFDevSound::PlayInitL()"));
sl@0
   430
				TRAPD(errPlay, iMMFDevSound->PlayInitL());
sl@0
   431
				if (errPlay != KErrNone)
sl@0
   432
					{
sl@0
   433
					ERR_PRINTF2(_L("CMMFDevSound::PlayInitL() left with error = %d"), errPlay);
sl@0
   434
					StopTest(errPlay);
sl@0
   435
					break;
sl@0
   436
					}
sl@0
   437
				INFO_PRINTF1(_L("State: EStatePlaying"));
sl@0
   438
				iPlayState = EStatePlaying;
sl@0
   439
				}
sl@0
   440
			else if (aDevSoundEvent == EEventInitCompletePlay && aError != KErrNone)
sl@0
   441
				{
sl@0
   442
				ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError);
sl@0
   443
				StopTest(aError);
sl@0
   444
				}
sl@0
   445
			else
sl@0
   446
				{
sl@0
   447
				ERR_PRINTF2(_L("DevSound EEventInitCompletePlay not received as expected. Received event: %d"), aDevSoundEvent);
sl@0
   448
				StopTest(aError, EFail);
sl@0
   449
				}
sl@0
   450
			break;
sl@0
   451
			}
sl@0
   452
sl@0
   453
		case EStatePlaying:
sl@0
   454
			{
sl@0
   455
			__ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RTestStepA3FDevSoundPlayBase"),EFsmIncorrectErrorPassed));
sl@0
   456
			if (aDevSoundEvent == EEventBTBF)
sl@0
   457
				{
sl@0
   458
				// Fill the buffer with audio data and play the data in the buffer
sl@0
   459
				CMMFDataBuffer* buffer = static_cast <CMMFDataBuffer*> (iBuffer);
sl@0
   460
				TInt err = iFile.Read(buffer->Data());
sl@0
   461
				if (err != KErrNone)
sl@0
   462
					{
sl@0
   463
					ERR_PRINTF2(_L("ERROR : iFile.Read() failed with %d"), err);
sl@0
   464
					StopTest(err);
sl@0
   465
					break;
sl@0
   466
					}
sl@0
   467
				if (buffer->Data().Length() != buffer->RequestSize())
sl@0
   468
					{
sl@0
   469
					INFO_PRINTF3(_L("Data length copied from file = %d. Expected = %d. Must be EOF."), buffer->Data().Length(), buffer->RequestSize());
sl@0
   470
					iBuffer->SetLastBuffer(ETrue);
sl@0
   471
					}
sl@0
   472
sl@0
   473
				// Playing data in the buffer at the current volume
sl@0
   474
				iMMFDevSound->PlayData();
sl@0
   475
				iBufferCount++;
sl@0
   476
				}
sl@0
   477
			else
sl@0
   478
				{
sl@0
   479
				ERR_PRINTF2(_L("DevSound EEventBTBF not received as expected. Received event: %d"), aDevSoundEvent);
sl@0
   480
				StopTest(aError, EFail);
sl@0
   481
				}
sl@0
   482
sl@0
   483
			break;
sl@0
   484
			}
sl@0
   485
sl@0
   486
		default:
sl@0
   487
			{
sl@0
   488
			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iPlayState);
sl@0
   489
			StopTest(KErrGeneral);
sl@0
   490
			}
sl@0
   491
		}
sl@0
   492
sl@0
   493
	}
sl@0
   494
sl@0
   495
/*
sl@0
   496
 *
sl@0
   497
 * DisplayCodecInfo
sl@0
   498
 *
sl@0
   499
 */
sl@0
   500
void RTestStepA3FDevSoundPlayBase::DisplayCodecInfo()
sl@0
   501
	{
sl@0
   502
	// Display trace about codec under test
sl@0
   503
	TUint32 fourCC = iInputDataType.FourCC();
sl@0
   504
	INFO_PRINTF5(_L("Codec under test -> %c%c%c%c"), fourCC, fourCC>>8, fourCC>>16, fourCC>>24);
sl@0
   505
sl@0
   506
	}
sl@0
   507
sl@0
   508
/*
sl@0
   509
 *
sl@0
   510
 * ConvertDesToTMMFSampleRate
sl@0
   511
 *
sl@0
   512
 */
sl@0
   513
TUint RTestStepA3FDevSoundPlayBase::ConvertDesToTMMFSampleRate(const TDesC& aSampleRateString)
sl@0
   514
	{
sl@0
   515
	TUint rate = 0;
sl@0
   516
sl@0
   517
	STR_SWITCH(aSampleRateString)
sl@0
   518
sl@0
   519
	STR_CASE(_L("EMMFSampleRate8000Hz"))
sl@0
   520
		{
sl@0
   521
		rate = EMMFSampleRate8000Hz;
sl@0
   522
		break;
sl@0
   523
		}
sl@0
   524
	STR_CASE(_L("EMMFSampleRate11025Hz"))
sl@0
   525
		{
sl@0
   526
		rate = EMMFSampleRate11025Hz;
sl@0
   527
		break;
sl@0
   528
		}
sl@0
   529
	STR_CASE(_L("EMMFSampleRate12000Hz"))
sl@0
   530
		{
sl@0
   531
		rate = EMMFSampleRate12000Hz;
sl@0
   532
		break;
sl@0
   533
		}
sl@0
   534
	STR_CASE(_L("EMMFSampleRate16000Hz"))
sl@0
   535
		{
sl@0
   536
		rate = EMMFSampleRate16000Hz;
sl@0
   537
		break;
sl@0
   538
		}
sl@0
   539
	STR_CASE(_L("EMMFSampleRate22050Hz"))
sl@0
   540
		{
sl@0
   541
		rate = EMMFSampleRate22050Hz;
sl@0
   542
		break;
sl@0
   543
		}
sl@0
   544
	STR_CASE(_L("EMMFSampleRate24000Hz"))
sl@0
   545
		{
sl@0
   546
		rate = EMMFSampleRate24000Hz;
sl@0
   547
		break;
sl@0
   548
		}
sl@0
   549
	STR_CASE(_L("EMMFSampleRate32000Hz"))
sl@0
   550
		{
sl@0
   551
		rate = EMMFSampleRate32000Hz;
sl@0
   552
		break;
sl@0
   553
		}
sl@0
   554
	STR_CASE(_L("EMMFSampleRate44100Hz"))
sl@0
   555
		{
sl@0
   556
		rate = EMMFSampleRate44100Hz;
sl@0
   557
		break;
sl@0
   558
		}
sl@0
   559
	STR_CASE(_L("EMMFSampleRate48000Hz"))
sl@0
   560
		{
sl@0
   561
		rate = EMMFSampleRate48000Hz;
sl@0
   562
		break;
sl@0
   563
		}
sl@0
   564
	STR_CASE(_L("EMMFSampleRate64000Hz"))
sl@0
   565
		{
sl@0
   566
		rate = EMMFSampleRate64000Hz;
sl@0
   567
		break;
sl@0
   568
		}
sl@0
   569
	STR_CASE(_L("EMMFSampleRate88200Hz"))
sl@0
   570
		{
sl@0
   571
		rate = EMMFSampleRate88200Hz;
sl@0
   572
		break;
sl@0
   573
		}
sl@0
   574
	STR_CASE(_L("EMMFSampleRate96000Hz"))
sl@0
   575
		{
sl@0
   576
		rate = EMMFSampleRate96000Hz;
sl@0
   577
		break;
sl@0
   578
		}
sl@0
   579
	STR_CASE(_L("InvalidRate"))
sl@0
   580
		{
sl@0
   581
		rate = 0x90000000;
sl@0
   582
		break;
sl@0
   583
		}
sl@0
   584
sl@0
   585
	DEFAULT_CASE()
sl@0
   586
		{
sl@0
   587
		ERR_PRINTF1(_L("Attempt to convert invalid sample rate"));
sl@0
   588
		StopTest(KErrGeneral);
sl@0
   589
		}
sl@0
   590
sl@0
   591
	STR_SWITCH_END()
sl@0
   592
sl@0
   593
	INFO_PRINTF2(_L("Sample Rate = %S"), &iSampleRate);
sl@0
   594
	return rate;
sl@0
   595
sl@0
   596
	}
sl@0
   597
sl@0
   598
/*
sl@0
   599
 *
sl@0
   600
 * ConvertDesToTMMFMonoStereo
sl@0
   601
 *
sl@0
   602
 */
sl@0
   603
TUint RTestStepA3FDevSoundPlayBase::ConvertDesToTMMFMonoStereo(const TDesC& aMonoStereoString)
sl@0
   604
	{
sl@0
   605
	TUint channelMode = 0;
sl@0
   606
sl@0
   607
	STR_SWITCH(aMonoStereoString)
sl@0
   608
sl@0
   609
	STR_CASE(_L("EMMFMono"))
sl@0
   610
		{
sl@0
   611
		channelMode = EMMFMono;
sl@0
   612
		break;
sl@0
   613
		}
sl@0
   614
	STR_CASE(_L("EMMFStereo"))
sl@0
   615
		{
sl@0
   616
		channelMode = EMMFStereo;
sl@0
   617
		break;
sl@0
   618
		}
sl@0
   619
	STR_CASE(_L("InvalidMode"))
sl@0
   620
		{
sl@0
   621
		channelMode = 0x90000000;
sl@0
   622
		break;
sl@0
   623
		}
sl@0
   624
	DEFAULT_CASE()
sl@0
   625
		{
sl@0
   626
		ERR_PRINTF1(_L("Attempt to convert invalid channel mode"));
sl@0
   627
		StopTest(KErrGeneral);
sl@0
   628
		}
sl@0
   629
sl@0
   630
	STR_SWITCH_END()
sl@0
   631
sl@0
   632
	INFO_PRINTF2(_L("Channel = %S"), &iMonoStereo);
sl@0
   633
	return channelMode;
sl@0
   634
sl@0
   635
	}
sl@0
   636
sl@0
   637
/*
sl@0
   638
 *
sl@0
   639
 * SetSampleRateAndChannelMode
sl@0
   640
 *
sl@0
   641
 */
sl@0
   642
void RTestStepA3FDevSoundPlayBase::SetSampleRateAndChannelMode()
sl@0
   643
	{
sl@0
   644
	if(!GetStringFromConfig(iSectName, _L("SampleRate"), iSampleRate))
sl@0
   645
		{
sl@0
   646
		TPtrC keyName(_L("SampleRate"));
sl@0
   647
		ERR_PRINTF3(_L("Error in getting sample rate from config file in %S section via the %S key field."), &iSectName, &keyName);
sl@0
   648
		StopTest(KErrPathNotFound);
sl@0
   649
		return;
sl@0
   650
		}
sl@0
   651
sl@0
   652
	if(!GetStringFromConfig(iSectName, _L("MonoStereo"), iMonoStereo))
sl@0
   653
		{
sl@0
   654
		TPtrC keyName(_L("MonoStereo"));
sl@0
   655
		ERR_PRINTF3(_L("Error in getting channel mode from config file in %S section via the %S key field."), &iSectName, &keyName);
sl@0
   656
		StopTest(KErrPathNotFound);
sl@0
   657
		return;
sl@0
   658
		}
sl@0
   659
sl@0
   660
	}
sl@0
   661
sl@0
   662
/*
sl@0
   663
 *
sl@0
   664
 * CheckConfigAndFourCCUsage
sl@0
   665
 *
sl@0
   666
 */
sl@0
   667
void RTestStepA3FDevSoundPlayBase::CheckConfigAndFourCCUsage()
sl@0
   668
	{
sl@0
   669
	if(!GetBoolFromConfig(iSectName, _L("SetConfig"), iConfig))
sl@0
   670
		{
sl@0
   671
		TPtrC keyName(_L("SetConfig"));
sl@0
   672
		ERR_PRINTF3(_L("Error in getting SetConfig flag value from config file in %S section via the %S key field."), &iSectName, &keyName);
sl@0
   673
		StopTest(KErrPathNotFound);
sl@0
   674
		return;
sl@0
   675
		}
sl@0
   676
	if(!GetBoolFromConfig(iSectName, _L("UseFourCC"), iUseFourCC))
sl@0
   677
		{
sl@0
   678
		TPtrC keyName(_L("UseFourCC"));
sl@0
   679
		ERR_PRINTF3(_L("Error in getting UseFourCC flag value from config file in %S section via the %S key field."), &iSectName, &keyName);
sl@0
   680
		StopTest(KErrPathNotFound);
sl@0
   681
		return;
sl@0
   682
		}
sl@0
   683
sl@0
   684
	}
sl@0
   685
sl@0
   686
//
sl@0
   687
// RStepA3FDevSoundPlaySimple
sl@0
   688
//
sl@0
   689
sl@0
   690
/*
sl@0
   691
 *
sl@0
   692
 * RStepA3FDevSoundPlaySimple - Test step constructor
sl@0
   693
 *
sl@0
   694
 */
sl@0
   695
RStepA3FDevSoundPlaySimple::RStepA3FDevSoundPlaySimple(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType)
sl@0
   696
:RTestStepA3FDevSoundPlayBase(aTestName, aSectName, aInputDataType)
sl@0
   697
	{
sl@0
   698
	}
sl@0
   699
sl@0
   700
/*
sl@0
   701
 *
sl@0
   702
 * RStepA3FDevSoundPlaySimple - Test step constructor
sl@0
   703
 *
sl@0
   704
 */
sl@0
   705
RStepA3FDevSoundPlaySimple::RStepA3FDevSoundPlaySimple(const TDesC& aTestName, const TDesC& aSectName)
sl@0
   706
:RTestStepA3FDevSoundPlayBase(aTestName, aSectName)
sl@0
   707
	{
sl@0
   708
	}
sl@0
   709
sl@0
   710
/*
sl@0
   711
 *
sl@0
   712
 * NewL
sl@0
   713
 *
sl@0
   714
 */
sl@0
   715
RStepA3FDevSoundPlaySimple* RStepA3FDevSoundPlaySimple::NewL(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType)
sl@0
   716
	{
sl@0
   717
	RStepA3FDevSoundPlaySimple* self = new (ELeave) RStepA3FDevSoundPlaySimple(aTestName, aSectName, aInputDataType);
sl@0
   718
	return self;
sl@0
   719
sl@0
   720
	}
sl@0
   721
sl@0
   722
/*
sl@0
   723
 *
sl@0
   724
 * NewL
sl@0
   725
 *
sl@0
   726
 */
sl@0
   727
RStepA3FDevSoundPlaySimple* RStepA3FDevSoundPlaySimple::NewL(const TDesC& aTestName, const TDesC& aSectName)
sl@0
   728
	{
sl@0
   729
	RStepA3FDevSoundPlaySimple* self = new (ELeave) RStepA3FDevSoundPlaySimple(aTestName, aSectName);
sl@0
   730
	return self;
sl@0
   731
sl@0
   732
	}
sl@0
   733
sl@0
   734
//
sl@0
   735
// RStepA3FDevSoundPlayEmpty
sl@0
   736
//
sl@0
   737
sl@0
   738
/*
sl@0
   739
 *
sl@0
   740
 * RStepA3FDevSoundPlayEmpty - Test step constructor
sl@0
   741
 *
sl@0
   742
 */
sl@0
   743
RStepA3FDevSoundPlayEmpty::RStepA3FDevSoundPlayEmpty(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType)
sl@0
   744
:RTestStepA3FDevSoundPlayBase(aTestName, aSectName, aInputDataType)
sl@0
   745
	{
sl@0
   746
	}
sl@0
   747
sl@0
   748
/*
sl@0
   749
 *
sl@0
   750
 * NewL
sl@0
   751
 *
sl@0
   752
 */
sl@0
   753
RStepA3FDevSoundPlayEmpty* RStepA3FDevSoundPlayEmpty::NewL(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType)
sl@0
   754
	{
sl@0
   755
	RStepA3FDevSoundPlayEmpty* self = new (ELeave) RStepA3FDevSoundPlayEmpty(aTestName, aSectName, aInputDataType);
sl@0
   756
	return self;
sl@0
   757
sl@0
   758
	}
sl@0
   759
sl@0
   760
/*
sl@0
   761
 *
sl@0
   762
 * Fsm
sl@0
   763
 *	- Executes playing events of DevSound in sequence
sl@0
   764
 *
sl@0
   765
 */
sl@0
   766
void RStepA3FDevSoundPlayEmpty::Fsm(TDevSoundPlayEvents aDevSoundEvent, TInt aError)
sl@0
   767
	{
sl@0
   768
	switch (iPlayState)
sl@0
   769
		{
sl@0
   770
		case EStatePlayStart:
sl@0
   771
			{
sl@0
   772
			__ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundPlayEmpty"),EFsmIncorrectErrorPassed));
sl@0
   773
			if (aDevSoundEvent == EEventPlayStart)
sl@0
   774
				{
sl@0
   775
				// Initializing DevSound object for playing mode to process audio data via desired FourCC code
sl@0
   776
				INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL"));
sl@0
   777
				TInt err;
sl@0
   778
				if(iUseFourCC)
sl@0
   779
					{
sl@0
   780
					TRAP(err, iMMFDevSound->InitializeL(*this, iInputDataType, EMMFStatePlaying));
sl@0
   781
					}
sl@0
   782
				else
sl@0
   783
					{
sl@0
   784
					TRAP(err, iMMFDevSound->InitializeL(*this, EMMFStatePlaying));
sl@0
   785
					}
sl@0
   786
				if (err != KErrNone)
sl@0
   787
					{
sl@0
   788
					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
sl@0
   789
					StopTest(err);
sl@0
   790
					break;
sl@0
   791
					}
sl@0
   792
				INFO_PRINTF1(_L("State: EStatePlayInitializing"));
sl@0
   793
				iPlayState = EStatePlayInitializing;
sl@0
   794
				}
sl@0
   795
			else
sl@0
   796
				{
sl@0
   797
				ERR_PRINTF2(_L("DevSound EEventPlayStart not received as expected. Received event: %d"), aDevSoundEvent);
sl@0
   798
				StopTest(aError, EFail);
sl@0
   799
				}
sl@0
   800
			break;
sl@0
   801
			}
sl@0
   802
sl@0
   803
		case EStatePlayInitializing:
sl@0
   804
			{
sl@0
   805
			if (aDevSoundEvent == EEventInitCompletePlay && aError == KErrNone)
sl@0
   806
				{
sl@0
   807
				if(iConfig)
sl@0
   808
					{
sl@0
   809
					// Set Devsound capability settings using CMMFDevSound::SetConfigL
sl@0
   810
					SetSampleRateAndChannelMode();
sl@0
   811
					TMMFCapabilities capabilities;
sl@0
   812
					capabilities.iRate = ConvertDesToTMMFSampleRate(iSampleRate);
sl@0
   813
					capabilities.iChannels = ConvertDesToTMMFMonoStereo(iMonoStereo);
sl@0
   814
sl@0
   815
					TRAPD(errConfig, iMMFDevSound->SetConfigL(capabilities));
sl@0
   816
					if (errConfig != KErrNone)
sl@0
   817
						{
sl@0
   818
						ERR_PRINTF2(_L("CMMFDevSound::SetConfigL() left with error = %d"), errConfig);
sl@0
   819
						StopTest(errConfig);
sl@0
   820
						return;
sl@0
   821
						}
sl@0
   822
					}
sl@0
   823
sl@0
   824
				// Initialize audio device and starts the playing process
sl@0
   825
				INFO_PRINTF1(_L("Calling CMMFDevSound::PlayInitL()"));
sl@0
   826
				TRAPD(errPlay, iMMFDevSound->PlayInitL());
sl@0
   827
				if (errPlay != KErrNone)
sl@0
   828
					{
sl@0
   829
					ERR_PRINTF2(_L("CMMFDevSound::PlayInitL() left with error = %d"), errPlay);
sl@0
   830
					StopTest(errPlay);
sl@0
   831
					break;
sl@0
   832
					}
sl@0
   833
				INFO_PRINTF1(_L("State: EStatePlaying"));
sl@0
   834
				iPlayState = EStatePlaying;
sl@0
   835
				}
sl@0
   836
			else if (aDevSoundEvent == EEventInitCompletePlay && aError != KErrNone)
sl@0
   837
				{
sl@0
   838
				ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError);
sl@0
   839
				StopTest(aError);
sl@0
   840
				}
sl@0
   841
			else
sl@0
   842
				{
sl@0
   843
				ERR_PRINTF2(_L("DevSound EEventInitCompletePlay not received as expected. Received event: %d"), aDevSoundEvent);
sl@0
   844
				StopTest(aError, EFail);
sl@0
   845
				}
sl@0
   846
			break;
sl@0
   847
			}
sl@0
   848
sl@0
   849
		case EStatePlaying:
sl@0
   850
			{
sl@0
   851
			__ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundPlayEmpty"),EFsmIncorrectErrorPassed));
sl@0
   852
			if (aDevSoundEvent == EEventBTBF)
sl@0
   853
				{
sl@0
   854
				// Fill the buffer with audio data and play the data in the buffer
sl@0
   855
				CMMFDataBuffer* buffer = static_cast <CMMFDataBuffer*> (iBuffer);
sl@0
   856
				TInt err = iFile.Read(buffer->Data());
sl@0
   857
				if (err != KErrNone)
sl@0
   858
					{
sl@0
   859
					ERR_PRINTF2(_L("ERROR : iFile.Read() failed with %d"), err);
sl@0
   860
					StopTest(err);
sl@0
   861
					break;
sl@0
   862
					}
sl@0
   863
				if (buffer->Data().Length() != buffer->RequestSize())
sl@0
   864
					{
sl@0
   865
					iBuffer->SetLastBuffer(ETrue);
sl@0
   866
					INFO_PRINTF3(_L("Data length copied from file = %d. Expected = %d. Must be EOF."), buffer->Data().Length(), buffer->RequestSize());
sl@0
   867
					// Playing empty data
sl@0
   868
					iMMFDevSound->PlayData();
sl@0
   869
sl@0
   870
					}
sl@0
   871
				iBufferCount++;
sl@0
   872
				}
sl@0
   873
			else
sl@0
   874
				{
sl@0
   875
				ERR_PRINTF2(_L("DevSound EEventBTBF not received as expected. Received event: %d"), aDevSoundEvent);
sl@0
   876
				StopTest(aError, EFail);
sl@0
   877
				}
sl@0
   878
sl@0
   879
			break;
sl@0
   880
			}
sl@0
   881
sl@0
   882
		default:
sl@0
   883
			{
sl@0
   884
			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iPlayState);
sl@0
   885
			StopTest(KErrGeneral);
sl@0
   886
			}
sl@0
   887
		}
sl@0
   888
sl@0
   889
	}
sl@0
   890
sl@0
   891
//
sl@0
   892
// RStepA3FDevSoundPlayInvalidFourCC
sl@0
   893
//
sl@0
   894
sl@0
   895
/*
sl@0
   896
 *
sl@0
   897
 * RStepA3FDevSoundPlayInvalidFourCC - Test step constructor
sl@0
   898
 *
sl@0
   899
 */
sl@0
   900
RStepA3FDevSoundPlayInvalidFourCC::RStepA3FDevSoundPlayInvalidFourCC(const TDesC& aTestName, const TFourCC& aInputDataType)
sl@0
   901
:RTestStepA3FDevSoundPlayBase(aTestName, aInputDataType)
sl@0
   902
	{
sl@0
   903
	}
sl@0
   904
sl@0
   905
/*
sl@0
   906
 *
sl@0
   907
 * NewL
sl@0
   908
 *
sl@0
   909
 */
sl@0
   910
RStepA3FDevSoundPlayInvalidFourCC* RStepA3FDevSoundPlayInvalidFourCC::NewL(const TDesC& aTestName, const TFourCC& aInputDataType)
sl@0
   911
	{
sl@0
   912
	RStepA3FDevSoundPlayInvalidFourCC* self = new (ELeave) RStepA3FDevSoundPlayInvalidFourCC(aTestName, aInputDataType);
sl@0
   913
	return self;
sl@0
   914
sl@0
   915
	}
sl@0
   916
sl@0
   917
/*
sl@0
   918
 *
sl@0
   919
 * KickoffTestL
sl@0
   920
 * - Starts the test
sl@0
   921
 *
sl@0
   922
 */
sl@0
   923
void RStepA3FDevSoundPlayInvalidFourCC::KickoffTestL()
sl@0
   924
	{
sl@0
   925
	// Create instance of CMMFDevSound
sl@0
   926
	INFO_PRINTF1(_L("--- Creating DevSound object..."));
sl@0
   927
	iMMFDevSound = CMMFDevSound::NewL();
sl@0
   928
sl@0
   929
	//Display the name of Codec being used
sl@0
   930
	DisplayCodecInfo();
sl@0
   931
	Fsm(EEventPlayStart,KErrNone); // call to start the DevSound finite state machine for playing
sl@0
   932
sl@0
   933
	}
sl@0
   934
sl@0
   935
/*
sl@0
   936
 *
sl@0
   937
 * Fsm
sl@0
   938
 *	- Executes playing events of DevSound in sequence
sl@0
   939
 *
sl@0
   940
 */
sl@0
   941
void RStepA3FDevSoundPlayInvalidFourCC::Fsm(TDevSoundPlayEvents aDevSoundEvent, TInt aError)
sl@0
   942
	{
sl@0
   943
	switch (iPlayState)
sl@0
   944
		{
sl@0
   945
		case EStatePlayStart:
sl@0
   946
			{
sl@0
   947
			__ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundPlayInvalidFourCC"),EFsmIncorrectErrorPassed));
sl@0
   948
			if (aDevSoundEvent == EEventPlayStart)
sl@0
   949
				{
sl@0
   950
				// Initializing DevSound object for playing mode to process audio data via desired FourCC code
sl@0
   951
				INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL"));
sl@0
   952
				TInt err;
sl@0
   953
				TRAP(err, iMMFDevSound->InitializeL(*this, iInputDataType, EMMFStatePlaying));
sl@0
   954
				if (err == KErrNotSupported)
sl@0
   955
					{
sl@0
   956
					INFO_PRINTF2(_L("CMMFDevSound::InitializeL left with expected error = %d"), err);
sl@0
   957
					StopTest(err, EPass);
sl@0
   958
					}
sl@0
   959
				else
sl@0
   960
					{
sl@0
   961
					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
sl@0
   962
					INFO_PRINTF2(_L("Expected error = %d"), KErrNotSupported);
sl@0
   963
					StopTest(err, EFail);
sl@0
   964
					}
sl@0
   965
				}
sl@0
   966
			else
sl@0
   967
				{
sl@0
   968
				ERR_PRINTF2(_L("DevSound EEventPlayStart not received as expected. Received event: %d"), aDevSoundEvent);
sl@0
   969
				StopTest(aError, EFail);
sl@0
   970
				}
sl@0
   971
			break;
sl@0
   972
			}
sl@0
   973
		default:
sl@0
   974
			{
sl@0
   975
			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iPlayState);
sl@0
   976
			StopTest(KErrGeneral);
sl@0
   977
			}
sl@0
   978
		}
sl@0
   979
sl@0
   980
	}
sl@0
   981
sl@0
   982
sl@0
   983
sl@0
   984
sl@0
   985
//
sl@0
   986
// RStepA3FDevSoundInitializeWithHwDeviceUID
sl@0
   987
//
sl@0
   988
sl@0
   989
/*
sl@0
   990
 *
sl@0
   991
 * RStepA3FDevSoundInitializeWithHwDeviceUID - Test step constructor
sl@0
   992
 *
sl@0
   993
 */
sl@0
   994
RStepA3FDevSoundInitializeWithHwDeviceUID::RStepA3FDevSoundInitializeWithHwDeviceUID(const TDesC& aTestName)
sl@0
   995
:RTestStepA3FDevSoundPlayBase(aTestName)
sl@0
   996
	{
sl@0
   997
	}
sl@0
   998
sl@0
   999
/*
sl@0
  1000
 *
sl@0
  1001
 * NewL
sl@0
  1002
 *
sl@0
  1003
 */
sl@0
  1004
RStepA3FDevSoundInitializeWithHwDeviceUID* RStepA3FDevSoundInitializeWithHwDeviceUID::NewL(const TDesC& aTestName)
sl@0
  1005
	{
sl@0
  1006
	RStepA3FDevSoundInitializeWithHwDeviceUID* self = new (ELeave) RStepA3FDevSoundInitializeWithHwDeviceUID(aTestName);
sl@0
  1007
	return self;
sl@0
  1008
sl@0
  1009
	}
sl@0
  1010
sl@0
  1011
/*
sl@0
  1012
 *
sl@0
  1013
 * KickoffTestL
sl@0
  1014
 * - Starts the test
sl@0
  1015
 *
sl@0
  1016
 */
sl@0
  1017
void RStepA3FDevSoundInitializeWithHwDeviceUID::KickoffTestL()
sl@0
  1018
	{
sl@0
  1019
	// Create instance of CMMFDevSound
sl@0
  1020
	INFO_PRINTF1(_L("--- Creating DevSound object..."));
sl@0
  1021
	iMMFDevSound = CMMFDevSound::NewL();
sl@0
  1022
sl@0
  1023
	//Display the name of Codec being used.
sl@0
  1024
	DisplayCodecInfo();
sl@0
  1025
	Fsm(EEventPlayStart,KErrNone); // call to start the DevSound finite state machine for playing
sl@0
  1026
sl@0
  1027
	}
sl@0
  1028
sl@0
  1029
/*
sl@0
  1030
 *
sl@0
  1031
 * Fsm
sl@0
  1032
 *	- Executes playing events of DevSound in sequence
sl@0
  1033
 *
sl@0
  1034
 */
sl@0
  1035
void RStepA3FDevSoundInitializeWithHwDeviceUID::Fsm(TDevSoundPlayEvents aDevSoundEvent, TInt aError)
sl@0
  1036
	{
sl@0
  1037
	switch (iPlayState)
sl@0
  1038
		{
sl@0
  1039
		case EStatePlayStart:
sl@0
  1040
			{
sl@0
  1041
			__ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundInitializeWithHwDeviceUID"),EFsmIncorrectErrorPassed));
sl@0
  1042
			if (aDevSoundEvent == EEventPlayStart)
sl@0
  1043
				{
sl@0
  1044
				// Initializing DevSound object for playing mode to process audio data via HwDeviceUID
sl@0
  1045
				INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL with KMmfUidHwDevicePCM16ToPCM16"));
sl@0
  1046
				TInt err;
sl@0
  1047
				TRAP(err, iMMFDevSound->InitializeL(*this, 0x101F9F00 , EMMFStatePlaying)); //KMmfUidHwDevicePCM16ToPCM16
sl@0
  1048
				if (err == KErrNotSupported)
sl@0
  1049
					{
sl@0
  1050
					INFO_PRINTF2(_L("CMMFDevSound::InitializeL left with expected error = %d"), err);
sl@0
  1051
					StopTest(err, EPass);
sl@0
  1052
					}
sl@0
  1053
				else
sl@0
  1054
					{
sl@0
  1055
					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
sl@0
  1056
					INFO_PRINTF2(_L("Expected error = %d"), KErrNotSupported);
sl@0
  1057
					StopTest(err, EFail);
sl@0
  1058
					}
sl@0
  1059
				}
sl@0
  1060
			else
sl@0
  1061
				{
sl@0
  1062
				ERR_PRINTF2(_L("DevSound EEventPlayStart not received as expected. Received event: %d"), aDevSoundEvent);
sl@0
  1063
				StopTest(aError, EFail);
sl@0
  1064
				}
sl@0
  1065
			break;
sl@0
  1066
			}
sl@0
  1067
		default:
sl@0
  1068
			{
sl@0
  1069
			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iPlayState);
sl@0
  1070
			StopTest(KErrGeneral);
sl@0
  1071
			}
sl@0
  1072
		}
sl@0
  1073
sl@0
  1074
	}
sl@0
  1075
sl@0
  1076
//
sl@0
  1077
// RStepA3FDevSoundPlayInvalidConfig
sl@0
  1078
//
sl@0
  1079
sl@0
  1080
/*
sl@0
  1081
 *
sl@0
  1082
 * RStepA3FDevSoundPlayInvalidConfig - Test step constructor
sl@0
  1083
 *
sl@0
  1084
 */
sl@0
  1085
RStepA3FDevSoundPlayInvalidConfig::RStepA3FDevSoundPlayInvalidConfig(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType)
sl@0
  1086
:RTestStepA3FDevSoundPlayBase(aTestName, aSectName, aInputDataType)
sl@0
  1087
	{
sl@0
  1088
	}
sl@0
  1089
sl@0
  1090
/*
sl@0
  1091
 *
sl@0
  1092
 * NewL
sl@0
  1093
 *
sl@0
  1094
 */
sl@0
  1095
RStepA3FDevSoundPlayInvalidConfig* RStepA3FDevSoundPlayInvalidConfig::NewL(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType)
sl@0
  1096
	{
sl@0
  1097
	RStepA3FDevSoundPlayInvalidConfig* self = new (ELeave) RStepA3FDevSoundPlayInvalidConfig(aTestName, aSectName, aInputDataType);
sl@0
  1098
	return self;
sl@0
  1099
sl@0
  1100
	}
sl@0
  1101
sl@0
  1102
/*
sl@0
  1103
 *
sl@0
  1104
 * KickoffTestL
sl@0
  1105
 * - Starts the test
sl@0
  1106
 *
sl@0
  1107
 */
sl@0
  1108
void RStepA3FDevSoundPlayInvalidConfig::KickoffTestL()
sl@0
  1109
	{
sl@0
  1110
	// Create instance of CMMFDevSound
sl@0
  1111
	INFO_PRINTF1(_L("--- Creating DevSound object..."));
sl@0
  1112
	iMMFDevSound = CMMFDevSound::NewL();
sl@0
  1113
	
sl@0
  1114
	iInvalidConfig = ETrue;
sl@0
  1115
	//Display the name of Codec being used
sl@0
  1116
	DisplayCodecInfo();
sl@0
  1117
	CheckConfigAndFourCCUsage();
sl@0
  1118
	Fsm(EEventPlayStart,KErrNone); // call to start the DevSound finite state machine for playing
sl@0
  1119
sl@0
  1120
	}
sl@0
  1121
sl@0
  1122
/*
sl@0
  1123
 *
sl@0
  1124
 * PlayError
sl@0
  1125
 *
sl@0
  1126
 */
sl@0
  1127
void RStepA3FDevSoundPlayInvalidConfig::PlayError(TInt aError)
sl@0
  1128
	{
sl@0
  1129
	if ((iPlayState == EStatePlaying) && (aError == KErrArgument))
sl@0
  1130
		{
sl@0
  1131
		INFO_PRINTF2(_L("DevSound called PlayError with expected error = %d"), aError);
sl@0
  1132
		StopTest(aError, EPass);
sl@0
  1133
		}
sl@0
  1134
	else
sl@0
  1135
		{
sl@0
  1136
		INFO_PRINTF1(_L("Expected error = -6"));
sl@0
  1137
		ERR_PRINTF2(_L("DevSound called PlayError with error = %d"), aError);
sl@0
  1138
		StopTest(aError, EFail);
sl@0
  1139
		}
sl@0
  1140
sl@0
  1141
	}
sl@0
  1142
sl@0
  1143
//
sl@0
  1144
// RStepA3FDevSoundReadConfigDuringPlay
sl@0
  1145
//
sl@0
  1146
sl@0
  1147
/*
sl@0
  1148
 *
sl@0
  1149
 * RStepA3FDevSoundReadConfigDuringPlay - Test step constructor
sl@0
  1150
 *
sl@0
  1151
 */
sl@0
  1152
RStepA3FDevSoundReadConfigDuringPlay::RStepA3FDevSoundReadConfigDuringPlay(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType)
sl@0
  1153
:RTestStepA3FDevSoundPlayBase(aTestName, aSectName, aInputDataType)
sl@0
  1154
	{
sl@0
  1155
	}
sl@0
  1156
sl@0
  1157
/*
sl@0
  1158
 *
sl@0
  1159
 * NewL
sl@0
  1160
 *
sl@0
  1161
 */
sl@0
  1162
RStepA3FDevSoundReadConfigDuringPlay* RStepA3FDevSoundReadConfigDuringPlay::NewL(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType)
sl@0
  1163
	{
sl@0
  1164
	RStepA3FDevSoundReadConfigDuringPlay* self = new (ELeave) RStepA3FDevSoundReadConfigDuringPlay(aTestName, aSectName, aInputDataType);
sl@0
  1165
	return self;
sl@0
  1166
sl@0
  1167
	}
sl@0
  1168
sl@0
  1169
/*
sl@0
  1170
 *
sl@0
  1171
 * PlayError
sl@0
  1172
 *
sl@0
  1173
 */
sl@0
  1174
void RStepA3FDevSoundReadConfigDuringPlay::BufferToBeFilled(CMMFBuffer* aBuffer)
sl@0
  1175
	{
sl@0
  1176
	if (!aBuffer)
sl@0
  1177
		{
sl@0
  1178
		ERR_PRINTF1(_L("BufferToBeFilled callback received a NULL CMMFBuffer!"));
sl@0
  1179
		StopTest(KErrGeneral);
sl@0
  1180
		return;
sl@0
  1181
		}
sl@0
  1182
sl@0
  1183
	iBuffer = aBuffer;
sl@0
  1184
sl@0
  1185
	if (iPlayState == EStatePlaying)
sl@0
  1186
		{
sl@0
  1187
		TMMFCapabilities capabilities;
sl@0
  1188
		capabilities = iMMFDevSound->Config();
sl@0
  1189
		INFO_PRINTF1(_L("Config values during Play: "));
sl@0
  1190
		if (capabilities.iRate == ConvertDesToTMMFSampleRate(iSampleRate) && capabilities.iChannels == ConvertDesToTMMFMonoStereo(iMonoStereo))
sl@0
  1191
			{
sl@0
  1192
			INFO_PRINTF1(_L("Config values before and during playback are same."));
sl@0
  1193
			StopTest(KErrNone);
sl@0
  1194
			}
sl@0
  1195
		else
sl@0
  1196
			{
sl@0
  1197
			ERR_PRINTF1(_L("Config values before and during playback are different."));
sl@0
  1198
			StopTest(KErrGeneral);
sl@0
  1199
			}
sl@0
  1200
		}
sl@0
  1201
sl@0
  1202
	}
sl@0
  1203
sl@0
  1204
//
sl@0
  1205
// RStepA3FDevSoundSetVolPlayStopGetVol
sl@0
  1206
//
sl@0
  1207
sl@0
  1208
/*
sl@0
  1209
 *
sl@0
  1210
 * RStepA3FDevSoundSetVolPlayStopGetVol - Test step constructor
sl@0
  1211
 *
sl@0
  1212
 */
sl@0
  1213
RStepA3FDevSoundSetVolPlayStopGetVol::RStepA3FDevSoundSetVolPlayStopGetVol(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType)
sl@0
  1214
:RTestStepA3FDevSoundPlayBase(aTestName, aSectName, aInputDataType),
sl@0
  1215
 iSetVolume(0),
sl@0
  1216
 iVolDuringStopped(0),
sl@0
  1217
 iCheckTimer(ETrue)
sl@0
  1218
	{
sl@0
  1219
	}
sl@0
  1220
sl@0
  1221
/*
sl@0
  1222
 *
sl@0
  1223
 * NewL
sl@0
  1224
 *
sl@0
  1225
 */
sl@0
  1226
RStepA3FDevSoundSetVolPlayStopGetVol* RStepA3FDevSoundSetVolPlayStopGetVol::NewL(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType)
sl@0
  1227
	{
sl@0
  1228
	RStepA3FDevSoundSetVolPlayStopGetVol* self = new (ELeave) RStepA3FDevSoundSetVolPlayStopGetVol(aTestName, aSectName, aInputDataType);
sl@0
  1229
	return self;
sl@0
  1230
sl@0
  1231
	}
sl@0
  1232
sl@0
  1233
/*
sl@0
  1234
 *
sl@0
  1235
 * DoKickoffTestL
sl@0
  1236
 *
sl@0
  1237
 */
sl@0
  1238
void RStepA3FDevSoundSetVolPlayStopGetVol::DoKickoffTestL()
sl@0
  1239
	{
sl@0
  1240
	INFO_PRINTF2(_L("File to be played -> %S"), &iFilename);
sl@0
  1241
	DisplayCodecInfo();
sl@0
  1242
	CheckConfigAndFourCCUsage();
sl@0
  1243
sl@0
  1244
	TBool vol = GetIntFromConfig(iSectName,_L("Setvolume"),iSetVolume);
sl@0
  1245
	if (vol)
sl@0
  1246
		{
sl@0
  1247
		INFO_PRINTF2(_L("SetVolume = %d"), iSetVolume );
sl@0
  1248
		}
sl@0
  1249
	else
sl@0
  1250
		{
sl@0
  1251
		TPtrC keyName(_L("Setvolume"));
sl@0
  1252
		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
  1253
		StopTest(KErrPathNotFound);
sl@0
  1254
		return;
sl@0
  1255
		}
sl@0
  1256
sl@0
  1257
	}
sl@0
  1258
sl@0
  1259
/*
sl@0
  1260
 *
sl@0
  1261
 * Fsm
sl@0
  1262
 *	- Executes playing events of DevSound in sequence
sl@0
  1263
 *
sl@0
  1264
 */
sl@0
  1265
void RStepA3FDevSoundSetVolPlayStopGetVol::Fsm(TDevSoundPlayEvents aDevSoundEvent, TInt aError)
sl@0
  1266
	{
sl@0
  1267
	switch (iPlayState)
sl@0
  1268
		{
sl@0
  1269
		case EStatePlayStart:
sl@0
  1270
			{
sl@0
  1271
			__ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundSetVolPlayStopGetVol"),EFsmIncorrectErrorPassed));
sl@0
  1272
			if (aDevSoundEvent == EEventPlayStart)
sl@0
  1273
				{
sl@0
  1274
				// Initializing DevSound object for playing mode to process audio data via desired FourCC code
sl@0
  1275
				INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL"));
sl@0
  1276
				TInt err;
sl@0
  1277
				if(iUseFourCC)
sl@0
  1278
					{
sl@0
  1279
					TRAP(err, iMMFDevSound->InitializeL(*this, iInputDataType, EMMFStatePlaying));
sl@0
  1280
					}
sl@0
  1281
				else
sl@0
  1282
					{
sl@0
  1283
					TRAP(err, iMMFDevSound->InitializeL(*this, EMMFStatePlaying));
sl@0
  1284
					}
sl@0
  1285
				if (err != KErrNone)
sl@0
  1286
					{
sl@0
  1287
					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
sl@0
  1288
					StopTest(err);
sl@0
  1289
					break;
sl@0
  1290
					}
sl@0
  1291
				INFO_PRINTF1(_L("State: EStatePlayInitializing"));
sl@0
  1292
				iPlayState = EStatePlayInitializing;
sl@0
  1293
				}
sl@0
  1294
			else
sl@0
  1295
				{
sl@0
  1296
				ERR_PRINTF2(_L("DevSound EEventPlayStart not received as expected. Received event: %d"), aDevSoundEvent);
sl@0
  1297
				StopTest(aError, EFail);
sl@0
  1298
				}
sl@0
  1299
			break;
sl@0
  1300
			}
sl@0
  1301
sl@0
  1302
		case EStatePlayInitializing:
sl@0
  1303
			{
sl@0
  1304
			if (aDevSoundEvent == EEventInitCompletePlay && aError == KErrNone)
sl@0
  1305
				{
sl@0
  1306
				if(iConfig)
sl@0
  1307
					{
sl@0
  1308
					// Set Devsound capability settings using CMMFDevSound::SetConfigL
sl@0
  1309
					SetSampleRateAndChannelMode();
sl@0
  1310
					TMMFCapabilities capabilities;
sl@0
  1311
					capabilities.iRate = ConvertDesToTMMFSampleRate(iSampleRate);
sl@0
  1312
					capabilities.iChannels = ConvertDesToTMMFMonoStereo(iMonoStereo);
sl@0
  1313
sl@0
  1314
					TRAPD(errConfig, iMMFDevSound->SetConfigL(capabilities));
sl@0
  1315
					if (errConfig != KErrNone)
sl@0
  1316
						{
sl@0
  1317
						ERR_PRINTF2(_L("CMMFDevSound::SetConfigL() left with error = %d"), errConfig);
sl@0
  1318
						StopTest(errConfig);
sl@0
  1319
						break;
sl@0
  1320
						}
sl@0
  1321
					}
sl@0
  1322
				// Setting Volume Before Playback
sl@0
  1323
				iMMFDevSound->SetVolume(iSetVolume);
sl@0
  1324
				INFO_PRINTF2(_L("Volume before playback = %d"), iSetVolume);
sl@0
  1325
				// Initialize audio device and starts the playing process
sl@0
  1326
				INFO_PRINTF1(_L("Calling CMMFDevSound::PlayInitL()"));
sl@0
  1327
				TRAPD(errPlay, iMMFDevSound->PlayInitL());
sl@0
  1328
				if (errPlay != KErrNone)
sl@0
  1329
					{
sl@0
  1330
					ERR_PRINTF2(_L("CMMFDevSound::PlayInitL() left with error = %d"), errPlay);
sl@0
  1331
					StopTest(errPlay);
sl@0
  1332
					break;
sl@0
  1333
					}
sl@0
  1334
				INFO_PRINTF1(_L("State: EStatePlaying"));
sl@0
  1335
				iPlayState = EStatePlaying;
sl@0
  1336
				}
sl@0
  1337
			else if (aDevSoundEvent == EEventInitCompletePlay && aError != KErrNone)
sl@0
  1338
				{
sl@0
  1339
				ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError);
sl@0
  1340
				StopTest(aError);
sl@0
  1341
				}
sl@0
  1342
			else
sl@0
  1343
				{
sl@0
  1344
				ERR_PRINTF2(_L("DevSound EEventInitCompletePlay not received as expected. Received event: %d"), aDevSoundEvent);
sl@0
  1345
				StopTest(aError, EFail);
sl@0
  1346
				}
sl@0
  1347
			break;
sl@0
  1348
			}
sl@0
  1349
sl@0
  1350
		case EStatePlaying:
sl@0
  1351
			{
sl@0
  1352
			__ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundSetVolPlayStopGetVol"),EFsmIncorrectErrorPassed));
sl@0
  1353
			if (aDevSoundEvent == EEventBTBF)
sl@0
  1354
				{
sl@0
  1355
				// Fill the buffer with audio data and play the data in the buffer
sl@0
  1356
				CMMFDataBuffer* buffer = static_cast <CMMFDataBuffer*> (iBuffer);
sl@0
  1357
				TInt err = iFile.Read(buffer->Data());
sl@0
  1358
				if (err != KErrNone)
sl@0
  1359
					{
sl@0
  1360
					ERR_PRINTF2(_L("ERROR : iFile.Read() failed with %d"), err);
sl@0
  1361
					StopTest(err);
sl@0
  1362
					}
sl@0
  1363
				if (buffer->Data().Length() != buffer->RequestSize())
sl@0
  1364
					{
sl@0
  1365
					INFO_PRINTF3(_L("Data length copied from file = %d. Expected = %d. Must be EOF."), buffer->Data().Length(), buffer->RequestSize());
sl@0
  1366
					iBuffer->SetLastBuffer(ETrue);
sl@0
  1367
					}
sl@0
  1368
sl@0
  1369
				if (iCheckTimer)
sl@0
  1370
					{
sl@0
  1371
					iTimer->Start(KMicroSecsInTenSecs, 0, iCallBack);
sl@0
  1372
					}
sl@0
  1373
				iCheckTimer = EFalse;
sl@0
  1374
				// Playing data in the buffer at the current volume
sl@0
  1375
				iMMFDevSound->PlayData();
sl@0
  1376
				iBufferCount++;
sl@0
  1377
				}
sl@0
  1378
			else if (aDevSoundEvent == EEventPlayTimerComplete)
sl@0
  1379
				{
sl@0
  1380
				iMMFDevSound->Stop();
sl@0
  1381
				iPlayState = EStatePlayStopped;
sl@0
  1382
				INFO_PRINTF1(_L("State: EStatePlayStopped"));
sl@0
  1383
				}
sl@0
  1384
			else
sl@0
  1385
				{
sl@0
  1386
				ERR_PRINTF2(_L("DevSound EEventBTBF not received as expected. Received event: %d"), aDevSoundEvent);
sl@0
  1387
				StopTest(aError, EFail);
sl@0
  1388
				}
sl@0
  1389
			break;
sl@0
  1390
			}
sl@0
  1391
sl@0
  1392
		case EStatePlayStopped:
sl@0
  1393
			{
sl@0
  1394
			__ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundSetVolPlayStopGetVol"),EFsmIncorrectErrorPassed));
sl@0
  1395
			if (aDevSoundEvent == EEventPlayStopped)
sl@0
  1396
				{
sl@0
  1397
				iVolDuringStopped = iMMFDevSound->Volume();
sl@0
  1398
				INFO_PRINTF2(_L("Volume when play is stopped: %d"), iVolDuringStopped);
sl@0
  1399
				if (iVolDuringStopped == iSetVolume)
sl@0
  1400
					{
sl@0
  1401
					INFO_PRINTF1(_L("Volume set before the playback is same as volume during playback stopped"));
sl@0
  1402
					StopTest(KErrNone);
sl@0
  1403
					}
sl@0
  1404
				else
sl@0
  1405
					{
sl@0
  1406
					ERR_PRINTF1(_L("Volume set before the playback is not the same as volume during playback stopped"));
sl@0
  1407
					StopTest(KErrGeneral);
sl@0
  1408
					}					
sl@0
  1409
				}
sl@0
  1410
			else
sl@0
  1411
				{
sl@0
  1412
				ERR_PRINTF1(_L("EStatePlayStopped event not received in EStatePlayStopped state"));
sl@0
  1413
				StopTest(KErrGeneral);
sl@0
  1414
				break;
sl@0
  1415
				}
sl@0
  1416
			}
sl@0
  1417
			break;
sl@0
  1418
sl@0
  1419
		default:
sl@0
  1420
			{
sl@0
  1421
			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iPlayState);
sl@0
  1422
			StopTest(KErrGeneral);
sl@0
  1423
			}
sl@0
  1424
		}
sl@0
  1425
sl@0
  1426
	}
sl@0
  1427
sl@0
  1428
/*
sl@0
  1429
 *
sl@0
  1430
 * DoTimerCallback
sl@0
  1431
 *
sl@0
  1432
 */
sl@0
  1433
void RStepA3FDevSoundSetVolPlayStopGetVol::DoTimerCallback()
sl@0
  1434
	{
sl@0
  1435
	iTimer->Cancel(); // only really wanted a one-shot
sl@0
  1436
	if(!iCheckTimer)
sl@0
  1437
		{
sl@0
  1438
		Fsm(EEventPlayTimerComplete, KErrNone);
sl@0
  1439
		Fsm(EEventPlayStopped, KErrNone);
sl@0
  1440
		}
sl@0
  1441
sl@0
  1442
	}
sl@0
  1443
sl@0
  1444
//
sl@0
  1445
// RStepA3FDevSoundFlushBuffersPaused
sl@0
  1446
//
sl@0
  1447
sl@0
  1448
/*
sl@0
  1449
 *
sl@0
  1450
 * RStepA3FDevSoundFlushBuffersPaused - Test step constructor
sl@0
  1451
 *
sl@0
  1452
 */
sl@0
  1453
RStepA3FDevSoundFlushBuffersPaused::RStepA3FDevSoundFlushBuffersPaused(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType)
sl@0
  1454
:RTestStepA3FDevSoundPlayBase(aTestName, aSectName, aInputDataType),
sl@0
  1455
 iCheckTimer(ETrue)
sl@0
  1456
	{
sl@0
  1457
	}
sl@0
  1458
sl@0
  1459
/*
sl@0
  1460
 *
sl@0
  1461
 * NewL
sl@0
  1462
 *
sl@0
  1463
 */
sl@0
  1464
RStepA3FDevSoundFlushBuffersPaused* RStepA3FDevSoundFlushBuffersPaused::NewL(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType)
sl@0
  1465
	{
sl@0
  1466
	RStepA3FDevSoundFlushBuffersPaused* self = new (ELeave) RStepA3FDevSoundFlushBuffersPaused(aTestName, aSectName, aInputDataType);
sl@0
  1467
	return self;
sl@0
  1468
sl@0
  1469
	}
sl@0
  1470
sl@0
  1471
/*
sl@0
  1472
 *
sl@0
  1473
 * Fsm
sl@0
  1474
 *	- Executes playing events of DevSound in sequence
sl@0
  1475
 *
sl@0
  1476
 */
sl@0
  1477
void RStepA3FDevSoundFlushBuffersPaused::Fsm(TDevSoundPlayEvents aDevSoundEvent, TInt aError)
sl@0
  1478
	{
sl@0
  1479
	switch (iPlayState)
sl@0
  1480
		{
sl@0
  1481
		case EStatePlayStart:
sl@0
  1482
			{
sl@0
  1483
			__ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundFlushBuffersPaused"),EFsmIncorrectErrorPassed));
sl@0
  1484
			if (aDevSoundEvent == EEventPlayStart)
sl@0
  1485
				{
sl@0
  1486
				// Initializing DevSound object for playing mode to process audio data via desired FourCC code
sl@0
  1487
				INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL"));
sl@0
  1488
				TInt err;
sl@0
  1489
				if(iUseFourCC)
sl@0
  1490
					{
sl@0
  1491
					TRAP(err, iMMFDevSound->InitializeL(*this, iInputDataType, EMMFStatePlaying));
sl@0
  1492
					}
sl@0
  1493
				else
sl@0
  1494
					{
sl@0
  1495
					TRAP(err, iMMFDevSound->InitializeL(*this, EMMFStatePlaying));
sl@0
  1496
					}
sl@0
  1497
				if (err != KErrNone)
sl@0
  1498
					{
sl@0
  1499
					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
sl@0
  1500
					StopTest(err);
sl@0
  1501
					break;
sl@0
  1502
					}
sl@0
  1503
				INFO_PRINTF1(_L("State: EStatePlayInitializing"));
sl@0
  1504
				iPlayState = EStatePlayInitializing;
sl@0
  1505
				}
sl@0
  1506
			else
sl@0
  1507
				{
sl@0
  1508
				ERR_PRINTF2(_L("DevSound EEventPlayStart not received as expected. Received event: %d"), aDevSoundEvent);
sl@0
  1509
				StopTest(aError, EFail);
sl@0
  1510
				}
sl@0
  1511
			break;
sl@0
  1512
			}
sl@0
  1513
sl@0
  1514
		case EStatePlayInitializing:
sl@0
  1515
			{
sl@0
  1516
			if (aDevSoundEvent == EEventInitCompletePlay && aError == KErrNone)
sl@0
  1517
				{
sl@0
  1518
				if(iConfig)
sl@0
  1519
					{
sl@0
  1520
					// Set Devsound capability settings using CMMFDevSound::SetConfigL
sl@0
  1521
					SetSampleRateAndChannelMode();
sl@0
  1522
					TMMFCapabilities capabilities;
sl@0
  1523
					capabilities.iRate = ConvertDesToTMMFSampleRate(iSampleRate);
sl@0
  1524
					capabilities.iChannels = ConvertDesToTMMFMonoStereo(iMonoStereo);
sl@0
  1525
sl@0
  1526
					TRAPD(errConfig, iMMFDevSound->SetConfigL(capabilities));
sl@0
  1527
					if (errConfig != KErrNone)
sl@0
  1528
						{
sl@0
  1529
						ERR_PRINTF2(_L("CMMFDevSound::SetConfigL() left with error = %d"), errConfig);
sl@0
  1530
						StopTest(errConfig);
sl@0
  1531
						return;
sl@0
  1532
						}
sl@0
  1533
					}
sl@0
  1534
				// Initialize audio device and starts the playing process
sl@0
  1535
				INFO_PRINTF1(_L("Calling CMMFDevSound::PlayInitL()"));
sl@0
  1536
				TRAPD(errPlay, iMMFDevSound->PlayInitL());
sl@0
  1537
				if (errPlay != KErrNone)
sl@0
  1538
					{
sl@0
  1539
					ERR_PRINTF2(_L("CMMFDevSound::PlayInitL() left with error = %d"), errPlay);
sl@0
  1540
					StopTest(errPlay);
sl@0
  1541
					break;
sl@0
  1542
					}
sl@0
  1543
				INFO_PRINTF1(_L("State: EStatePlaying"));
sl@0
  1544
				iPlayState = EStatePlaying;
sl@0
  1545
				}
sl@0
  1546
			else if (aDevSoundEvent == EEventInitCompletePlay && aError != KErrNone)
sl@0
  1547
				{
sl@0
  1548
				ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError);
sl@0
  1549
				StopTest(aError);
sl@0
  1550
				}
sl@0
  1551
			else
sl@0
  1552
				{
sl@0
  1553
				ERR_PRINTF2(_L("DevSound EEventInitCompletePlay not received as expected. Received event: %d"), aDevSoundEvent);
sl@0
  1554
				StopTest(aError, EFail);
sl@0
  1555
				}
sl@0
  1556
			break;
sl@0
  1557
			}
sl@0
  1558
sl@0
  1559
		case EStatePlaying:
sl@0
  1560
			{
sl@0
  1561
			__ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundFlushBuffersPaused"),EFsmIncorrectErrorPassed));
sl@0
  1562
			if (aDevSoundEvent == EEventBTBF)
sl@0
  1563
				{
sl@0
  1564
				// Fill the buffer with audio data and play the data in the buffer
sl@0
  1565
				CMMFDataBuffer* buffer = static_cast <CMMFDataBuffer*> (iBuffer);
sl@0
  1566
				TInt err = iFile.Read(buffer->Data());
sl@0
  1567
				if (err != KErrNone)
sl@0
  1568
					{
sl@0
  1569
					ERR_PRINTF2(_L("ERROR : iFile.Read() failed with %d"), err);
sl@0
  1570
					StopTest(err);
sl@0
  1571
					break;
sl@0
  1572
					}
sl@0
  1573
				if (buffer->Data().Length() != buffer->RequestSize())
sl@0
  1574
					{
sl@0
  1575
					INFO_PRINTF3(_L("Data length copied from file = %d. Expected = %d. Must be EOF."), buffer->Data().Length(), buffer->RequestSize());
sl@0
  1576
					iBuffer->SetLastBuffer(ETrue);
sl@0
  1577
					}
sl@0
  1578
				if (iCheckTimer)
sl@0
  1579
					{
sl@0
  1580
					iTimer->Start(KMicroSecsInTenSecs, 0, iCallBack);
sl@0
  1581
					}
sl@0
  1582
				// Playing data in the buffer at the current volume
sl@0
  1583
				iMMFDevSound->PlayData();
sl@0
  1584
				iBufferCount++;
sl@0
  1585
				iCheckTimer = EFalse;
sl@0
  1586
				}
sl@0
  1587
			else if (aDevSoundEvent == EEventPlayTimerComplete)
sl@0
  1588
				{
sl@0
  1589
				INFO_PRINTF1(_L("Calling CMMFDevSound::Pause()"));
sl@0
  1590
				iMMFDevSound->Pause();
sl@0
  1591
				iPlayState = EStatePlayPaused;
sl@0
  1592
				INFO_PRINTF1(_L("State: EStatePlayPaused"));
sl@0
  1593
				}
sl@0
  1594
			else
sl@0
  1595
				{
sl@0
  1596
				ERR_PRINTF2(_L("DevSound EEventBTBF not received as expected. Received event: %d"), aDevSoundEvent);
sl@0
  1597
				StopTest(aError, EFail);
sl@0
  1598
				}
sl@0
  1599
sl@0
  1600
			break;
sl@0
  1601
			}
sl@0
  1602
sl@0
  1603
		case EStatePlayPaused:
sl@0
  1604
			{
sl@0
  1605
			__ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundFlushBuffersPaused"),EFsmIncorrectErrorPassed));
sl@0
  1606
			TInt err;
sl@0
  1607
			if (aDevSoundEvent == EEventPlayPaused)
sl@0
  1608
				{
sl@0
  1609
				err = iMMFDevSound->EmptyBuffers();
sl@0
  1610
				INFO_PRINTF2(_L("EmptyBuffers in paused state returned with %d"), err);
sl@0
  1611
				INFO_PRINTF2(_L("Expected to return with %d"), KErrNone);
sl@0
  1612
				StopTest(err);
sl@0
  1613
				}
sl@0
  1614
			break;
sl@0
  1615
			}
sl@0
  1616
sl@0
  1617
		default:
sl@0
  1618
			{
sl@0
  1619
			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iPlayState);
sl@0
  1620
			StopTest(KErrGeneral);
sl@0
  1621
			}
sl@0
  1622
		}
sl@0
  1623
sl@0
  1624
	}
sl@0
  1625
sl@0
  1626
/*
sl@0
  1627
 *
sl@0
  1628
 * BufferToBeFilled
sl@0
  1629
 *
sl@0
  1630
 */
sl@0
  1631
void RStepA3FDevSoundFlushBuffersPaused::BufferToBeFilled(CMMFBuffer* aBuffer)
sl@0
  1632
	{
sl@0
  1633
	if (!aBuffer)
sl@0
  1634
		{
sl@0
  1635
		ERR_PRINTF1(_L("BufferToBeFilled callback received a NULL CMMFBuffer!"));
sl@0
  1636
		StopTest(KErrGeneral);
sl@0
  1637
		return;
sl@0
  1638
		}
sl@0
  1639
sl@0
  1640
	iBuffer = aBuffer;
sl@0
  1641
sl@0
  1642
	if(iPlayState != EStatePlayPaused)
sl@0
  1643
		{
sl@0
  1644
		Fsm(EEventBTBF, KErrNone);
sl@0
  1645
		}
sl@0
  1646
sl@0
  1647
	}
sl@0
  1648
sl@0
  1649
/*
sl@0
  1650
 *
sl@0
  1651
 * DoTimerCallback
sl@0
  1652
 *
sl@0
  1653
 */
sl@0
  1654
void RStepA3FDevSoundFlushBuffersPaused::DoTimerCallback()
sl@0
  1655
	{
sl@0
  1656
	iTimer->Cancel(); // only really wanted a one-shot
sl@0
  1657
	if(!iCheckTimer)
sl@0
  1658
		{
sl@0
  1659
		Fsm(EEventPlayTimerComplete, KErrNone);
sl@0
  1660
		Fsm(EEventPlayPaused, KErrNone);
sl@0
  1661
		}
sl@0
  1662
	else
sl@0
  1663
		{
sl@0
  1664
		StopTest(KErrGeneral);
sl@0
  1665
		}
sl@0
  1666
sl@0
  1667
	}
sl@0
  1668
sl@0
  1669
//
sl@0
  1670
// RStepA3FDevSoundInvalidStatePlay
sl@0
  1671
//
sl@0
  1672
sl@0
  1673
/*
sl@0
  1674
 *
sl@0
  1675
 * RStepA3FDevSoundInvalidStatePlay - Test step constructor
sl@0
  1676
 *
sl@0
  1677
 */
sl@0
  1678
RStepA3FDevSoundInvalidStatePlay::RStepA3FDevSoundInvalidStatePlay(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType)
sl@0
  1679
:RTestStepA3FDevSoundPlayBase(aTestName, aSectName, aInputDataType)
sl@0
  1680
	{
sl@0
  1681
	}
sl@0
  1682
sl@0
  1683
/*
sl@0
  1684
 *
sl@0
  1685
 * NewL
sl@0
  1686
 *
sl@0
  1687
 */
sl@0
  1688
RStepA3FDevSoundInvalidStatePlay* RStepA3FDevSoundInvalidStatePlay::NewL(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType)
sl@0
  1689
	{
sl@0
  1690
	RStepA3FDevSoundInvalidStatePlay* self = new (ELeave) RStepA3FDevSoundInvalidStatePlay(aTestName, aSectName, aInputDataType);
sl@0
  1691
	return self;
sl@0
  1692
sl@0
  1693
	}
sl@0
  1694
sl@0
  1695
/*
sl@0
  1696
 *
sl@0
  1697
 * KickoffTestL
sl@0
  1698
 * - Starts the test
sl@0
  1699
 *
sl@0
  1700
 */
sl@0
  1701
void RStepA3FDevSoundInvalidStatePlay::KickoffTestL()
sl@0
  1702
	{
sl@0
  1703
	// Create instance of CMMFDevSound
sl@0
  1704
	INFO_PRINTF1(_L("--- Creating DevSound object..."));
sl@0
  1705
	iMMFDevSound = CMMFDevSound::NewL();
sl@0
  1706
sl@0
  1707
	//Display the name of Codec being used
sl@0
  1708
	DisplayCodecInfo();
sl@0
  1709
	if(!GetBoolFromConfig(iSectName, _L("UseFourCC"), iUseFourCC))
sl@0
  1710
		{
sl@0
  1711
		TPtrC keyName(_L("UseFourCC"));
sl@0
  1712
		ERR_PRINTF3(_L("Error in getting UseFourCC flag value from config file in %S section via the %S key field."), &iSectName, &keyName);
sl@0
  1713
		StopTest(KErrPathNotFound);
sl@0
  1714
		return;
sl@0
  1715
		}
sl@0
  1716
sl@0
  1717
	Fsm(EEventPlayStart,KErrNone); // call to start the DevSound finite state machine for playing
sl@0
  1718
sl@0
  1719
	}
sl@0
  1720
sl@0
  1721
/*
sl@0
  1722
 *
sl@0
  1723
 * Fsm
sl@0
  1724
 *	- Executes playing events of DevSound in sequence
sl@0
  1725
 *
sl@0
  1726
 */
sl@0
  1727
void RStepA3FDevSoundInvalidStatePlay::Fsm(TDevSoundPlayEvents aDevSoundEvent, TInt aError)
sl@0
  1728
	{
sl@0
  1729
	switch (iPlayState)
sl@0
  1730
		{
sl@0
  1731
		case EStatePlayStart:
sl@0
  1732
			{
sl@0
  1733
			__ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundInvalidStatePlay"),EFsmIncorrectErrorPassed));
sl@0
  1734
			if (aDevSoundEvent == EEventPlayStart)
sl@0
  1735
				{
sl@0
  1736
				// Initializing DevSound object for playing mode to process audio data via desired FourCC code
sl@0
  1737
				INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL"));
sl@0
  1738
				TInt err;
sl@0
  1739
				INFO_PRINTF1(_L("Initializing DevSound in EMMFStateRecording"));
sl@0
  1740
				if(iUseFourCC)
sl@0
  1741
					{
sl@0
  1742
					TRAP(err, iMMFDevSound->InitializeL(*this, iInputDataType, EMMFStateRecording));
sl@0
  1743
					}
sl@0
  1744
				else
sl@0
  1745
					{
sl@0
  1746
					TRAP(err, iMMFDevSound->InitializeL(*this, EMMFStateRecording));
sl@0
  1747
					}
sl@0
  1748
				if (err != KErrNone)
sl@0
  1749
					{
sl@0
  1750
					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
sl@0
  1751
					StopTest(err, EFail);
sl@0
  1752
					break;
sl@0
  1753
					}
sl@0
  1754
				INFO_PRINTF1(_L("State: EStatePlayInitializing"));
sl@0
  1755
				iPlayState = EStatePlayInitializing;
sl@0
  1756
				}
sl@0
  1757
			else
sl@0
  1758
				{
sl@0
  1759
				ERR_PRINTF2(_L("DevSound EEventPlayStart not received as expected. Received event: %d"), aDevSoundEvent);
sl@0
  1760
				StopTest(aError, EFail);
sl@0
  1761
				}
sl@0
  1762
			break;
sl@0
  1763
			}
sl@0
  1764
sl@0
  1765
		case EStatePlayInitializing:
sl@0
  1766
			{
sl@0
  1767
			if (aDevSoundEvent == EEventInitCompletePlay && aError == KErrNone)
sl@0
  1768
				{
sl@0
  1769
				// Initialize audio device and start the playing process
sl@0
  1770
				// Calling CMMFDevSound::PlayInitL() when DevSound initialized for record mode!
sl@0
  1771
				INFO_PRINTF1(_L("Calling CMMFDevSound::PlayInitL()"));
sl@0
  1772
				TRAPD(errPlay, iMMFDevSound->PlayInitL());
sl@0
  1773
				if (errPlay == KErrNotReady)
sl@0
  1774
					{
sl@0
  1775
					ERR_PRINTF2(_L("CMMFDevSound::PlayInitL() left as expected with error = %d"), errPlay);
sl@0
  1776
					StopTest(errPlay,EPass);
sl@0
  1777
					}
sl@0
  1778
				else
sl@0
  1779
					{
sl@0
  1780
					ERR_PRINTF2(_L("CMMFDevSound::PlayInitL did NOT leave with KErrNotReady as expected. Error = %d"), errPlay);
sl@0
  1781
					StopTest(KErrUnknown);
sl@0
  1782
					}
sl@0
  1783
				}
sl@0
  1784
			else if (aDevSoundEvent == EEventInitCompletePlay && aError != KErrNone)
sl@0
  1785
				{
sl@0
  1786
				ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError);
sl@0
  1787
				StopTest(aError);
sl@0
  1788
				}
sl@0
  1789
			else
sl@0
  1790
				{
sl@0
  1791
				ERR_PRINTF2(_L("DevSound EEventInitCompletePlay not received as expected. Received event: %d"), aDevSoundEvent);
sl@0
  1792
				StopTest(aError, EFail);
sl@0
  1793
				}
sl@0
  1794
sl@0
  1795
			break;
sl@0
  1796
sl@0
  1797
			}
sl@0
  1798
		default:
sl@0
  1799
			{
sl@0
  1800
			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iPlayState);
sl@0
  1801
			StopTest(KErrGeneral);
sl@0
  1802
			}
sl@0
  1803
		}
sl@0
  1804
sl@0
  1805
	}
sl@0
  1806
sl@0
  1807
/*
sl@0
  1808
 *
sl@0
  1809
 * BufferToBeFilled
sl@0
  1810
 *
sl@0
  1811
 */
sl@0
  1812
void RStepA3FDevSoundInvalidStatePlay::BufferToBeFilled(CMMFBuffer* aBuffer)
sl@0
  1813
	{
sl@0
  1814
	if (!aBuffer)
sl@0
  1815
		{
sl@0
  1816
		ERR_PRINTF1(_L("BufferToBeFilled callback received a NULL CMMFBuffer!"));
sl@0
  1817
		StopTest(KErrGeneral);
sl@0
  1818
		return;
sl@0
  1819
		}
sl@0
  1820
sl@0
  1821
	iBuffer = aBuffer;
sl@0
  1822
sl@0
  1823
	// Call to continue the Play process
sl@0
  1824
	Fsm(EEventBTBF,KErrNone);
sl@0
  1825
sl@0
  1826
	}
sl@0
  1827
sl@0
  1828
/*
sl@0
  1829
 *
sl@0
  1830
 * PlayError
sl@0
  1831
 *
sl@0
  1832
 */
sl@0
  1833
void RStepA3FDevSoundInvalidStatePlay::PlayError(TInt aError)
sl@0
  1834
	{
sl@0
  1835
	if ((iPlayState == EStatePlaying) && (aError == KErrNotSupported))
sl@0
  1836
		{
sl@0
  1837
		INFO_PRINTF2(_L("DevSound called PlayError with expected error = %d"), aError);
sl@0
  1838
		StopTest(aError, EPass);
sl@0
  1839
		}
sl@0
  1840
	else
sl@0
  1841
		{
sl@0
  1842
		INFO_PRINTF1(_L("Expected error = -5"));
sl@0
  1843
		ERR_PRINTF2(_L("DevSound called PlayError with error = %d"), aError);
sl@0
  1844
		StopTest(aError, EFail);
sl@0
  1845
		}
sl@0
  1846
sl@0
  1847
	}
sl@0
  1848
sl@0
  1849
//
sl@0
  1850
// RStepA3FDevSoundFlushBuffersPlaying
sl@0
  1851
//
sl@0
  1852
sl@0
  1853
/*
sl@0
  1854
 *
sl@0
  1855
 * RStepA3FDevSoundFlushBuffersPlaying - Test step constructor
sl@0
  1856
 *
sl@0
  1857
 */
sl@0
  1858
RStepA3FDevSoundFlushBuffersPlaying::RStepA3FDevSoundFlushBuffersPlaying(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType)
sl@0
  1859
:RTestStepA3FDevSoundPlayBase(aTestName, aSectName, aInputDataType)
sl@0
  1860
	{
sl@0
  1861
	}
sl@0
  1862
sl@0
  1863
/*
sl@0
  1864
 *
sl@0
  1865
 * NewL
sl@0
  1866
 *
sl@0
  1867
 */
sl@0
  1868
RStepA3FDevSoundFlushBuffersPlaying* RStepA3FDevSoundFlushBuffersPlaying::NewL(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType)
sl@0
  1869
	{
sl@0
  1870
	RStepA3FDevSoundFlushBuffersPlaying* self = new (ELeave) RStepA3FDevSoundFlushBuffersPlaying(aTestName, aSectName, aInputDataType);
sl@0
  1871
	return self;
sl@0
  1872
sl@0
  1873
	}
sl@0
  1874
sl@0
  1875
/*
sl@0
  1876
 *
sl@0
  1877
 * Fsm
sl@0
  1878
 *	- Executes playing events of DevSound in sequence
sl@0
  1879
 *
sl@0
  1880
 */
sl@0
  1881
void RStepA3FDevSoundFlushBuffersPlaying::Fsm(TDevSoundPlayEvents aDevSoundEvent, TInt aError)
sl@0
  1882
	{
sl@0
  1883
	switch (iPlayState)
sl@0
  1884
		{
sl@0
  1885
		case EStatePlayStart:
sl@0
  1886
			{
sl@0
  1887
			__ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundFlushBuffersPlaying"),EFsmIncorrectErrorPassed));
sl@0
  1888
			if (aDevSoundEvent == EEventPlayStart)
sl@0
  1889
				{
sl@0
  1890
				// Initializing DevSound object for playing mode to process audio data via desired FourCC code
sl@0
  1891
				INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL"));
sl@0
  1892
				TInt err;
sl@0
  1893
				if(iUseFourCC)
sl@0
  1894
					{
sl@0
  1895
					TRAP(err, iMMFDevSound->InitializeL(*this, iInputDataType, EMMFStatePlaying));
sl@0
  1896
					}
sl@0
  1897
				else
sl@0
  1898
					{
sl@0
  1899
					TRAP(err, iMMFDevSound->InitializeL(*this, EMMFStatePlaying));
sl@0
  1900
					}
sl@0
  1901
				if (err != KErrNone)
sl@0
  1902
					{
sl@0
  1903
					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
sl@0
  1904
					StopTest(err);
sl@0
  1905
					break;
sl@0
  1906
					}
sl@0
  1907
				INFO_PRINTF1(_L("State: EStatePlayInitializing"));
sl@0
  1908
				iPlayState = EStatePlayInitializing;
sl@0
  1909
				}
sl@0
  1910
			else
sl@0
  1911
				{
sl@0
  1912
				ERR_PRINTF2(_L("DevSound EEventPlayStart not received as expected. Received event: %d"), aDevSoundEvent);
sl@0
  1913
				StopTest(aError, EFail);
sl@0
  1914
				}
sl@0
  1915
			break;
sl@0
  1916
			}
sl@0
  1917
sl@0
  1918
		case EStatePlayInitializing:
sl@0
  1919
			{
sl@0
  1920
			if (aDevSoundEvent == EEventInitCompletePlay && aError == KErrNone)
sl@0
  1921
				{
sl@0
  1922
				if(iConfig)
sl@0
  1923
					{
sl@0
  1924
					// Set Devsound capability settings using CMMFDevSound::SetConfigL
sl@0
  1925
					SetSampleRateAndChannelMode();
sl@0
  1926
					TMMFCapabilities capabilities;
sl@0
  1927
					capabilities.iRate = ConvertDesToTMMFSampleRate(iSampleRate);
sl@0
  1928
					capabilities.iChannels = ConvertDesToTMMFMonoStereo(iMonoStereo);
sl@0
  1929
sl@0
  1930
					TRAPD(errConfig, iMMFDevSound->SetConfigL(capabilities));
sl@0
  1931
					if (errConfig != KErrNone)
sl@0
  1932
						{
sl@0
  1933
						ERR_PRINTF2(_L("CMMFDevSound::SetConfigL() left with error = %d"), errConfig);
sl@0
  1934
						StopTest(errConfig);
sl@0
  1935
						break;
sl@0
  1936
						}
sl@0
  1937
					}
sl@0
  1938
				// Initialize audio device and starts the playing process
sl@0
  1939
				INFO_PRINTF1(_L("Calling CMMFDevSound::PlayInitL()"));
sl@0
  1940
				TRAPD(errPlay, iMMFDevSound->PlayInitL());
sl@0
  1941
				if (errPlay != KErrNone)
sl@0
  1942
					{
sl@0
  1943
					ERR_PRINTF2(_L("CMMFDevSound::PlayInitL() left with error = %d"), errPlay);
sl@0
  1944
					StopTest(errPlay);
sl@0
  1945
					break;
sl@0
  1946
					}
sl@0
  1947
				INFO_PRINTF1(_L("State: EStatePlaying"));
sl@0
  1948
				iPlayState = EStatePlaying;
sl@0
  1949
				}
sl@0
  1950
			else if (aDevSoundEvent == EEventInitCompletePlay && aError != KErrNone)
sl@0
  1951
				{
sl@0
  1952
				ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError);
sl@0
  1953
				StopTest(aError);
sl@0
  1954
				}
sl@0
  1955
			else
sl@0
  1956
				{
sl@0
  1957
				ERR_PRINTF2(_L("DevSound EEventInitCompletePlay not received as expected. Received event: %d"), aDevSoundEvent);
sl@0
  1958
				StopTest(aError, EFail);
sl@0
  1959
				}
sl@0
  1960
			break;
sl@0
  1961
			}
sl@0
  1962
sl@0
  1963
		case EStatePlaying:
sl@0
  1964
			{
sl@0
  1965
			__ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundFlushBuffersPlaying"),EFsmIncorrectErrorPassed));
sl@0
  1966
			if (aDevSoundEvent == EEventBTBF)
sl@0
  1967
				{
sl@0
  1968
				// Fill the buffer with audio data and play the data in the buffer
sl@0
  1969
				CMMFDataBuffer* buffer = static_cast <CMMFDataBuffer*> (iBuffer);
sl@0
  1970
				TInt err = iFile.Read(buffer->Data());
sl@0
  1971
				if (err != KErrNone)
sl@0
  1972
					{
sl@0
  1973
					ERR_PRINTF2(_L("ERROR : iFile.Read() failed with %d"), err);
sl@0
  1974
					StopTest(err);
sl@0
  1975
					break;
sl@0
  1976
					}
sl@0
  1977
				if (buffer->Data().Length() != buffer->RequestSize())
sl@0
  1978
					{
sl@0
  1979
					INFO_PRINTF3(_L("Data length copied from file = %d. Expected = %d. Must be EOF."), buffer->Data().Length(), buffer->RequestSize());
sl@0
  1980
					iBuffer->SetLastBuffer(ETrue);
sl@0
  1981
					}
sl@0
  1982
sl@0
  1983
				INFO_PRINTF1(_L("Calling CMMFDevSound::EmptyBuffers() during playing"));
sl@0
  1984
				err = iMMFDevSound->EmptyBuffers();
sl@0
  1985
				INFO_PRINTF2(_L("CMMFDevSound::EmptyBuffers() left with error = %d"), err);
sl@0
  1986
				if(err == KErrNone)
sl@0
  1987
					{
sl@0
  1988
					StopTest(err, EPass);
sl@0
  1989
					}
sl@0
  1990
				else
sl@0
  1991
					{
sl@0
  1992
					StopTest(err, EFail);
sl@0
  1993
					}
sl@0
  1994
				}
sl@0
  1995
			else
sl@0
  1996
				{
sl@0
  1997
				ERR_PRINTF2(_L("DevSound EEventBTBF not received as expected. Received event: %d"), aDevSoundEvent);
sl@0
  1998
				StopTest(aError, EFail);
sl@0
  1999
				}
sl@0
  2000
			break;
sl@0
  2001
			}
sl@0
  2002
sl@0
  2003
		default:
sl@0
  2004
			{
sl@0
  2005
			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iPlayState);
sl@0
  2006
			StopTest(KErrGeneral);
sl@0
  2007
			}
sl@0
  2008
		}
sl@0
  2009
sl@0
  2010
	}
sl@0
  2011
sl@0
  2012
//
sl@0
  2013
// RStepA3FDevSoundInitializeWhilePlaying
sl@0
  2014
//
sl@0
  2015
sl@0
  2016
/*
sl@0
  2017
 *
sl@0
  2018
 * RStepA3FDevSoundInitializeWhilePlaying - Test step constructor
sl@0
  2019
 *
sl@0
  2020
 */
sl@0
  2021
RStepA3FDevSoundInitializeWhilePlaying::RStepA3FDevSoundInitializeWhilePlaying(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType)
sl@0
  2022
:RTestStepA3FDevSoundPlayBase(aTestName, aSectName, aInputDataType),
sl@0
  2023
 iCheckTimer(ETrue)
sl@0
  2024
	{
sl@0
  2025
	}
sl@0
  2026
sl@0
  2027
/*
sl@0
  2028
 *
sl@0
  2029
 * NewL
sl@0
  2030
 *
sl@0
  2031
 */
sl@0
  2032
RStepA3FDevSoundInitializeWhilePlaying* RStepA3FDevSoundInitializeWhilePlaying::NewL(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType)
sl@0
  2033
	{
sl@0
  2034
	RStepA3FDevSoundInitializeWhilePlaying* self = new (ELeave) RStepA3FDevSoundInitializeWhilePlaying(aTestName, aSectName, aInputDataType);
sl@0
  2035
	return self;
sl@0
  2036
sl@0
  2037
	}
sl@0
  2038
sl@0
  2039
/*
sl@0
  2040
 *
sl@0
  2041
 * Fsm
sl@0
  2042
 *	- Executes playing events of DevSound in sequence
sl@0
  2043
 *
sl@0
  2044
 */
sl@0
  2045
void RStepA3FDevSoundInitializeWhilePlaying::Fsm(TDevSoundPlayEvents aDevSoundEvent, TInt aError)
sl@0
  2046
	{
sl@0
  2047
	switch (iPlayState)
sl@0
  2048
		{
sl@0
  2049
		case EStatePlayStart:
sl@0
  2050
			{
sl@0
  2051
			__ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundInitializeWhilePlaying"),EFsmIncorrectErrorPassed));
sl@0
  2052
			if (aDevSoundEvent == EEventPlayStart)
sl@0
  2053
				{
sl@0
  2054
				// Initializing DevSound object for playing mode to process audio data via desired FourCC code
sl@0
  2055
				INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL"));
sl@0
  2056
				TInt err;
sl@0
  2057
				if(iUseFourCC)
sl@0
  2058
					{
sl@0
  2059
					TRAP(err, iMMFDevSound->InitializeL(*this, iInputDataType, EMMFStatePlaying));
sl@0
  2060
					}
sl@0
  2061
				else
sl@0
  2062
					{
sl@0
  2063
					TRAP(err, iMMFDevSound->InitializeL(*this, EMMFStatePlaying));
sl@0
  2064
					}
sl@0
  2065
				if (err != KErrNone)
sl@0
  2066
					{
sl@0
  2067
					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
sl@0
  2068
					StopTest(err);
sl@0
  2069
					break;
sl@0
  2070
					}
sl@0
  2071
				INFO_PRINTF1(_L("State: EStatePlayInitializing"));
sl@0
  2072
				iPlayState = EStatePlayInitializing;
sl@0
  2073
				}
sl@0
  2074
			else
sl@0
  2075
				{
sl@0
  2076
				ERR_PRINTF2(_L("DevSound EEventPlayStart not received as expected. Received event: %d"), aDevSoundEvent);
sl@0
  2077
				StopTest(aError, EFail);
sl@0
  2078
				}
sl@0
  2079
			break;
sl@0
  2080
			}
sl@0
  2081
sl@0
  2082
		case EStatePlayInitializing:
sl@0
  2083
			{
sl@0
  2084
			if (aDevSoundEvent == EEventInitCompletePlay && aError == KErrNone)
sl@0
  2085
				{
sl@0
  2086
				if(iConfig)
sl@0
  2087
					{
sl@0
  2088
					// Set Devsound capability settings using CMMFDevSound::SetConfigL
sl@0
  2089
					SetSampleRateAndChannelMode();
sl@0
  2090
					TMMFCapabilities capabilities;
sl@0
  2091
					capabilities.iRate = ConvertDesToTMMFSampleRate(iSampleRate);
sl@0
  2092
					capabilities.iChannels = ConvertDesToTMMFMonoStereo(iMonoStereo);
sl@0
  2093
sl@0
  2094
					TRAPD(errConfig, iMMFDevSound->SetConfigL(capabilities));
sl@0
  2095
					if (errConfig != KErrNone)
sl@0
  2096
						{
sl@0
  2097
						ERR_PRINTF2(_L("CMMFDevSound::SetConfigL() left with error = %d"), errConfig);
sl@0
  2098
						StopTest(errConfig);
sl@0
  2099
						break;
sl@0
  2100
						}
sl@0
  2101
					}
sl@0
  2102
				// Initialize audio device and starts the playing process
sl@0
  2103
				INFO_PRINTF1(_L("Calling CMMFDevSound::PlayInitL()"));
sl@0
  2104
				TRAPD(errPlay, iMMFDevSound->PlayInitL());
sl@0
  2105
				if (errPlay != KErrNone)
sl@0
  2106
					{
sl@0
  2107
					ERR_PRINTF2(_L("CMMFDevSound::PlayInitL() left with error = %d"), errPlay);
sl@0
  2108
					StopTest(errPlay);
sl@0
  2109
					break;
sl@0
  2110
					}
sl@0
  2111
				INFO_PRINTF1(_L("State: EStatePlaying"));
sl@0
  2112
				iPlayState = EStatePlaying;
sl@0
  2113
				}
sl@0
  2114
			else if (aDevSoundEvent == EEventInitCompletePlay && aError != KErrNone)
sl@0
  2115
				{
sl@0
  2116
				ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError);
sl@0
  2117
				StopTest(aError);
sl@0
  2118
				}
sl@0
  2119
			else
sl@0
  2120
				{
sl@0
  2121
				ERR_PRINTF2(_L("DevSound EEventInitCompletePlay not received as expected. Received event: %d"), aDevSoundEvent);
sl@0
  2122
				StopTest(aError, EFail);
sl@0
  2123
				}
sl@0
  2124
			break;
sl@0
  2125
			}
sl@0
  2126
sl@0
  2127
		case EStatePlaying:
sl@0
  2128
			{
sl@0
  2129
			__ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundInitializeWhilePlaying"),EFsmIncorrectErrorPassed));
sl@0
  2130
			if (aDevSoundEvent == EEventBTBF)
sl@0
  2131
				{
sl@0
  2132
				// Fill the buffer with audio data and play the data in the buffer
sl@0
  2133
				CMMFDataBuffer* buffer = static_cast <CMMFDataBuffer*> (iBuffer);
sl@0
  2134
				TInt err = iFile.Read(buffer->Data());
sl@0
  2135
				if (err != KErrNone)
sl@0
  2136
					{
sl@0
  2137
					ERR_PRINTF2(_L("ERROR : iFile.Read() failed with %d"), err);
sl@0
  2138
					StopTest(err);
sl@0
  2139
					break;
sl@0
  2140
					}
sl@0
  2141
				if (buffer->Data().Length() != buffer->RequestSize())
sl@0
  2142
					{
sl@0
  2143
					INFO_PRINTF3(_L("Data length copied from file = %d. Expected = %d. Must be EOF."), buffer->Data().Length(), buffer->RequestSize());
sl@0
  2144
					iBuffer->SetLastBuffer(ETrue);
sl@0
  2145
					}
sl@0
  2146
sl@0
  2147
				if (iCheckTimer)
sl@0
  2148
					{
sl@0
  2149
					iTimer->Start(KMicroSecsInTenSecs, 0, iCallBack);
sl@0
  2150
					}
sl@0
  2151
				iCheckTimer = EFalse;
sl@0
  2152
				}
sl@0
  2153
			else
sl@0
  2154
				{
sl@0
  2155
				ERR_PRINTF2(_L("DevSound EEventBTBF not received as expected. Received event: %d"), aDevSoundEvent);
sl@0
  2156
				StopTest(aError, EFail);
sl@0
  2157
				}
sl@0
  2158
			break;
sl@0
  2159
			}
sl@0
  2160
sl@0
  2161
		default:
sl@0
  2162
			{
sl@0
  2163
			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iPlayState);
sl@0
  2164
			StopTest(KErrGeneral);
sl@0
  2165
			}
sl@0
  2166
		}
sl@0
  2167
sl@0
  2168
	}
sl@0
  2169
sl@0
  2170
/*
sl@0
  2171
 *
sl@0
  2172
 * DoTimerCallback
sl@0
  2173
 *
sl@0
  2174
 */
sl@0
  2175
void RStepA3FDevSoundInitializeWhilePlaying::DoTimerCallback()
sl@0
  2176
	{
sl@0
  2177
	iTimer->Cancel(); // only really wanted a one-shot
sl@0
  2178
	if(!iCheckTimer)
sl@0
  2179
		{
sl@0
  2180
		INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL() during playing"));
sl@0
  2181
		TRAPD(errInit, iMMFDevSound->InitializeL(*this, iInputDataType, EMMFStatePlaying));
sl@0
  2182
		INFO_PRINTF2(_L("CMMFDevSound::InitializeL() left with error = %d"), errInit);
sl@0
  2183
		INFO_PRINTF2(_L("Expected error = %d"), KErrNotReady);
sl@0
  2184
		if(errInit == KErrNotReady)
sl@0
  2185
			{
sl@0
  2186
			StopTest(errInit, EPass);
sl@0
  2187
			}
sl@0
  2188
			else
sl@0
  2189
			{
sl@0
  2190
			StopTest(errInit, EFail);
sl@0
  2191
			}
sl@0
  2192
		}
sl@0
  2193
sl@0
  2194
	}
sl@0
  2195
sl@0
  2196
//
sl@0
  2197
// RStepA3FDevSoundSetBalanceDuringPlay
sl@0
  2198
//
sl@0
  2199
sl@0
  2200
/*
sl@0
  2201
 *
sl@0
  2202
 * RStepA3FDevSoundSetBalanceDuringPlay - Test step constructor
sl@0
  2203
 *
sl@0
  2204
 */
sl@0
  2205
RStepA3FDevSoundSetBalanceDuringPlay::RStepA3FDevSoundSetBalanceDuringPlay(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType)
sl@0
  2206
:RTestStepA3FDevSoundPlayBase(aTestName, aSectName, aInputDataType),
sl@0
  2207
 iPlaybalanceLeft(0),
sl@0
  2208
 iPlaybalanceRight(0)
sl@0
  2209
	{
sl@0
  2210
	}
sl@0
  2211
sl@0
  2212
/*
sl@0
  2213
 *
sl@0
  2214
 * NewL
sl@0
  2215
 *
sl@0
  2216
 */
sl@0
  2217
RStepA3FDevSoundSetBalanceDuringPlay* RStepA3FDevSoundSetBalanceDuringPlay::NewL(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType)
sl@0
  2218
	{
sl@0
  2219
	RStepA3FDevSoundSetBalanceDuringPlay* self = new (ELeave) RStepA3FDevSoundSetBalanceDuringPlay(aTestName, aSectName, aInputDataType);
sl@0
  2220
	return self;
sl@0
  2221
sl@0
  2222
	}
sl@0
  2223
sl@0
  2224
/*
sl@0
  2225
 *
sl@0
  2226
 * DoKickoffTestL
sl@0
  2227
 *
sl@0
  2228
 */
sl@0
  2229
void RStepA3FDevSoundSetBalanceDuringPlay::DoKickoffTestL()
sl@0
  2230
	{
sl@0
  2231
	INFO_PRINTF2(_L("File to be played -> %S"), &iFilename);
sl@0
  2232
	DisplayCodecInfo();
sl@0
  2233
	CheckConfigAndFourCCUsage();
sl@0
  2234
sl@0
  2235
	TBool balance = GetIntFromConfig(iSectName,_L("PlaybalanceLeft"),iPlaybalanceLeft );
sl@0
  2236
	if (balance)
sl@0
  2237
		{
sl@0
  2238
		// Getting the Left balance from Config file
sl@0
  2239
		INFO_PRINTF2(_L("Left Percentage Playbalance = %d"),iPlaybalanceLeft);
sl@0
  2240
		}
sl@0
  2241
	else
sl@0
  2242
		{
sl@0
  2243
		TPtrC keyName(_L("PlaybalanceLeft"));
sl@0
  2244
		ERR_PRINTF3(_L("Error in getting left pc playbalance from config file in %S section via the %S key field."), &iSectName, &keyName);
sl@0
  2245
		StopTest(KErrPathNotFound);
sl@0
  2246
		return;
sl@0
  2247
		}
sl@0
  2248
	balance = GetIntFromConfig(iSectName,_L("PlaybalanceRight"),iPlaybalanceRight );
sl@0
  2249
	if (balance)
sl@0
  2250
		{
sl@0
  2251
		// Getting the Right balance from Config file
sl@0
  2252
		INFO_PRINTF2(_L("Right Percentage Playbalance = %d"),iPlaybalanceRight);
sl@0
  2253
		}
sl@0
  2254
	else
sl@0
  2255
		{
sl@0
  2256
		TPtrC keyName(_L("PlaybalanceRight"));
sl@0
  2257
		ERR_PRINTF3(_L("Error in getting right pc playbalance from config file in %S section via the %S key field."), &iSectName, &keyName);
sl@0
  2258
		StopTest(KErrPathNotFound);
sl@0
  2259
		return;
sl@0
  2260
		}
sl@0
  2261
sl@0
  2262
	}
sl@0
  2263
sl@0
  2264
/*
sl@0
  2265
 *
sl@0
  2266
 * BufferToBeFilled
sl@0
  2267
 *
sl@0
  2268
 */
sl@0
  2269
void RStepA3FDevSoundSetBalanceDuringPlay::BufferToBeFilled(CMMFBuffer* aBuffer)
sl@0
  2270
	{
sl@0
  2271
	if (!aBuffer)
sl@0
  2272
		{
sl@0
  2273
		ERR_PRINTF1(_L("BufferToBeFilled callback received a NULL CMMFBuffer!"));
sl@0
  2274
		StopTest(KErrGeneral);
sl@0
  2275
		return;
sl@0
  2276
		}
sl@0
  2277
sl@0
  2278
	iBuffer = aBuffer;
sl@0
  2279
sl@0
  2280
	INFO_PRINTF3(_L("Setting left and right playbalance. left = %d right = %d"), iPlaybalanceLeft, iPlaybalanceRight );
sl@0
  2281
	TRAPD(setErr, iMMFDevSound->SetPlayBalanceL(iPlaybalanceLeft, iPlaybalanceRight));
sl@0
  2282
	if (setErr == KErrNone)
sl@0
  2283
		{
sl@0
  2284
		TInt getLeft = 0;
sl@0
  2285
		TInt getRight = 0;
sl@0
  2286
		INFO_PRINTF1(_L("Getting left and right playbalance"));
sl@0
  2287
		TRAPD(getErr, iMMFDevSound->GetPlayBalanceL(getLeft, getRight));
sl@0
  2288
		INFO_PRINTF3(_L("Got left and right playbalance. left = %d right = %d"), getLeft, getRight);
sl@0
  2289
		if (getErr == KErrNone)
sl@0
  2290
			{
sl@0
  2291
			if ((getLeft == iPlaybalanceLeft) && (getRight == iPlaybalanceRight ))
sl@0
  2292
				{
sl@0
  2293
				INFO_PRINTF1(_L("Left and Right playbalanace values are same as the ones that were set"));
sl@0
  2294
				StopTest(getErr);
sl@0
  2295
				}
sl@0
  2296
			else
sl@0
  2297
				{
sl@0
  2298
				ERR_PRINTF1(_L("Let and right playbalanace values are not the same as the ones that were set"));
sl@0
  2299
				StopTest(KErrGeneral);
sl@0
  2300
				}
sl@0
  2301
			}
sl@0
  2302
		else
sl@0
  2303
			{
sl@0
  2304
			ERR_PRINTF1(_L("Error in getting left and right play balance."));
sl@0
  2305
			StopTest(getErr);
sl@0
  2306
			}
sl@0
  2307
		}
sl@0
  2308
	else
sl@0
  2309
		{
sl@0
  2310
		ERR_PRINTF1(_L("Error in setting left and right play balance."));
sl@0
  2311
		StopTest(setErr);
sl@0
  2312
		}
sl@0
  2313
sl@0
  2314
	}
sl@0
  2315
sl@0
  2316
//
sl@0
  2317
// RStepA3FDevSoundPlayStopMultipleTimes
sl@0
  2318
//
sl@0
  2319
sl@0
  2320
/*
sl@0
  2321
 *
sl@0
  2322
 * RStepA3FDevSoundPlayStopMultipleTimes - Test step constructor
sl@0
  2323
 *
sl@0
  2324
 */
sl@0
  2325
RStepA3FDevSoundPlayStopMultipleTimes::RStepA3FDevSoundPlayStopMultipleTimes(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType)
sl@0
  2326
:RTestStepA3FDevSoundPlayBase(aTestName, aSectName, aInputDataType),
sl@0
  2327
iRepeatCount(0),
sl@0
  2328
iRepeatCounter(0),
sl@0
  2329
iCheckTimer(ETrue)
sl@0
  2330
	{
sl@0
  2331
	}
sl@0
  2332
sl@0
  2333
/*
sl@0
  2334
 *
sl@0
  2335
 * NewL
sl@0
  2336
 *
sl@0
  2337
 */
sl@0
  2338
RStepA3FDevSoundPlayStopMultipleTimes* RStepA3FDevSoundPlayStopMultipleTimes::NewL(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType)
sl@0
  2339
	{
sl@0
  2340
	RStepA3FDevSoundPlayStopMultipleTimes* self = new (ELeave) RStepA3FDevSoundPlayStopMultipleTimes(aTestName, aSectName, aInputDataType);
sl@0
  2341
	return self;
sl@0
  2342
sl@0
  2343
	}
sl@0
  2344
sl@0
  2345
/*
sl@0
  2346
 *
sl@0
  2347
 * DoKickoffTestL
sl@0
  2348
 *
sl@0
  2349
 */
sl@0
  2350
void RStepA3FDevSoundPlayStopMultipleTimes::DoKickoffTestL()
sl@0
  2351
	{
sl@0
  2352
	INFO_PRINTF2(_L("File to be played -> %S"), &iFilename);
sl@0
  2353
	DisplayCodecInfo();
sl@0
  2354
	CheckConfigAndFourCCUsage();
sl@0
  2355
sl@0
  2356
	TBool repeatCount = GetIntFromConfig(iSectName,_L("Repeat"),iRepeatCount);
sl@0
  2357
	if (repeatCount)
sl@0
  2358
		{
sl@0
  2359
		INFO_PRINTF2(_L("No. of times to Repeat = %d"), iRepeatCount);
sl@0
  2360
		}
sl@0
  2361
	else
sl@0
  2362
		{
sl@0
  2363
		TPtrC keyName(_L("Repeat"));
sl@0
  2364
		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
  2365
		StopTest(KErrPathNotFound);
sl@0
  2366
		return;
sl@0
  2367
		}
sl@0
  2368
sl@0
  2369
	}
sl@0
  2370
sl@0
  2371
/*
sl@0
  2372
 *
sl@0
  2373
 * Fsm
sl@0
  2374
 *	- Executes playing events of DevSound in sequence
sl@0
  2375
 *
sl@0
  2376
 */
sl@0
  2377
void RStepA3FDevSoundPlayStopMultipleTimes::Fsm(TDevSoundPlayEvents aDevSoundEvent, TInt aError)
sl@0
  2378
	{
sl@0
  2379
	switch (iPlayState)
sl@0
  2380
		{
sl@0
  2381
		case EStatePlayStart:
sl@0
  2382
			{
sl@0
  2383
			__ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundPlayStopMultipleTimes"),EFsmIncorrectErrorPassed));
sl@0
  2384
			if (aDevSoundEvent == EEventPlayStart)
sl@0
  2385
				{
sl@0
  2386
				// Initializing DevSound object for playing mode to process audio data via desired FourCC code
sl@0
  2387
				INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL"));
sl@0
  2388
				TInt err;
sl@0
  2389
				if(iUseFourCC)
sl@0
  2390
					{
sl@0
  2391
					TRAP(err, iMMFDevSound->InitializeL(*this, iInputDataType, EMMFStatePlaying));
sl@0
  2392
					}
sl@0
  2393
				else
sl@0
  2394
					{
sl@0
  2395
					TRAP(err, iMMFDevSound->InitializeL(*this, EMMFStatePlaying));
sl@0
  2396
					}
sl@0
  2397
				if (err != KErrNone)
sl@0
  2398
					{
sl@0
  2399
					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
sl@0
  2400
					StopTest(err);
sl@0
  2401
					break;
sl@0
  2402
					}
sl@0
  2403
				INFO_PRINTF1(_L("State: EStatePlayInitializing"));
sl@0
  2404
				iPlayState = EStatePlayInitializing;
sl@0
  2405
				}
sl@0
  2406
			else
sl@0
  2407
				{
sl@0
  2408
				ERR_PRINTF2(_L("DevSound EEventPlayStart not received as expected. Received event: %d"), aDevSoundEvent);
sl@0
  2409
				StopTest(aError, EFail);
sl@0
  2410
				}
sl@0
  2411
			break;
sl@0
  2412
			}
sl@0
  2413
sl@0
  2414
		case EStatePlayInitializing:
sl@0
  2415
			{
sl@0
  2416
			if (aDevSoundEvent == EEventInitCompletePlay && aError == KErrNone)
sl@0
  2417
				{
sl@0
  2418
				if(iConfig)
sl@0
  2419
					{
sl@0
  2420
					// Set Devsound capability settings using CMMFDevSound::SetConfigL
sl@0
  2421
					SetSampleRateAndChannelMode();
sl@0
  2422
					TMMFCapabilities capabilities;
sl@0
  2423
					capabilities.iRate = ConvertDesToTMMFSampleRate(iSampleRate);
sl@0
  2424
					capabilities.iChannels = ConvertDesToTMMFMonoStereo(iMonoStereo);
sl@0
  2425
sl@0
  2426
					TRAPD(errConfig, iMMFDevSound->SetConfigL(capabilities));
sl@0
  2427
					if (errConfig != KErrNone)
sl@0
  2428
						{
sl@0
  2429
						ERR_PRINTF2(_L("CMMFDevSound::SetConfigL() left with error = %d"), errConfig);
sl@0
  2430
						StopTest(errConfig);
sl@0
  2431
						break;
sl@0
  2432
						}
sl@0
  2433
					}
sl@0
  2434
				// Initialize audio device and starts the playing process
sl@0
  2435
				INFO_PRINTF1(_L("Calling CMMFDevSound::PlayInitL()"));
sl@0
  2436
				TRAPD(errPlay, iMMFDevSound->PlayInitL());
sl@0
  2437
				if (errPlay != KErrNone)
sl@0
  2438
					{
sl@0
  2439
					ERR_PRINTF2(_L("CMMFDevSound::PlayInitL() left with error = %d"), errPlay);
sl@0
  2440
					StopTest(errPlay);
sl@0
  2441
					break;
sl@0
  2442
					}
sl@0
  2443
				INFO_PRINTF1(_L("State: EStatePlaying"));
sl@0
  2444
				iPlayState = EStatePlaying;
sl@0
  2445
				}
sl@0
  2446
			else if (aDevSoundEvent == EEventInitCompletePlay && aError != KErrNone)
sl@0
  2447
				{
sl@0
  2448
				ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError);
sl@0
  2449
				StopTest(aError);
sl@0
  2450
				}
sl@0
  2451
			else
sl@0
  2452
				{
sl@0
  2453
				ERR_PRINTF2(_L("DevSound EEventInitCompletePlay not received as expected. Received event: %d"), aDevSoundEvent);
sl@0
  2454
				StopTest(aError, EFail);
sl@0
  2455
				}
sl@0
  2456
			break;
sl@0
  2457
			}
sl@0
  2458
sl@0
  2459
		case EStatePlaying:
sl@0
  2460
			{
sl@0
  2461
			__ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundPlayStopMultipleTimes"),EFsmIncorrectErrorPassed));
sl@0
  2462
			if (aDevSoundEvent == EEventBTBF)
sl@0
  2463
				{
sl@0
  2464
				// Fill the buffer with audio data and play the data in the buffer
sl@0
  2465
				CMMFDataBuffer* buffer = static_cast <CMMFDataBuffer*> (iBuffer);
sl@0
  2466
				TInt err = iFile.Read(buffer->Data());
sl@0
  2467
				if (err != KErrNone)
sl@0
  2468
					{
sl@0
  2469
					ERR_PRINTF2(_L("ERROR : iFile.Read() failed with %d"), err);
sl@0
  2470
					StopTest(err);
sl@0
  2471
					break;
sl@0
  2472
					}
sl@0
  2473
				if (buffer->Data().Length() != buffer->RequestSize())
sl@0
  2474
					{
sl@0
  2475
					INFO_PRINTF3(_L("Data length copied from file = %d. Expected = %d. Must be EOF."), buffer->Data().Length(), buffer->RequestSize());
sl@0
  2476
					iBuffer->SetLastBuffer(ETrue);
sl@0
  2477
					}
sl@0
  2478
sl@0
  2479
				if ((iCheckTimer) && (iRepeatCounter < iRepeatCount))
sl@0
  2480
					{
sl@0
  2481
					iTimer->Start(KMicroSecsInTenSecs, 0, iCallBack);
sl@0
  2482
					}
sl@0
  2483
				iCheckTimer = EFalse;
sl@0
  2484
				// Playing data in the buffer at the current volume
sl@0
  2485
				iMMFDevSound->PlayData();
sl@0
  2486
				iBufferCount++;
sl@0
  2487
				}
sl@0
  2488
			else if (aDevSoundEvent == EEventPlayTimerComplete)
sl@0
  2489
				{
sl@0
  2490
				while(iRepeatCounter <= iRepeatCount)
sl@0
  2491
					{
sl@0
  2492
					INFO_PRINTF1(_L("Calling iMMFDevSound->Stop()"));
sl@0
  2493
					iMMFDevSound->Stop();
sl@0
  2494
					iRepeatCounter++;
sl@0
  2495
					INFO_PRINTF2(_L("Playback Stopped. Count = %d"), iRepeatCounter);
sl@0
  2496
					INFO_PRINTF1(_L("Changing the state to: EStatePlaying "));
sl@0
  2497
					iPlayState = EStatePlayInitializing;
sl@0
  2498
					break;
sl@0
  2499
					}
sl@0
  2500
				}
sl@0
  2501
			else
sl@0
  2502
				{
sl@0
  2503
				ERR_PRINTF2(_L("DevSound EEventBTBF not received as expected. Received event: %d"), aDevSoundEvent);
sl@0
  2504
				StopTest(aError, EFail);
sl@0
  2505
				}
sl@0
  2506
			break;
sl@0
  2507
			}
sl@0
  2508
sl@0
  2509
		default:
sl@0
  2510
			{
sl@0
  2511
			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iPlayState);
sl@0
  2512
			StopTest(KErrGeneral);
sl@0
  2513
			}
sl@0
  2514
		}
sl@0
  2515
	}
sl@0
  2516
sl@0
  2517
/*
sl@0
  2518
 *
sl@0
  2519
 * DoTimerCallback
sl@0
  2520
 *
sl@0
  2521
 */
sl@0
  2522
void RStepA3FDevSoundPlayStopMultipleTimes::DoTimerCallback()
sl@0
  2523
	{
sl@0
  2524
	iTimer->Cancel(); // only really wanted a one-shot
sl@0
  2525
	if(!iCheckTimer)
sl@0
  2526
		{
sl@0
  2527
		iCheckTimer = ETrue;
sl@0
  2528
		Fsm(EEventPlayTimerComplete, KErrNone);
sl@0
  2529
		if (iRepeatCounter <= iRepeatCount)
sl@0
  2530
			{
sl@0
  2531
			Fsm(EEventInitCompletePlay, KErrNone);
sl@0
  2532
			}
sl@0
  2533
		}
sl@0
  2534
sl@0
  2535
	}
sl@0
  2536
sl@0
  2537
//
sl@0
  2538
// RStepA3FDevSoundPlayEOFPlayMultipleTimes
sl@0
  2539
//
sl@0
  2540
sl@0
  2541
/*
sl@0
  2542
 *
sl@0
  2543
 * RStepA3FDevSoundPlayEOFPlayMultipleTimes - Test step constructor
sl@0
  2544
 *
sl@0
  2545
 */
sl@0
  2546
RStepA3FDevSoundPlayEOFPlayMultipleTimes::RStepA3FDevSoundPlayEOFPlayMultipleTimes(const TDesC& aTestName, const TDesC& aSectName)
sl@0
  2547
:RTestStepA3FDevSoundPlayBase(aTestName, aSectName),
sl@0
  2548
 iRepeatCount(0),
sl@0
  2549
 iRepeatCounter(1)
sl@0
  2550
	{
sl@0
  2551
	}
sl@0
  2552
sl@0
  2553
/*
sl@0
  2554
 *
sl@0
  2555
 * NewL
sl@0
  2556
 *
sl@0
  2557
 */
sl@0
  2558
RStepA3FDevSoundPlayEOFPlayMultipleTimes* RStepA3FDevSoundPlayEOFPlayMultipleTimes::NewL(const TDesC& aTestName, const TDesC& aSectName)
sl@0
  2559
	{
sl@0
  2560
	RStepA3FDevSoundPlayEOFPlayMultipleTimes* self = new (ELeave) RStepA3FDevSoundPlayEOFPlayMultipleTimes(aTestName, aSectName);
sl@0
  2561
	return self;
sl@0
  2562
sl@0
  2563
	}
sl@0
  2564
sl@0
  2565
/*
sl@0
  2566
 *
sl@0
  2567
 * DoKickoffTestL
sl@0
  2568
 *
sl@0
  2569
 */
sl@0
  2570
void RStepA3FDevSoundPlayEOFPlayMultipleTimes::DoKickoffTestL()
sl@0
  2571
	{
sl@0
  2572
	INFO_PRINTF2(_L("File to be played -> %S"), &iFilename);
sl@0
  2573
	DisplayCodecInfo();
sl@0
  2574
	CheckConfigAndFourCCUsage();
sl@0
  2575
sl@0
  2576
	TBool repeatCount = GetIntFromConfig(iSectName,_L("Repeat"),iRepeatCount);
sl@0
  2577
	if (repeatCount)
sl@0
  2578
		{
sl@0
  2579
		INFO_PRINTF2(_L("No. of times to Repeat = %d"), iRepeatCount);
sl@0
  2580
		}
sl@0
  2581
	else
sl@0
  2582
		{
sl@0
  2583
		TPtrC keyName(_L("Repeat"));
sl@0
  2584
		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
  2585
		StopTest(KErrPathNotFound);
sl@0
  2586
		return;
sl@0
  2587
		}
sl@0
  2588
sl@0
  2589
	}
sl@0
  2590
sl@0
  2591
/*
sl@0
  2592
 *
sl@0
  2593
 * PlayError
sl@0
  2594
 *
sl@0
  2595
 */
sl@0
  2596
void RStepA3FDevSoundPlayEOFPlayMultipleTimes::PlayError(TInt aError)
sl@0
  2597
	{
sl@0
  2598
	INFO_PRINTF2(_L("DevSound called PlayError with error = %d"), aError);
sl@0
  2599
	if ((iBuffer->LastBuffer()) && (aError == KErrUnderflow))
sl@0
  2600
		{
sl@0
  2601
		INFO_PRINTF2(_L("Finished playing. Playback Count = %d"), iRepeatCounter);
sl@0
  2602
		if (iRepeatCounter < iRepeatCount)
sl@0
  2603
			{
sl@0
  2604
			iRepeatCounter++;
sl@0
  2605
			INFO_PRINTF1(_L("Starting to Play again"));
sl@0
  2606
			iFile.Close();
sl@0
  2607
			TInt err = iFile.Open(iFs, iFilename, EFileRead);
sl@0
  2608
			if (err != KErrNone)
sl@0
  2609
				{
sl@0
  2610
				ERR_PRINTF2(_L("Could not Open the File: Error = %d"), err);
sl@0
  2611
				StopTest(err);
sl@0
  2612
				}
sl@0
  2613
			iPlayState = EStatePlayInitializing;
sl@0
  2614
			Fsm(EEventInitCompletePlay, KErrNone);
sl@0
  2615
			}
sl@0
  2616
		else
sl@0
  2617
			{
sl@0
  2618
			INFO_PRINTF2(_L("Finished playing %d number of times."), iRepeatCounter);
sl@0
  2619
			StopTest(KErrNone);
sl@0
  2620
			}
sl@0
  2621
		}
sl@0
  2622
	else
sl@0
  2623
		{
sl@0
  2624
		StopTest(aError, EFail);
sl@0
  2625
		}
sl@0
  2626
sl@0
  2627
	}
sl@0
  2628
sl@0
  2629
//
sl@0
  2630
// RStepA3FDevSoundInititalizeDuringInitialize
sl@0
  2631
//
sl@0
  2632
sl@0
  2633
/*
sl@0
  2634
 *
sl@0
  2635
 * RStepA3FDevSoundInititalizeDuringInitialize - Test step constructor
sl@0
  2636
 *
sl@0
  2637
 */
sl@0
  2638
RStepA3FDevSoundInititalizeDuringInitialize::RStepA3FDevSoundInititalizeDuringInitialize(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType)
sl@0
  2639
:RTestStepA3FDevSoundPlayBase(aTestName, aSectName, aInputDataType),
sl@0
  2640
 iSecondInitErr(0)
sl@0
  2641
	{
sl@0
  2642
	}
sl@0
  2643
sl@0
  2644
/*
sl@0
  2645
 *
sl@0
  2646
 * NewL
sl@0
  2647
 *
sl@0
  2648
 */
sl@0
  2649
RStepA3FDevSoundInititalizeDuringInitialize* RStepA3FDevSoundInititalizeDuringInitialize::NewL(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType)
sl@0
  2650
	{
sl@0
  2651
	RStepA3FDevSoundInititalizeDuringInitialize* self = new (ELeave) RStepA3FDevSoundInititalizeDuringInitialize(aTestName, aSectName, aInputDataType);
sl@0
  2652
	return self;
sl@0
  2653
sl@0
  2654
	}
sl@0
  2655
sl@0
  2656
/*
sl@0
  2657
 *
sl@0
  2658
 * KickoffTestL
sl@0
  2659
 * - Starts the test
sl@0
  2660
 *
sl@0
  2661
 */
sl@0
  2662
void RStepA3FDevSoundInititalizeDuringInitialize::KickoffTestL()
sl@0
  2663
	{
sl@0
  2664
	// Create instance of CMMFDevSound
sl@0
  2665
	INFO_PRINTF1(_L("--- Creating DevSound object..."));
sl@0
  2666
	iMMFDevSound = CMMFDevSound::NewL();
sl@0
  2667
sl@0
  2668
	//Display the name of Codec being used
sl@0
  2669
	DisplayCodecInfo();
sl@0
  2670
sl@0
  2671
	if(!GetBoolFromConfig(iSectName, _L("UseFourCC"), iUseFourCC))
sl@0
  2672
		{
sl@0
  2673
		TPtrC keyName(_L("UseFourCC"));
sl@0
  2674
		ERR_PRINTF3(_L("Error in getting UseFourCC flag value from config file in %S section via the %S key field."), &iSectName, &keyName);
sl@0
  2675
		StopTest(KErrPathNotFound);
sl@0
  2676
		return;
sl@0
  2677
		}
sl@0
  2678
sl@0
  2679
	Fsm(EEventPlayStart,KErrNone); // call to start the DevSound finite state machine for playing
sl@0
  2680
sl@0
  2681
	}
sl@0
  2682
sl@0
  2683
/*
sl@0
  2684
 *
sl@0
  2685
 * Fsm
sl@0
  2686
 *	- Executes playing events of DevSound in sequence
sl@0
  2687
 *
sl@0
  2688
 */
sl@0
  2689
void RStepA3FDevSoundInititalizeDuringInitialize::Fsm(TDevSoundPlayEvents aDevSoundEvent, TInt aError)
sl@0
  2690
	{
sl@0
  2691
	switch (iPlayState)
sl@0
  2692
		{
sl@0
  2693
		case EStatePlayStart:
sl@0
  2694
			{
sl@0
  2695
			__ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundInititalizeDuringInitialize"),EFsmIncorrectErrorPassed));
sl@0
  2696
			if (aDevSoundEvent == EEventPlayStart)
sl@0
  2697
				{
sl@0
  2698
				// Initializing DevSound object for playing mode to process audio data via desired FourCC code
sl@0
  2699
				INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL"));
sl@0
  2700
				TInt err;
sl@0
  2701
				if(iUseFourCC)
sl@0
  2702
					{
sl@0
  2703
					INFO_PRINTF1(_L("Calling first InitializeL()"));
sl@0
  2704
					TRAP(err, iMMFDevSound->InitializeL(*this, iInputDataType, EMMFStatePlaying));
sl@0
  2705
					if (err != KErrNone)
sl@0
  2706
						{
sl@0
  2707
						ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
sl@0
  2708
						StopTest(err);
sl@0
  2709
						break;
sl@0
  2710
						}
sl@0
  2711
					else
sl@0
  2712
						{
sl@0
  2713
						INFO_PRINTF1(_L("Calling second InitializeL() beofre first InitializeL() returns."));
sl@0
  2714
						TRAP(iSecondInitErr, iMMFDevSound->InitializeL(*this, iInputDataType, EMMFStatePlaying));
sl@0
  2715
						}
sl@0
  2716
					}
sl@0
  2717
				else
sl@0
  2718
					{
sl@0
  2719
					INFO_PRINTF1(_L("Calling first InitializeL()"));
sl@0
  2720
					TRAP(err, iMMFDevSound->InitializeL(*this, EMMFStatePlaying));
sl@0
  2721
					if (err != KErrNone)
sl@0
  2722
						{
sl@0
  2723
						ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
sl@0
  2724
						StopTest(err);
sl@0
  2725
						break;
sl@0
  2726
						}
sl@0
  2727
					else
sl@0
  2728
						{
sl@0
  2729
						INFO_PRINTF1(_L("Calling second InitializeL() beofre first InitializeL() returns."));
sl@0
  2730
						TRAP(iSecondInitErr, iMMFDevSound->InitializeL(*this, EMMFStatePlaying));
sl@0
  2731
						}
sl@0
  2732
					}
sl@0
  2733
				INFO_PRINTF1(_L("State: EStatePlayInitializing"));
sl@0
  2734
				iPlayState = EStatePlayInitializing;
sl@0
  2735
				}
sl@0
  2736
			else
sl@0
  2737
				{
sl@0
  2738
				ERR_PRINTF2(_L("DevSound EEventPlayStart not received as expected. Received event: %d"), aDevSoundEvent);
sl@0
  2739
				StopTest(aError, EFail);
sl@0
  2740
				}
sl@0
  2741
			break;
sl@0
  2742
			}
sl@0
  2743
sl@0
  2744
		default:
sl@0
  2745
			{
sl@0
  2746
			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iPlayState);
sl@0
  2747
			StopTest(KErrGeneral);
sl@0
  2748
			}
sl@0
  2749
		}
sl@0
  2750
sl@0
  2751
	}
sl@0
  2752
sl@0
  2753
/*
sl@0
  2754
 *
sl@0
  2755
 * InitializeComplete
sl@0
  2756
 *
sl@0
  2757
 */
sl@0
  2758
void RStepA3FDevSoundInititalizeDuringInitialize::InitializeComplete(TInt aError)
sl@0
  2759
	{
sl@0
  2760
	INFO_PRINTF2(_L("First Initialize returned with = %d"), aError);
sl@0
  2761
	INFO_PRINTF2(_L("Second Initialize left with = %d"), iSecondInitErr);
sl@0
  2762
sl@0
  2763
	if ((aError == KErrNone) && (iSecondInitErr == KErrNotReady))
sl@0
  2764
		{
sl@0
  2765
		INFO_PRINTF1(_L("This is expected"));
sl@0
  2766
		StopTest(aError);
sl@0
  2767
		}
sl@0
  2768
	else
sl@0
  2769
		{
sl@0
  2770
		INFO_PRINTF2(_L("This is not expected. Second InitializeL should fail with %d"), KErrNotReady);
sl@0
  2771
		StopTest(aError, EFail);
sl@0
  2772
		}
sl@0
  2773
sl@0
  2774
	}
sl@0
  2775
sl@0
  2776
//
sl@0
  2777
// RStepA3FDevSoundPlayInitDuringPlayInit
sl@0
  2778
//
sl@0
  2779
sl@0
  2780
/*
sl@0
  2781
 *
sl@0
  2782
 * RStepA3FDevSoundPlayInitDuringPlayInit - Test step constructor
sl@0
  2783
 *
sl@0
  2784
 */
sl@0
  2785
RStepA3FDevSoundPlayInitDuringPlayInit::RStepA3FDevSoundPlayInitDuringPlayInit(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType)
sl@0
  2786
:RTestStepA3FDevSoundPlayBase(aTestName, aSectName, aInputDataType),
sl@0
  2787
 iFirstPlayInitErr(0),
sl@0
  2788
 iSecondPlayInitErr(0)
sl@0
  2789
	{
sl@0
  2790
	}
sl@0
  2791
sl@0
  2792
/*
sl@0
  2793
 *
sl@0
  2794
 * NewL
sl@0
  2795
 *
sl@0
  2796
 */
sl@0
  2797
RStepA3FDevSoundPlayInitDuringPlayInit* RStepA3FDevSoundPlayInitDuringPlayInit::NewL(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType)
sl@0
  2798
	{
sl@0
  2799
	RStepA3FDevSoundPlayInitDuringPlayInit* self = new (ELeave) RStepA3FDevSoundPlayInitDuringPlayInit(aTestName, aSectName, aInputDataType);
sl@0
  2800
	return self;
sl@0
  2801
	}
sl@0
  2802
sl@0
  2803
/*
sl@0
  2804
 *
sl@0
  2805
 * KickoffTestL
sl@0
  2806
 * - Starts the test
sl@0
  2807
 *
sl@0
  2808
 */
sl@0
  2809
void RStepA3FDevSoundPlayInitDuringPlayInit::KickoffTestL()
sl@0
  2810
	{
sl@0
  2811
	// Create instance of CMMFDevSound
sl@0
  2812
	INFO_PRINTF1(_L("--- Creating DevSound object..."));
sl@0
  2813
	iMMFDevSound = CMMFDevSound::NewL();
sl@0
  2814
sl@0
  2815
	//Display the name of Codec being used
sl@0
  2816
	DisplayCodecInfo();
sl@0
  2817
	CheckConfigAndFourCCUsage();
sl@0
  2818
	Fsm(EEventPlayStart,KErrNone); // call to start the DevSound finite state machine for playing
sl@0
  2819
sl@0
  2820
	}
sl@0
  2821
sl@0
  2822
/*
sl@0
  2823
 *
sl@0
  2824
 * Fsm
sl@0
  2825
 *	- Executes playing events of DevSound in sequence
sl@0
  2826
 *
sl@0
  2827
 */
sl@0
  2828
void RStepA3FDevSoundPlayInitDuringPlayInit::Fsm(TDevSoundPlayEvents aDevSoundEvent, TInt aError)
sl@0
  2829
	{
sl@0
  2830
	switch (iPlayState)
sl@0
  2831
		{
sl@0
  2832
		case EStatePlayStart:
sl@0
  2833
			{
sl@0
  2834
			__ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundPlayInitDuringPlayInit"),EFsmIncorrectErrorPassed));
sl@0
  2835
			if (aDevSoundEvent == EEventPlayStart)
sl@0
  2836
				{
sl@0
  2837
				// Initializing DevSound object for playing mode to process audio data via desired FourCC code
sl@0
  2838
				INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL"));
sl@0
  2839
				TInt err;
sl@0
  2840
				if(iUseFourCC)
sl@0
  2841
					{
sl@0
  2842
					TRAP(err, iMMFDevSound->InitializeL(*this, iInputDataType, EMMFStatePlaying));
sl@0
  2843
					}
sl@0
  2844
				else
sl@0
  2845
					{
sl@0
  2846
					TRAP(err, iMMFDevSound->InitializeL(*this, EMMFStatePlaying));
sl@0
  2847
					}
sl@0
  2848
				if (err != KErrNone)
sl@0
  2849
					{
sl@0
  2850
					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
sl@0
  2851
					StopTest(err);
sl@0
  2852
					break;
sl@0
  2853
					}
sl@0
  2854
				INFO_PRINTF1(_L("State: EStatePlayInitializing"));
sl@0
  2855
				iPlayState = EStatePlayInitializing;
sl@0
  2856
				}
sl@0
  2857
			else
sl@0
  2858
				{
sl@0
  2859
				ERR_PRINTF2(_L("DevSound EEventPlayStart not received as expected. Received event: %d"), aDevSoundEvent);
sl@0
  2860
				StopTest(aError, EFail);
sl@0
  2861
				}
sl@0
  2862
			break;
sl@0
  2863
			}
sl@0
  2864
sl@0
  2865
		case EStatePlayInitializing:
sl@0
  2866
			{
sl@0
  2867
			if (aDevSoundEvent == EEventInitCompletePlay && aError == KErrNone)
sl@0
  2868
				{
sl@0
  2869
				if(iConfig)
sl@0
  2870
					{
sl@0
  2871
					// Set Devsound capability settings using CMMFDevSound::SetConfigL
sl@0
  2872
					SetSampleRateAndChannelMode();
sl@0
  2873
					TMMFCapabilities capabilities;
sl@0
  2874
					capabilities.iRate = ConvertDesToTMMFSampleRate(iSampleRate);
sl@0
  2875
					capabilities.iChannels = ConvertDesToTMMFMonoStereo(iMonoStereo);
sl@0
  2876
sl@0
  2877
					TRAPD(errConfig, iMMFDevSound->SetConfigL(capabilities));
sl@0
  2878
					if (errConfig != KErrNone)
sl@0
  2879
						{
sl@0
  2880
						ERR_PRINTF2(_L("CMMFDevSound::SetConfigL() left with error = %d"), errConfig);
sl@0
  2881
						StopTest(errConfig);
sl@0
  2882
						break;
sl@0
  2883
						}
sl@0
  2884
					}
sl@0
  2885
sl@0
  2886
				// Initialize audio device and starts the playing process
sl@0
  2887
				INFO_PRINTF1(_L("Calling First CMMFDevSound::PlayInitL()"));
sl@0
  2888
				TRAPD(iFirstPlayInitErr, iMMFDevSound->PlayInitL());
sl@0
  2889
				TRAP(iSecondPlayInitErr, iMMFDevSound->PlayInitL());
sl@0
  2890
				if (iFirstPlayInitErr != KErrNone)
sl@0
  2891
					{
sl@0
  2892
					ERR_PRINTF2(_L("First CMMFDevSound::PlayInitL() left with error = %d"), iFirstPlayInitErr);
sl@0
  2893
					StopTest(iFirstPlayInitErr);
sl@0
  2894
					break;
sl@0
  2895
					}
sl@0
  2896
				INFO_PRINTF1(_L("State: EStatePlaying"));
sl@0
  2897
				iPlayState = EStatePlaying;
sl@0
  2898
				}
sl@0
  2899
			else if (aDevSoundEvent == EEventInitCompletePlay && aError != KErrNone)
sl@0
  2900
				{
sl@0
  2901
				ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError);
sl@0
  2902
				StopTest(aError);
sl@0
  2903
				}
sl@0
  2904
			else
sl@0
  2905
				{
sl@0
  2906
				ERR_PRINTF2(_L("DevSound EEventInitCompletePlay not received as expected. Received event: %d"), aDevSoundEvent);
sl@0
  2907
				StopTest(aError, EFail);
sl@0
  2908
				}
sl@0
  2909
			break;
sl@0
  2910
			}
sl@0
  2911
sl@0
  2912
		default:
sl@0
  2913
			{
sl@0
  2914
			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iPlayState);
sl@0
  2915
			StopTest(KErrGeneral);
sl@0
  2916
			}
sl@0
  2917
		}
sl@0
  2918
sl@0
  2919
	}
sl@0
  2920
sl@0
  2921
/*
sl@0
  2922
 *
sl@0
  2923
 * BufferToBeFilled
sl@0
  2924
 *
sl@0
  2925
 */
sl@0
  2926
void RStepA3FDevSoundPlayInitDuringPlayInit::BufferToBeFilled(CMMFBuffer* aBuffer)
sl@0
  2927
	{
sl@0
  2928
	if (!aBuffer)
sl@0
  2929
		{
sl@0
  2930
		ERR_PRINTF1(_L("BufferToBeFilled callback received a NULL CMMFBuffer!"));
sl@0
  2931
		StopTest(KErrGeneral);
sl@0
  2932
		return;
sl@0
  2933
		}
sl@0
  2934
	iBuffer = aBuffer;
sl@0
  2935
sl@0
  2936
	INFO_PRINTF2(_L("First PlayInit left with = %d"), iFirstPlayInitErr);
sl@0
  2937
	INFO_PRINTF2(_L("Second PlayInit left with = %d"), iSecondPlayInitErr);
sl@0
  2938
sl@0
  2939
	if ((iFirstPlayInitErr == KErrNone) && (iSecondPlayInitErr == KErrNotReady))
sl@0
  2940
		{
sl@0
  2941
		INFO_PRINTF1(_L("This is expected"));
sl@0
  2942
		StopTest(KErrNone);
sl@0
  2943
		}
sl@0
  2944
	else
sl@0
  2945
		{
sl@0
  2946
		INFO_PRINTF2(_L("This is not expected. Second PlayInit should fail with  %d"), KErrNotReady);
sl@0
  2947
		StopTest(iFirstPlayInitErr, EFail);
sl@0
  2948
		}
sl@0
  2949
sl@0
  2950
	}
sl@0
  2951
sl@0
  2952
//
sl@0
  2953
// RStepA3FDevSoundVolumeCrop
sl@0
  2954
//
sl@0
  2955
sl@0
  2956
/*
sl@0
  2957
 *
sl@0
  2958
 * RStepA3FDevSoundVolumeCrop - Test step constructor
sl@0
  2959
 *
sl@0
  2960
 */
sl@0
  2961
RStepA3FDevSoundVolumeCrop::RStepA3FDevSoundVolumeCrop(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType)
sl@0
  2962
:RTestStepA3FDevSoundPlayBase(aTestName, aSectName, aInputDataType),
sl@0
  2963
 iIncreaseMaxVolume(0),
sl@0
  2964
 iMinVolume(0)
sl@0
  2965
	{
sl@0
  2966
	}
sl@0
  2967
sl@0
  2968
/*
sl@0
  2969
 *
sl@0
  2970
 * NewL
sl@0
  2971
 *
sl@0
  2972
 */
sl@0
  2973
RStepA3FDevSoundVolumeCrop* RStepA3FDevSoundVolumeCrop::NewL(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType)
sl@0
  2974
	{
sl@0
  2975
	RStepA3FDevSoundVolumeCrop* self = new (ELeave) RStepA3FDevSoundVolumeCrop(aTestName, aSectName, aInputDataType);
sl@0
  2976
	return self;
sl@0
  2977
sl@0
  2978
	}
sl@0
  2979
sl@0
  2980
/*
sl@0
  2981
 *
sl@0
  2982
 * KickoffTestL
sl@0
  2983
 *
sl@0
  2984
 */
sl@0
  2985
void RStepA3FDevSoundVolumeCrop::KickoffTestL()
sl@0
  2986
	{
sl@0
  2987
	//Create instance of CMMFDevSound
sl@0
  2988
	iMMFDevSound = CMMFDevSound::NewL();
sl@0
  2989
	//Display the name of Codec being used
sl@0
  2990
	DisplayCodecInfo();
sl@0
  2991
sl@0
  2992
	if(!GetBoolFromConfig(iSectName, _L("UseFourCC"), iUseFourCC))
sl@0
  2993
		{
sl@0
  2994
		TPtrC keyName(_L("UseFourCC"));
sl@0
  2995
		ERR_PRINTF3(_L("Error in getting UseFourCC flag from config file in %S section via the %S key field."), &iSectName, &keyName);
sl@0
  2996
		StopTest(KErrPathNotFound);
sl@0
  2997
		return;
sl@0
  2998
		}
sl@0
  2999
sl@0
  3000
	TBool maxVol = GetIntFromConfig(iSectName,_L("IncreaseMaxVolume"),iIncreaseMaxVolume);
sl@0
  3001
	if (maxVol)
sl@0
  3002
		{
sl@0
  3003
		INFO_PRINTF2(_L("Volume to be added to the MaxVolume supported by device = %d"), iIncreaseMaxVolume);
sl@0
  3004
		}
sl@0
  3005
	else
sl@0
  3006
		{
sl@0
  3007
		TPtrC keyName(_L("IncreaseMaxVolume"));
sl@0
  3008
		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
  3009
		StopTest(KErrPathNotFound);
sl@0
  3010
		return;
sl@0
  3011
		}
sl@0
  3012
sl@0
  3013
	TBool minVol = GetIntFromConfig(iSectName,_L("SetMinVolume"),iMinVolume);
sl@0
  3014
	if (minVol)
sl@0
  3015
		{
sl@0
  3016
		INFO_PRINTF2(_L("Seting MinVolume value = %d"), iMinVolume);
sl@0
  3017
		}
sl@0
  3018
	else
sl@0
  3019
		{
sl@0
  3020
		TPtrC keyName(_L("SetMinVolume"));
sl@0
  3021
		ERR_PRINTF3(_L("Error in getting volume below zero from config file in %S section via the %S key field."), &iSectName, &keyName);
sl@0
  3022
		return;
sl@0
  3023
		}
sl@0
  3024
sl@0
  3025
	Fsm(EEventPlayStart,KErrNone); // call to start the DevSound finite state machine for playing
sl@0
  3026
sl@0
  3027
	}
sl@0
  3028
sl@0
  3029
/*
sl@0
  3030
 *
sl@0
  3031
 * Fsm
sl@0
  3032
 *	- Executes playing events of DevSound in sequence
sl@0
  3033
 *
sl@0
  3034
 */
sl@0
  3035
void RStepA3FDevSoundVolumeCrop::Fsm(TDevSoundPlayEvents aDevSoundEvent, TInt aError)
sl@0
  3036
	{
sl@0
  3037
	switch (iPlayState)
sl@0
  3038
		{
sl@0
  3039
		case EStatePlayStart:
sl@0
  3040
			{
sl@0
  3041
			__ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundVolumeCrop"),EFsmIncorrectErrorPassed));
sl@0
  3042
			if (aDevSoundEvent == EEventPlayStart)
sl@0
  3043
				{
sl@0
  3044
				// Initializing DevSound object for playing mode to process audio data via desired FourCC code
sl@0
  3045
				INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL"));
sl@0
  3046
				TInt err;
sl@0
  3047
				if(iUseFourCC)
sl@0
  3048
					{
sl@0
  3049
					TRAP(err, iMMFDevSound->InitializeL(*this, iInputDataType, EMMFStatePlaying));
sl@0
  3050
					}
sl@0
  3051
				else
sl@0
  3052
					{
sl@0
  3053
					TRAP(err, iMMFDevSound->InitializeL(*this, EMMFStatePlaying));
sl@0
  3054
					}
sl@0
  3055
				if (err != KErrNone)
sl@0
  3056
					{
sl@0
  3057
					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
sl@0
  3058
					StopTest(err);
sl@0
  3059
					break;
sl@0
  3060
					}
sl@0
  3061
				else
sl@0
  3062
					{
sl@0
  3063
					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
sl@0
  3064
					TInt deviceMaxVol = iMMFDevSound->MaxVolume();
sl@0
  3065
					INFO_PRINTF2(_L("Maximum volume supported by the device is %d"), deviceMaxVol);
sl@0
  3066
					INFO_PRINTF2(_L("Setting the volume beyond the maximum volume supported by the device: %d"), deviceMaxVol + iIncreaseMaxVolume);
sl@0
  3067
					iMMFDevSound->SetVolume(deviceMaxVol + iIncreaseMaxVolume);
sl@0
  3068
					INFO_PRINTF1(_L("Getting the volume set"));
sl@0
  3069
					TInt maxVolumeObtained = iMMFDevSound->Volume();
sl@0
  3070
					INFO_PRINTF2(_L("iMMFDevSound->Volume(): %d"), maxVolumeObtained);
sl@0
  3071
					if (maxVolumeObtained != deviceMaxVol)
sl@0
  3072
						{
sl@0
  3073
						ERR_PRINTF1(_L("Volume was not cropped to equal to maximum volume supported by device"));
sl@0
  3074
						StopTest(KErrGeneral);
sl@0
  3075
						}
sl@0
  3076
					else
sl@0
  3077
						{
sl@0
  3078
						INFO_PRINTF1(_L("Volume was cropped to equal to maximum volume supported by device"));
sl@0
  3079
						INFO_PRINTF2(_L("Setting volume to less than zero: %d"), iMinVolume);
sl@0
  3080
						iMMFDevSound->SetVolume(iMinVolume);
sl@0
  3081
						INFO_PRINTF1(_L("Getting the volume set"));
sl@0
  3082
						TInt minVolumeObtained = iMMFDevSound->Volume();
sl@0
  3083
						INFO_PRINTF2(_L("iMMFDevSound->Volume(): %d"), minVolumeObtained);
sl@0
  3084
						if (minVolumeObtained != KNULLVolume)
sl@0
  3085
							{
sl@0
  3086
							ERR_PRINTF1(_L("Volume was not cropped to equal to minimum volume supported by device"));
sl@0
  3087
							StopTest(KErrGeneral);
sl@0
  3088
							}
sl@0
  3089
						else
sl@0
  3090
							{
sl@0
  3091
							INFO_PRINTF1(_L("Volume was cropped to equal to minimum volume supported by device"));
sl@0
  3092
							StopTest(KErrNone);
sl@0
  3093
							}
sl@0
  3094
						}
sl@0
  3095
					}
sl@0
  3096
				}
sl@0
  3097
			else
sl@0
  3098
				{
sl@0
  3099
				ERR_PRINTF2(_L("DevSound EEventPlayStart not received as expected. Received event: %d"), aDevSoundEvent);
sl@0
  3100
				StopTest(aError, EFail);
sl@0
  3101
				}
sl@0
  3102
		break;
sl@0
  3103
		}
sl@0
  3104
		default:
sl@0
  3105
			{
sl@0
  3106
			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iPlayState);
sl@0
  3107
			StopTest(KErrGeneral);
sl@0
  3108
			}
sl@0
  3109
		}
sl@0
  3110
sl@0
  3111
	}
sl@0
  3112
sl@0
  3113
//
sl@0
  3114
// RStepA3FDevSoundInitializeForConverting
sl@0
  3115
//
sl@0
  3116
sl@0
  3117
/*
sl@0
  3118
 *
sl@0
  3119
 * RStepA3FDevSoundInitializeForConverting - Test step constructor
sl@0
  3120
 *
sl@0
  3121
 */
sl@0
  3122
RStepA3FDevSoundInitializeForConverting::RStepA3FDevSoundInitializeForConverting(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType)
sl@0
  3123
:RTestStepA3FDevSoundPlayBase(aTestName, aSectName, aInputDataType)
sl@0
  3124
	{
sl@0
  3125
	}
sl@0
  3126
sl@0
  3127
/*
sl@0
  3128
 *
sl@0
  3129
 * NewL
sl@0
  3130
 *
sl@0
  3131
 */
sl@0
  3132
RStepA3FDevSoundInitializeForConverting* RStepA3FDevSoundInitializeForConverting::NewL(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType)
sl@0
  3133
	{
sl@0
  3134
	RStepA3FDevSoundInitializeForConverting* self = new (ELeave) RStepA3FDevSoundInitializeForConverting(aTestName, aSectName, aInputDataType);
sl@0
  3135
	return self;
sl@0
  3136
sl@0
  3137
	}
sl@0
  3138
sl@0
  3139
/*
sl@0
  3140
 *
sl@0
  3141
 * KickoffTestL
sl@0
  3142
 * - Starts the test
sl@0
  3143
 *
sl@0
  3144
 */
sl@0
  3145
void RStepA3FDevSoundInitializeForConverting::KickoffTestL()
sl@0
  3146
	{
sl@0
  3147
	// Create instance of CMMFDevSound
sl@0
  3148
	INFO_PRINTF1(_L("--- Creating DevSound object..."));
sl@0
  3149
	iMMFDevSound = CMMFDevSound::NewL();
sl@0
  3150
sl@0
  3151
	//Display the name of Codec being used
sl@0
  3152
	DisplayCodecInfo();
sl@0
  3153
sl@0
  3154
	if(!GetBoolFromConfig(iSectName, _L("UseFourCC"), iUseFourCC))
sl@0
  3155
		{
sl@0
  3156
		TPtrC keyName(_L("UseFourCC"));
sl@0
  3157
		ERR_PRINTF3(_L("Error in getting UseFourCC flag value from config file in %S section via the %S key field."), &iSectName, &keyName);
sl@0
  3158
		StopTest(KErrPathNotFound);
sl@0
  3159
		return;
sl@0
  3160
		}
sl@0
  3161
sl@0
  3162
	Fsm(EEventPlayStart,KErrNone); // call to start the DevSound finite state machine for playing
sl@0
  3163
sl@0
  3164
	}
sl@0
  3165
sl@0
  3166
/*
sl@0
  3167
 *
sl@0
  3168
 * Fsm
sl@0
  3169
 *	- Executes playing events of DevSound in sequence
sl@0
  3170
 *
sl@0
  3171
 */
sl@0
  3172
void RStepA3FDevSoundInitializeForConverting::Fsm(TDevSoundPlayEvents aDevSoundEvent, TInt aError)
sl@0
  3173
	{
sl@0
  3174
	switch (iPlayState)
sl@0
  3175
		{
sl@0
  3176
		case EStatePlayStart:
sl@0
  3177
			{
sl@0
  3178
			__ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundInitializeForConverting"),EFsmIncorrectErrorPassed));
sl@0
  3179
			if (aDevSoundEvent == EEventPlayStart)
sl@0
  3180
				{
sl@0
  3181
				// Initializing DevSound object for playing mode to process audio data via desired FourCC code
sl@0
  3182
				INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL"));
sl@0
  3183
				TInt err;
sl@0
  3184
				if(iUseFourCC)
sl@0
  3185
					{
sl@0
  3186
					TRAP(err, iMMFDevSound->InitializeL(*this, iInputDataType, EMMFStateConverting));
sl@0
  3187
					}
sl@0
  3188
				else
sl@0
  3189
					{
sl@0
  3190
					TRAP(err, iMMFDevSound->InitializeL(*this, EMMFStateConverting));
sl@0
  3191
					}
sl@0
  3192
				if (err == KErrNotSupported)
sl@0
  3193
					{
sl@0
  3194
					INFO_PRINTF2(_L("CMMFDevSound::InitializeL left with expected error = %d for EMMFStateConverting"), err);
sl@0
  3195
					StopTest(err, EPass);
sl@0
  3196
					}
sl@0
  3197
				else
sl@0
  3198
					{
sl@0
  3199
					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d for EMMFStateConverting"), err);
sl@0
  3200
					StopTest(err, EFail);
sl@0
  3201
					}
sl@0
  3202
				}
sl@0
  3203
			else
sl@0
  3204
				{
sl@0
  3205
				ERR_PRINTF2(_L("DevSound EEventPlayStart not received as expected. Received event: %d"), aDevSoundEvent);
sl@0
  3206
				StopTest(aError, EFail);
sl@0
  3207
				}
sl@0
  3208
			break;
sl@0
  3209
			}
sl@0
  3210
		}
sl@0
  3211
sl@0
  3212
	}
sl@0
  3213
sl@0
  3214
//
sl@0
  3215
// RStepA3FDevSoundGetSampleNumsAfterStop
sl@0
  3216
//
sl@0
  3217
sl@0
  3218
/*
sl@0
  3219
 *
sl@0
  3220
 * RStepA3FDevSoundGetSampleNumsAfterStop - Test step constructor
sl@0
  3221
 *
sl@0
  3222
 */
sl@0
  3223
RStepA3FDevSoundGetSampleNumsAfterStop::RStepA3FDevSoundGetSampleNumsAfterStop(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType)
sl@0
  3224
:RTestStepA3FDevSoundPlayBase(aTestName, aSectName, aInputDataType),
sl@0
  3225
 iCheckTimer(ETrue)
sl@0
  3226
	{
sl@0
  3227
	}
sl@0
  3228
sl@0
  3229
/*
sl@0
  3230
 *
sl@0
  3231
 * NewL
sl@0
  3232
 *
sl@0
  3233
 */
sl@0
  3234
RStepA3FDevSoundGetSampleNumsAfterStop* RStepA3FDevSoundGetSampleNumsAfterStop::NewL(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType)
sl@0
  3235
	{
sl@0
  3236
	RStepA3FDevSoundGetSampleNumsAfterStop* self = new (ELeave) RStepA3FDevSoundGetSampleNumsAfterStop(aTestName, aSectName, aInputDataType);
sl@0
  3237
	return self;
sl@0
  3238
sl@0
  3239
	}
sl@0
  3240
sl@0
  3241
/*
sl@0
  3242
 *
sl@0
  3243
 * Fsm
sl@0
  3244
 *	- Executes playing events of DevSound in sequence
sl@0
  3245
 *
sl@0
  3246
 */
sl@0
  3247
void RStepA3FDevSoundGetSampleNumsAfterStop::Fsm(TDevSoundPlayEvents aDevSoundEvent, TInt aError)
sl@0
  3248
	{
sl@0
  3249
	switch (iPlayState)
sl@0
  3250
		{
sl@0
  3251
		case EStatePlayStart:
sl@0
  3252
			{
sl@0
  3253
			__ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundGetSampleNumsAfterStop"),EFsmIncorrectErrorPassed));
sl@0
  3254
			if (aDevSoundEvent == EEventPlayStart)
sl@0
  3255
				{
sl@0
  3256
				// Initializing DevSound object for playing mode to process audio data via desired FourCC code
sl@0
  3257
				INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL"));
sl@0
  3258
				TInt err;
sl@0
  3259
				if(iUseFourCC)
sl@0
  3260
					{
sl@0
  3261
					TRAP(err, iMMFDevSound->InitializeL(*this, iInputDataType, EMMFStatePlaying));
sl@0
  3262
					}
sl@0
  3263
				else
sl@0
  3264
					{
sl@0
  3265
					TRAP(err, iMMFDevSound->InitializeL(*this, EMMFStatePlaying));
sl@0
  3266
					}
sl@0
  3267
				if (err != KErrNone)
sl@0
  3268
					{
sl@0
  3269
					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
sl@0
  3270
					StopTest(err);
sl@0
  3271
					break;
sl@0
  3272
					}
sl@0
  3273
				INFO_PRINTF1(_L("State: EStatePlayInitializing"));
sl@0
  3274
				iPlayState = EStatePlayInitializing;
sl@0
  3275
				}
sl@0
  3276
			else
sl@0
  3277
				{
sl@0
  3278
				ERR_PRINTF2(_L("DevSound EEventPlayStart not received as expected. Received event: %d"), aDevSoundEvent);
sl@0
  3279
				StopTest(aError, EFail);
sl@0
  3280
				}
sl@0
  3281
			break;
sl@0
  3282
			}
sl@0
  3283
sl@0
  3284
		case EStatePlayInitializing:
sl@0
  3285
			{
sl@0
  3286
			if (aDevSoundEvent == EEventInitCompletePlay && aError == KErrNone)
sl@0
  3287
				{
sl@0
  3288
				if(iConfig)
sl@0
  3289
					{
sl@0
  3290
					// Set Devsound capability settings using CMMFDevSound::SetConfigL
sl@0
  3291
					SetSampleRateAndChannelMode();
sl@0
  3292
					TMMFCapabilities capabilities;
sl@0
  3293
					capabilities.iRate = ConvertDesToTMMFSampleRate(iSampleRate);
sl@0
  3294
					capabilities.iChannels = ConvertDesToTMMFMonoStereo(iMonoStereo);
sl@0
  3295
sl@0
  3296
					TRAPD(errConfig, iMMFDevSound->SetConfigL(capabilities));
sl@0
  3297
					if (errConfig != KErrNone)
sl@0
  3298
						{
sl@0
  3299
						ERR_PRINTF2(_L("CMMFDevSound::SetConfigL() left with error = %d"), errConfig);
sl@0
  3300
						StopTest(errConfig);
sl@0
  3301
						break;
sl@0
  3302
						}
sl@0
  3303
					}
sl@0
  3304
				// Initialize audio device and starts the playing process
sl@0
  3305
				INFO_PRINTF1(_L("Calling CMMFDevSound::PlayInitL()"));
sl@0
  3306
				TRAPD(errPlay, iMMFDevSound->PlayInitL());
sl@0
  3307
				if (errPlay != KErrNone)
sl@0
  3308
					{
sl@0
  3309
					ERR_PRINTF2(_L("CMMFDevSound::PlayInitL() left with error = %d"), errPlay);
sl@0
  3310
					StopTest(errPlay);
sl@0
  3311
					break;
sl@0
  3312
					}
sl@0
  3313
				INFO_PRINTF1(_L("State: EStatePlaying"));
sl@0
  3314
				iPlayState = EStatePlaying;
sl@0
  3315
				}
sl@0
  3316
			else if (aDevSoundEvent == EEventInitCompletePlay && aError != KErrNone)
sl@0
  3317
				{
sl@0
  3318
				ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError);
sl@0
  3319
				StopTest(aError);
sl@0
  3320
				}
sl@0
  3321
			else
sl@0
  3322
				{
sl@0
  3323
				ERR_PRINTF2(_L("DevSound EEventInitCompletePlay not received as expected. Received event: %d"), aDevSoundEvent);
sl@0
  3324
				StopTest(aError, EFail);
sl@0
  3325
				}
sl@0
  3326
sl@0
  3327
			break;
sl@0
  3328
sl@0
  3329
			}
sl@0
  3330
sl@0
  3331
		case EStatePlaying:
sl@0
  3332
			{
sl@0
  3333
			__ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundGetSampleNumsAfterStop"),EFsmIncorrectErrorPassed));
sl@0
  3334
			if (aDevSoundEvent == EEventBTBF)
sl@0
  3335
				{
sl@0
  3336
				// Fill the buffer with audio data and play the data in the buffer
sl@0
  3337
				CMMFDataBuffer* buffer = static_cast <CMMFDataBuffer*> (iBuffer);
sl@0
  3338
				TInt err = iFile.Read(buffer->Data());
sl@0
  3339
				if (err != KErrNone)
sl@0
  3340
					{
sl@0
  3341
					ERR_PRINTF2(_L("ERROR : iFile.Read() failed with %d"), err);
sl@0
  3342
					StopTest(err);
sl@0
  3343
					break;
sl@0
  3344
					}
sl@0
  3345
				if (buffer->Data().Length() != buffer->RequestSize())
sl@0
  3346
					{
sl@0
  3347
					INFO_PRINTF3(_L("Data length copied from file = %d. Expected = %d. Must be EOF."), buffer->Data().Length(), buffer->RequestSize());
sl@0
  3348
					iBuffer->SetLastBuffer(ETrue);
sl@0
  3349
					}
sl@0
  3350
sl@0
  3351
				if (iCheckTimer)
sl@0
  3352
					{
sl@0
  3353
					iTimer->Start(KMicroSecsInTenSecs, 0, iCallBack);
sl@0
  3354
					}
sl@0
  3355
				iCheckTimer = EFalse;
sl@0
  3356
				// Playing data in the buffer at the current volume
sl@0
  3357
				iMMFDevSound->PlayData();
sl@0
  3358
				iBufferCount++;
sl@0
  3359
				}
sl@0
  3360
			else if (aDevSoundEvent == EEventPlayTimerComplete)
sl@0
  3361
				{
sl@0
  3362
				iMMFDevSound->Stop();
sl@0
  3363
				iPlayState = EStatePlayStopped;
sl@0
  3364
				INFO_PRINTF1(_L("EStatePlayStopped"));
sl@0
  3365
				}
sl@0
  3366
			else
sl@0
  3367
				{
sl@0
  3368
				ERR_PRINTF2(_L("DevSound EEventBTBF not received as expected. Received event: %d"), aDevSoundEvent);
sl@0
  3369
				StopTest(aError, EFail);
sl@0
  3370
				}
sl@0
  3371
			break;
sl@0
  3372
			}
sl@0
  3373
sl@0
  3374
		case EStatePlayStopped:
sl@0
  3375
			{
sl@0
  3376
			__ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundGetSampleNumsAfterStop"),EFsmIncorrectErrorPassed));
sl@0
  3377
			if (aDevSoundEvent == EEventPlayStopped)
sl@0
  3378
				{
sl@0
  3379
				INFO_PRINTF1(_L("Getting SamplesPlayed after Stop"));
sl@0
  3380
				TInt numSamplesStop = iMMFDevSound->SamplesPlayed();
sl@0
  3381
				INFO_PRINTF2(_L("SamplesPlayed after Stop: %d"), numSamplesStop);
sl@0
  3382
				if (numSamplesStop == KNULLSamples)
sl@0
  3383
					{
sl@0
  3384
					ERR_PRINTF2(_L("Number of samples played after stop should not be %d"), KNULLSamples );
sl@0
  3385
					StopTest(KErrGeneral);
sl@0
  3386
					}
sl@0
  3387
				else
sl@0
  3388
					{
sl@0
  3389
					INFO_PRINTF2(_L("Number of samples played after stop is greater than %d"), KNULLSamples );
sl@0
  3390
					StopTest(KErrNone);
sl@0
  3391
					}
sl@0
  3392
				}
sl@0
  3393
			else
sl@0
  3394
				{
sl@0
  3395
				ERR_PRINTF2(_L("Invalid DevSound event received: %d"), aDevSoundEvent);
sl@0
  3396
				StopTest(KErrGeneral);
sl@0
  3397
				}
sl@0
  3398
			}
sl@0
  3399
			break;
sl@0
  3400
sl@0
  3401
		default:
sl@0
  3402
			{
sl@0
  3403
			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iPlayState);
sl@0
  3404
			StopTest(KErrGeneral);
sl@0
  3405
			}
sl@0
  3406
		}
sl@0
  3407
sl@0
  3408
	}
sl@0
  3409
sl@0
  3410
/*
sl@0
  3411
 *
sl@0
  3412
 * DoTimerCallback
sl@0
  3413
 *
sl@0
  3414
 */
sl@0
  3415
void RStepA3FDevSoundGetSampleNumsAfterStop::DoTimerCallback()
sl@0
  3416
	{
sl@0
  3417
	iTimer->Cancel(); // only really wanted a one-shot
sl@0
  3418
	if(!iCheckTimer)
sl@0
  3419
		{
sl@0
  3420
		Fsm(EEventPlayTimerComplete, KErrNone);
sl@0
  3421
		Fsm(EEventPlayStopped, KErrNone);
sl@0
  3422
		}
sl@0
  3423
sl@0
  3424
	}
sl@0
  3425
sl@0
  3426
//
sl@0
  3427
// RStepA3FDevSoundCancelInitializePlay
sl@0
  3428
//
sl@0
  3429
sl@0
  3430
/*
sl@0
  3431
 *
sl@0
  3432
 * RStepA3FDevSoundCancelInitializePlay - Test step constructor
sl@0
  3433
 *
sl@0
  3434
 */
sl@0
  3435
RStepA3FDevSoundCancelInitializePlay::RStepA3FDevSoundCancelInitializePlay(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType)
sl@0
  3436
:RTestStepA3FDevSoundPlayBase(aTestName, aSectName, aInputDataType)
sl@0
  3437
	{
sl@0
  3438
	}
sl@0
  3439
sl@0
  3440
/*
sl@0
  3441
 *
sl@0
  3442
 * NewL
sl@0
  3443
 *
sl@0
  3444
 */
sl@0
  3445
RStepA3FDevSoundCancelInitializePlay* RStepA3FDevSoundCancelInitializePlay::NewL(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType)
sl@0
  3446
	{
sl@0
  3447
	RStepA3FDevSoundCancelInitializePlay* self = new (ELeave) RStepA3FDevSoundCancelInitializePlay(aTestName, aSectName, aInputDataType);
sl@0
  3448
	return self;
sl@0
  3449
sl@0
  3450
	}
sl@0
  3451
sl@0
  3452
/*
sl@0
  3453
 *
sl@0
  3454
 * KickoffTestL
sl@0
  3455
 * - Starts the test
sl@0
  3456
 *
sl@0
  3457
 */
sl@0
  3458
void RStepA3FDevSoundCancelInitializePlay::KickoffTestL()
sl@0
  3459
	{
sl@0
  3460
	// Create instance of CMMFDevSound
sl@0
  3461
	INFO_PRINTF1(_L("--- Creating DevSound object..."));
sl@0
  3462
	iMMFDevSound = CMMFDevSound::NewL();
sl@0
  3463
sl@0
  3464
	iTimer = CPeriodic::NewL(CActive::EPriorityHigh);
sl@0
  3465
	iCallBack = TCallBack(TimerCallback, this);
sl@0
  3466
	
sl@0
  3467
	//Display the name of Codec being used
sl@0
  3468
	DisplayCodecInfo();
sl@0
  3469
	CheckConfigAndFourCCUsage();
sl@0
  3470
sl@0
  3471
	Fsm(EEventPlayStart,KErrNone); // call to start the DevSound finite state machine for playing
sl@0
  3472
sl@0
  3473
	}
sl@0
  3474
	
sl@0
  3475
/*
sl@0
  3476
 *
sl@0
  3477
 * InitializeComplete
sl@0
  3478
 *
sl@0
  3479
 */
sl@0
  3480
void RStepA3FDevSoundCancelInitializePlay::InitializeComplete(TInt aError)
sl@0
  3481
	{
sl@0
  3482
	INFO_PRINTF1(_L("InitializeComplete callback was received. This is not the expected behaviour"));
sl@0
  3483
	INFO_PRINTF1(_L("InitializeL was not cancelled"));
sl@0
  3484
	StopTest(aError, EFail);
sl@0
  3485
	}
sl@0
  3486
sl@0
  3487
/*
sl@0
  3488
 *
sl@0
  3489
 * DoTimerCallback
sl@0
  3490
 *
sl@0
  3491
 */
sl@0
  3492
void RStepA3FDevSoundCancelInitializePlay::DoTimerCallback()
sl@0
  3493
	{
sl@0
  3494
	iTimer->Cancel(); // only really wanted a one-shot
sl@0
  3495
	INFO_PRINTF1(_L("InitializeComplete callback was not received. This is the expected behaviour"));
sl@0
  3496
	INFO_PRINTF1(_L("Use SetConfigL to verify that DevSound has not been initialised"));
sl@0
  3497
	SetSampleRateAndChannelMode();
sl@0
  3498
	TMMFCapabilities capabilities;
sl@0
  3499
	capabilities.iRate = ConvertDesToTMMFSampleRate(iSampleRate);
sl@0
  3500
	capabilities.iChannels = ConvertDesToTMMFMonoStereo(iMonoStereo);
sl@0
  3501
sl@0
  3502
	TRAPD(errConfig, iMMFDevSound->SetConfigL(capabilities));	
sl@0
  3503
	if(errConfig == KErrNotReady)
sl@0
  3504
		{
sl@0
  3505
		INFO_PRINTF2(_L("SetConfigL returned with %d as expected"), errConfig);
sl@0
  3506
		INFO_PRINTF1(_L("InitializeL was cancelled successfully"));
sl@0
  3507
		StopTest(KErrNone);
sl@0
  3508
		}
sl@0
  3509
	else if (errConfig == KErrNone)
sl@0
  3510
		{
sl@0
  3511
		INFO_PRINTF2(_L("SetConfigL returned with KErrNone %d"), errConfig);
sl@0
  3512
		INFO_PRINTF1(_L("InitializeL was not cancelled successfully"));
sl@0
  3513
		StopTest(errConfig, EFail);
sl@0
  3514
		}
sl@0
  3515
	else
sl@0
  3516
		{
sl@0
  3517
		INFO_PRINTF2(_L("SetConfigL returned with unexpected error %d"), errConfig);
sl@0
  3518
		StopTest(errConfig, EFail);
sl@0
  3519
		}
sl@0
  3520
	}
sl@0
  3521
	
sl@0
  3522
/*
sl@0
  3523
 *
sl@0
  3524
 * Fsm
sl@0
  3525
 *	- Executes playing events of DevSound in sequence
sl@0
  3526
 *
sl@0
  3527
 */
sl@0
  3528
void RStepA3FDevSoundCancelInitializePlay::Fsm(TDevSoundPlayEvents aDevSoundEvent, TInt aError)
sl@0
  3529
	{
sl@0
  3530
	switch (iPlayState)
sl@0
  3531
		{
sl@0
  3532
		case EStatePlayStart:
sl@0
  3533
			{
sl@0
  3534
			__ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundCancelInitializePlay"),EFsmIncorrectErrorPassed));
sl@0
  3535
			if (aDevSoundEvent == EEventPlayStart)
sl@0
  3536
				{
sl@0
  3537
				// Initializing DevSound object for playing mode to process audio data via desired FourCC code
sl@0
  3538
				INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL"));
sl@0
  3539
				TInt err;
sl@0
  3540
				if(iUseFourCC)
sl@0
  3541
					{
sl@0
  3542
					TRAP(err, iMMFDevSound->InitializeL(*this, iInputDataType, EMMFStatePlaying));
sl@0
  3543
					}
sl@0
  3544
				else
sl@0
  3545
					{
sl@0
  3546
					TRAP(err, iMMFDevSound->InitializeL(*this, EMMFStatePlaying));
sl@0
  3547
					}
sl@0
  3548
				if (err != KErrNone)
sl@0
  3549
					{
sl@0
  3550
					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
sl@0
  3551
					StopTest(err);
sl@0
  3552
					break;
sl@0
  3553
					}
sl@0
  3554
				else
sl@0
  3555
					{
sl@0
  3556
					INFO_PRINTF1(_L("State: EStatePlayInitializing"));
sl@0
  3557
					iPlayState = EStatePlayInitializing;					
sl@0
  3558
					INFO_PRINTF1(_L("Calling CMMFDevSound::CancelInitialize()"));
sl@0
  3559
					iMMFDevSound->CancelInitialize();
sl@0
  3560
					}
sl@0
  3561
					INFO_PRINTF1(_L("Start timer to wait for InitializeComplete"));
sl@0
  3562
					iTimer->Start(KMicroSecsInTenSecs, 0, iCallBack);	
sl@0
  3563
				}
sl@0
  3564
			else
sl@0
  3565
				{
sl@0
  3566
				ERR_PRINTF2(_L("DevSound EEventPlayStart not received as expected. Received event: %d"), aDevSoundEvent);
sl@0
  3567
				StopTest(aError, EFail);
sl@0
  3568
				}
sl@0
  3569
			break;
sl@0
  3570
			}
sl@0
  3571
		default:
sl@0
  3572
			{
sl@0
  3573
			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iPlayState);
sl@0
  3574
			StopTest(KErrGeneral);
sl@0
  3575
			}
sl@0
  3576
		}
sl@0
  3577
sl@0
  3578
	}
sl@0
  3579
sl@0
  3580
//
sl@0
  3581
// RStepA3FDevSoundNegCancelInitializePlay
sl@0
  3582
//
sl@0
  3583
sl@0
  3584
/*
sl@0
  3585
 *
sl@0
  3586
 * RStepA3FDevSoundNegCancelInitializePlay - Test step constructor
sl@0
  3587
 *
sl@0
  3588
 */
sl@0
  3589
RStepA3FDevSoundNegCancelInitializePlay::RStepA3FDevSoundNegCancelInitializePlay(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType)
sl@0
  3590
:RTestStepA3FDevSoundPlayBase(aTestName, aSectName, aInputDataType)
sl@0
  3591
	{
sl@0
  3592
	}
sl@0
  3593
sl@0
  3594
/*
sl@0
  3595
 *
sl@0
  3596
 * NewL
sl@0
  3597
 *
sl@0
  3598
 */
sl@0
  3599
RStepA3FDevSoundNegCancelInitializePlay* RStepA3FDevSoundNegCancelInitializePlay::NewL(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType)
sl@0
  3600
	{
sl@0
  3601
	RStepA3FDevSoundNegCancelInitializePlay* self = new (ELeave) RStepA3FDevSoundNegCancelInitializePlay(aTestName, aSectName, aInputDataType);
sl@0
  3602
	return self;
sl@0
  3603
sl@0
  3604
	}
sl@0
  3605
sl@0
  3606
/*
sl@0
  3607
 *
sl@0
  3608
 * KickoffTestL
sl@0
  3609
 * - Starts the test
sl@0
  3610
 *
sl@0
  3611
 */
sl@0
  3612
void RStepA3FDevSoundNegCancelInitializePlay::KickoffTestL()
sl@0
  3613
	{
sl@0
  3614
	// Create instance of CMMFDevSound
sl@0
  3615
	INFO_PRINTF1(_L("--- Creating DevSound object..."));
sl@0
  3616
	iMMFDevSound = CMMFDevSound::NewL();
sl@0
  3617
sl@0
  3618
	//Display the name of Codec being used
sl@0
  3619
	DisplayCodecInfo();
sl@0
  3620
	if(!GetBoolFromConfig(iSectName, _L("UseFourCC"), iUseFourCC))
sl@0
  3621
		{
sl@0
  3622
		TPtrC keyName(_L("UseFourCC"));
sl@0
  3623
		ERR_PRINTF3(_L("Error in getting UseFourCC flag value from config file in %S section via the %S key field."), &iSectName, &keyName);
sl@0
  3624
		StopTest(KErrPathNotFound);
sl@0
  3625
		return;
sl@0
  3626
		}
sl@0
  3627
sl@0
  3628
	Fsm(EEventPlayStart,KErrNone); // call to start the DevSound finite state machine for playing
sl@0
  3629
sl@0
  3630
	}
sl@0
  3631
	
sl@0
  3632
/*
sl@0
  3633
 *
sl@0
  3634
 * InitializeComplete
sl@0
  3635
 *
sl@0
  3636
 */
sl@0
  3637
void RStepA3FDevSoundNegCancelInitializePlay::InitializeComplete(TInt aError)
sl@0
  3638
	{
sl@0
  3639
	if (aError == KErrNone)
sl@0
  3640
		{
sl@0
  3641
		INFO_PRINTF1(_L("InitializeComplete returned with KErrNone"));
sl@0
  3642
		INFO_PRINTF1(_L("Calling CancelInitialize after InitializeComplete"));
sl@0
  3643
		TInt err;
sl@0
  3644
		err = iMMFDevSound->CancelInitialize();
sl@0
  3645
		if (err == KErrNotReady)
sl@0
  3646
			{
sl@0
  3647
			INFO_PRINTF1(_L("CancelInitialize returned with KErrNotReady as expected"));
sl@0
  3648
			StopTest(aError);
sl@0
  3649
			}
sl@0
  3650
		else
sl@0
  3651
			{
sl@0
  3652
			INFO_PRINTF2(_L("CancelInitialize return with error %d instead of KErrNotReady as expected"), aError);
sl@0
  3653
			StopTest(aError, EFail);
sl@0
  3654
			}
sl@0
  3655
		}
sl@0
  3656
	else
sl@0
  3657
		{
sl@0
  3658
		INFO_PRINTF2(_L("InitializeComplete returned with error %d"), aError);
sl@0
  3659
		StopTest(aError, EFail);
sl@0
  3660
		}
sl@0
  3661
	
sl@0
  3662
	}
sl@0
  3663
sl@0
  3664
/*
sl@0
  3665
 *
sl@0
  3666
 * Fsm
sl@0
  3667
 *	- Executes playing events of DevSound in sequence
sl@0
  3668
 *
sl@0
  3669
 */
sl@0
  3670
void RStepA3FDevSoundNegCancelInitializePlay::Fsm(TDevSoundPlayEvents aDevSoundEvent, TInt aError)
sl@0
  3671
	{
sl@0
  3672
	switch (iPlayState)
sl@0
  3673
		{
sl@0
  3674
		case EStatePlayStart:
sl@0
  3675
			{
sl@0
  3676
			__ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundNegCancelInitializePlay"),EFsmIncorrectErrorPassed));
sl@0
  3677
			if (aDevSoundEvent == EEventPlayStart)
sl@0
  3678
				{
sl@0
  3679
				// Initializing DevSound object for playing mode to process audio data via desired FourCC code
sl@0
  3680
				INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL"));
sl@0
  3681
				TInt err;
sl@0
  3682
				if(iUseFourCC)
sl@0
  3683
					{
sl@0
  3684
					TRAP(err, iMMFDevSound->InitializeL(*this, iInputDataType, EMMFStatePlaying));
sl@0
  3685
					}
sl@0
  3686
				else
sl@0
  3687
					{
sl@0
  3688
					TRAP(err, iMMFDevSound->InitializeL(*this, EMMFStatePlaying));
sl@0
  3689
					}
sl@0
  3690
				if (err != KErrNone)
sl@0
  3691
					{
sl@0
  3692
					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
sl@0
  3693
					StopTest(err);
sl@0
  3694
					break;
sl@0
  3695
					}
sl@0
  3696
				INFO_PRINTF1(_L("State: EStatePlayInitializing"));
sl@0
  3697
				iPlayState = EStatePlayInitializing;					
sl@0
  3698
				}
sl@0
  3699
			else
sl@0
  3700
				{
sl@0
  3701
				ERR_PRINTF2(_L("DevSound EEventPlayStart not received as expected. Received event: %d"), aDevSoundEvent);
sl@0
  3702
				StopTest(aError, EFail);
sl@0
  3703
				}
sl@0
  3704
			break;
sl@0
  3705
			}
sl@0
  3706
sl@0
  3707
		default:
sl@0
  3708
			{
sl@0
  3709
			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iPlayState);
sl@0
  3710
			StopTest(KErrGeneral);
sl@0
  3711
			}
sl@0
  3712
		}
sl@0
  3713
sl@0
  3714
	}
sl@0
  3715
sl@0
  3716
//
sl@0
  3717
// RStepA3FDevSoundEmptyBuffersInCreatedState
sl@0
  3718
//
sl@0
  3719
sl@0
  3720
/*
sl@0
  3721
 *
sl@0
  3722
 * RStepA3FDevSoundEmptyBuffersInCreatedState - Test step constructor
sl@0
  3723
 *
sl@0
  3724
 */
sl@0
  3725
RStepA3FDevSoundEmptyBuffersInCreatedState::RStepA3FDevSoundEmptyBuffersInCreatedState(const TDesC& aTestName)
sl@0
  3726
:RTestStepA3FDevSoundPlayBase(aTestName)
sl@0
  3727
	{
sl@0
  3728
	}
sl@0
  3729
sl@0
  3730
/*
sl@0
  3731
 *
sl@0
  3732
 * NewL
sl@0
  3733
 *
sl@0
  3734
 */
sl@0
  3735
RStepA3FDevSoundEmptyBuffersInCreatedState* RStepA3FDevSoundEmptyBuffersInCreatedState::NewL(const TDesC& aTestName)
sl@0
  3736
	{
sl@0
  3737
	RStepA3FDevSoundEmptyBuffersInCreatedState* self = new (ELeave) RStepA3FDevSoundEmptyBuffersInCreatedState(aTestName);
sl@0
  3738
	return self;
sl@0
  3739
sl@0
  3740
	}
sl@0
  3741
sl@0
  3742
/*
sl@0
  3743
 *
sl@0
  3744
 * KickoffTestL
sl@0
  3745
 * - Starts the test
sl@0
  3746
 *
sl@0
  3747
 */
sl@0
  3748
void RStepA3FDevSoundEmptyBuffersInCreatedState::KickoffTestL()
sl@0
  3749
	{
sl@0
  3750
	// Create instance of CMMFDevSound
sl@0
  3751
	INFO_PRINTF1(_L("--- Creating DevSound object..."));
sl@0
  3752
	iMMFDevSound = CMMFDevSound::NewL();
sl@0
  3753
	
sl@0
  3754
	//Display the name of Codec being used
sl@0
  3755
	DisplayCodecInfo();
sl@0
  3756
sl@0
  3757
	Fsm(EEventPlayStart,KErrNone); // call to start the DevSound finite state machine for playing
sl@0
  3758
sl@0
  3759
	}
sl@0
  3760
	
sl@0
  3761
/*
sl@0
  3762
 *
sl@0
  3763
 * Fsm
sl@0
  3764
 *	- Executes playing events of DevSound in sequence
sl@0
  3765
 *
sl@0
  3766
 */
sl@0
  3767
void RStepA3FDevSoundEmptyBuffersInCreatedState::Fsm(TDevSoundPlayEvents aDevSoundEvent, TInt aError)
sl@0
  3768
	{
sl@0
  3769
	switch (iPlayState)
sl@0
  3770
		{
sl@0
  3771
		case EStatePlayStart:
sl@0
  3772
			{
sl@0
  3773
			__ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundEmptyBuffersInCreatedState"),EFsmIncorrectErrorPassed));
sl@0
  3774
			if (aDevSoundEvent == EEventPlayStart)
sl@0
  3775
				{
sl@0
  3776
				// Calling EmptyBuffers
sl@0
  3777
				INFO_PRINTF1(_L("Calling CMMFDevSound::EmptyBuffers()"));
sl@0
  3778
				TInt err;
sl@0
  3779
				err = iMMFDevSound->EmptyBuffers();
sl@0
  3780
				if (err == KErrNotReady)
sl@0
  3781
					{
sl@0
  3782
					ERR_PRINTF2(_L("CMMFDevSound::EmptyBuffers() returned expected error = %d"), err);
sl@0
  3783
					StopTest();
sl@0
  3784
					}
sl@0
  3785
				else
sl@0
  3786
					{
sl@0
  3787
					ERR_PRINTF2(_L("CMMFDevSound::EmptyBuffers() did not return KErrNotReady as expected. Returned with unexpected error = %d"), err);
sl@0
  3788
					StopTest(err);
sl@0
  3789
					}
sl@0
  3790
				}
sl@0
  3791
			else
sl@0
  3792
				{
sl@0
  3793
				ERR_PRINTF2(_L("DevSound EEventPlayStart not received as expected. Received event: %d"), aDevSoundEvent);
sl@0
  3794
				StopTest(aError, EFail);
sl@0
  3795
				}
sl@0
  3796
			break;
sl@0
  3797
			}
sl@0
  3798
		default:
sl@0
  3799
			{
sl@0
  3800
			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iPlayState);
sl@0
  3801
			StopTest(KErrGeneral);
sl@0
  3802
			}
sl@0
  3803
		}
sl@0
  3804
sl@0
  3805
	}
sl@0
  3806
sl@0
  3807
//
sl@0
  3808
// RStepA3FDevSoundEmptyBuffersInInitializedState
sl@0
  3809
//
sl@0
  3810
sl@0
  3811
/*
sl@0
  3812
 *
sl@0
  3813
 * RStepA3FDevSoundEmptyBuffersInCreatedState - Test step constructor
sl@0
  3814
 *
sl@0
  3815
 */
sl@0
  3816
RStepA3FDevSoundEmptyBuffersInInitializedState::RStepA3FDevSoundEmptyBuffersInInitializedState(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType)
sl@0
  3817
:RTestStepA3FDevSoundPlayBase(aTestName, aSectName, aInputDataType)
sl@0
  3818
	{
sl@0
  3819
	}
sl@0
  3820
sl@0
  3821
/*
sl@0
  3822
 *
sl@0
  3823
 * NewL
sl@0
  3824
 *
sl@0
  3825
 */
sl@0
  3826
RStepA3FDevSoundEmptyBuffersInInitializedState* RStepA3FDevSoundEmptyBuffersInInitializedState::NewL(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType)
sl@0
  3827
	{
sl@0
  3828
	RStepA3FDevSoundEmptyBuffersInInitializedState* self = new (ELeave) RStepA3FDevSoundEmptyBuffersInInitializedState(aTestName, aSectName, aInputDataType);
sl@0
  3829
	return self;
sl@0
  3830
sl@0
  3831
	}
sl@0
  3832
sl@0
  3833
/*
sl@0
  3834
 *
sl@0
  3835
 * KickoffTestL
sl@0
  3836
 * - Starts the test
sl@0
  3837
 *
sl@0
  3838
 */
sl@0
  3839
void RStepA3FDevSoundEmptyBuffersInInitializedState::KickoffTestL()
sl@0
  3840
	{
sl@0
  3841
	// Create instance of CMMFDevSound
sl@0
  3842
	INFO_PRINTF1(_L("--- Creating DevSound object..."));
sl@0
  3843
	iMMFDevSound = CMMFDevSound::NewL();
sl@0
  3844
	
sl@0
  3845
	//Display the name of Codec being used
sl@0
  3846
	DisplayCodecInfo();
sl@0
  3847
	CheckConfigAndFourCCUsage();
sl@0
  3848
sl@0
  3849
	Fsm(EEventPlayStart,KErrNone); // call to start the DevSound finite state machine for playing
sl@0
  3850
sl@0
  3851
	}
sl@0
  3852
	
sl@0
  3853
/*
sl@0
  3854
 *
sl@0
  3855
 * Fsm
sl@0
  3856
 *	- Executes playing events of DevSound in sequence
sl@0
  3857
 *
sl@0
  3858
 */
sl@0
  3859
void RStepA3FDevSoundEmptyBuffersInInitializedState::Fsm(TDevSoundPlayEvents aDevSoundEvent, TInt aError)
sl@0
  3860
	{
sl@0
  3861
	switch (iPlayState)
sl@0
  3862
		{
sl@0
  3863
		case EStatePlayStart:
sl@0
  3864
			{
sl@0
  3865
			__ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundEmptyBuffersInCreatedState"),EFsmIncorrectErrorPassed));
sl@0
  3866
			if (aDevSoundEvent == EEventPlayStart)
sl@0
  3867
				{
sl@0
  3868
				// Initializing DevSound object for playing mode to process audio data via desired FourCC code
sl@0
  3869
				INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL"));
sl@0
  3870
				TInt err;
sl@0
  3871
				if(iUseFourCC)
sl@0
  3872
					{
sl@0
  3873
					TRAP(err, iMMFDevSound->InitializeL(*this, iInputDataType, EMMFStatePlaying));
sl@0
  3874
					}
sl@0
  3875
				else
sl@0
  3876
					{
sl@0
  3877
					TRAP(err, iMMFDevSound->InitializeL(*this, EMMFStatePlaying));
sl@0
  3878
					}
sl@0
  3879
				if (err != KErrNone)
sl@0
  3880
					{
sl@0
  3881
					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
sl@0
  3882
					StopTest(err);
sl@0
  3883
					break;
sl@0
  3884
					}
sl@0
  3885
				INFO_PRINTF1(_L("State: EStatePlayInitializing"));
sl@0
  3886
				iPlayState = EStatePlayInitializing;
sl@0
  3887
				}
sl@0
  3888
			else
sl@0
  3889
				{
sl@0
  3890
				ERR_PRINTF2(_L("DevSound EEventPlayStart not received as expected. Received event: %d"), aDevSoundEvent);
sl@0
  3891
				StopTest(aError, EFail);
sl@0
  3892
				}
sl@0
  3893
			break;
sl@0
  3894
			}
sl@0
  3895
		case EStatePlayInitializing:
sl@0
  3896
			{
sl@0
  3897
			if (aDevSoundEvent == EEventInitCompletePlay && aError == KErrNone)
sl@0
  3898
				{
sl@0
  3899
				// Calling EmptyBuffers
sl@0
  3900
				INFO_PRINTF1(_L("Calling CMMFDevSound::EmptyBuffers()"));
sl@0
  3901
				TInt err;
sl@0
  3902
				err = iMMFDevSound->EmptyBuffers();
sl@0
  3903
				if (err == KErrNotReady)
sl@0
  3904
					{
sl@0
  3905
					ERR_PRINTF2(_L("CMMFDevSound::EmptyBuffers() returned expected error = %d"), err);
sl@0
  3906
					StopTest();
sl@0
  3907
					}
sl@0
  3908
				else
sl@0
  3909
					{
sl@0
  3910
					ERR_PRINTF2(_L("CMMFDevSound::EmptyBuffers() did not return KErrNotReady as expected. Returned with unexpected error = %d"), err);
sl@0
  3911
					StopTest(err);
sl@0
  3912
					}
sl@0
  3913
				}
sl@0
  3914
			else if (aDevSoundEvent == EEventInitCompletePlay && aError != KErrNone)
sl@0
  3915
				{
sl@0
  3916
				ERR_PRINTF2(_L("DevSound called CMMFDevSound::InitializeComplete with error = %d"), aError);
sl@0
  3917
				StopTest(aError);
sl@0
  3918
				}
sl@0
  3919
			else
sl@0
  3920
				{
sl@0
  3921
				ERR_PRINTF2(_L("DevSound EEventInitCompletePlay not received as expected. Received event: %d"), aDevSoundEvent);
sl@0
  3922
				StopTest(aError, EFail);
sl@0
  3923
				}
sl@0
  3924
			break;
sl@0
  3925
			}
sl@0
  3926
		default:
sl@0
  3927
			{
sl@0
  3928
			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iPlayState);
sl@0
  3929
			StopTest(KErrGeneral);
sl@0
  3930
			}
sl@0
  3931
		}
sl@0
  3932
	}
sl@0
  3933
sl@0
  3934
//
sl@0
  3935
// RStepA3FDevSoundEmptyBuffersInInitializingState
sl@0
  3936
//
sl@0
  3937
sl@0
  3938
/*
sl@0
  3939
 *
sl@0
  3940
 * RStepA3FDevSoundCancelInitializePlay - Test step constructor
sl@0
  3941
 *
sl@0
  3942
 */
sl@0
  3943
RStepA3FDevSoundEmptyBuffersInInitializingState::RStepA3FDevSoundEmptyBuffersInInitializingState(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType)
sl@0
  3944
:RTestStepA3FDevSoundPlayBase(aTestName, aSectName, aInputDataType)
sl@0
  3945
	{
sl@0
  3946
	}
sl@0
  3947
sl@0
  3948
/*
sl@0
  3949
 *
sl@0
  3950
 * NewL
sl@0
  3951
 *
sl@0
  3952
 */
sl@0
  3953
RStepA3FDevSoundEmptyBuffersInInitializingState* RStepA3FDevSoundEmptyBuffersInInitializingState::NewL(const TDesC& aTestName, const TDesC& aSectName, const TFourCC& aInputDataType)
sl@0
  3954
	{
sl@0
  3955
	RStepA3FDevSoundEmptyBuffersInInitializingState* self = new (ELeave) RStepA3FDevSoundEmptyBuffersInInitializingState(aTestName, aSectName, aInputDataType);
sl@0
  3956
	return self;
sl@0
  3957
sl@0
  3958
	}
sl@0
  3959
sl@0
  3960
/*
sl@0
  3961
 *
sl@0
  3962
 * KickoffTestL
sl@0
  3963
 * - Starts the test
sl@0
  3964
 *
sl@0
  3965
 */
sl@0
  3966
void RStepA3FDevSoundEmptyBuffersInInitializingState::KickoffTestL()
sl@0
  3967
	{
sl@0
  3968
	// Create instance of CMMFDevSound
sl@0
  3969
	INFO_PRINTF1(_L("--- Creating DevSound object..."));
sl@0
  3970
	iMMFDevSound = CMMFDevSound::NewL();
sl@0
  3971
	
sl@0
  3972
	//Display the name of Codec being used
sl@0
  3973
	DisplayCodecInfo();
sl@0
  3974
	CheckConfigAndFourCCUsage();
sl@0
  3975
sl@0
  3976
	Fsm(EEventPlayStart,KErrNone); // call to start the DevSound finite state machine for playing
sl@0
  3977
sl@0
  3978
	}
sl@0
  3979
	
sl@0
  3980
/*
sl@0
  3981
 *
sl@0
  3982
 * InitializeComplete
sl@0
  3983
 *
sl@0
  3984
 */
sl@0
  3985
void RStepA3FDevSoundEmptyBuffersInInitializingState::InitializeComplete(TInt aError)
sl@0
  3986
	{
sl@0
  3987
	INFO_PRINTF1(_L("InitializeComplete callback was received. This is not the expected behaviour"));
sl@0
  3988
	INFO_PRINTF1(_L("EmptyBuffers was not called before InitializeComplete "));
sl@0
  3989
	StopTest(aError, EFail);
sl@0
  3990
	}
sl@0
  3991
	
sl@0
  3992
/*
sl@0
  3993
 *
sl@0
  3994
 * Fsm
sl@0
  3995
 *	- Executes playing events of DevSound in sequence
sl@0
  3996
 *
sl@0
  3997
 */
sl@0
  3998
void RStepA3FDevSoundEmptyBuffersInInitializingState::Fsm(TDevSoundPlayEvents aDevSoundEvent, TInt aError)
sl@0
  3999
	{
sl@0
  4000
	switch (iPlayState)
sl@0
  4001
		{
sl@0
  4002
		case EStatePlayStart:
sl@0
  4003
			{
sl@0
  4004
			__ASSERT_ALWAYS((aError == KErrNone),Panic(_L("RStepA3FDevSoundCancelInitializePlay"),EFsmIncorrectErrorPassed));
sl@0
  4005
			if (aDevSoundEvent == EEventPlayStart)
sl@0
  4006
				{
sl@0
  4007
				// Initializing DevSound object for playing mode to process audio data via desired FourCC code
sl@0
  4008
				INFO_PRINTF1(_L("Calling CMMFDevSound::InitializeL"));
sl@0
  4009
				TInt err;
sl@0
  4010
				if(iUseFourCC)
sl@0
  4011
					{
sl@0
  4012
					TRAP(err, iMMFDevSound->InitializeL(*this, iInputDataType, EMMFStatePlaying));
sl@0
  4013
					}
sl@0
  4014
				else
sl@0
  4015
					{
sl@0
  4016
					TRAP(err, iMMFDevSound->InitializeL(*this, EMMFStatePlaying));
sl@0
  4017
					}
sl@0
  4018
				if (err != KErrNone)
sl@0
  4019
					{
sl@0
  4020
					ERR_PRINTF2(_L("CMMFDevSound::InitializeL left with error = %d"), err);
sl@0
  4021
					StopTest(err);
sl@0
  4022
					break;
sl@0
  4023
					}
sl@0
  4024
				else
sl@0
  4025
					{
sl@0
  4026
					INFO_PRINTF1(_L("State: EStatePlayInitializing"));
sl@0
  4027
					iPlayState = EStatePlayInitializing;					
sl@0
  4028
					INFO_PRINTF1(_L("Calling CMMFDevSound::EmptyBuffers()"));
sl@0
  4029
					TInt err;
sl@0
  4030
					err = iMMFDevSound->EmptyBuffers();
sl@0
  4031
					if (err == KErrNotReady)
sl@0
  4032
						{
sl@0
  4033
						ERR_PRINTF2(_L("CMMFDevSound::EmptyBuffers() returned expected error = %d"), err);
sl@0
  4034
						StopTest();
sl@0
  4035
						}
sl@0
  4036
					else
sl@0
  4037
						{
sl@0
  4038
						ERR_PRINTF2(_L("CMMFDevSound::EmptyBuffers() did not return KErrNotReady as expected. Returned with unexpected error = %d"), err);
sl@0
  4039
						StopTest(err);
sl@0
  4040
						}
sl@0
  4041
					}
sl@0
  4042
				}
sl@0
  4043
			else
sl@0
  4044
				{
sl@0
  4045
				ERR_PRINTF2(_L("DevSound EEventPlayStart not received as expected. Received event: %d"), aDevSoundEvent);
sl@0
  4046
				StopTest(aError, EFail);
sl@0
  4047
				}
sl@0
  4048
			break;
sl@0
  4049
			}
sl@0
  4050
		default:
sl@0
  4051
			{
sl@0
  4052
			ERR_PRINTF2(_L("Invalid DevSound state received: %d"), iPlayState);
sl@0
  4053
			StopTest(KErrGeneral);
sl@0
  4054
			}
sl@0
  4055
		}
sl@0
  4056
	}