mmlibs/mmfw/tsrc/mmfunittest/Actrl/TestStepsGetSet.cpp
changeset 0 40261b775718
child 31 ae0addfe117e
equal deleted inserted replaced
-1:000000000000 0:40261b775718
       
     1 // Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // TestStepsGetSet
       
    15 //
       
    16 
       
    17 #include <e32std.h>
       
    18 #include <e32base.h>
       
    19 #include <mmf/common/mmfcontroller.h>
       
    20 #include <mmf/server/mmffile.h>
       
    21 #include <mmf/server/mmfdes.h>
       
    22 #include <mmf/plugin/mmfcontrollerimplementationuids.hrh>
       
    23 #include <mmf/common/mmfstandardcustomcommands.h>
       
    24 
       
    25 //const TInt KPlayDelayNewMail = 100000000;  //arbitrary delay
       
    26 
       
    27 // Test system includes
       
    28 #include <testframework.h>
       
    29 
       
    30 #include "ActrlTestUids.h"
       
    31 
       
    32 // Specific includes for this test suite
       
    33 #include "TS_MMF_ACTRL_TestStep.h"
       
    34 #include "TS_MMF_ACTRL_TestSuite.h"
       
    35 
       
    36 // Specific includes for these test steps
       
    37 #include "TestStepsGetSet.h"
       
    38 
       
    39 /**
       
    40 *
       
    41 * Test step constructor.
       
    42 * Each test step initialises its own name.
       
    43 *
       
    44 */
       
    45 CTestStepGetSetVolumeInPrimed::CTestStepGetSetVolumeInPrimed()
       
    46 	{
       
    47 	// store the name of this test case
       
    48 	// this is the name that is used by the script file
       
    49 	iTestStepName = _L("MM-MMF-ACTRL-U-0001-HP");
       
    50 	}
       
    51 
       
    52 /**
       
    53 *
       
    54 * Test step destructor.
       
    55 * 
       
    56 */
       
    57 CTestStepGetSetVolumeInPrimed::~CTestStepGetSetVolumeInPrimed()
       
    58 	{
       
    59 	}
       
    60 
       
    61 /**
       
    62 * 
       
    63 * Do the test step.
       
    64 * Each test step must supply an implementation for DoTestStepL.
       
    65 * This test does nothing more than exercise the rotate & scale code
       
    66 * @return	"TVerdict" the status of the test
       
    67 *			The result of the test step 
       
    68 */
       
    69 TVerdict CTestStepGetSetVolumeInPrimed::DoTestStepL( void )
       
    70 	{
       
    71     __MM_HEAP_MARK;
       
    72 	
       
    73 	TVerdict result = EPass;
       
    74 	
       
    75 	_LIT( KTestPlay, "Play Test");
       
    76 	Log( KTestPlay );
       
    77 	
       
    78 	_LIT( KTestStepPlay, "This test checks getting/setting volume in primed");
       
    79 	Log( KTestStepPlay );
       
    80 	
       
    81 	// [ audio file to play ]
       
    82 	_LIT(KTestWavFile, "newmail.wav");
       
    83 	SetReadFileNameL( KTestWavFile );
       
    84    	
       
    85 	TInt errorCode = iController.Open(KUidCustomTestAudioPlugin, iPriority);
       
    86 	User::LeaveIfError( errorCode );
       
    87 		
       
    88 	//[ add data source and sink and prime the controller ]
       
    89     errorCode = iController.AddDataSource(KUidMmfFileSource, ReadFileConfig());
       
    90 	User::LeaveIfError( errorCode );
       
    91 	
       
    92 	errorCode =	iController.AddDataSink(KUidMmfAudioOutput, KNullDesC8);
       
    93     User::LeaveIfError( errorCode );
       
    94 	
       
    95 	errorCode =	iController.Prime();
       
    96 	User::LeaveIfError( errorCode );
       
    97 	
       
    98 	// [ wait for and process the return event from the audio output ]
       
    99 	
       
   100 	TMMFEvent primeEvent( KPrimeTestId, KErrNone);
       
   101 	result = SearchForEvent( primeEvent );
       
   102 	if( result == EFail )
       
   103 		{
       
   104 		return result;
       
   105 		}
       
   106 
       
   107    //[ set up audio commands utility ]	
       
   108    RMMFAudioPlayDeviceCustomCommands theCommander( iController );	
       
   109 
       
   110     // [ get the maximum volume ]
       
   111 	TInt maxVolume = 0;
       
   112     errorCode =theCommander.GetMaxVolume( maxVolume );
       
   113 	User::LeaveIfError( errorCode );
       
   114 
       
   115 	//[ set the volume to 1/2 max volume ]
       
   116 	TInt theVolume = maxVolume /2;
       
   117 
       
   118 	//[ set the volume ]
       
   119 	errorCode =theCommander.SetVolume( theVolume );
       
   120 	User::LeaveIfError( errorCode );
       
   121 	
       
   122 	//[ get the volume ]
       
   123 	TInt theNewVolume (0);
       
   124 	errorCode =theCommander.GetVolume( theNewVolume );
       
   125 	User::LeaveIfError( errorCode );
       
   126 
       
   127 	// [ if set volume = got volume  and 
       
   128 	//   rx'd event was ok then we are fine ]
       
   129 	if( theNewVolume == theVolume )
       
   130 		{
       
   131          result = EPass ;
       
   132 		}
       
   133 	//[ ensure the controller is unloaded so that it does 
       
   134 	// not interfere with the following test ]
       
   135 	// There is a bug in this code and the stop followed by reset
       
   136 	// ensure the controller resources are released.
       
   137 	iController.Stop();
       
   138 	iController.Reset();
       
   139 	iController.Close();  
       
   140 	
       
   141 	__MM_HEAP_MARKEND;
       
   142 	   
       
   143 	// test steps return a result
       
   144 	return result;
       
   145 	}
       
   146 
       
   147 
       
   148 /**
       
   149 *
       
   150 *
       
   151 *
       
   152 */
       
   153 CTestStepGetSetVolumeInPlay::CTestStepGetSetVolumeInPlay()
       
   154 	{
       
   155 	// store the name of this test case
       
   156 	// this is the name that is used by the script file
       
   157 	iTestStepName = _L("MM-MMF-ACTRL-U-0002-HP");
       
   158 	}
       
   159 
       
   160 /**
       
   161 *
       
   162 * ~CTestStepGetSetVolumeInPlay
       
   163 *
       
   164 */
       
   165 CTestStepGetSetVolumeInPlay::~CTestStepGetSetVolumeInPlay()
       
   166 	{
       
   167 	}
       
   168 
       
   169 /**
       
   170 *
       
   171 * DoTestStepL
       
   172 *
       
   173 */
       
   174 TVerdict CTestStepGetSetVolumeInPlay::DoTestStepL( void )
       
   175 	{
       
   176      __MM_HEAP_MARK;
       
   177 	
       
   178 	TVerdict result = EFail;
       
   179 	
       
   180 	_LIT( KTestPlay, "Play Test");
       
   181 	Log( KTestPlay );
       
   182 	
       
   183 	_LIT( KTestStepPlay, "This test checks playing an audio clip");
       
   184 	Log( KTestStepPlay );
       
   185 	
       
   186 	// [ audio file to play ]
       
   187 	_LIT(KTestWavFile, "newmail.wav");
       
   188 	SetReadFileNameL( KTestWavFile );
       
   189    	
       
   190 	TInt errorCode = iController.Open(KUidCustomTestAudioPlugin, iPriority);
       
   191 	User::LeaveIfError( errorCode );
       
   192 
       
   193 	//[ add data source and sink and prime the controller ]
       
   194     errorCode = iController.AddDataSource(KUidMmfFileSource, ReadFileConfig());
       
   195 	User::LeaveIfError( errorCode );
       
   196 	
       
   197 	errorCode =	iController.AddDataSink(KUidMmfAudioOutput, KNullDesC8);
       
   198     User::LeaveIfError( errorCode );
       
   199 	
       
   200 	errorCode =	iController.Prime();
       
   201 	User::LeaveIfError( errorCode );
       
   202 	
       
   203 	// [ wait for and process the return event from the audio output ]
       
   204 	
       
   205 	TMMFEvent primeEvent( KPrimeTestId, KErrNone);
       
   206 	TVerdict searchResult = SearchForEvent( primeEvent );
       
   207 	if( searchResult == EFail )
       
   208 		{
       
   209 		return searchResult;
       
   210 		}
       
   211 
       
   212 	 User::LeaveIfError( iController.Play() );
       
   213 
       
   214 	// note this test does not wait around 
       
   215 	// to detect that the audio has been played
       
   216 	// [ now process the confirmation event that play has reached audio output
       
   217 	//   this is the raison detre of the test ]
       
   218 	TMMFEvent playEvent( KPlayTestId, KErrNone );
       
   219 	
       
   220 	searchResult = SearchForEvent( playEvent );
       
   221 	if( searchResult == EFail )
       
   222 		{
       
   223 		return searchResult;
       
   224 		}
       
   225 	
       
   226 	   //[ set up audio commands utility ]	
       
   227    RMMFAudioPlayDeviceCustomCommands theCommander( iController );	
       
   228 
       
   229     // [ get the maximum volume ]
       
   230 	TInt maxVolume = 0;
       
   231     errorCode =theCommander.GetMaxVolume( maxVolume );
       
   232 	User::LeaveIfError( errorCode );
       
   233 
       
   234 	//[ set the volume to 1/2 max volume ]
       
   235 	TInt theVolume = maxVolume /2;
       
   236 
       
   237 	//[ set the volume ]
       
   238 	errorCode =theCommander.SetVolume( theVolume );
       
   239 	User::LeaveIfError( errorCode );
       
   240 	//[ get the volume ]
       
   241 	TInt theNewVolume (0);
       
   242 	errorCode =theCommander.GetVolume( theNewVolume );
       
   243 	User::LeaveIfError( errorCode );
       
   244 
       
   245 	// [ if set volume = got volume, setVolume2 != got volume
       
   246 	// and  rx'd event was ok then we are fine ]
       
   247     TInt overVolume  = maxVolume+1;
       
   248  
       
   249 	//[ set the volume ]
       
   250 	TInt overVolumeErrorCode =theCommander.SetVolume( overVolume );
       
   251 	//[ get the volume ]
       
   252 	TInt overVolumeResult (-100); // arbitrary initial value
       
   253 	errorCode =theCommander.GetVolume( overVolumeResult );
       
   254 	User::LeaveIfError( errorCode );
       
   255 
       
   256 	TInt underVolume = -1;
       
   257 
       
   258 	//[ set the volume ]
       
   259 	TInt underVolumeErrorCode =theCommander.SetVolume( underVolume );
       
   260 	//[ get the volume ]
       
   261 	TInt underVolumeResult (0); //arbitrary initial value
       
   262 	errorCode =theCommander.GetVolume( underVolumeResult );
       
   263 	User::LeaveIfError( errorCode );
       
   264 
       
   265     //[ set the status of the test ]
       
   266     if( ( theVolume == theNewVolume ) &&       // volume has been set correctly
       
   267 		( overVolumeErrorCode != KErrNone) &&  // over volume detected
       
   268 		(theVolume == overVolumeResult) &&    // volume remains unchanged
       
   269 		(underVolumeErrorCode != KErrNone) && // under volume detected
       
   270 		( theVolume == underVolumeResult))    // volume remains unchanged
       
   271 		{
       
   272 		result = EPass;
       
   273 		}
       
   274 		
       
   275 	//[ ensure the controller is unloaded so that it does 
       
   276 	// not interfere with the following test ]
       
   277 	// There is a bug in this code and the stop followed by reset
       
   278 	// ensure the controller resources are released.
       
   279 	iController.Stop();
       
   280 	iController.Reset();
       
   281 	iController.Close();  
       
   282 	
       
   283 	__MM_HEAP_MARKEND;
       
   284 	   
       
   285 	// test steps return a result
       
   286 	return result;
       
   287 	}
       
   288 
       
   289 /**
       
   290 CTestStepGetSetVolumeInStopped
       
   291 
       
   292 */
       
   293 CTestStepGetSetVolumeInStopped::CTestStepGetSetVolumeInStopped()
       
   294 	{
       
   295 	iTestStepName = _L("MM-MMF-ACTRL-U-0003-HP");
       
   296 	}
       
   297 
       
   298 /**
       
   299 ~CTestStepGetSetVolumeInStopped
       
   300 */
       
   301 CTestStepGetSetVolumeInStopped::~CTestStepGetSetVolumeInStopped()
       
   302 	{
       
   303 	}
       
   304 
       
   305 /**
       
   306 *
       
   307 *DoTestStepL
       
   308 *
       
   309 */
       
   310 TVerdict CTestStepGetSetVolumeInStopped::DoTestStepL( void )
       
   311 	{
       
   312 	__MM_HEAP_MARK;
       
   313 	TVerdict result = EFail;
       
   314 
       
   315 	_LIT( KTestPlay, "Get/Set Volume while stopped");
       
   316 	Log( KTestPlay );
       
   317 	
       
   318 	_LIT( KTestStepPlay, "This test checks get/set volume while stopped");
       
   319 	Log( KTestStepPlay );
       
   320 	
       
   321 	// [ audio file to play ]
       
   322 	_LIT(KTestWavFile, "newmail.wav");
       
   323    	SetReadFileNameL( KTestWavFile );
       
   324 
       
   325 	TInt errorCode = iController.Open(KUidCustomTestAudioPlugin, iPriority);
       
   326 	User::LeaveIfError( errorCode );
       
   327 
       
   328 	//[ add data source and sink and prime the controller ]
       
   329     errorCode = iController.AddDataSource(KUidMmfFileSource, ReadFileConfig());
       
   330 	User::LeaveIfError( errorCode );
       
   331 	
       
   332 	errorCode =	iController.AddDataSink(KUidMmfAudioOutput, KNullDesC8);
       
   333     User::LeaveIfError( errorCode );
       
   334 
       
   335 	//[ set up audio commands utility ]	
       
   336 	RMMFAudioPlayDeviceCustomCommands theCommander( iController );	
       
   337 
       
   338 	// [ get the maximum volume ]
       
   339 	TInt maxVolume = 0;
       
   340     errorCode =theCommander.GetMaxVolume( maxVolume );
       
   341 	User::LeaveIfError( errorCode );
       
   342 
       
   343 	//[ set the volume to 1/2 max volume ]
       
   344 	TInt theVolume = maxVolume /2;
       
   345 
       
   346 	//[ set the volume ]
       
   347 	errorCode =theCommander.SetVolume( theVolume );
       
   348 	User::LeaveIfError( errorCode );
       
   349 	//[ get the volume ]
       
   350 	TInt theNewVolume (0);
       
   351 	errorCode =theCommander.GetVolume( theNewVolume );
       
   352 	User::LeaveIfError( errorCode );
       
   353 
       
   354 	// [ if set volume = got volume, setVolume2 != got volume
       
   355 	// and  rx'd event was ok then we are fine ]
       
   356     TInt overVolume  = maxVolume+1;
       
   357  
       
   358 	//[ set the volume ]
       
   359 	TInt overVolumeErrorCode =theCommander.SetVolume( overVolume );
       
   360 	//[ get the volume ]
       
   361 	TInt overVolumeResult (-100); //arbitrary initial value
       
   362 	errorCode =theCommander.GetVolume( overVolumeResult );
       
   363 	User::LeaveIfError( errorCode );
       
   364 
       
   365 	TInt underVolume = -1; //arbitrary initial value
       
   366 
       
   367 	//[ set the volume ]
       
   368 	TInt underVolumeErrorCode =theCommander.SetVolume( underVolume );
       
   369 	//[ get the volume ]
       
   370 	TInt underVolumeResult (0);
       
   371 	errorCode =theCommander.GetVolume( underVolumeResult );
       
   372 	User::LeaveIfError( errorCode );
       
   373 
       
   374     //[ set the status of the test ]
       
   375     if( ( theVolume == theNewVolume ) &&       // volume has been set correctly
       
   376 		( overVolumeErrorCode != KErrNone) &&  // over volume detected
       
   377 		(theVolume == overVolumeResult) &&    // volume remains unchanged
       
   378 		(underVolumeErrorCode != KErrNone) && // under volume detected
       
   379 		( theVolume == underVolumeResult))    // volume remains unchanged
       
   380 		{
       
   381 		result = EPass;
       
   382 		}
       
   383 	
       
   384 	//[ ensure the controller is unloaded so that it does 
       
   385 	// not interfere with the following test ]
       
   386 	// There is a bug in this code and the stop followed by reset
       
   387 	// ensure the controller resources are released.
       
   388 	iController.Stop();
       
   389 	iController.Reset();
       
   390 	iController.Close();  
       
   391 	
       
   392 	__MM_HEAP_MARKEND;
       
   393 	return result;
       
   394 	}
       
   395 
       
   396 /**
       
   397 *
       
   398 * CTestStepGetSetBalanceInPrimed
       
   399 *
       
   400 */
       
   401 CTestStepGetSetBalanceInPrimed::CTestStepGetSetBalanceInPrimed()
       
   402 	{
       
   403 	iTestStepName = _L("MM-MMF-ACTRL-U-0005-HP");
       
   404 	}
       
   405 
       
   406 /**
       
   407 *
       
   408 * ~CTestStepGetSetBalanceInPrimed
       
   409 */
       
   410 CTestStepGetSetBalanceInPrimed::~CTestStepGetSetBalanceInPrimed()
       
   411 	{
       
   412 	}
       
   413 
       
   414 /**
       
   415 *
       
   416 * DoTestStepL
       
   417 *
       
   418 */
       
   419 TVerdict  CTestStepGetSetBalanceInPrimed::DoTestStepL( void )
       
   420 	{
       
   421 	__MM_HEAP_MARK;
       
   422 	TVerdict result = EFail;
       
   423 
       
   424 	_LIT( KTestPlay, "Get/Set Balance while primed");
       
   425 	Log( KTestPlay );
       
   426 	
       
   427 	_LIT( KTestStepPlay, "This test checks get/set balance while primed");
       
   428 	Log( KTestStepPlay );
       
   429 	
       
   430 	// [ audio file to play ]
       
   431 	_LIT(KTestWavFile, "newmail.wav");
       
   432 	SetReadFileNameL( KTestWavFile );
       
   433    	
       
   434 	TInt errorCode = iController.Open(KUidCustomTestAudioPlugin, iPriority);
       
   435 	User::LeaveIfError( errorCode );
       
   436 	
       
   437 	//[ add data source and sink and prime the controller ]
       
   438     errorCode = iController.AddDataSource(KUidMmfFileSource, ReadFileConfig());
       
   439 	User::LeaveIfError( errorCode );
       
   440 	
       
   441 	errorCode =	iController.AddDataSink(KUidMmfAudioOutput, KNullDesC8);
       
   442     User::LeaveIfError( errorCode );
       
   443 
       
   444 	errorCode =	iController.Prime();
       
   445 	User::LeaveIfError( errorCode );
       
   446 	
       
   447 	// [ wait for and process the return event from the audio output ]
       
   448 	
       
   449 	TMMFEvent primeEvent( KPrimeTestId, KErrNone);
       
   450 	TVerdict searchResult = SearchForEvent( primeEvent );
       
   451 	if( searchResult == EFail )
       
   452 		{
       
   453 		return searchResult;
       
   454 		}
       
   455 	
       
   456 	//[ set up audio commands utility ]	
       
   457 	RMMFAudioPlayDeviceCustomCommands theCommander( iController );	
       
   458 
       
   459 	// [ set the balance to an arbitrary value within the range -100 , 100 ]
       
   460 	TInt theBalance = (30 * (KMMFBalanceMaxRight-KMMFBalanceMaxLeft))/100 + KMMFBalanceMaxLeft;
       
   461 	//[ set the Balance, we are expecting failure ]
       
   462 	TInt setErrorCode =theCommander.SetBalance( theBalance );
       
   463 
       
   464 	//[ get the balance, we are expecting failure ]
       
   465 	TInt theNewBalance (0);
       
   466 	TInt getErrorCode =theCommander.GetBalance( theNewBalance );
       
   467 
       
   468 	//[ set the status of the test ]
       
   469     if( ( getErrorCode ==  KErrNone) &&
       
   470 		( setErrorCode ==  KErrNone) )
       
   471 		{
       
   472 		result = EPass;
       
   473 		}
       
   474 
       
   475 	//[ ensure the controller is unloaded so that it does 
       
   476 	// not interfere with the following test ]
       
   477 	// There is a bug in this code and the stop followed by reset
       
   478 	// ensure the controller resources are released.
       
   479 	iController.Stop();
       
   480 	iController.Reset();
       
   481 	iController.Close();  
       
   482 	
       
   483 	__MM_HEAP_MARKEND;
       
   484 	return result;
       
   485 	}
       
   486 
       
   487 /**
       
   488 *
       
   489 * CTestStepGetSetBalanceInPlay
       
   490 */
       
   491 CTestStepGetSetBalanceInPlay::CTestStepGetSetBalanceInPlay()
       
   492 	{
       
   493    	iTestStepName = _L("MM-MMF-ACTRL-U-0007-HP");
       
   494 	}
       
   495 
       
   496 /**
       
   497 *
       
   498 * ~CTestStepGetSetBalanceInPlay
       
   499 */
       
   500 CTestStepGetSetBalanceInPlay::~CTestStepGetSetBalanceInPlay()
       
   501 	{
       
   502 	}
       
   503 
       
   504 /**
       
   505 *
       
   506 * DoTestStepL
       
   507 *
       
   508 */
       
   509 TVerdict CTestStepGetSetBalanceInPlay::DoTestStepL( void )
       
   510 	{
       
   511 	__MM_HEAP_MARK;
       
   512 	TVerdict result = EFail;
       
   513 
       
   514 	_LIT( KTestPlay, "Get/Set Balance while in Play");
       
   515 	Log( KTestPlay );
       
   516 	
       
   517 	_LIT( KTestStepPlay, "This test checks get/set balance while playing");
       
   518 	Log( KTestStepPlay );
       
   519 	
       
   520 	// [ audio file to play ]
       
   521 	_LIT(KTestWavFile, "newmail.wav");
       
   522 	SetReadFileNameL( KTestWavFile );
       
   523    	
       
   524 	TInt errorCode = iController.Open(KUidCustomTestAudioPlugin, iPriority);
       
   525 	User::LeaveIfError( errorCode );
       
   526 
       
   527 	//[ add data source and sink and prime the controller ]
       
   528     errorCode = iController.AddDataSource(KUidMmfFileSource, ReadFileConfig());
       
   529 	User::LeaveIfError( errorCode );
       
   530 	
       
   531 	errorCode =	iController.AddDataSink(KUidMmfAudioOutput, KNullDesC8);
       
   532     User::LeaveIfError( errorCode );
       
   533 
       
   534 	errorCode =	iController.Prime();
       
   535 	User::LeaveIfError( errorCode );
       
   536 	
       
   537 	// [ wait for and process the return event from the audio output ]
       
   538 	
       
   539 	TMMFEvent primeEvent( KPrimeTestId, KErrNone);
       
   540 	TVerdict searchResult = SearchForEvent( primeEvent );
       
   541 	if( searchResult == EFail )
       
   542 		{
       
   543 		return searchResult;
       
   544 		}
       
   545 	
       
   546 	//[ set the controller to play ]
       
   547 	User::LeaveIfError( iController.Play() );
       
   548 	
       
   549 	//[ set up audio commands utility ]	
       
   550 	RMMFAudioPlayDeviceCustomCommands theCommander( iController );	
       
   551 
       
   552 	// [ set the balance to an arbitrary value between 0,100 and map to the range -100,100 ]
       
   553 	TInt theBalance = (30 * (KMMFBalanceMaxRight-KMMFBalanceMaxLeft))/100 + KMMFBalanceMaxLeft;;
       
   554 	//[ set the Balance ]
       
   555 	TInt setErrorCode =theCommander.SetBalance( theBalance );
       
   556 	
       
   557 	//[ get the balance ]
       
   558 	TInt theNewBalance (0);
       
   559 	TInt getErrorCode =theCommander.GetBalance( theNewBalance );
       
   560 
       
   561 	//[ set the status of the test ]
       
   562     if( 
       
   563 		( getErrorCode != KErrNone) && // under volume detected
       
   564 		( setErrorCode != KErrNone))    // volume remains unchanged
       
   565 		{
       
   566 		result = EPass;
       
   567 		}
       
   568 
       
   569     TMMFEvent playEvent( KPlayTestId, KErrNone );
       
   570 	searchResult = SearchForEvent( playEvent );
       
   571 	if( searchResult != EFail )
       
   572 		{
       
   573 		result = EPass;
       
   574 		}
       
   575 
       
   576 	//[ ensure the controller is unloaded so that it does 
       
   577 	// not interfere with the following test ]
       
   578 	// There is a bug in this code and the stop followed by reset
       
   579 	// ensure the controller resources are released.
       
   580 	iController.Stop();
       
   581 	iController.Reset();
       
   582 	iController.Close();  
       
   583 	
       
   584 	__MM_HEAP_MARKEND;
       
   585 	return result;
       
   586 	}
       
   587 
       
   588 /**
       
   589 *
       
   590 * CTestStepGetSetBalanceInStopped
       
   591 *
       
   592 */
       
   593 CTestStepGetSetBalanceInStopped::CTestStepGetSetBalanceInStopped()
       
   594 	{
       
   595 	iTestStepName = _L("MM-MMF-ACTRL-U-0006-HP");
       
   596 	}
       
   597 
       
   598 /**
       
   599 *
       
   600 * CTestStepGetSetBalanceInStopped
       
   601 *
       
   602 */
       
   603 CTestStepGetSetBalanceInStopped::~CTestStepGetSetBalanceInStopped()
       
   604 	{
       
   605 	}
       
   606 
       
   607 /**
       
   608 *
       
   609 * DoTestStepL
       
   610 *
       
   611 */
       
   612 TVerdict CTestStepGetSetBalanceInStopped::DoTestStepL( void )
       
   613 	{
       
   614 	__MM_HEAP_MARK;
       
   615 	TVerdict result = EFail;
       
   616 
       
   617 	_LIT( KTestPlay, "Get/Set Balance while stopped");
       
   618 	Log( KTestPlay );
       
   619 	
       
   620 	_LIT( KTestStepPlay, "This test checks get/set balance while stopped");
       
   621 	Log( KTestStepPlay );
       
   622 	
       
   623 	// [ audio file to play ]
       
   624 	_LIT(KTestWavFile, "newmail.wav");
       
   625 	SetReadFileNameL( KTestWavFile );
       
   626    	
       
   627 	TInt errorCode = iController.Open(KUidCustomTestAudioPlugin, iPriority);
       
   628 	User::LeaveIfError( errorCode );
       
   629 
       
   630 	//[ add data source and sink and prime the controller ]
       
   631     errorCode = iController.AddDataSource(KUidMmfFileSource, ReadFileConfig());
       
   632 	User::LeaveIfError( errorCode );
       
   633 	
       
   634 	errorCode =	iController.AddDataSink(KUidMmfAudioOutput, KNullDesC8);
       
   635     User::LeaveIfError( errorCode );
       
   636 
       
   637 	//[ set up audio commands utility ]	
       
   638 	RMMFAudioPlayDeviceCustomCommands theCommander( iController );	
       
   639 
       
   640 	// [ set the balance ]
       
   641 	TInt theBalance = (30 * (KMMFBalanceMaxRight-KMMFBalanceMaxLeft))/100 + KMMFBalanceMaxLeft;;
       
   642 	//[ set the Balance ]
       
   643 	errorCode =theCommander.SetBalance( theBalance );
       
   644 	User::LeaveIfError( errorCode );
       
   645 
       
   646 	//[ get the balance ]
       
   647 	TInt theNewBalance (0);
       
   648 	errorCode =theCommander.GetBalance( theNewBalance );
       
   649 	User::LeaveIfError( errorCode );
       
   650 
       
   651 	// [ if set balance = got balance, setbalance2 != got balance
       
   652 	// and  rx'd event was ok then we are fine 
       
   653 	// set the balance to an arbitrary value in the range 0..100 and map to the soundev range]
       
   654     TInt overBalance  = (300 * (KMMFBalanceMaxRight-KMMFBalanceMaxLeft))/100 + KMMFBalanceMaxLeft;
       
   655  
       
   656 	//[ set the volume ]
       
   657 	TInt overBalanceErrorCode =theCommander.SetBalance( overBalance );
       
   658 	//[ get the volume ]
       
   659 	TInt overBalanceResult (-106); // set to an arbitrary value
       
   660 	errorCode =theCommander.GetBalance( overBalanceResult );
       
   661 	User::LeaveIfError( errorCode );
       
   662 
       
   663 	// [ set the under balance to a value < 0 and map to the correct range]
       
   664 	TInt underBalance = (-50 * (KMMFBalanceMaxRight-KMMFBalanceMaxLeft))/100 + KMMFBalanceMaxLeft;
       
   665 
       
   666 	//[ set the volume ]
       
   667 	TInt underBalanceErrorCode =theCommander.SetBalance( underBalance );
       
   668 	//[ get the volume ]
       
   669 	TInt underBalanceResult (0);
       
   670 	errorCode =theCommander.GetBalance( underBalanceResult );
       
   671 	User::LeaveIfError( errorCode );
       
   672 
       
   673 	// Set the test result
       
   674 	if ((theBalance == theNewBalance) &&				// balance set correctly
       
   675 		(overBalanceErrorCode == KErrNone) &&			// no error setting over balance
       
   676 		(overBalanceResult == KMMFBalanceMaxRight) &&	// over balance is set to KMMFBalanceMaxRight
       
   677 		(underBalanceErrorCode == KErrNone) &&			// no error setting under balance
       
   678 		(underBalanceResult == KMMFBalanceMaxLeft))		// under balance is set to KMMFBalanceMaxLeft
       
   679 		{
       
   680 		result = EPass;
       
   681 		}
       
   682 
       
   683 	//[ ensure the controller is unloaded so that it does 
       
   684 	// not interfere with the following test ]
       
   685 	// There is a bug in this code and the stop followed by reset
       
   686 	// ensure the controller resources are released.
       
   687 	iController.Stop();
       
   688 	iController.Reset();
       
   689 	iController.Close();  
       
   690 	
       
   691 	__MM_HEAP_MARKEND;
       
   692 	return result;
       
   693 	}
       
   694 //
       
   695 /**
       
   696 *
       
   697 * CTestStepGetSetPositionInPaused
       
   698 *
       
   699 */
       
   700 CTestStepGetSetPositionInPaused::CTestStepGetSetPositionInPaused()
       
   701 	{
       
   702 	iTestStepName = _L("MM-MMF-ACTRL-U-0070-HP");
       
   703 	}
       
   704 
       
   705 /**
       
   706 *
       
   707 * ~CTestStepGetSetPositionInPaused
       
   708 *
       
   709 */
       
   710 CTestStepGetSetPositionInPaused::~CTestStepGetSetPositionInPaused()
       
   711 	{
       
   712 	}
       
   713 
       
   714 /**
       
   715 *
       
   716 * DoTestStepL
       
   717 *
       
   718 */
       
   719 TVerdict CTestStepGetSetPositionInPaused::DoTestStepL( void )
       
   720 	{
       
   721 	 __MM_HEAP_MARK;
       
   722 	
       
   723 	TVerdict result = EPass;
       
   724 	TTimeIntervalMicroSeconds position(0);
       
   725 	
       
   726 	_LIT( KTestPause, "Pause Test");
       
   727 	Log( KTestPause );
       
   728 	
       
   729 	_LIT( KTestStepPause, "This test checks set/get position whilst paused: Play->Pause->Rewind->Play (Proper verification requires headphones)");
       
   730 	Log( KTestStepPause );
       
   731 	
       
   732 	// [ audio file to play ]
       
   733 	// At time of writing, this file is approx 8s duration.
       
   734 	_LIT(KTestWavFile, "mainTst.wav");
       
   735 	SetReadFileNameL( KTestWavFile );
       
   736    	
       
   737 	TInt errorCode = iController.Open(KUidCustomTestAudioPlugin, iPriority);
       
   738 	User::LeaveIfError( errorCode );
       
   739 
       
   740 	//[ add data source and sink and prime the controller ]
       
   741     errorCode = iController.AddDataSource(KUidMmfFileSource, ReadFileConfig());
       
   742 	User::LeaveIfError( errorCode );
       
   743 	
       
   744 	errorCode =	iController.AddDataSink(KUidMmfAudioOutput, KNullDesC8);
       
   745     User::LeaveIfError( errorCode );
       
   746 	
       
   747 	User::LeaveIfError( iController.Prime() );
       
   748 	
       
   749 	// [ wait for and process the return event from the audio output ]
       
   750 	
       
   751 	TMMFEvent primeEvent( KPrimeTestId, KErrNone);
       
   752 	TVerdict searchResult = SearchForEvent( primeEvent );
       
   753 	if( searchResult == EFail )
       
   754 		{
       
   755 		return searchResult;
       
   756 		}
       
   757 
       
   758 	User::LeaveIfError( iController.GetPosition( position ) );
       
   759 	INFO_PRINTF2(_L("Position at start is %d"), position.Int64());
       
   760 
       
   761 
       
   762 	// note this test does not wait around 
       
   763 	// to detect that the audio has been played
       
   764 	User::LeaveIfError( iController.Play() );
       
   765 
       
   766 	// [ now process the confirmation event that play has reached audio output
       
   767 	//   this is the raison detre of the test ]
       
   768 	TMMFEvent playEvent1( KPlayTestId, KErrNone );
       
   769 	searchResult = SearchForEvent( playEvent1 );
       
   770 	if( searchResult == EFail )
       
   771 		{
       
   772 		return searchResult;
       
   773 		}	
       
   774 
       
   775 	// [ play for two seconds ]
       
   776 	User::After(2000000); 
       
   777 
       
   778 	User::LeaveIfError( iController.GetPosition( position ) );
       
   779 	INFO_PRINTF2(_L("Position before pause is %d"), position.Int64());
       
   780 
       
   781 
       
   782     // [ The controller is in the play state and
       
   783 	//   should not return an error if pause is called ]
       
   784 	User::LeaveIfError( iController.Pause() );
       
   785 
       
   786 	TMMFEvent pauseEvent( KPauseTestId, KErrNone );
       
   787 	result = SearchForEvent( pauseEvent );
       
   788 	if( result == EFail )
       
   789 		{
       
   790 		return result;
       
   791 		}
       
   792 
       
   793 	User::LeaveIfError( iController.GetPosition( position ) );
       
   794 	INFO_PRINTF2(_L("Position after pause is %d"), position.Int64());
       
   795 
       
   796 	//[ ok lets reset to the beginning ]
       
   797 	User::LeaveIfError( iController.SetPosition( TTimeIntervalMicroSeconds(0) ) );
       
   798 	
       
   799 	User::LeaveIfError( iController.GetPosition( position ) );
       
   800 	INFO_PRINTF2(_L("Position after rewind is %d"), position.Int64());
       
   801 
       
   802 
       
   803 	// [ Now let's start to play again ]
       
   804 
       
   805 	// note this test does not wait around 
       
   806 	// to detect that the audio has been played
       
   807 	User::LeaveIfError( iController.Play() );
       
   808 
       
   809 	// [ now process the confirmation event that play has reached audio output
       
   810 	//   this is the raison detre of the test ]
       
   811 	TMMFEvent playEvent2( KPlayTestId, KErrNone );
       
   812 	searchResult = SearchForEvent( playEvent2 );
       
   813 	if( searchResult == EFail )
       
   814 		{
       
   815 		return searchResult;
       
   816 		}	
       
   817 
       
   818 	// [ play for 10s (approx entire file) ]
       
   819 	User::After(10000000); 
       
   820 
       
   821 	//[ ensure the controller is unloaded so that it does 
       
   822 	// not interfere with the following test ]
       
   823 	// There is a bug in this code and the stop followed by reset
       
   824 	// ensure the controller resources are released.
       
   825 	iController.Stop();
       
   826 	iController.Reset();
       
   827 	iController.Close();  
       
   828 	
       
   829 	__MM_HEAP_MARKEND;
       
   830 	return result;
       
   831 	}
       
   832 //
       
   833 /**
       
   834 *
       
   835 * CTestStepGetSetPositionInPlay
       
   836 *
       
   837 */
       
   838 CTestStepGetSetPositionInPlay::CTestStepGetSetPositionInPlay()
       
   839 	{
       
   840 	iTestStepName = _L("MM-MMF-ACTRL-U-0008-HP");
       
   841 	}
       
   842 
       
   843 /**
       
   844 *
       
   845 * ~CTestStepGetSetPositionInPlay
       
   846 *
       
   847 */
       
   848 CTestStepGetSetPositionInPlay::~CTestStepGetSetPositionInPlay()
       
   849 	{
       
   850 	}
       
   851 
       
   852 /**
       
   853 *
       
   854 * DoTestStepL
       
   855 *
       
   856 */
       
   857 TVerdict CTestStepGetSetPositionInPlay::DoTestStepL( void )
       
   858 	{
       
   859 	 __MM_HEAP_MARK;
       
   860 	
       
   861 	TVerdict result = EPass;
       
   862 	
       
   863 	_LIT( KTestPlay, "Play Test");
       
   864 	Log( KTestPlay );
       
   865 	
       
   866 	_LIT( KTestStepPlay, "This test checks set/get position whilst playing");
       
   867 	Log( KTestStepPlay );
       
   868 	
       
   869 	// [ audio file to play ]
       
   870 	_LIT(KTestWavFile, "newmail.wav");
       
   871 	SetReadFileNameL( KTestWavFile );
       
   872    	
       
   873 	TInt errorCode = iController.Open(KUidCustomTestAudioPlugin, iPriority);
       
   874 	User::LeaveIfError( errorCode );
       
   875 
       
   876 	//[ add data source and sink and prime the controller ]
       
   877     errorCode = iController.AddDataSource(KUidMmfFileSource, ReadFileConfig());
       
   878 	User::LeaveIfError( errorCode );
       
   879 	
       
   880 	errorCode =	iController.AddDataSink(KUidMmfAudioOutput, KNullDesC8);
       
   881     User::LeaveIfError( errorCode );
       
   882 	
       
   883 	errorCode =	iController.Prime();
       
   884 	User::LeaveIfError( errorCode );
       
   885 	
       
   886 	// [ wait for and process the return event from the audio output ]
       
   887 	
       
   888 	TMMFEvent primeEvent( KPrimeTestId, KErrNone);
       
   889 	TVerdict searchResult = SearchForEvent( primeEvent );
       
   890 	if( searchResult == EFail )
       
   891 		{
       
   892 		return searchResult;
       
   893 		}
       
   894 
       
   895 	 User::LeaveIfError( iController.Play() );
       
   896 
       
   897 	// note this test does not wait around 
       
   898 	// to detect that the audio has been played
       
   899 	// [ now process the confirmation event that play has reached audio output
       
   900 	//   this is the raison detre of the test ]
       
   901 	TMMFEvent playEvent( KPlayTestId, KErrNone );
       
   902 	
       
   903 	searchResult = SearchForEvent( playEvent );
       
   904 	if( searchResult == EFail )
       
   905 		{
       
   906 		return searchResult;
       
   907 		}	
       
   908 
       
   909 	//[ ok lets set/get the position ]
       
   910 	TTimeIntervalMicroSeconds theStartPosition(0);
       
   911 	TInt posSetError = iController.SetPosition( theStartPosition );
       
   912 	
       
   913 	// [get the position ]
       
   914 	TTimeIntervalMicroSeconds theCurrentPosition;
       
   915 	TInt posGetError = iController.GetPosition( theCurrentPosition );
       
   916 
       
   917 	// [ the test has passed if we have no errors in both cases ]
       
   918 	if( (posGetError != KErrNone ) &&
       
   919 		(posSetError != KErrNone ) )
       
   920 		{
       
   921 		result = EFail ;
       
   922 		}
       
   923 
       
   924 	//[ ensure the controller is unloaded so that it does 
       
   925 	// not interfere with the following test ]
       
   926 	// There is a bug in this code and the stop followed by reset
       
   927 	// ensure the controller resources are released.
       
   928 	iController.Stop();
       
   929 	iController.Reset();
       
   930 	iController.Close();  
       
   931 	
       
   932 	__MM_HEAP_MARKEND;
       
   933 	return result;
       
   934 	}
       
   935 
       
   936 /**
       
   937 *
       
   938 *
       
   939 * CTestStepGetSetPositionInStopped
       
   940 *
       
   941 */
       
   942 CTestStepGetSetPositionInStopped::CTestStepGetSetPositionInStopped()
       
   943 	{
       
   944 	iTestStepName = _L("MM-MMF-ACTRL-U-0009-HP");
       
   945 	}
       
   946 
       
   947 /**
       
   948 *
       
   949 * ~CTestStepGetSetPositionInStopped
       
   950 */
       
   951 CTestStepGetSetPositionInStopped::~CTestStepGetSetPositionInStopped()
       
   952 	{
       
   953 	}
       
   954 
       
   955 /**
       
   956 *
       
   957 * DoTestStepL
       
   958 *
       
   959 */
       
   960 TVerdict CTestStepGetSetPositionInStopped::DoTestStepL( void )
       
   961 	{
       
   962 	__MM_HEAP_MARK;
       
   963 	TVerdict result = EPass ;
       
   964 	//[ In this state it should not be possible to set the positio]
       
   965 
       
   966 	_LIT( KTestPlay, "Set/Get Position while stopped");
       
   967 	Log( KTestPlay );
       
   968 	
       
   969 	_LIT( KTestStepPlay, "This test checks get/set position while stopped");
       
   970 	Log( KTestStepPlay );
       
   971 	
       
   972 	// [ audio file to play ]
       
   973 	_LIT(KTestWavFile, "newmail.wav");
       
   974 	SetReadFileNameL( KTestWavFile );
       
   975    	
       
   976 	TInt errorCode = iController.Open(KUidCustomTestAudioPlugin, iPriority);
       
   977 	User::LeaveIfError( errorCode );
       
   978 
       
   979 	
       
   980 	//[ add data source and sink and prime the controller ]
       
   981     errorCode = iController.AddDataSource(KUidMmfFileSource, ReadFileConfig());
       
   982 	User::LeaveIfError( errorCode );
       
   983 	
       
   984 	errorCode =	iController.AddDataSink(KUidMmfAudioOutput, KNullDesC8);
       
   985     User::LeaveIfError( errorCode );
       
   986 
       
   987     //[ set the position to the start ]
       
   988 	TTimeIntervalMicroSeconds theStartPosition(0);
       
   989 	TInt posSetError = iController.SetPosition( theStartPosition );
       
   990 	
       
   991 	// [get the position ]
       
   992 	TTimeIntervalMicroSeconds theCurrentPosition;
       
   993 	TInt posGetError = iController.GetPosition( theCurrentPosition );
       
   994 
       
   995 	// [ the test has passed if we have errors in both cases ]
       
   996 	if( (posGetError == KErrNone ) ||
       
   997 		(posSetError == KErrNone ) )
       
   998 		{
       
   999 		result = EFail ;
       
  1000 		}
       
  1001 
       
  1002 	//[ ensure the controller is unloaded so that it does 
       
  1003 	// not interfere with the following test ]
       
  1004 	// There is a bug in this code and the stop followed by reset
       
  1005 	// ensure the controller resources are released.
       
  1006 	iController.Stop();
       
  1007 	iController.Reset();
       
  1008 	iController.Close();  
       
  1009 	
       
  1010 	__MM_HEAP_MARKEND;
       
  1011 	return result ;
       
  1012 	}
       
  1013 
       
  1014 /**
       
  1015 *
       
  1016 * CTestStepGetSetPositionInPrimed
       
  1017 */
       
  1018 CTestStepGetSetPositionInPrimed::CTestStepGetSetPositionInPrimed()
       
  1019 	{
       
  1020 	iTestStepName = _L("MM-MMF-ACTRL-U-0010-HP");
       
  1021 	}
       
  1022 
       
  1023 /**
       
  1024 *
       
  1025 * ~CTestStepGetSetPositionInStopped
       
  1026 */
       
  1027 CTestStepGetSetPositionInPrimed::~CTestStepGetSetPositionInPrimed()
       
  1028 	{
       
  1029 	}
       
  1030 
       
  1031 /**
       
  1032 *
       
  1033 * DoTestStepL
       
  1034 *
       
  1035 */
       
  1036 TVerdict CTestStepGetSetPositionInPrimed::DoTestStepL( void )
       
  1037 	{
       
  1038 	__MM_HEAP_MARK;
       
  1039 	TVerdict result = EPass ;
       
  1040 
       
  1041 	_LIT( KTestStepPlay, "GetSet Position In Primed");
       
  1042 	Log( KTestStepPlay );
       
  1043 	
       
  1044 	// [ audio file to play ]
       
  1045 	_LIT(KTestWavFile, "newmail.wav");
       
  1046 	SetReadFileNameL( KTestWavFile );
       
  1047    	
       
  1048 	TInt errorCode = iController.Open(KUidCustomTestAudioPlugin, iPriority);
       
  1049 	User::LeaveIfError( errorCode );
       
  1050 
       
  1051 	//[ add data source and sink and prime the controller ]
       
  1052     errorCode = iController.AddDataSource(KUidMmfFileSource, ReadFileConfig());
       
  1053 	User::LeaveIfError( errorCode );
       
  1054 	
       
  1055 	errorCode =	iController.AddDataSink(KUidMmfAudioOutput, KNullDesC8);
       
  1056     User::LeaveIfError( errorCode );
       
  1057 
       
  1058 	errorCode =	iController.Prime();
       
  1059 	User::LeaveIfError( errorCode );
       
  1060 	
       
  1061 	// [ wait for and process the return event from the audio output ]
       
  1062 	
       
  1063 	TMMFEvent primeEvent( KPrimeTestId, KErrNone);
       
  1064 	TVerdict searchResult = SearchForEvent( primeEvent );
       
  1065 	if( searchResult == EFail )
       
  1066 		{
       
  1067 		return searchResult;
       
  1068 		}
       
  1069 
       
  1070 	// [get the duration of the file]
       
  1071 	TTimeIntervalMicroSeconds theDuration;
       
  1072 	TInt durationError = iController.GetDuration(theDuration);
       
  1073 	User::LeaveIfError( durationError );
       
  1074 
       
  1075 	//[ set the position to the end ]
       
  1076 	TInt posError = iController.SetPosition( theDuration );
       
  1077 	User::LeaveIfError( posError );
       
  1078 
       
  1079 	// [get the position ]
       
  1080 	TTimeIntervalMicroSeconds theEndPosition;
       
  1081 	TInt positionError = iController.GetPosition( theEndPosition );
       
  1082 	User::LeaveIfError( positionError );
       
  1083 	  
       
  1084 	// [ set the position beyond the end ]
       
  1085     TInt64 beyondTheEnd = theDuration.Int64();
       
  1086 	beyondTheEnd *= 1000000;
       
  1087 	TTimeIntervalMicroSeconds beyondTheEndPosition( beyondTheEnd);
       
  1088 
       
  1089 	// [get the position ]
       
  1090 	TTimeIntervalMicroSeconds theCurrentPosition;
       
  1091 	TInt currentPositionError = iController.GetPosition( theCurrentPosition );
       
  1092 	User::LeaveIfError( currentPositionError );
       
  1093 
       
  1094 	//[ set the position beyond the end ]
       
  1095 	TInt beyondEndError = iController.SetPosition( beyondTheEndPosition );
       
  1096 
       
  1097 	//[ get the position ]
       
  1098 	TTimeIntervalMicroSeconds theCurrentPosition2;
       
  1099 	currentPositionError = iController.GetPosition( theCurrentPosition2 );
       
  1100 	User::LeaveIfError( currentPositionError );
       
  1101      
       
  1102 	if( (theCurrentPosition2 != theCurrentPosition ) && 
       
  1103 		( beyondEndError == KErrNone ))
       
  1104 		{
       
  1105 		// altered position when wrong position was sent
       
  1106 		// assumes this violation does not corrupt the current position
       
  1107 		return EFail;
       
  1108 		}
       
  1109    
       
  1110 	// [ set the position before the start ]
       
  1111 	currentPositionError = iController.GetPosition( theCurrentPosition );
       
  1112 	User::LeaveIfError( currentPositionError );
       
  1113 
       
  1114 	//[ set the position to a time < 0 ]
       
  1115 	TTimeIntervalMicroSeconds beforeTheStart( -10000 );
       
  1116 	//[ set the position beyond the end ]
       
  1117 	TInt beforeStartError = iController.SetPosition( beforeTheStart );
       
  1118 
       
  1119 	//[ get the position ]
       
  1120 	currentPositionError = iController.GetPosition( theCurrentPosition2 );
       
  1121 	User::LeaveIfError( currentPositionError );
       
  1122 
       
  1123 	// [determine the results of the test]
       
  1124 	if( (theCurrentPosition2 != theCurrentPosition ) && 
       
  1125 		( beforeStartError == KErrNone ))
       
  1126 		{
       
  1127 		// altered position when wrong position was sent
       
  1128 		// assumes this violation does not corrupt the current position
       
  1129 		return EFail;
       
  1130 		}
       
  1131 
       
  1132 	//[ ensure the controller is unloaded so that it does 
       
  1133 	// not interfere with the following test ]
       
  1134 	// There is a bug in this code and the stop followed by reset
       
  1135 	// ensure the controller resources are released.
       
  1136 	iController.Stop();
       
  1137 	iController.Reset();
       
  1138 	iController.Close();  
       
  1139 	
       
  1140 	__MM_HEAP_MARKEND;
       
  1141 	return result;
       
  1142 	}
       
  1143 
       
  1144 /**
       
  1145 *
       
  1146 * CTestStepGetSetNumChannelsOnSource
       
  1147 *
       
  1148 */
       
  1149 CTestStepGetSetNumChannelsOnSource::CTestStepGetSetNumChannelsOnSource()
       
  1150 	{
       
  1151 	iTestStepName = _L("MM-MMF-ACTRL-U-0021-HP");
       
  1152 	}
       
  1153 
       
  1154 /**
       
  1155 *
       
  1156 * ~CTestStepGetSetNumChannelsOnSource
       
  1157 *
       
  1158 */
       
  1159 CTestStepGetSetNumChannelsOnSource::~CTestStepGetSetNumChannelsOnSource()
       
  1160 	{
       
  1161 	}
       
  1162 
       
  1163 /**
       
  1164 *
       
  1165 * DoTestStepL
       
  1166 *
       
  1167 */
       
  1168 TVerdict CTestStepGetSetNumChannelsOnSource::DoTestStepL( void )
       
  1169 	{
       
  1170 	__MM_HEAP_MARK;
       
  1171 	TVerdict result = EPass;
       
  1172 	
       
  1173 	_LIT( KTestSourceNumChannels, "GetSet Num Channels on the Source");
       
  1174 	Log( KTestSourceNumChannels);
       
  1175 	
       
  1176 	_LIT( KTestSinkBitRateReason, "This test checks the set/get num channels on the source");
       
  1177 	Log( KTestSinkBitRateReason );
       
  1178 	
       
  1179 	// [ audio file to play ]
       
  1180 	_LIT(KTestWavFile, "newmail.wav");
       
  1181 	SetReadFileNameL( KTestWavFile );
       
  1182    	
       
  1183 	TInt errorCode = iController.Open(KUidCustomTestAudioPlugin, iPriority);
       
  1184 	User::LeaveIfError( errorCode );
       
  1185 
       
  1186 	// [ attempt to get the source num channels ]
       
  1187     RMMFAudioControllerCustomCommands theCommander( iController );
       
  1188 
       
  1189 	TUint theRate = 0;
       
  1190 	errorCode = theCommander.GetSourceNumChannels(theRate);
       
  1191 	if( errorCode == KErrNone )
       
  1192 		{
       
  1193 		result = EFail;
       
  1194 		return result;
       
  1195 		}
       
  1196 
       
  1197 	//[ ok lets add the source and sink ]
       
  1198     errorCode = iController.AddDataSource(KUidMmfFileSource, ReadFileConfig());
       
  1199 	User::LeaveIfError( errorCode );
       
  1200 
       
  1201 	errorCode =	iController.AddDataSink(KUidMmfAudioOutput, KNullDesC8);
       
  1202     User::LeaveIfError( errorCode );
       
  1203 
       
  1204 	theRate = 0;
       
  1205 	errorCode = theCommander.GetSourceNumChannels(theRate);
       
  1206 	User::LeaveIfError( errorCode );
       
  1207 
       
  1208 	//[ get the format ]
       
  1209 	TUid theFormatUID;
       
  1210 	errorCode = theCommander.GetSourceFormat(theFormatUID);
       
  1211 	User::LeaveIfError( errorCode );
       
  1212 
       
  1213 	//[ ensure we are in are not a raw format because 
       
  1214 	//  this functionality is only supported in raw format]
       
  1215 	if( theFormatUID == KFormatRAWRead )
       
  1216 		{
       
  1217 		result = EFail;
       
  1218 		return result;
       
  1219 		}
       
  1220 	
       
  1221 	// lets set the num of channels to 2
       
  1222 	errorCode = theCommander.SetSourceNumChannels(theRate);
       
  1223 	if( errorCode != KErrNone )
       
  1224 		{
       
  1225 		result = EFail;
       
  1226 		return result ;
       
  1227 		}
       
  1228 
       
  1229 	//[ ensure the controller is unloaded so that it does 
       
  1230 	// not interfere with the following test ]
       
  1231 	// There is a bug in this code and the stop followed by reset
       
  1232 	// ensure the controller resources are released.
       
  1233 	iController.Stop();
       
  1234 	iController.Reset();
       
  1235 	iController.Close();  
       
  1236 	
       
  1237 	__MM_HEAP_MARKEND;
       
  1238 	return EPass;
       
  1239 	}
       
  1240 
       
  1241 /**
       
  1242 *
       
  1243 * CTestStepGetSetNumChannelsOnSink
       
  1244 *
       
  1245 */
       
  1246 CTestStepGetSetNumChannelsOnSink::CTestStepGetSetNumChannelsOnSink()
       
  1247 	{
       
  1248 	iTestStepName = _L("MM-MMF-ACTRL-U-0022-HP");
       
  1249 	}
       
  1250 
       
  1251 /**
       
  1252 *
       
  1253 * ~CTestStepGetSetNumChannelsOnSink
       
  1254 *
       
  1255 */
       
  1256 CTestStepGetSetNumChannelsOnSink::~CTestStepGetSetNumChannelsOnSink()
       
  1257 	{
       
  1258 	}
       
  1259 
       
  1260 /**
       
  1261 *
       
  1262 * DoTestStepL
       
  1263 *
       
  1264 */
       
  1265 TVerdict CTestStepGetSetNumChannelsOnSink::DoTestStepL( void )
       
  1266 	{
       
  1267 	__MM_HEAP_MARK;
       
  1268 	TVerdict result = EPass;
       
  1269 	
       
  1270 	_LIT( KTestSourceNumChannels, "GetSet Num Channels on the Sink");
       
  1271 	Log( KTestSourceNumChannels);
       
  1272 	
       
  1273 	_LIT( KTestSinkBitRateReason, "This test checks the set/get num channels on the sink");
       
  1274 	Log( KTestSinkBitRateReason );
       
  1275 	
       
  1276 	// [ audio file to play ]
       
  1277 	_LIT(KTestWavFile, "newmail.wav");
       
  1278 	SetReadFileNameL( KTestWavFile );
       
  1279 
       
  1280 	TInt errorCode = iController.Open(KUidCustomTestAudioPlugin, iPriority);
       
  1281 	User::LeaveIfError( errorCode );
       
  1282 
       
  1283 	//[ attempt to get the sink num channels ]
       
  1284     RMMFAudioControllerCustomCommands theCommander( iController );
       
  1285 
       
  1286 	TUint theRate = 0;
       
  1287 	errorCode = theCommander.GetSinkNumChannels(theRate);
       
  1288 	if( errorCode == KErrNone )
       
  1289 		{
       
  1290 		result = EFail;
       
  1291 		return result;
       
  1292 		}
       
  1293 
       
  1294 	//[ ok lets add the source and sink ]
       
  1295     errorCode = iController.AddDataSource(KUidMmfFileSource, ReadFileConfig());
       
  1296 	User::LeaveIfError( errorCode );
       
  1297 
       
  1298 	//[ add data source and sink and prime the controller ]
       
  1299     errorCode = iController.AddDataSink(KUidMmfFileSink, ReadFileConfig());
       
  1300 	User::LeaveIfError( errorCode );
       
  1301 
       
  1302 	//[ ok lets try to set the sink format to raw]
       
  1303 	errorCode = theCommander.SetSinkFormat(KFormatRAWWrite);
       
  1304 	User::LeaveIfError( errorCode );
       
  1305 
       
  1306 	//[ ok lets set the number of channels ]
       
  1307 	// lets set the num of channels to 2
       
  1308 	TUint theNumChannels = 2;
       
  1309 	errorCode = theCommander.SetSinkNumChannels(theNumChannels);
       
  1310 	User::LeaveIfError( errorCode );
       
  1311 
       
  1312 	// [ get the number of channels and see if it is the same ]
       
  1313 	TUint theNewNumChannels = 0;
       
  1314 	errorCode = theCommander.GetSinkNumChannels(theNewNumChannels);
       
  1315 	User::LeaveIfError( errorCode );
       
  1316 
       
  1317 	if( theNumChannels != theNewNumChannels )
       
  1318 		{
       
  1319 		result = EFail;
       
  1320 		return result;
       
  1321 		}
       
  1322 
       
  1323 	//[ ensure the controller is unloaded so that it does 
       
  1324 	// not interfere with the following test ]
       
  1325 	// There is a bug in this code and the stop followed by reset
       
  1326 	// ensure the controller resources are released.
       
  1327 	iController.Stop();
       
  1328 	iController.Reset();
       
  1329 	iController.Close();  
       
  1330 	
       
  1331 	__MM_HEAP_MARKEND;
       
  1332 	return result;
       
  1333 	}
       
  1334 
       
  1335 /**
       
  1336 *
       
  1337 * CTestStepGetSetSinkFormat
       
  1338 *
       
  1339 */
       
  1340 CTestStepGetSetSinkFormat::CTestStepGetSetSinkFormat()
       
  1341 	{
       
  1342 	iTestStepName = _L("MM-MMF-ACTRL-U-0023-HP");
       
  1343 	}
       
  1344 
       
  1345 /**
       
  1346 *
       
  1347 * ~CTestStepGetSetSinkFormat
       
  1348 *
       
  1349 */
       
  1350 CTestStepGetSetSinkFormat::~CTestStepGetSetSinkFormat()
       
  1351 	{
       
  1352 	}
       
  1353 
       
  1354 /**
       
  1355 *
       
  1356 * DoTestStepL
       
  1357 *
       
  1358 */
       
  1359 TVerdict CTestStepGetSetSinkFormat::DoTestStepL( void )
       
  1360 	{
       
  1361 	__MM_HEAP_MARK;
       
  1362 	TVerdict result = EPass ;
       
  1363 
       
  1364 	_LIT( KTestSinkFormat, "Test Step Get/Set sink format");
       
  1365 	Log( KTestSinkFormat );
       
  1366 	
       
  1367 	_LIT( KTestStepSinkFormat, "This test checks the set/get sink format");
       
  1368 	Log( KTestStepSinkFormat );
       
  1369 	
       
  1370 	// [ audio file to play ]
       
  1371 	_LIT(KTestWavFileRecord, "TempW.wav");
       
  1372 	SetWriteFileNameL( KTestWavFileRecord );
       
  1373  	
       
  1374 	TInt errorCode = iController.Open(KUidCustomTestAudioPlugin, iPriority);
       
  1375 	User::LeaveIfError( errorCode );
       
  1376 
       
  1377     RMMFAudioControllerCustomCommands theCommander( iController );
       
  1378 
       
  1379 
       
  1380 	//[ add sink format when no sink exists ]
       
  1381 	errorCode = theCommander.SetSinkFormat( KFormatWAVWrite );
       
  1382 	if( errorCode == KErrNone )
       
  1383 	   {
       
  1384 	   result = EFail;
       
  1385 	   return result;
       
  1386 	   }
       
  1387 
       
  1388 	//[ ok lets add the source and sink ]
       
  1389     errorCode = iController.AddDataSource(KUidMmfAudioInput, KNullDesC8);
       
  1390 	User::LeaveIfError( errorCode );
       
  1391 
       
  1392     errorCode = iController.AddDataSink(KUidMmfFileSink, WriteFileConfig());
       
  1393 	User::LeaveIfError( errorCode );
       
  1394 	
       
  1395     errorCode = theCommander.SetSinkFormat( KFormatWAVWrite );
       
  1396     User::LeaveIfError( errorCode );
       
  1397 
       
  1398 	// [ add the format where the uid == the uid of the format ]
       
  1399     errorCode = theCommander.SetSinkFormat( KFormatWAVWrite );
       
  1400     User::LeaveIfError( errorCode );
       
  1401 
       
  1402 	//[ ok lets try to set the sink format to au]
       
  1403     errorCode = theCommander.SetSinkFormat( KFormatAUWrite );
       
  1404     User::LeaveIfError( errorCode );
       
  1405 
       
  1406     errorCode = theCommander.SetSinkFormat( KFormatWAVWrite );
       
  1407     User::LeaveIfError( errorCode );
       
  1408 
       
  1409 	// [ wait for and process the return event from the audio output ]
       
  1410 	errorCode =	iController.Prime();
       
  1411 	User::LeaveIfError( errorCode );
       
  1412 	TMMFEvent primeEvent( KPrimeTestId, KErrNone);
       
  1413 	result = SearchForEvent( primeEvent );
       
  1414 	if( result == EFail )
       
  1415 		{
       
  1416 		return result;
       
  1417 		}
       
  1418 
       
  1419     errorCode = theCommander.SetSinkFormat( KFormatWAVWrite );
       
  1420     if( errorCode == KErrNone )
       
  1421 	   {
       
  1422 	   result = EFail;
       
  1423 	   return result;
       
  1424 	   }
       
  1425 	
       
  1426 	//[ lets do some recording ]
       
  1427 	// note this test does not wait around 
       
  1428 	// to detect that the audio has been played
       
  1429 	// [ now process the confirmation event that play has reached audio output
       
  1430 	//   this is the raison detre of the test ]
       
  1431 	errorCode =	iController.Play();
       
  1432     User::LeaveIfError( errorCode );
       
  1433 	TMMFEvent playEvent( KPlayTestId, KErrNone );
       
  1434 	result = SearchForEvent( playEvent );
       
  1435 	if( result == EFail )
       
  1436 		{
       
  1437 		return result;
       
  1438 		}
       
  1439 
       
  1440 	// [ check that we cannot set the sink format when 
       
  1441 	// no data sink has been added to the controller ]
       
  1442    errorCode = theCommander.SetSinkFormat( KFormatWAVWrite );
       
  1443    if( errorCode == KErrNone )
       
  1444 	   {
       
  1445 	   result = EFail;
       
  1446 	   return result;
       
  1447 	   }
       
  1448 
       
  1449 	// [ lets wait a few seconds for record to write its data ]
       
  1450 	RTimer  myTimer ;
       
  1451 	User::LeaveIfError( myTimer.CreateLocal());
       
  1452 	TRequestStatus timerStatus    ;
       
  1453     const TInt KDelay   = 1000000 ; // arbitrary delay
       
  1454 	myTimer.After( timerStatus, KDelay );
       
  1455 	User::WaitForRequest( timerStatus );
       
  1456 
       
  1457 	//[ ensure the controller is unloaded so that it does 
       
  1458 	// not interfere with the following test ]
       
  1459 	// There is a bug in this code and the stop followed by reset
       
  1460 	// ensure the controller resources are released.
       
  1461 	iController.Stop();
       
  1462 	iController.Reset();
       
  1463 	iController.Close();  
       
  1464 	
       
  1465 	__MM_HEAP_MARKEND;
       
  1466 	return result;
       
  1467 	}
       
  1468 
       
  1469 /**
       
  1470 *
       
  1471 * CTestStepGetSetSourceFormat
       
  1472 *
       
  1473 */
       
  1474 CTestStepGetSetSourceFormat::CTestStepGetSetSourceFormat()
       
  1475 	{
       
  1476 	iTestStepName = _L("MM-MMF-ACTRL-U-0024-HP");
       
  1477 	}
       
  1478 
       
  1479 /**
       
  1480 *
       
  1481 * CTestStepGetSetSourceFormat
       
  1482 *
       
  1483 */
       
  1484 CTestStepGetSetSourceFormat::~CTestStepGetSetSourceFormat()
       
  1485 	{
       
  1486 	}
       
  1487 
       
  1488 /**
       
  1489 *
       
  1490 * DoTestStepL
       
  1491 *
       
  1492 */
       
  1493 TVerdict CTestStepGetSetSourceFormat::DoTestStepL( void )
       
  1494 	{
       
  1495 	__MM_HEAP_MARK;
       
  1496 	TVerdict result = EPass;
       
  1497 	
       
  1498 	_LIT( KTestSourceNumChannels, "Test Step GetSet Source Format");
       
  1499 	Log( KTestSourceNumChannels);
       
  1500 	
       
  1501 	_LIT( KTestSinkBitRateReason, "This test checks the set/get source format");
       
  1502 	Log( KTestSinkBitRateReason );
       
  1503 	
       
  1504 	// [ audio file to play ]
       
  1505 	_LIT(KTestWavFile, "newmail.wav");
       
  1506 	SetReadFileNameL( KTestWavFile );
       
  1507    	
       
  1508 	TInt errorCode = iController.Open(KUidCustomTestAudioPlugin, iPriority);
       
  1509 	User::LeaveIfError( errorCode );
       
  1510 
       
  1511     RMMFAudioControllerCustomCommands theCommander( iController );
       
  1512 
       
  1513 	//[ add source format when no source exists ]
       
  1514 	errorCode = theCommander.SetSourceFormat( KFormatWAVRead );
       
  1515 	if( errorCode == KErrNone )
       
  1516 	   {
       
  1517 	   result = EFail;
       
  1518 	   return result;
       
  1519 	   }
       
  1520 
       
  1521 	//[ ok lets add the source and sink ]
       
  1522     errorCode = iController.AddDataSource(KUidMmfFileSource, ReadFileConfig());
       
  1523 	User::LeaveIfError( errorCode );
       
  1524 
       
  1525 	errorCode =	iController.AddDataSink(KUidMmfAudioOutput, KNullDesC8);
       
  1526     User::LeaveIfError( errorCode );
       
  1527 	
       
  1528 	//errorCode = theCommander.SetSourceFormat( KWavUid );
       
  1529 	errorCode = theCommander.SetSourceFormat( KFormatWAVRead );
       
  1530 	User::LeaveIfError( errorCode );
       
  1531 
       
  1532 	// [ add the format where the uid == the uid of the format ]
       
  1533 	errorCode = theCommander.SetSourceFormat(  KFormatWAVRead );
       
  1534 	User::LeaveIfError( errorCode );
       
  1535 
       
  1536 	//[ ok lets try to set the source format to raw]
       
  1537 	errorCode = theCommander.SetSourceFormat(KFormatRAWRead);
       
  1538 	User::LeaveIfError( errorCode );
       
  1539 
       
  1540 	// [ add the format where the uid == the uid of the format ]
       
  1541 	errorCode = theCommander.SetSourceFormat( KFormatWAVRead );
       
  1542 	User::LeaveIfError( errorCode );
       
  1543 
       
  1544 
       
  1545 	// [ wait for and process the return event from the audio output ]
       
  1546 	errorCode =	iController.Prime();
       
  1547 	User::LeaveIfError( errorCode );
       
  1548 	TMMFEvent primeEvent( KPrimeTestId, KErrNone);
       
  1549 	result = SearchForEvent( primeEvent );
       
  1550 	if( result == EFail )
       
  1551 		{
       
  1552 		return result;
       
  1553 		}
       
  1554 
       
  1555 	// [ check that we cannot set the sink format when 
       
  1556 	// no data sink has been added to the controller ]
       
  1557    errorCode = theCommander.SetSourceFormat( KFormatWAVRead );
       
  1558    if( errorCode == KErrNone )
       
  1559 	   {
       
  1560 	   result = EFail;
       
  1561 	   return result;
       
  1562 	   }
       
  1563 	
       
  1564 	// [ lets do some recording ]
       
  1565 	// note this test does not wait around 
       
  1566 	// to detect that the audio has been played
       
  1567 	// [ now process the confirmation event that play has reached audio output
       
  1568 	// this is the raison detre of the test ]
       
  1569 	errorCode =	iController.Play();
       
  1570     User::LeaveIfError( errorCode );
       
  1571 	TMMFEvent playEvent( KPlayTestId, KErrNone );
       
  1572 	result = SearchForEvent( playEvent );
       
  1573 	if( result == EFail )
       
  1574 		{
       
  1575 		return result;
       
  1576 		}
       
  1577 
       
  1578 
       
  1579 	// [ check that we cannot set the sink format when 
       
  1580 	// no data sink has been added to the controller ]
       
  1581    errorCode = theCommander.SetSourceFormat( KFormatWAVRead );
       
  1582    if( errorCode == KErrNone )
       
  1583 	   {
       
  1584 	   result = EFail;
       
  1585 	   return result;
       
  1586 	   }
       
  1587 
       
  1588 	// [ lets wait a few seconds for record to write its data ]
       
  1589 	RTimer  myTimer ;
       
  1590 	User::LeaveIfError( myTimer.CreateLocal());
       
  1591 	TRequestStatus timerStatus    ;
       
  1592     const TInt KDelay   = 1000000 ; // arbitrary delay
       
  1593 	myTimer.After( timerStatus, KDelay );
       
  1594 	User::WaitForRequest( timerStatus );
       
  1595 
       
  1596 	//[ ensure the controller is unloaded so that it does 
       
  1597 	// not interfere with the following test ]
       
  1598 	// There is a bug in this code and the stop followed by reset
       
  1599 	// ensure the controller resources are released.
       
  1600 	iController.Stop();
       
  1601 	iController.Reset();
       
  1602 	iController.Close();  
       
  1603 	
       
  1604 	__MM_HEAP_MARKEND;
       
  1605 	return result;
       
  1606 	}
       
  1607 
       
  1608 /**
       
  1609 *
       
  1610 * CTestStepGetSetSourceSampleRate
       
  1611 *
       
  1612 */
       
  1613 CTestStepGetSetSourceSampleRate::CTestStepGetSetSourceSampleRate()
       
  1614 	{
       
  1615 	iTestStepName = _L("MM-MMF-ACTRL-U-0025-HP");
       
  1616 	}
       
  1617 
       
  1618 /**
       
  1619 *
       
  1620 * ~CTestStepGetSetSourceSampleRate
       
  1621 *
       
  1622 */
       
  1623 CTestStepGetSetSourceSampleRate::~CTestStepGetSetSourceSampleRate()
       
  1624 	{
       
  1625 	}
       
  1626 
       
  1627 /**
       
  1628 *
       
  1629 * CTestStepGetSetSourceSampleRate
       
  1630 *
       
  1631 */
       
  1632 TVerdict  CTestStepGetSetSourceSampleRate::DoTestStepL( void )
       
  1633 	{
       
  1634 	__MM_HEAP_MARK;
       
  1635 	TVerdict result = EPass;
       
  1636 	
       
  1637 	_LIT( KTestSourceNumChannels, "GetSet Source Sample Rate");
       
  1638 	Log( KTestSourceNumChannels);
       
  1639 	
       
  1640 	_LIT( KTestSinkBitRateReason, "This test checks the set/get source sample rate");
       
  1641 	Log( KTestSinkBitRateReason );
       
  1642 	
       
  1643 	// [ audio file to play ]
       
  1644 	_LIT(KTestWavFile, "newmail.wav");
       
  1645 	SetReadFileNameL( KTestWavFile );
       
  1646    	
       
  1647 	TInt errorCode = iController.Open(KUidCustomTestAudioPlugin, iPriority);
       
  1648 	User::LeaveIfError( errorCode );
       
  1649 
       
  1650 	//[ attempt to get the sink num channels ]
       
  1651     RMMFAudioControllerCustomCommands theCommander( iController );
       
  1652 
       
  1653 	RArray<TUint> supportedRates;
       
  1654 	CleanupClosePushL(supportedRates);
       
  1655 	TRAPD(errorCode2, theCommander.GetSupportedSourceSampleRatesL(supportedRates));
       
  1656 	if ((errorCode2 == KErrNone ) || supportedRates.Count())
       
  1657 		{
       
  1658 		// should have failed with either an error code or non zero supported rates
       
  1659 		result = EFail;
       
  1660 		return result;
       
  1661 		}
       
  1662 
       
  1663 	TUint theRate = 0;
       
  1664 	errorCode = theCommander.GetSourceSampleRate(theRate);
       
  1665 	if( errorCode == KErrNone )
       
  1666 		{
       
  1667 		result = EFail;
       
  1668 		return result;
       
  1669 		}
       
  1670 
       
  1671 	//[ ok lets add the source and sink ]
       
  1672     errorCode = iController.AddDataSource(KUidMmfFileSource, ReadFileConfig());
       
  1673 	User::LeaveIfError( errorCode );
       
  1674 
       
  1675 	errorCode =	iController.AddDataSink(KUidMmfAudioOutput, KNullDesC8);
       
  1676     User::LeaveIfError( errorCode );
       
  1677 
       
  1678 	// Store the original sample rate
       
  1679 	TUint origRate = 0;
       
  1680 	errorCode = theCommander.GetSourceSampleRate(origRate);
       
  1681 	if (errorCode != KErrNone)
       
  1682 		{
       
  1683 		INFO_PRINTF2(_L("Error getting original source sample rate %d"), errorCode);
       
  1684 		return EFail;
       
  1685 		}
       
  1686 
       
  1687 	// Ensure the array is empty
       
  1688 	supportedRates.Reset();
       
  1689 	TRAPD( errorCode3,theCommander.GetSupportedSourceSampleRatesL(supportedRates));
       
  1690 	User::LeaveIfError( errorCode3 );
       
  1691 
       
  1692 	TUint theNewRate = 0;
       
  1693 
       
  1694 	for (TInt index = 0; index < supportedRates.Count(); index++)
       
  1695 		{
       
  1696 		theRate = supportedRates[index];
       
  1697 		// SetSourceSampleRate
       
  1698 		errorCode = theCommander.SetSourceSampleRate(theRate);
       
  1699 		if (theRate == origRate)
       
  1700 			{
       
  1701 			if (errorCode != KErrNone)
       
  1702 				{
       
  1703 				INFO_PRINTF2(_L("SetSourceSampleRate returned unexpected error %d"), errorCode);
       
  1704 				result = EFail;
       
  1705 				break;
       
  1706 				}
       
  1707 			}
       
  1708 		else
       
  1709 			{
       
  1710 			// Setting source sample rate to a different value 
       
  1711 			// is tolerated (INC038043) to preserve BC with 6.1
       
  1712 			if (errorCode != KErrNone)
       
  1713 				{
       
  1714 				INFO_PRINTF3(_L("SetSourceDataType returned %d, expecting %d"), errorCode, KErrAlreadyExists);
       
  1715 				result = EFail;
       
  1716 				break;
       
  1717 				}
       
  1718 			}
       
  1719 		// GetSourceSampleRate
       
  1720 		errorCode = theCommander.GetSourceSampleRate(theNewRate);
       
  1721 		if (theNewRate != origRate)
       
  1722 			{
       
  1723 			INFO_PRINTF3(_L("GetSourceSampleRate rate %d did not match expected %d"), theNewRate, origRate);
       
  1724 			result = EFail;
       
  1725 			break;
       
  1726 			}
       
  1727 
       
  1728 		if (errorCode != KErrNone)
       
  1729 			{
       
  1730 			INFO_PRINTF3(_L("GetSourceSampleRate returned unexpected error %d, expected %d"), errorCode, KErrNone);
       
  1731 			result = EFail;
       
  1732 			break;
       
  1733 			}
       
  1734 		}
       
  1735 
       
  1736 	CleanupStack::PopAndDestroy(1);		// supportedRates
       
  1737 	
       
  1738 	//[ ensure the controller is unloaded so that it does 
       
  1739 	// not interfere with the following test ]
       
  1740 	// There is a bug in this code and the stop followed by reset
       
  1741 	// ensure the controller resources are released.
       
  1742 	iController.Stop();
       
  1743 	iController.Reset();
       
  1744 	iController.Close();  
       
  1745 	
       
  1746 	__MM_HEAP_MARKEND;
       
  1747 	return result ;	
       
  1748 	}
       
  1749 
       
  1750 /**
       
  1751 *
       
  1752 * CTestStepGetSetSinkSampleRate
       
  1753 *
       
  1754 */
       
  1755 CTestStepGetSetSinkSampleRate::CTestStepGetSetSinkSampleRate()
       
  1756 	{
       
  1757 	iTestStepName = _L("MM-MMF-ACTRL-U-0026-HP");
       
  1758 	}
       
  1759 
       
  1760 /**
       
  1761 *
       
  1762 * ~CTestStepGetSetSinkSampleRate
       
  1763 *
       
  1764 */
       
  1765 CTestStepGetSetSinkSampleRate::~CTestStepGetSetSinkSampleRate()
       
  1766 	{
       
  1767 	}
       
  1768 
       
  1769 /**
       
  1770 *
       
  1771 * DoTestStepL
       
  1772 *
       
  1773 */
       
  1774 TVerdict  CTestStepGetSetSinkSampleRate::DoTestStepL( void )
       
  1775 	{
       
  1776 	__MM_HEAP_MARK;
       
  1777 	TVerdict result = EPass;
       
  1778 	
       
  1779 	_LIT( KTestSourceNumChannels, "GetSet Sink Sample Rate");
       
  1780 	Log( KTestSourceNumChannels);
       
  1781 	
       
  1782 	_LIT( KTestSinkBitRateReason, "This test checks the set/get sink sample rate");
       
  1783 	Log( KTestSinkBitRateReason );
       
  1784 	
       
  1785 	// [ audio file to play ]
       
  1786 	_LIT(KTestWavFile, "newmail.wav");
       
  1787 	SetReadFileNameL( KTestWavFile );
       
  1788    	
       
  1789 	TInt errorCode = iController.Open(KUidCustomTestAudioPlugin, iPriority);
       
  1790 	User::LeaveIfError( errorCode );
       
  1791 
       
  1792 	//[ attempt to get the sink num channels ]
       
  1793     RMMFAudioControllerCustomCommands theCommander( iController );
       
  1794 	
       
  1795 	TUint theRate = 0;
       
  1796 	errorCode = theCommander.GetSinkSampleRate(theRate);
       
  1797 	if( errorCode == KErrNone )
       
  1798 		{
       
  1799 		result = EFail;
       
  1800 		}
       
  1801 
       
  1802 	//[ ok lets add the source and sink ]
       
  1803     if(result==EPass)
       
  1804     	{
       
  1805     	errorCode = iController.AddDataSource(KUidMmfFileSource, ReadFileConfig());
       
  1806     	if(errorCode!=KErrNone)
       
  1807     		{
       
  1808     		result=EFail;
       
  1809     		}
       
  1810     	}
       
  1811     
       
  1812     if(result==EPass)
       
  1813     	{
       
  1814 		errorCode =	iController.AddDataSink(KUidMmfAudioOutput, KNullDesC8);
       
  1815     	if(errorCode!=KErrNone)
       
  1816     		{
       
  1817     		result=EFail;
       
  1818     		}
       
  1819     	}
       
  1820 	
       
  1821 	if(result==EPass)
       
  1822 		{
       
  1823 		theRate = 0;
       
  1824 		errorCode = theCommander.GetSinkSampleRate(theRate);
       
  1825 	    if(errorCode!=KErrNotSupported)
       
  1826 	    	{
       
  1827 	    	INFO_PRINTF2(_L("GetSinkSampleRate returned %d when KErrNotSupported is expected"), errorCode);
       
  1828 	    	result = EFail;
       
  1829 	    	}
       
  1830 		}
       
  1831 	
       
  1832 	if(result==EPass)
       
  1833 		{
       
  1834 		//[ set the sample rate ]
       
  1835 		errorCode = theCommander.SetSinkSampleRate(theRate);
       
  1836 		if(errorCode!=KErrNotSupported)
       
  1837 	    	{
       
  1838 	    	INFO_PRINTF2(_L("SetSinkSampleRate returned %d when KErrNotSupported is expected"), errorCode);
       
  1839 	    	result = EFail;
       
  1840 	    	}
       
  1841 		}
       
  1842 	
       
  1843 	if(result==EPass)
       
  1844 		{
       
  1845 		TUint theSampleRate( 8000); // set sample rate to 8khz arbitrary value
       
  1846 		//[ set the sample rate ]
       
  1847 		theRate = theSampleRate; // known reasonable value
       
  1848 		errorCode = theCommander.SetSinkSampleRate(theRate);
       
  1849 		if(errorCode!=KErrNotSupported)
       
  1850 	    	{
       
  1851 	    	INFO_PRINTF2(_L("SetSinkSampleRate returned %d when KErrNotSupported is expected"), errorCode);
       
  1852 	    	result = EFail;
       
  1853 	    	}
       
  1854 		}
       
  1855 	
       
  1856 	if(result==EPass)
       
  1857 		{
       
  1858 		theRate = 0;
       
  1859 		errorCode = theCommander.GetSinkSampleRate(theRate);
       
  1860 	    if(errorCode!=KErrNotSupported)
       
  1861 	    	{
       
  1862 	    	INFO_PRINTF2(_L("GetSinkSampleRate returned %d when KErrNotSupported is expected"), errorCode);
       
  1863 	    	result = EFail;
       
  1864 	    	}
       
  1865 		}
       
  1866     
       
  1867 	//[ ensure the controller is unloaded so that it does 
       
  1868 	// not interfere with the following test ]
       
  1869 	// There is a bug in this code and the stop followed by reset
       
  1870 	// ensure the controller resources are released.
       
  1871 	iController.Stop();
       
  1872 	iController.Reset();
       
  1873 	iController.Close();  
       
  1874 	
       
  1875 	__MM_HEAP_MARKEND;
       
  1876 	return result;
       
  1877 	}
       
  1878 
       
  1879 /**
       
  1880 *
       
  1881 * CTestStepGetSetSourceBitRate
       
  1882 *
       
  1883 */
       
  1884 CTestStepGetSetSourceBitRate::CTestStepGetSetSourceBitRate()
       
  1885 	{
       
  1886 	iTestStepName = _L("MM-MMF-ACTRL-U-0027-HP");
       
  1887 	}
       
  1888 
       
  1889 /**
       
  1890 *
       
  1891 * ~CTestStepGetSetSourceBitRate
       
  1892 *
       
  1893 */
       
  1894 CTestStepGetSetSourceBitRate::~CTestStepGetSetSourceBitRate()
       
  1895 	{
       
  1896 	}
       
  1897 
       
  1898 /**
       
  1899 *
       
  1900 * DoTestStepL
       
  1901 *
       
  1902 */
       
  1903 TVerdict CTestStepGetSetSourceBitRate::DoTestStepL( void )
       
  1904 	{
       
  1905 	__MM_HEAP_MARK;
       
  1906 	TVerdict result = EPass;
       
  1907 	
       
  1908 	_LIT( KTestSourceNumChannels, "GetSet Source Bit Rate");
       
  1909 	Log( KTestSourceNumChannels);
       
  1910 	
       
  1911 	_LIT( KTestSinkBitRateReason, "This test checks the set/get source bit rate");
       
  1912 	Log( KTestSinkBitRateReason );
       
  1913 	
       
  1914 	// [ audio file to play ]
       
  1915 	_LIT(KTestWavFile, "newmail.wav");
       
  1916 	SetReadFileNameL( KTestWavFile );
       
  1917    	
       
  1918 	TInt errorCode = iController.Open(KUidCustomTestAudioPlugin, iPriority);
       
  1919 	User::LeaveIfError( errorCode );
       
  1920 
       
  1921 	//[ attempt to get the sink num channels ]
       
  1922     RMMFAudioControllerCustomCommands theCommander( iController );
       
  1923 
       
  1924 	TUint theRate = 0;
       
  1925 	errorCode = theCommander.GetSourceBitRate(theRate);
       
  1926 	if( errorCode == KErrNone )
       
  1927 		{
       
  1928 		result = EFail;
       
  1929 		return result;
       
  1930 		}
       
  1931 
       
  1932 	//[ ok lets add the source and sink ]
       
  1933     errorCode = iController.AddDataSource(KUidMmfFileSource, ReadFileConfig());
       
  1934 	User::LeaveIfError( errorCode );
       
  1935 
       
  1936 	errorCode =	iController.AddDataSink(KUidMmfAudioOutput, KNullDesC8);
       
  1937     User::LeaveIfError( errorCode );
       
  1938 
       
  1939 	theRate = 0;
       
  1940 	errorCode = theCommander.GetSourceBitRate(theRate);
       
  1941     User::LeaveIfError( errorCode );
       
  1942 
       
  1943 	// check to see if the bitrate is greater than zero
       
  1944 	// (it should exactly be samplerate*bitspersample)
       
  1945 	if (theRate == 0)
       
  1946 		{
       
  1947 		result = EFail;
       
  1948 		return result;
       
  1949 		}
       
  1950 
       
  1951 	//[ this is currently not supported ]
       
  1952 	errorCode = theCommander.SetSourceBitRate(theRate);
       
  1953 	if( errorCode == KErrNone )
       
  1954 	{
       
  1955 	result = EFail;
       
  1956 	return result;
       
  1957 	}
       
  1958 
       
  1959 	//[ ensure the controller is unloaded so that it does 
       
  1960 	// not interfere with the following test ]
       
  1961 	// There is a bug in this code and the stop followed by reset
       
  1962 	// ensure the controller resources are released.
       
  1963 	iController.Stop();
       
  1964 	iController.Reset();
       
  1965 	iController.Close();  
       
  1966 	
       
  1967 	__MM_HEAP_MARKEND;
       
  1968 	return result;
       
  1969 	}
       
  1970 
       
  1971 /**
       
  1972 *
       
  1973 * CTestStepGetSetSourceDataType
       
  1974 *
       
  1975 */
       
  1976 CTestStepGetSetSourceDataType::CTestStepGetSetSourceDataType()
       
  1977 	{
       
  1978 	iTestStepName = _L("MM-MMF-ACTRL-U-0028-HP");
       
  1979 	}
       
  1980 
       
  1981 /**
       
  1982 *
       
  1983 * ~CTestStepGetSetSourceDataType
       
  1984 *
       
  1985 */
       
  1986 CTestStepGetSetSourceDataType::~CTestStepGetSetSourceDataType()
       
  1987 	{
       
  1988 	}
       
  1989 
       
  1990 /**
       
  1991 *
       
  1992 * DoTestStepL
       
  1993 *
       
  1994 */
       
  1995 TVerdict  CTestStepGetSetSourceDataType::DoTestStepL( void )
       
  1996 	{
       
  1997 	__MM_HEAP_MARK;
       
  1998 	TVerdict result = EPass;
       
  1999 	
       
  2000 	_LIT( KTestSourceNumChannels, "GetSet Source Data type");
       
  2001 	Log( KTestSourceNumChannels);
       
  2002 	
       
  2003 	_LIT( KTestSinkBitRateReason, "This test checks the set/get source data type");
       
  2004 	Log( KTestSinkBitRateReason );
       
  2005 	
       
  2006 	// [ audio file to play ]
       
  2007 	_LIT(KTestWavFile, "newmail.wav");
       
  2008 	SetReadFileNameL( KTestWavFile );
       
  2009    	
       
  2010 	TInt errorCode = iController.Open(KUidCustomTestAudioPlugin, iPriority);
       
  2011 	User::LeaveIfError( errorCode );
       
  2012 
       
  2013 	//[ attempt to get the sink num channels ]
       
  2014     RMMFAudioControllerCustomCommands theCommander( iController );
       
  2015 
       
  2016 	TFourCC theFCC;
       
  2017 	errorCode = theCommander.GetSourceDataType( theFCC );
       
  2018 	if( errorCode == KErrNone )
       
  2019 		{
       
  2020 		result = EFail;
       
  2021 		return result;
       
  2022 		}
       
  2023 
       
  2024 	//[ ok lets add the source and sink ]
       
  2025     errorCode = iController.AddDataSource(KUidMmfFileSource, ReadFileConfig());
       
  2026 	User::LeaveIfError( errorCode );
       
  2027 
       
  2028 	errorCode =	iController.AddDataSink(KUidMmfAudioOutput, KNullDesC8);
       
  2029     User::LeaveIfError( errorCode );
       
  2030 
       
  2031 	errorCode = theCommander.GetSourceDataType( theFCC );
       
  2032 	User::LeaveIfError( errorCode );
       
  2033 
       
  2034 	TFourCC theNewFCC;
       
  2035 	errorCode = theCommander.SetSourceDataType( theFCC );
       
  2036 	User::LeaveIfError( errorCode );
       
  2037 
       
  2038 	errorCode = theCommander.GetSourceDataType( theNewFCC );
       
  2039 	User::LeaveIfError( errorCode );
       
  2040 
       
  2041 	if( theNewFCC != theFCC )
       
  2042 		{
       
  2043 		result = EFail;
       
  2044 		}
       
  2045 
       
  2046 	//[ ensure the controller is unloaded so that it does 
       
  2047 	// not interfere with the following test ]
       
  2048 	// There is a bug in this code and the stop followed by reset
       
  2049 	// ensure the controller resources are released.
       
  2050 	iController.Stop();
       
  2051 	iController.Reset();
       
  2052 	iController.Close();  
       
  2053 	
       
  2054 	__MM_HEAP_MARKEND;
       
  2055 	return result;
       
  2056 	}
       
  2057 
       
  2058 /**
       
  2059 *
       
  2060 * CTestStepGetSetSinkDataType
       
  2061 *
       
  2062 */
       
  2063 CTestStepGetSetSinkDataType::CTestStepGetSetSinkDataType()
       
  2064 	{
       
  2065 	iTestStepName = _L("MM-MMF-ACTRL-U-0029-HP");
       
  2066 	}
       
  2067 
       
  2068 /**
       
  2069 *
       
  2070 * ~CTestStepGetSetSinkDataType
       
  2071 *
       
  2072 */
       
  2073 CTestStepGetSetSinkDataType::~CTestStepGetSetSinkDataType()
       
  2074 	{
       
  2075 	}
       
  2076 
       
  2077 /**
       
  2078 *
       
  2079 * DoTestStepL
       
  2080 *
       
  2081 */
       
  2082 TVerdict CTestStepGetSetSinkDataType::DoTestStepL( void )
       
  2083 	{
       
  2084 	__MM_HEAP_MARK;
       
  2085 	TVerdict result = EPass;
       
  2086 	
       
  2087 	_LIT( KTestSourceNumChannels, "GetSet Sink Data type");
       
  2088 	Log( KTestSourceNumChannels);
       
  2089 	
       
  2090 	_LIT( KTestSinkBitRateReason, "This test checks the set/get sink data type");
       
  2091 	Log( KTestSinkBitRateReason );
       
  2092 	
       
  2093 	// [ audio file to play ]
       
  2094 	_LIT(KTestWavFile, "newmail.wav");
       
  2095 	SetReadFileNameL( KTestWavFile );
       
  2096    	
       
  2097 	TInt errorCode = iController.Open(KUidCustomTestAudioPlugin, iPriority);
       
  2098 	User::LeaveIfError( errorCode );
       
  2099 
       
  2100 	//[ attempt to get the sink num channels ]
       
  2101     RMMFAudioControllerCustomCommands theCommander( iController );
       
  2102 	
       
  2103 	TFourCC theFCC;
       
  2104 	errorCode = theCommander.GetSinkDataType( theFCC );
       
  2105 	if( errorCode == KErrNone )
       
  2106 		{
       
  2107 		result = EFail;
       
  2108 		}
       
  2109 
       
  2110 	//[ ok lets add the source and sink ]
       
  2111     if(result==EPass)
       
  2112     	{
       
  2113     	errorCode = iController.AddDataSource(KUidMmfFileSource, ReadFileConfig());
       
  2114     	if(errorCode!=KErrNone)
       
  2115     		{
       
  2116     		result=EFail;
       
  2117     		}
       
  2118     	}
       
  2119     
       
  2120     if(result==EPass)
       
  2121     	{
       
  2122 		errorCode =	iController.AddDataSink(KUidMmfAudioOutput, KNullDesC8);
       
  2123     	if(errorCode!=KErrNone)
       
  2124     		{
       
  2125     		result=EFail;
       
  2126     		}
       
  2127     	}
       
  2128     	
       
  2129 	if(result==EPass)
       
  2130 		{
       
  2131 		errorCode = theCommander.GetSinkDataType( theFCC );
       
  2132 		if(errorCode!=KErrNotSupported)
       
  2133 	    	{
       
  2134 	    	INFO_PRINTF2(_L("GetSinkDataType returned %d when KErrNotSupported is expected"), errorCode);
       
  2135 	    	result = EFail;
       
  2136 	    	}
       
  2137 		}
       
  2138 	
       
  2139 	if(result==EPass)
       
  2140 		{
       
  2141 		errorCode = theCommander.SetSinkDataType( theFCC );
       
  2142 		if(errorCode!=KErrNotSupported)
       
  2143 	    	{
       
  2144 	    	INFO_PRINTF2(_L("SetSinkDataType returned %d when KErrNotSupported is expected"), errorCode);
       
  2145 	    	result = EFail;
       
  2146 	    	}
       
  2147 		}
       
  2148 	
       
  2149 	if(result==EPass)
       
  2150 		{
       
  2151 		TFourCC theNewFCC;
       
  2152 		errorCode = theCommander.GetSinkDataType( theNewFCC );
       
  2153 		if(errorCode!=KErrNotSupported)
       
  2154 	    	{
       
  2155 	    	INFO_PRINTF2(_L("GetSinkDataType returned %d when KErrNotSupported is expected"), errorCode);
       
  2156 	    	result = EFail;
       
  2157 	    	}
       
  2158 		}
       
  2159 
       
  2160 	//[ ensure the controller is unloaded so that it does 
       
  2161 	// not interfere with the following test ]
       
  2162 	// There is a bug in this code and the stop followed by reset
       
  2163 	// ensure the controller resources are released.
       
  2164 	iController.Stop();
       
  2165 	iController.Reset();
       
  2166 	iController.Close();  
       
  2167 	
       
  2168 	__MM_HEAP_MARKEND;
       
  2169 	return result;
       
  2170 	}
       
  2171 
       
  2172 /**
       
  2173 *
       
  2174 * CTestStepGetSetSinkBitRate
       
  2175 *
       
  2176 */
       
  2177 
       
  2178 CTestStepGetSetSinkBitRate::CTestStepGetSetSinkBitRate()
       
  2179 	{
       
  2180 	iTestStepName = _L("MM-MMF-ACTRL-U-0030-HP");
       
  2181 	}
       
  2182 
       
  2183 /**
       
  2184 *
       
  2185 * ~CTestStepGetSetSinkDataType
       
  2186 *
       
  2187 */
       
  2188 
       
  2189 CTestStepGetSetSinkBitRate::~CTestStepGetSetSinkBitRate()
       
  2190 	{
       
  2191 	}
       
  2192 
       
  2193 /**
       
  2194 *
       
  2195 * DoTestStepL
       
  2196 *
       
  2197 */
       
  2198 
       
  2199 TVerdict CTestStepGetSetSinkBitRate::DoTestStepL( void )
       
  2200 	{
       
  2201 	__MM_HEAP_MARK;
       
  2202 	TVerdict result = EPass;
       
  2203 	
       
  2204 	_LIT( KTestSourceNumChannels, "GetSetSinkBitRate");
       
  2205 	Log( KTestSourceNumChannels);
       
  2206 	
       
  2207 	_LIT( KTestSinkBitRateReason, "This test checks setting and getting a sinks bit rate");
       
  2208 	Log( KTestSinkBitRateReason );
       
  2209 	
       
  2210 	// [ audio file to play ]
       
  2211 	_LIT(KTestWavFile, "newmail.wav");
       
  2212 	SetReadFileNameL( KTestWavFile );
       
  2213    	
       
  2214 	TInt errorCode = iController.Open(KUidCustomTestAudioPlugin, iPriority);
       
  2215 	User::LeaveIfError( errorCode );
       
  2216 
       
  2217 	// [ attempt to get the bit rate with out a sink]
       
  2218     RMMFAudioControllerCustomCommands theCommander( iController );
       
  2219 
       
  2220 	TUint theRate = 0;
       
  2221 	errorCode = theCommander.GetSinkBitRate(theRate);
       
  2222 	if( errorCode == KErrNone )
       
  2223 		{
       
  2224 		result = EFail;
       
  2225 		return result;
       
  2226 		}
       
  2227 
       
  2228 	//[ add data source and sink and prime the controller ]
       
  2229     errorCode = iController.AddDataSource(KUidMmfFileSource, ReadFileConfig());
       
  2230 	User::LeaveIfError( errorCode );
       
  2231 	
       
  2232 	errorCode =	iController.AddDataSink(KUidMmfAudioOutput, KNullDesC8);
       
  2233     User::LeaveIfError( errorCode );
       
  2234 
       
  2235 	errorCode = theCommander.GetSinkBitRate(theRate);
       
  2236 	if( errorCode == KErrNone )
       
  2237 		{
       
  2238 		result = EFail;
       
  2239 		return result;
       
  2240 		}
       
  2241 	
       
  2242 	errorCode =	iController.Prime();
       
  2243 	User::LeaveIfError( errorCode );
       
  2244 
       
  2245 	// [ wait for and process the return event from the audio output ]
       
  2246 	
       
  2247 	TMMFEvent primeEvent( KPrimeTestId, KErrNone);
       
  2248 	result = SearchForEvent( primeEvent );
       
  2249 	if( result == EFail )
       
  2250 		{
       
  2251 		return result;
       
  2252 		}
       
  2253 
       
  2254 	//[ check when we are primed ]
       
  2255 	errorCode = theCommander.GetSinkBitRate(theRate);
       
  2256 	if( errorCode == KErrNone )
       
  2257 		{
       
  2258 		result = EFail;
       
  2259 		return result;
       
  2260 		}
       
  2261    
       
  2262 	// [ lets reset and add a data sink and source that will
       
  2263 	//   exercise the happy day scenario ]
       
  2264 	errorCode =	iController.Reset();
       
  2265 	User::LeaveIfError( errorCode );
       
  2266 
       
  2267 	// [ check when recording ]
       
  2268 	_LIT(KTestWavFileRecord, "16bitmpcm.wav");
       
  2269 	
       
  2270    	SetReadFileNameL( KTestWavFileRecord );
       
  2271    	// check if record file already exists
       
  2272    	TEntry fileEntry;
       
  2273    	TInt fileErr = iFs.Entry(ReadFileConfig()().iPath, fileEntry);
       
  2274    	if (fileErr != KErrNotFound)
       
  2275    		{
       
  2276    		User::LeaveIfError(fileErr);
       
  2277    		}
       
  2278 
       
  2279 	//[ add data source and sink and prime the controller ]
       
  2280     errorCode = iController.AddDataSource(KUidMmfAudioInput, KNullDesC8);
       
  2281 	User::LeaveIfError( errorCode );
       
  2282 	
       
  2283 	//[ add data source and sink and prime the controller ]
       
  2284     errorCode = iController.AddDataSink(KUidMmfFileSink, ReadFileConfig());
       
  2285 	User::LeaveIfError( errorCode );
       
  2286 	
       
  2287 	//[lets get the sink bit rate]
       
  2288 	errorCode = theCommander.GetSinkBitRate(theRate);
       
  2289 	User::LeaveIfError( errorCode );
       
  2290 
       
  2291 	// check to see if the bitrate is greater than zero
       
  2292 	// (it should exactly be samplerate*bitspersample)
       
  2293 	// fail if the bitrate returned is zero and the record file exists
       
  2294 	if ((theRate == 0) && (fileErr != KErrNotFound))
       
  2295 		{
       
  2296 		result = EFail;
       
  2297 		return result;
       
  2298 		}
       
  2299 
       
  2300 	const TUint KArbitraryBitRate = 1000; // 1 Khz
       
  2301 	//[lets get the sink bit rate]
       
  2302 	errorCode = theCommander.SetSinkBitRate( KArbitraryBitRate );
       
  2303 	if( errorCode == KErrNone )
       
  2304 		{
       
  2305 		result = EFail;
       
  2306 		return result;
       
  2307 		}
       
  2308 
       
  2309 	errorCode =	iController.Prime();
       
  2310 	User::LeaveIfError( errorCode );
       
  2311 
       
  2312 	// [ wait for and process the return event from the audio output ]
       
  2313 	result = SearchForEvent( primeEvent );
       
  2314 	if( result == EFail )
       
  2315 		{
       
  2316 		return result;
       
  2317 		}
       
  2318 
       
  2319     //[ get the bit rate while playing ]
       
  2320 	User::LeaveIfError( iController.Play() );
       
  2321 	TMMFEvent playEvent( KPlayTestId, KErrNone );
       
  2322 
       
  2323     result = SearchForEvent( playEvent );
       
  2324 	if( result == EFail )
       
  2325 		{
       
  2326 		return result;
       
  2327 		}
       
  2328 
       
  2329 	//[lets get the sink bit rate]
       
  2330 	errorCode = theCommander.GetSinkBitRate(theRate);
       
  2331 	User::LeaveIfError( errorCode );
       
  2332 
       
  2333 	// check to see if the bitrate is greater than zero
       
  2334 	// (it should exactly be samplerate*bitspersample)
       
  2335 	if (theRate == 0)
       
  2336 		{
       
  2337 		result = EFail;
       
  2338 		return result;
       
  2339 		}
       
  2340 
       
  2341     //[lets get the sink bit rate]
       
  2342 	errorCode = theCommander.SetSinkBitRate(1000);
       
  2343 	if( errorCode == KErrNone )
       
  2344 		{
       
  2345 		result = EFail;
       
  2346 		return result;
       
  2347 		}
       
  2348 
       
  2349 	//[ ensure the controller is unloaded so that it does 
       
  2350 	// not interfere with the following test ]
       
  2351 	// There is a bug in this code and the stop followed by reset
       
  2352 	// ensure the controller resources are released.
       
  2353 	iController.Stop();
       
  2354 	iController.Reset();
       
  2355 	iController.Close();  
       
  2356 	
       
  2357 	__MM_HEAP_MARKEND;
       
  2358 	   
       
  2359 	// test steps return a result
       
  2360 	return result;
       
  2361 	}
       
  2362 
       
  2363 /**
       
  2364 *
       
  2365 * CTestStepGetSetMetaData
       
  2366 */
       
  2367 CTestStepGetSetMetaData::CTestStepGetSetMetaData()
       
  2368 	{
       
  2369 	iTestStepName = _L("MM-MMF-ACTRL-U-0031-HP");
       
  2370 	}
       
  2371 
       
  2372 /**
       
  2373 *
       
  2374 * ~CTestStepGetSetMetaData
       
  2375 */
       
  2376 CTestStepGetSetMetaData::~CTestStepGetSetMetaData()
       
  2377 	{
       
  2378 	}
       
  2379 
       
  2380 /**
       
  2381 *
       
  2382 * DoTestStepL
       
  2383 */
       
  2384 TVerdict CTestStepGetSetMetaData::DoTestStepL( void )
       
  2385 	{
       
  2386 	__MM_HEAP_MARK;
       
  2387 	
       
  2388 	TVerdict result = EFail;
       
  2389 	
       
  2390 	_LIT( KTestPlay, "Meta data test with play scenario Test");
       
  2391 	Log( KTestPlay );
       
  2392 	
       
  2393 	_LIT( KTestStepPlay, "This test checks setting/getting meta data");
       
  2394 	Log( KTestStepPlay );
       
  2395 	
       
  2396 	// [ audio file to play ]
       
  2397 	_LIT(KTestWavFile, "newmail.wav");
       
  2398 	SetReadFileNameL( KTestWavFile );
       
  2399    	
       
  2400 	TInt errorCode = iController.Open(KUidCustomTestAudioPlugin, iPriority);
       
  2401 	User::LeaveIfError( errorCode );
       
  2402 
       
  2403 	//[ add data source and sink and prime the controller ]
       
  2404     errorCode = iController.AddDataSource(KUidMmfFileSource, ReadFileConfig());
       
  2405 	User::LeaveIfError( errorCode );
       
  2406 	
       
  2407 	errorCode =	iController.AddDataSink(KUidMmfAudioOutput, KNullDesC8);
       
  2408     User::LeaveIfError( errorCode );
       
  2409 
       
  2410 	// [ lets get the number of meta data entries 
       
  2411 	// for this format the meta data is unsupported ]
       
  2412 	TInt numEntries = 0;
       
  2413 	errorCode = iController.GetNumberOfMetaDataEntries( numEntries ); 
       
  2414 	if( errorCode != KErrNotSupported )
       
  2415 		{
       
  2416 		User::LeaveIfError( errorCode );
       
  2417 		}
       
  2418 
       
  2419 	// [ lets get a meta data entry ]
       
  2420 	const TInt KIndex = 0;
       
  2421 	TRAP( errorCode, iController.GetMetaDataEntryL( KIndex ));
       
  2422 	if( errorCode != KErrNotSupported )
       
  2423 		{
       
  2424 		User::LeaveIfError( errorCode );
       
  2425 		}
       
  2426 		
       
  2427 	errorCode =	iController.Prime();
       
  2428 	User::LeaveIfError( errorCode );
       
  2429 	
       
  2430 	// [ wait for and process the return event from the audio output ]
       
  2431 	
       
  2432 	TMMFEvent primeEvent( KPrimeTestId, KErrNone);
       
  2433 	result = SearchForEvent( primeEvent );
       
  2434 	if( result == EFail )
       
  2435 		{
       
  2436 		return result;
       
  2437 		}
       
  2438 	
       
  2439 	// [ lets get the number of meta data entries 
       
  2440 	// for this format the meta data is unsupported ]
       
  2441 	numEntries = 0;
       
  2442 	errorCode = iController.GetNumberOfMetaDataEntries( numEntries ); 
       
  2443 	if( errorCode != KErrNotSupported )
       
  2444 		{
       
  2445 		User::LeaveIfError( errorCode );
       
  2446 		}
       
  2447 
       
  2448 	// [ lets get a meta data entry ]
       
  2449 	TRAP( errorCode, iController.GetMetaDataEntryL( KIndex ));
       
  2450 	if( errorCode != KErrNotSupported )
       
  2451 		{
       
  2452 		User::LeaveIfError( errorCode );
       
  2453 		}
       
  2454 	
       
  2455     User::LeaveIfError( iController.Play() );
       
  2456 	
       
  2457 	// note this test does not wait around 
       
  2458 	// to detect that the audio has been played
       
  2459 	// [ now process the confirmation event that play has reached audio output
       
  2460 	//   this is the raison detre of the test ]
       
  2461 	TMMFEvent playEvent( KPlayTestId, KErrNone );
       
  2462 	
       
  2463 	result = SearchForEvent( playEvent );
       
  2464 
       
  2465 	// [ lets try to get the meta data when playing ]
       
  2466 
       
  2467 	errorCode = iController.GetNumberOfMetaDataEntries( numEntries ); 
       
  2468 	if( errorCode != KErrNotReady )
       
  2469 		{
       
  2470 		User::LeaveIfError( errorCode );
       
  2471 		}
       
  2472 
       
  2473 	// [ lets get a meta data entry ]
       
  2474 	// This kills the thread and is under investigation
       
  2475 	TRAP( errorCode, iController.GetMetaDataEntryL( KIndex ));
       
  2476 	if( errorCode != KErrNotReady )
       
  2477 		{
       
  2478 		User::LeaveIfError( errorCode );
       
  2479 		}
       
  2480 
       
  2481 	//[ ensure the controller is unloaded so that it does 
       
  2482 	// not interfere with the following test ]
       
  2483 	// There is a bug in this code and the stop followed by reset
       
  2484 	// ensure the controller resources are released.
       
  2485 	iController.Stop();
       
  2486 	iController.Reset();
       
  2487 	iController.Close();  
       
  2488 	
       
  2489 	__MM_HEAP_MARKEND;
       
  2490 	   
       
  2491 	// test steps return a result
       
  2492 	return EPass;
       
  2493 	}
       
  2494 
       
  2495 /**
       
  2496 *
       
  2497 * CTestStepGetSupportedSinkDataTypes
       
  2498 *
       
  2499 */
       
  2500 CTestStepGetSupportedSinkDataTypes::CTestStepGetSupportedSinkDataTypes()
       
  2501 	{
       
  2502 	iTestStepName = _L("MM-MMF-ACTRL-U-0034-HP");
       
  2503 	}
       
  2504 
       
  2505 /**
       
  2506 *
       
  2507 * ~CTestStepGetSupportedSinkDataTypes
       
  2508 *
       
  2509 */
       
  2510 CTestStepGetSupportedSinkDataTypes::~CTestStepGetSupportedSinkDataTypes()
       
  2511 	{
       
  2512 	}
       
  2513 
       
  2514 /**
       
  2515 *
       
  2516 * DoTestStepL
       
  2517 * This test gets the supported sink data types
       
  2518 *
       
  2519 */
       
  2520 TVerdict CTestStepGetSupportedSinkDataTypes::DoTestStepL( void )
       
  2521 	{
       
  2522 	__MM_HEAP_MARK;
       
  2523 	TVerdict result = EPass;
       
  2524 	_LIT( KTestSourceNumChannels, "GetSupported Sink Data types");
       
  2525 	Log( KTestSourceNumChannels);
       
  2526 	
       
  2527 	_LIT( KTestSinkBitRateReason, "This test checks the get supported sink data types method");
       
  2528 	Log( KTestSinkBitRateReason );
       
  2529 	
       
  2530 	// [ audio file to play ]
       
  2531 	_LIT(KTestWavFile, "newmail.wav");
       
  2532 	SetReadFileNameL( KTestWavFile );
       
  2533    	
       
  2534 	TInt errorCode = iController.Open(KUidCustomTestAudioPlugin, iPriority);
       
  2535 	User::LeaveIfError( errorCode );
       
  2536 
       
  2537 	//[ attempt to get the sink num channels ]
       
  2538     RMMFAudioControllerCustomCommands theCommander( iController );
       
  2539 
       
  2540 	RArray<TFourCC> supportedDataTypes;
       
  2541 	CleanupClosePushL(supportedDataTypes);
       
  2542 
       
  2543 	TRAPD( errorCode2, theCommander.GetSupportedSinkDataTypesL( supportedDataTypes ));
       
  2544 	if( ( errorCode2 == KErrNone ) || supportedDataTypes.Count() )
       
  2545 		{
       
  2546 		//[ should have failed with either an error code or non zero supported types ]
       
  2547 		result = EFail;
       
  2548 		}
       
  2549 
       
  2550 	//[ ok lets add the source and sink ]
       
  2551     if(result==EPass)
       
  2552     	{
       
  2553     	errorCode = iController.AddDataSource(KUidMmfFileSource, ReadFileConfig());
       
  2554     	if(errorCode!=KErrNone)
       
  2555     		{
       
  2556     		result=EFail;
       
  2557     		}
       
  2558     	}
       
  2559     
       
  2560     if(result==EPass)
       
  2561     	{
       
  2562 		errorCode =	iController.AddDataSink(KUidMmfAudioOutput, KNullDesC8);
       
  2563     	if(errorCode!=KErrNone)
       
  2564     		{
       
  2565     		result=EFail;
       
  2566     		}
       
  2567     	}
       
  2568     
       
  2569     if(result==EPass)
       
  2570     	{
       
  2571     	//[ ensure the array is empty ]
       
  2572 		supportedDataTypes.Reset();
       
  2573 		TRAPD( errorCode3,theCommander.GetSupportedSinkDataTypesL( supportedDataTypes ));
       
  2574 		if(errorCode3!=KErrNotSupported)
       
  2575 	    	{
       
  2576 	    	INFO_PRINTF2(_L("GetSupportedSinkDataTypesL left with %d when KErrNotSupported is expected"), errorCode);
       
  2577 	    	result = EFail;
       
  2578 	    	}
       
  2579     	}
       
  2580 	
       
  2581 
       
  2582 	//[ pop supportedDataTypes ]
       
  2583 	CleanupStack::PopAndDestroy(1);//supportedDataTypes
       
  2584 	
       
  2585 	//[ ensure the controller is unloaded so that it does 
       
  2586 	// not interfere with the following test ]
       
  2587 	// There is a bug in this code and the stop followed by reset
       
  2588 	// ensure the controller resources are released.
       
  2589 	iController.Stop();
       
  2590 	iController.Reset();
       
  2591 	iController.Close();  
       
  2592 	
       
  2593 	__MM_HEAP_MARKEND;
       
  2594 	return result;
       
  2595 	}
       
  2596 
       
  2597 /**
       
  2598 *
       
  2599 * CTestStepGetSupportedSourceDataTypes
       
  2600 *
       
  2601 */
       
  2602 CTestStepGetSupportedSourceDataTypes::CTestStepGetSupportedSourceDataTypes()
       
  2603 	{
       
  2604 	iTestStepName = _L("MM-MMF-ACTRL-U-0035-HP");
       
  2605 	}
       
  2606 
       
  2607 /**
       
  2608 *
       
  2609 * ~CTestStepGetSupportedSourceDataTypes
       
  2610 *
       
  2611 */
       
  2612 CTestStepGetSupportedSourceDataTypes::~CTestStepGetSupportedSourceDataTypes()
       
  2613 	{
       
  2614 	}
       
  2615 
       
  2616 /**
       
  2617 *
       
  2618 * DoTestStepL
       
  2619 *
       
  2620 */
       
  2621 TVerdict CTestStepGetSupportedSourceDataTypes::DoTestStepL( void )
       
  2622 	{
       
  2623 	__MM_HEAP_MARK;
       
  2624 	TVerdict result = EPass;
       
  2625 	
       
  2626 	_LIT( KTestSourceNumChannels, "GetSupported Source Data types");
       
  2627 	Log( KTestSourceNumChannels);
       
  2628 	
       
  2629 	_LIT( KTestSinkBitRateReason, "This test checks the get supported source data types method");
       
  2630 	Log( KTestSinkBitRateReason );
       
  2631 	
       
  2632 	// [ audio file to play ]
       
  2633 	_LIT(KTestWavFile, "newmail.wav");
       
  2634 	SetReadFileNameL( KTestWavFile );
       
  2635    	
       
  2636 	TInt errorCode = iController.Open(KUidCustomTestAudioPlugin, iPriority);
       
  2637 	User::LeaveIfError( errorCode );
       
  2638 	
       
  2639 	//[ attempt to get the sink num channels ]
       
  2640     RMMFAudioControllerCustomCommands theCommander( iController );
       
  2641 	
       
  2642 	RArray<TFourCC> supportedDataTypes;
       
  2643 	CleanupClosePushL(supportedDataTypes);
       
  2644 	
       
  2645 	TRAPD( errorCode2, theCommander.GetSupportedSourceDataTypesL( supportedDataTypes ));
       
  2646 	if( ( errorCode2 == KErrNone ) || supportedDataTypes.Count() )
       
  2647 		{
       
  2648 		//[ should have failed with either an error code or non zero supported types ]
       
  2649 		result = EFail;
       
  2650 		return result;
       
  2651 		}
       
  2652 	
       
  2653 	//[ ok lets add the source and sink ]
       
  2654     errorCode = iController.AddDataSource(KUidMmfFileSource, ReadFileConfig());
       
  2655 	User::LeaveIfError( errorCode );
       
  2656 	
       
  2657 	errorCode =	iController.AddDataSink(KUidMmfAudioOutput, KNullDesC8);
       
  2658     User::LeaveIfError( errorCode );
       
  2659 	
       
  2660 	//[ ensure the array is empty ]
       
  2661 	supportedDataTypes.Reset();
       
  2662 	TRAPD( errorCode3,theCommander.GetSupportedSourceDataTypesL( supportedDataTypes ));
       
  2663 	User::LeaveIfError( errorCode3 );
       
  2664 	
       
  2665 	// Store the original FCC
       
  2666 	TFourCC origFCC;
       
  2667 	errorCode = theCommander.GetSourceDataType(origFCC);
       
  2668 	if (errorCode != KErrNone)
       
  2669 		{
       
  2670 		INFO_PRINTF2(_L("GetSourceDataType returned error %d"), errorCode);
       
  2671 		return EFail;
       
  2672 		}
       
  2673 
       
  2674 	TFourCC theNewFCC;
       
  2675 	TFourCC theFCC;
       
  2676 	
       
  2677 	//[ loop over the possible set of data types that are supported ]
       
  2678 	for( TInt index = 0; index < supportedDataTypes.Count(); index++ )
       
  2679 		{
       
  2680 		theFCC = supportedDataTypes[ index];
       
  2681 		errorCode = theCommander.SetSourceDataType( theFCC );
       
  2682 
       
  2683 		if (theFCC == origFCC)
       
  2684 			{
       
  2685 			// Trying to set the correct FCC
       
  2686 			if (errorCode != KErrNone)
       
  2687 				{
       
  2688 				INFO_PRINTF2(_L("SetSourceDataType returned unexpected error %d"), errorCode);
       
  2689 				result = EFail;
       
  2690 				break;
       
  2691 				}
       
  2692 			}
       
  2693 		else
       
  2694 			{
       
  2695 			if (errorCode != KErrAlreadyExists)
       
  2696 				{
       
  2697 				INFO_PRINTF3(_L("SetSourceDataType returned %d, expecting %d"), errorCode, KErrAlreadyExists);
       
  2698 				result = EFail;
       
  2699 				break;
       
  2700 				}
       
  2701 			}
       
  2702 
       
  2703 		errorCode = theCommander.GetSourceDataType( theNewFCC );
       
  2704 		if (theNewFCC != origFCC)
       
  2705 			{
       
  2706 			INFO_PRINTF1(_L("GetSourceDataType returned incorrect FCC"));
       
  2707 			result = EFail;
       
  2708 			break;
       
  2709 			}
       
  2710 
       
  2711 		if (errorCode != KErrNone)
       
  2712 			{
       
  2713 			INFO_PRINTF2(_L("GetSourceDataType returned unexpected error %d"), errorCode);
       
  2714 			result = EFail;
       
  2715 			break;
       
  2716 			}
       
  2717 		}
       
  2718 	
       
  2719 	//[ pop supportedDataTypes ]
       
  2720 	CleanupStack::PopAndDestroy(1);//supportedDataTypes
       
  2721 	
       
  2722 	//[ ensure the controller is unloaded so that it does 
       
  2723 	// not interfere with the following test ]
       
  2724 	// There is a bug in this code and the stop followed by reset
       
  2725 	// ensure the controller resources are released.
       
  2726 	iController.Stop();
       
  2727 	iController.Reset();
       
  2728 	iController.Close();  
       
  2729 	
       
  2730 	__MM_HEAP_MARKEND;
       
  2731 	return result;
       
  2732 	}
       
  2733 
       
  2734 /**
       
  2735 *
       
  2736 * CTestStepGetSupportedSourceNumChannels
       
  2737 * 
       
  2738 */
       
  2739 CTestStepGetSupportedSourceNumChannels::CTestStepGetSupportedSourceNumChannels()
       
  2740 	{
       
  2741 	iTestStepName = _L("MM-MMF-ACTRL-U-0036-HP");
       
  2742 	}
       
  2743 
       
  2744 /**
       
  2745 *
       
  2746 * ~CTestStepGetSupportedSourceNumChannels
       
  2747 *
       
  2748 */
       
  2749 CTestStepGetSupportedSourceNumChannels::~CTestStepGetSupportedSourceNumChannels()
       
  2750 	{
       
  2751 	}
       
  2752 
       
  2753 /**
       
  2754 *
       
  2755 * DoTestStepL
       
  2756 * This test  tests the number of channels supported by a source
       
  2757 *
       
  2758 */
       
  2759 TVerdict CTestStepGetSupportedSourceNumChannels::DoTestStepL( void )
       
  2760 	{
       
  2761 	__MM_HEAP_MARK;
       
  2762 	TVerdict result = EPass;
       
  2763 	
       
  2764 	_LIT( KTestSourceNumChannels, "GetSupported Source Num Channels");
       
  2765 	Log( KTestSourceNumChannels);
       
  2766 	
       
  2767 	_LIT( KTestSinkBitRateReason, "This test checks the get supported source channels");
       
  2768 	Log( KTestSinkBitRateReason );
       
  2769 	
       
  2770 	// [ audio file to play ]
       
  2771 	_LIT(KTestWavFile, "newmail.wav");
       
  2772 	SetReadFileNameL( KTestWavFile );
       
  2773    	
       
  2774 	TInt errorCode = iController.Open(KUidCustomTestAudioPlugin, iPriority);
       
  2775 	User::LeaveIfError( errorCode );
       
  2776 	
       
  2777 	//[ attempt to get the sink num channels ]
       
  2778     RMMFAudioControllerCustomCommands theCommander( iController );
       
  2779 			
       
  2780 	RArray<TUint> supportedChannels;
       
  2781 	CleanupClosePushL(supportedChannels);
       
  2782 
       
  2783 	TRAPD( errorCode2, theCommander.GetSupportedSourceNumChannelsL( supportedChannels));
       
  2784 	if( errorCode2 == KErrNone ) 
       
  2785 		{
       
  2786 		//[ should have failed with either an error code or non zero supported types ]
       
  2787 		result = EFail;
       
  2788 		return result;
       
  2789 		}
       
  2790 	
       
  2791 	//[ ok lets add the source and sink ]
       
  2792     errorCode = iController.AddDataSource(KUidMmfFileSource, ReadFileConfig());
       
  2793 	User::LeaveIfError( errorCode );
       
  2794 	
       
  2795 	errorCode =	iController.AddDataSink(KUidMmfAudioOutput, KNullDesC8);
       
  2796     User::LeaveIfError( errorCode );
       
  2797 
       
  2798 	//[ ensure the array is empty ]
       
  2799 	supportedChannels.Reset();
       
  2800 	TRAPD( errorCode3, theCommander.GetSupportedSourceNumChannelsL( supportedChannels));	
       
  2801 	User::LeaveIfError( errorCode3 );
       
  2802 	
       
  2803 	TUint orgNumChannels = 0;
       
  2804 	errorCode = theCommander.GetSourceNumChannels( orgNumChannels);
       
  2805 	User::LeaveIfError( errorCode );
       
  2806 
       
  2807 	//[ loop over the possible set of data types that are supported ]
       
  2808 	for( TInt index = 0; index < supportedChannels.Count(); index++ )
       
  2809 		{
       
  2810 		TUint oldNumChannels = supportedChannels[ index];
       
  2811 		TUint numChannels    = 0;
       
  2812 		//[ wav files currently do not support a variable num source channels]
       
  2813 		errorCode = theCommander.SetSourceNumChannels( oldNumChannels);
       
  2814 		if (oldNumChannels == orgNumChannels)
       
  2815 			{
       
  2816 			// We tried to set the right number of channels for clip
       
  2817 			if (errorCode != KErrNone)
       
  2818 				{
       
  2819 				INFO_PRINTF2(_L("Error calling SetSourceNumChannels %d"), errorCode);
       
  2820 				result = EFail;
       
  2821 				break;
       
  2822 				}
       
  2823 			}
       
  2824 		else
       
  2825 			{
       
  2826 			// Setting source sample rate to a different value 
       
  2827 			// is tolerated (INC038043) to preserve BC with 6.1
       
  2828 			if (errorCode != KErrNone)
       
  2829 				{
       
  2830 				INFO_PRINTF2(_L("Unexpected error code returned by SetSourceNumChannels %d"), errorCode);
       
  2831 				result = EFail;
       
  2832 				break;
       
  2833 				}
       
  2834 			}
       
  2835 		
       
  2836 		//[ check the set operation resulted in no change of the
       
  2837 		// number of channels ]
       
  2838 		errorCode = theCommander.GetSourceNumChannels( numChannels);
       
  2839 		User::LeaveIfError( errorCode );
       
  2840 		if( orgNumChannels != numChannels )
       
  2841 			{
       
  2842 			INFO_PRINTF3(_L("GetSourceNumChannels returned %d, expecting %d"), numChannels, orgNumChannels);
       
  2843 			result = EFail;
       
  2844 			break;
       
  2845 			}
       
  2846 		}
       
  2847 
       
  2848 	//[ pop supportedChannels ]
       
  2849 	CleanupStack::PopAndDestroy(1);//supportedChannels
       
  2850 	
       
  2851 	//[ ensure the controller is unloaded so that it does 
       
  2852 	// not interfere with the following test ]
       
  2853 	// There is a bug in this code and the stop followed by reset
       
  2854 	// ensure the controller resources are released.
       
  2855 	iController.Stop();
       
  2856 	iController.Reset();
       
  2857 	iController.Close();  
       
  2858 	
       
  2859 	__MM_HEAP_MARKEND;
       
  2860 	return result;
       
  2861 	}