/**
*
* Test step Preamble.
*
* @return TVerdict: The result of the test step.
* 
*/
TVerdict CTestMmfOggAudioRecorderBase::DoTestStepPreambleL()
    {
    // Install the scheduler
    TVerdict verdict = CTestMmfAclntStep::DoTestStepPreambleL();

    iError = KErrNone;

    // Get the filename
    TPtrC filename1;
    if (!GetStringFromConfig(iSectName, iKeyName, filename1))
        {
        return EInconclusive;
        }
    GetDriveName(iFileName);
    iFileName.Append(filename1);

    // Create an audio recorder
    iAudioRecorder = CMdaAudioRecorderUtility::NewL(*this);
    if (iAudioRecorder == NULL)
        {
        return EInconclusive;
        }

    return verdict;
    }
Example #2
0
signed char GetDrive(int item)
{
	byte b;
	const char* name = GetItem(item);
	for (b = 0; b < 8; b++)
		if (strncmp(name,GetDriveName(b),16) == 0)
			return b;
	return -1;
}
void CTestMmfAclntCaps0014::CreatePlayer() 
	{
	// Get the test filename from the configuration file
	TBuf<KSizeBuf> filename;
	TPtrC filename1; 
	if(!GetStringFromConfig(iSectName,iKeyName,filename1))
		{
		iVerdict = EFail;
		CActiveScheduler::Stop();
		}
	GetDriveName(filename);
	filename.Append(filename1);
	
	iPlayer = CMdaAudioRecorderUtility::NewL(*this, NULL, EMdaPriorityNormal);
	iPlayer->OpenFileL(_L("c:\\rectest2.wav"));
	}
Example #4
0
//安装驱动
BOOL VirtualDrive::InstallDriver()
{
	if (!IsISOCmdExist())
	{
		return FALSE;
	}
	//清理旧驱动信息
	CString subPath= L"SYSTEM\\CurrentControlSet\\Services\\ISODrive";
	RegDeleteKey(HKEY_LOCAL_MACHINE,subPath);
	//安装新驱动
	ExecuteCmd(L"CMD /C ISOCmd -Install",m_CurrentISOCmdDirectory);
	//设定盘符数量
	ExecuteCmd(L"CMD /C ISOCmd -Number 1",m_CurrentISOCmdDirectory);
	//获取当前盘符
	m_DrivrName=GetDriveName();
	if (!IsDriveLoadSuccess())
	{
		return FALSE;
	}
	return TRUE;
}
/** Play and record an audio file using the UseOldCodecAudioController
 *  which uses CMMFCodecs and the 'null' pcm16->pcm16 hw device plugin
 *  This is for DEF039267
 */
