First public contribution.
1 // Copyright (c) 2004-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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 #include "TestPlayerUtils.h"
17 #include "OpenFileByHandle7902.h"
24 CTestMmfAclntOpenFile7902::CTestMmfAclntOpenFile7902(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, const TTestFormat aFormat, const TBool aCreateFile)
27 // store the name of this test case
28 // this is the name that is used by the script file
29 // Each test step initialises it's own name
30 iTestStepName = aTestName;
31 iHeapSize = 200000; // playback part of test loads whole sound file into buffer, so need large heap
32 iSectName = aSectName;
34 iTestFormat = aFormat;
35 iCreateFile = aCreateFile;
38 CTestMmfAclntOpenFile7902* CTestMmfAclntOpenFile7902::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, const TTestFormat aFormat, const TBool aCreateFile)
40 CTestMmfAclntOpenFile7902* self = new (ELeave) CTestMmfAclntOpenFile7902(aTestName,aSectName,aKeyName,aFormat,aCreateFile);
44 CTestMmfAclntOpenFile7902* CTestMmfAclntOpenFile7902::NewLC(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, const TTestFormat aFormat, const TBool aCreateFile)
46 CTestMmfAclntOpenFile7902* self = CTestMmfAclntOpenFile7902::NewLC(aTestName,aSectName,aKeyName,aFormat,aCreateFile);
47 CleanupStack::PushL(self);
51 void CTestMmfAclntOpenFile7902::MoscoStateChangeEvent(CBase* /*aObject*/, TInt /*aPreviousState*/, TInt /*aCurrentState*/, TInt aErrorCode)
54 INFO_PRINTF2( _L("iError %d "), iError);
55 CActiveScheduler::Stop();
58 // Audio utility callbacks
59 void CTestMmfAclntOpenFile7902::MapcInitComplete(TInt aError, const TTimeIntervalMicroSeconds& /*aDuration*/)
62 CActiveScheduler::Stop();
65 void CTestMmfAclntOpenFile7902::MapcPlayComplete(TInt aError)
68 CActiveScheduler::Stop();
71 // Audio output stream callbacks
72 void CTestMmfAclntOpenFile7902::MaoscOpenComplete(TInt aError)
75 CActiveScheduler::Stop();
78 void CTestMmfAclntOpenFile7902::MaoscBufferCopied(TInt aError, const TDesC8& /*aBuffer*/)
81 CActiveScheduler::Stop();
84 void CTestMmfAclntOpenFile7902::MaoscPlayComplete(TInt aError)
87 CActiveScheduler::Stop();
91 TVerdict CTestMmfAclntOpenFile7902::DoTestStepPreambleL()
93 SetupFormatL(iTestFormat);
95 return CTestMmfAclntStep::DoTestStepPreambleL();
99 * Open a file based clip and record
101 TVerdict CTestMmfAclntOpenFile7902::DoTestStepL()
103 return( PerformTestStepL() );
107 * TVerdict CTestMmfAclntOpenFile7902::PerformTestStepL()
110 TVerdict CTestMmfAclntOpenFile7902::PerformTestStepL()
112 TVerdict ret = EFail;
113 iError = KErrTimedOut;
118 User::LeaveIfError(fs.Connect());
119 CleanupClosePushL(fs);
120 User::LeaveIfError(fs.ShareProtected());
123 if(!GetStringFromConfig(iSectName, iKeyName, filename))
128 CMdaAudioRecorderUtility* recUtil = CMdaAudioRecorderUtility::NewL(*this);
129 CleanupStack::PushL(recUtil);
131 User::LeaveIfError(file.Replace(fs,filename,EFileWrite));
132 CleanupClosePushL(file);
134 recUtil->OpenFileL(file);
136 CActiveScheduler::Start();
138 if(iError == KErrNone)
140 iError = KErrTimedOut;
142 CActiveScheduler::Start(); // open -> record
144 User::After(500000); // 0.5 sec
148 CleanupStack::PopAndDestroy(2, recUtil); // file, recUtil
152 if (iError == KErrNone)
155 CMdaAudioPlayerUtility* playUtil = CMdaAudioPlayerUtility::NewL(*this);
156 CleanupStack::PushL(playUtil);
157 TRAPD(err, playUtil->OpenFileL(filename));
160 INFO_PRINTF2(_L("Error opening file for playback err = %d"), err);
163 CActiveScheduler::Start();
164 if (iError != KErrNone)
166 INFO_PRINTF2(_L("Error opening file for playback iError = %d"), iError);
170 if( iError == KErrNone )
173 CActiveScheduler::Start();
175 CleanupStack::PopAndDestroy(playUtil);
176 if (iError != KErrNone)
178 INFO_PRINTF2(_L("Error during playback of recorded file iError=%d"), iError);
183 if( iError == KErrNone )
187 User::LeaveIfError(file.Open(fs,filename,EFileRead));
188 CleanupClosePushL(file);
189 User::LeaveIfError(file.Size(size));
195 CleanupStack::PopAndDestroy(); //file
198 CleanupStack::PopAndDestroy(&fs); // fs
200 ERR_PRINTF2( _L("CMdaAudioRecorderUtility completed with error %d"),iError );