kerneltest/e32test/multimedia/t_sound2.cpp
changeset 15 4122176ea935
parent 0 a41df078684a
child 109 b3a1d9898418
equal deleted inserted replaced
0:a41df078684a 15:4122176ea935
   422 
   422 
   423 	RxSoundDevice.RecordData(stat,length);
   423 	RxSoundDevice.RecordData(stat,length);
   424 	User::WaitForRequest(stat);
   424 	User::WaitForRequest(stat);
   425 	retOffset=stat.Int();
   425 	retOffset=stat.Int();
   426 	CHECK(retOffset==KErrOverflow);
   426 	CHECK(retOffset==KErrOverflow);
       
   427 
       
   428 	// Make sure we can issue a successful RecordData after recovering from overflow.
       
   429 	RxSoundDevice.RecordData(stat,length);
       
   430 	User::WaitForRequest(stat);
       
   431 	retOffset=stat.Int();
       
   432 	CHECK_POSITIVE(retOffset);
       
   433     r=RxSoundDevice.ReleaseBuffer(retOffset);
       
   434     CHECK_NOERROR(r);
   427 
   435 
   428 	RxSoundDevice.CancelRecordData();	// Stop the driver from recording.
   436 	RxSoundDevice.CancelRecordData();	// Stop the driver from recording.
   429 	chunk.Close();
   437 	chunk.Close();
   430 	}
   438 	}
   431 
   439 
  1053 	@SYMTestExpectedResults	1)	The pause and resume requests should both complete with KErrNone.
  1061 	@SYMTestExpectedResults	1)	The pause and resume requests should both complete with KErrNone.
  1054 							2)	The pause and resume requests should both complete with KErrNone.
  1062 							2)	The pause and resume requests should both complete with KErrNone.
  1055 							3)	The counts should be equal.
  1063 							3)	The counts should be equal.
  1056 	@SYMREQ					PREQ1073.4
  1064 	@SYMREQ					PREQ1073.4
  1057 */
  1065 */
  1058 LOCAL_C void TestRecordPauseResume()
  1066 LOCAL_C void TestRecordPauseResume(TUint aChannels)
  1059 	{
  1067 	{
  1060 	TRequestStatus stat[2];
  1068 	TRequestStatus stat[2];
  1061 	TInt length[2];
  1069 	TInt length[2];
  1062 
  1070 
  1063 	Test.Next(_L("Test record pause and resume"));
  1071 	Test.Next(_L("Test record pause and resume"));
  1064 	RecordFormatBuf().iRate = ESoundRate44100Hz;
  1072 	RecordFormatBuf().iRate = ESoundRate44100Hz;
  1065 	if (RecordCapsBuf().iEncodings&KSoundEncoding16BitPCM)
  1073 	if (RecordCapsBuf().iEncodings&KSoundEncoding16BitPCM)
  1066 		RecordFormatBuf().iEncoding = ESoundEncoding16BitPCM;
  1074 		RecordFormatBuf().iEncoding = ESoundEncoding16BitPCM;
  1067 	PlayFormatBuf().iChannels = 2;
  1075 	RecordFormatBuf().iChannels = aChannels;
  1068 	PrintConfig(RecordFormatBuf(),Test);
  1076 	PrintConfig(RecordFormatBuf(),Test);
  1069 	TInt r = RxSoundDevice.SetAudioFormat(RecordFormatBuf);
  1077 	TInt r = RxSoundDevice.SetAudioFormat(RecordFormatBuf);
  1070 	CHECK_NOERROR(r);
  1078 	CHECK_NOERROR(r);
  1071 
  1079 
  1072 	// Set the record buffer configuration, then read it back.
  1080 	// Set the record buffer configuration, then read it back.
  1125 				{
  1133 				{
  1126 				// Partially filled buffer. We need to adjust the bytes expected when an incomplete buffer arrives.
  1134 				// Partially filled buffer. We need to adjust the bytes expected when an incomplete buffer arrives.
  1127 				remainingRecordCount--;
  1135 				remainingRecordCount--;
  1128 
  1136 
  1129 				CHECK_POSITIVE(length[currentReq]);
  1137 				CHECK_POSITIVE(length[currentReq]);
       
  1138 				CHECK(length[currentReq]<=bufSize);
  1130 				bytesRecorded += length[currentReq];
  1139 				bytesRecorded += length[currentReq];
  1131 				if (length[currentReq]<bufSize)
  1140 				if (length[currentReq]<bufSize)
  1132 					bytesToRecord-=(bufSize-length[currentReq]);
  1141 					bytesToRecord-=(bufSize-length[currentReq]);
  1133 				Test.Printf(_L("1st outstanding req partially completed(len=%d)\r\n"),length[currentReq]);
  1142 				Test.Printf(_L("1st outstanding req partially completed(len=%d)\r\n"),length[currentReq]);
  1134 
  1143 
  1215 	retOffset=stat[0].Int();
  1224 	retOffset=stat[0].Int();
  1216 	if (retOffset>=0)
  1225 	if (retOffset>=0)
  1217 		{
  1226 		{
  1218 		// Partially filled buffer.
  1227 		// Partially filled buffer.
  1219 		CHECK(length[0]>0);
  1228 		CHECK(length[0]>0);
       
  1229 		CHECK(length[0] <= bufSize);
  1220 		Test.Printf(_L("2nd req partially completed(len=%d)\r\n"),length[0]);
  1230 		Test.Printf(_L("2nd req partially completed(len=%d)\r\n"),length[0]);
  1221 		r=RxSoundDevice.ReleaseBuffer(retOffset);
  1231 		r=RxSoundDevice.ReleaseBuffer(retOffset);
  1222 		CHECK_NOERROR(r);
  1232 		CHECK_NOERROR(r);
  1223 		}
  1233 		}
  1224 	else
  1234 	else
  1225 		{
  1235 		{
  1226 		CHECK(retOffset==KErrCancel);
  1236 		CHECK(retOffset==KErrCancel);
  1227 		Test.Printf(_L("2nd req cancelled\r\n"));
  1237 		Test.Printf(_L("2nd req cancelled\r\n"));
  1228 		}
  1238 		}
  1229 
  1239 
  1230 	// Any further record request should return straight away with KErrCancel
  1240 	for(;;)
  1231 	RxSoundDevice.RecordData(stat[0],length[0]);
  1241 		{
  1232 	User::WaitForRequest(stat[0]);
  1242 		// Read all buffers until driver is empty. The RecordData call after that should immediately return with KErrCancel
  1233 	retOffset=stat[0].Int();
  1243 		Test.Printf(_L("Draining driver\r\n"));
  1234 	CHECK(retOffset==KErrCancel);
  1244 		RxSoundDevice.RecordData(stat[0],length[0]);
  1235 	Test.Printf(_L("3rd req cancelled\r\n"));
  1245 		User::WaitForRequest(stat[0]);
       
  1246 		retOffset=stat[0].Int();
       
  1247 		if(retOffset==KErrCancel)
       
  1248 			{
       
  1249 			break;
       
  1250 			}
       
  1251 		CHECK_NOERROR(retOffset);
       
  1252 		}
       
  1253 	Test.Printf(_L("Driver empty\r\n"));
  1236 
  1254 
  1237 	r=RxSoundDevice.Resume();			// Don't leave it in paused state.
  1255 	r=RxSoundDevice.Resume();			// Don't leave it in paused state.
  1238 	CHECK_NOERROR(r);
  1256 	CHECK_NOERROR(r);
  1239 	RxSoundDevice.CancelRecordData();	// Stop the driver from recording.
  1257 	RxSoundDevice.CancelRecordData();	// Stop the driver from recording.
  1240 	Test.Printf(_L("Record pause successful\r\n"));
  1258 	Test.Printf(_L("Record pause successful\r\n"));
  1429 				stat[2]=KRequestPending;
  1447 				stat[2]=KRequestPending;
  1430 				}
  1448 				}
  1431 			}
  1449 			}
  1432 		else
  1450 		else
  1433 			{
  1451 			{
  1434 			// Its one of the play requests that have completed, release the buffer.
  1452 			// Its one of the play requests that have completed
  1435 			CHECK_NOERROR(stat[i].Int());
  1453 			if(stat[i].Int() >= 0)
  1436 //			Test.Printf(_L("PLAY(%d) i%d CompBuf %d\r\n"),remainingPlayCount-1,i,activePlayOffset[i]);
  1454 				{
  1437 			r=RxSoundDevice.ReleaseBuffer(activePlayOffset[i]);
  1455 				// release the buffer.
  1438 			CHECK_NOERROR(r);
  1456 //				Test.Printf(_L("PLAY(%d) i%d CompBuf %d\r\n"),remainingPlayCount-1,i,activePlayOffset[i]);
       
  1457 				r=RxSoundDevice.ReleaseBuffer(activePlayOffset[i]);
       
  1458 				CHECK_NOERROR(r);
       
  1459 				Test.Printf(_L("*"));
       
  1460 				}
       
  1461 			else
       
  1462 				{
       
  1463 				// Play failed - but we ignore underflow because it often happens on WDP roms.
       
  1464 				CHECK(stat[i].Int() == KErrUnderflow);
       
  1465 				Test.Printf(_L("U"));
       
  1466 				}
  1439 
  1467 
  1440 			remainingPlayCount--;
  1468 			remainingPlayCount--;
  1441 			bytesPlayed += bufSize;
  1469 			bytesPlayed += bufSize;
  1442 			Test.Printf(_L("*"));
       
  1443 
  1470 
  1444 			// If there are buffers available then issue a further play request and update the 'next to play' list.
  1471 			// If there are buffers available then issue a further play request and update the 'next to play' list.
  1445 			if (playQueue.Count() != 0)
  1472 			if (playQueue.Count() != 0)
  1446 				{
  1473 				{
  1447 				activePlayOffset[i]=playQueue.PopL();
  1474 				activePlayOffset[i]=playQueue.PopL();
  2452 		TestRecordAllRates(1,4);
  2479 		TestRecordAllRates(1,4);
  2453 		TestRecordAllRates(2,4);
  2480 		TestRecordAllRates(2,4);
  2454 		TestRecordVolume(2,10);
  2481 		TestRecordVolume(2,10);
  2455 		TestPlayCancel();
  2482 		TestPlayCancel();
  2456 		TestRecordCancel();
  2483 		TestRecordCancel();
  2457 		TestRecordPauseResume();
  2484 		TestRecordPauseResume(1);
       
  2485 		TestRecordPauseResume(2);
  2458 		TestSimultaneousPlayRecord();
  2486 		TestSimultaneousPlayRecord();
  2459 		TestTimePlayed();
  2487 		TestTimePlayed();
  2460 		TestTimeRecorded();
  2488 		TestTimeRecorded();
  2461 #ifdef __WINS__
  2489 #ifdef __WINS__
  2462 		TestDefectDTWMM00678();
  2490 		TestDefectDTWMM00678();