TVerdict CTestMmfAclntOldCodecFile::DoTestStepL( void )
	{
	INFO_PRINTF1( _L("TestPlayerUtils : File"));
	TVerdict ret = EFail;

	iError = KErrTimedOut;

	TBuf<KSizeBuf>	filename;
	TPtrC			filename1; 
	if(!GetStringFromConfig(iSectName,iKeyName,filename1))
		return EInconclusive;
	GetDriveName(filename);
	filename.Append(filename1);
	TUid useCMMFCodecAudioController;

	useCMMFCodecAudioController.iUid = KMmfUidUseOldCodecAudioController;

	CMdaAudioRecorderUtility* recUtil = CMdaAudioRecorderUtility::NewL(*this);

	TRAPD(err, recUtil->OpenFileL(filename,useCMMFCodecAudioController));

	if (err)
		{
		INFO_PRINTF2( _L("error opening record to file %d "), err);
		}
	else
		{
		CActiveScheduler::Start();
		TTimeIntervalMicroSeconds duration = recUtil->Duration();
		// Wait for initialisation callback
		INFO_PRINTF1( _L("Initialise CMdaAudioPlayerUtility"));

		// Check for errors.
		if (iError == KErrNone && recUtil != NULL)
			{
			if(iPlay)
				{
				iError = KErrTimedOut;
				TRAPD(err, recUtil->PlayL());
				if (err)
					{
					INFO_PRINTF2( _L("error opening record to file %d "), err);
					}
				else
					{
					//lets time how long the file plays for and check 
					//it has played for the full time
					TTime startTime(0);
					TTime endTime(0);
					startTime.HomeTime();
					// Wait for init callback
					CActiveScheduler::Start();
					endTime.HomeTime();
					//check file played for the expected time - allow margin of error + 1S -0.5S
					TTimeIntervalMicroSeconds playduration = endTime.MicroSecondsFrom(startTime);
					if ( (playduration.Int64() < (duration.Int64()-KOneSecond/2)) ||
						(playduration.Int64() > (duration.Int64()+KOneSecond)) )
						{
						INFO_PRINTF2(_L("file didn't play for the expected duration expected %ld"), duration.Int64());
						INFO_PRINTF2(_L("but actual duration was %ld"), playduration.Int64());
						}
					else if(iError == KErrNone)
						ret = EPass;
					}
				}		
			}

		recUtil->Close();
		}

	//now try recording file

	TFourCC recordedDataType;
	TUid format;
	format.iUid = KMmfUidFormatWAVWrite;

	//check that the datatype is a valid datatype to record
	if (!iKeyName.Compare(_L("ALAW ")))
		recordedDataType.Set(KMMFFourCCCodeALAW);
	else if (!iKeyName.Compare(_L("PCMU8")))
		recordedDataType.Set(KMMFFourCCCodePCMU8);
	else if (!iKeyName.Compare(_L("MULAW")))
		recordedDataType.Set(KMMFFourCCCodeMuLAW);
	else if (!iKeyName.Compare(_L("IMAD")))
		recordedDataType.Set(KMMFFourCCCodeIMAD);
	else if (!iKeyName.Compare(_L("GSM610")))
		recordedDataType.Set(KMMFFourCCCodeGSM610);

	//rename file to indicate it is recorded
	if (recordedDataType != KMMFFourCCCodeNULL)
		{
		TInt matchpos = filename.Find(_L(".wav"));//get position of extension
		filename.Insert(matchpos,_L("recorded"));//change filename to indicate it is recorded

		//delete file prior to recording
		RFs fs;
		fs.Connect();
		fs.Delete(filename);
		fs.Close();
	
		TRAPD(err,recUtil->OpenFileL(filename,useCMMFCodecAudioController,useCMMFCodecAudioController,format,recordedDataType));

		if (err)
			{
			ret = EFail;
			INFO_PRINTF2( _L("error opening record to file %d "), err);
			}
		else
			{
			INFO_PRINTF1( _L("Initialise CMdaAudioRecorderUtility"));
			CActiveScheduler::Start();	// idle -> open

			recUtil->RecordL();

			// Commented this line of code as a fix for DEF 40709 as it looks like sending a trace message
			// to the TestFramework server(for some reason)and taking a very long time on beech/lubbock 

			//INFO_PRINTF1( _L("Record CMdaAudioRecorderUtility"));
			CActiveScheduler::Start(); // open -> record
			User::After(KTwoSeconds);
			
			recUtil->Stop();
	
			TTimeIntervalMicroSeconds expectedDuration(KTwoSeconds);
			TTimeIntervalMicroSeconds duration = recUtil->Duration();
			//we'll alow +/- 0.5 variance 
			if (duration > TTimeIntervalMicroSeconds(expectedDuration.Int64() + KDeviation/2))
				{
				INFO_PRINTF3( _L("Duration too long expected %ld actual %ld "), expectedDuration.Int64(), duration.Int64());
				ret = EFail;
				}
			else if (duration < TTimeIntervalMicroSeconds(expectedDuration.Int64() - KDeviation/2))
				{
				INFO_PRINTF3( _L("Duration too short expected %ld actual %ld "), expectedDuration.Int64(), duration.Int64());
				ret = EFail;
				}

			recUtil->Close();
			}
		}

	delete recUtil;
	User::After(KOneSecond); // wait for deletion to shut down devsound
	if(iError != KErrNone)
		ERR_PRINTF2( _L("CMdaAudioPlayerUtility failed with error %d"),iError );
	return	ret;
	}
/**
 * Load and initialise an audio file.
 */
TVerdict CTestMmfAclntFileSource::DoTestStepL( void )
	{
	INFO_PRINTF1( _L("TestPlayerUtils : File"));
	TVerdict ret = EFail;
	
	iError = KErrTimedOut;
	
	TBuf<KSizeBuf>	filename;
	TPtrC			filename1;
	
	if(!GetStringFromConfig(iSectName,iKeyName,filename1))
		{
		return EInconclusive;
		}
	
	GetDriveName(filename);
	filename.Append(filename1);
	
	// Create CMdaAudioPlayerUtility Object
	CMdaAudioPlayerUtility* player = NULL;
	player = CMdaAudioPlayerUtility::NewL(*this);
	
	// Create TMMFileSource Object
	TMMFileSource filesource(filename);
	player->OpenFileL(filesource);
	
	// Wait for initialisation callback
	INFO_PRINTF1(_L("Initialise CMdaAudioPlayerUtility"));
	CActiveScheduler::Start();
	
	// Check for expected errors.
	if(iError != KErrNone && (iExpectedError == iError))
		{
		ret = EPass;	// all other tests pass
		delete player;
		User::After(KOneSecond); // wait for deletion to shut down devsound
		ERR_PRINTF2( _L("CMdaAudioPlayerUtility failed with expected error %d"),iError );
		return ret;
		}

	// Check for errors (after OPEN).
	if (iError == KErrNone && player != NULL)
		{
		if(iPlay)
			{
			iError = KErrTimedOut;
			player->Play();
			
			// Wait for play complete callback
			INFO_PRINTF1(_L("Play CMdaAudioPlayerUtility"));
			CActiveScheduler::Start();
			
			// Check for Callback errors
			if(iError == KErrNone)
				{
				ret = EPass;
				}
			}
		else
			{
			ret = EPass;
			}
		}
	
	// Clean up activities.
	delete player;
	User::After(KOneSecond); // wait for deletion to shut down devsound

	// Check for errors (final check).
	if(iError != KErrNone)
		{
		ERR_PRINTF2( _L("CMdaAudioPlayerUtility failed with error %d"),iError );
		}
	return	ret;
	}
/**
 * Load and initialise an audio file.
 */
TVerdict CTestMmfAclntFileHandleSource::DoTestStepL( void )
	{
	INFO_PRINTF1( _L("TestPlayerUtils : File"));
	TVerdict ret = EFail;

	iError = KErrTimedOut;
	
	// Get the file name.
	TBuf<KSizeBuf> filename;
	TPtrC filename1;
	if(!GetStringFromConfig(iSectName,iKeyName,filename1))
		{
		return EInconclusive;
		}
	GetDriveName(filename);
	filename.Append(filename1);
	
	// Create CMdaAudioPlayerUtility Object
	CMdaAudioPlayerUtility* player = NULL;
	player = CMdaAudioPlayerUtility::NewL(*this);
	
	// Create RFs and RFile Objects
	RFs fs;
	User::LeaveIfError(fs.Connect());
	CleanupClosePushL(fs);
	User::LeaveIfError(fs.ShareProtected());
	
	RFile file;
	User::LeaveIfError( file.Open( fs, filename, EFileRead ) );
	CleanupClosePushL(file);
	
	// Create TMMFileSource Object
	TMMFileHandleSource filehandlesource(file);
	player->OpenFileL(filehandlesource);
	
	// Wait for initialisation callback
	INFO_PRINTF1(_L("CMdaAudioPlayerUtility->OpenFileL(TMMFileHandleSource)"));
	CActiveScheduler::Start();
	
	// Check for expected errors.
	if((iError != KErrNone) && (iExpectedError == iError))
		{
		ERR_PRINTF2(_L("CMdaAudioPlayerUtility->OpenFileL() Returned the Expected Error : %d"),iError);
		ret=EPass;
		}
	
	// Check for errors.
	if(iError != KErrNone)
		{
		ERR_PRINTF2(_L("CMdaAudioPlayerUtility->OpenFileL() Failed with Error : %d"),iError);
		ret=EFail;
		}
	
	// Check for No errors, so as to start Playback
	if (iError == KErrNone && player != NULL)
		{
		if(iPlay)
			{
			iError = KErrTimedOut;
			player->Play();
			
			// Wait for play complete callback
			INFO_PRINTF1(_L("CMdaAudioPlayerUtility->Play()"));
			CActiveScheduler::Start();
			
			// Check for Callback errors
			if(iError == KErrNone)
				{
				ERR_PRINTF2(_L("CMdaAudioPlayerUtility->Play() completed successfully with return code : %d"),iError);
				ret = EPass;
				}
			else
				{
				ERR_PRINTF2(_L("CMdaAudioPlayerUtility->Play() Failed with Error : %d"),iError );
				ret = EFail;
				}
			}
		else
			{
			ret = EPass;
			}
		}
	
	// Clean up activities.
	delete player;
	User::After(KOneSecond); // wait for deletion to shut down devsound
	CleanupStack::PopAndDestroy(2);

	return	ret;
	}