Update contrib.
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 "OpenFileByHandle1211.h"
24 CTestMmfAclntOpenFile1211::CTestMmfAclntOpenFile1211(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 CTestMmfAclntOpenFile1211* CTestMmfAclntOpenFile1211::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, const TTestFormat aFormat, const TBool aCreateFile)
40 CTestMmfAclntOpenFile1211* self = new (ELeave) CTestMmfAclntOpenFile1211(aTestName,aSectName,aKeyName,aFormat,aCreateFile);
44 CTestMmfAclntOpenFile1211* CTestMmfAclntOpenFile1211::NewLC(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, const TTestFormat aFormat, const TBool aCreateFile)
46 CTestMmfAclntOpenFile1211* self = CTestMmfAclntOpenFile1211::NewLC(aTestName,aSectName,aKeyName,aFormat,aCreateFile);
47 CleanupStack::PushL(self);
51 void CTestMmfAclntOpenFile1211::MoscoStateChangeEvent(CBase* /*aObject*/, TInt /*aPreviousState*/, TInt /*aCurrentState*/, TInt aErrorCode)
54 INFO_PRINTF1( _L("CTestMmfAclntOpenFile1211 : MMdaObjectStateChangeObserver Callback for CMdaAudioRecorderUtility complete"));
55 INFO_PRINTF2( _L("iError %d "), iError);
57 CActiveScheduler::Stop();
60 // Audio utility callbacks
61 void CTestMmfAclntOpenFile1211::MapcInitComplete(TInt aError, const TTimeIntervalMicroSeconds& /*aDuration*/)
64 CActiveScheduler::Stop();
67 void CTestMmfAclntOpenFile1211::MapcPlayComplete(TInt aError)
70 CActiveScheduler::Stop();
73 // Audio output stream callbacks
74 void CTestMmfAclntOpenFile1211::MaoscOpenComplete(TInt aError)
77 CActiveScheduler::Stop();
80 void CTestMmfAclntOpenFile1211::MaoscBufferCopied(TInt aError, const TDesC8& /*aBuffer*/)
83 CActiveScheduler::Stop();
86 void CTestMmfAclntOpenFile1211::MaoscPlayComplete(TInt aError)
89 CActiveScheduler::Stop();
93 TVerdict CTestMmfAclntOpenFile1211::DoTestStepPreambleL()
95 SetupFormatL(iTestFormat);
97 return CTestMmfAclntStep::DoTestStepPreambleL();
101 * Open a file based clip and record
103 TVerdict CTestMmfAclntOpenFile1211::DoTestStepL()
105 return( PerformTestStepL() );
109 * TVerdict CTestMmfAclntOpenFile1211::PerformTestStepL()
112 TVerdict CTestMmfAclntOpenFile1211::PerformTestStepL()
114 INFO_PRINTF1( _L("TestRecorder : Record File"));
115 TVerdict ret = EFail;
116 iError = KErrTimedOut;
121 User::LeaveIfError(fs.Connect());
122 CleanupClosePushL(fs);
123 User::LeaveIfError(fs.ShareProtected());
126 if(!GetStringFromConfig(iSectName, iKeyName, filename))
128 return EInconclusive;
131 CMdaAudioRecorderUtility* recUtil = CMdaAudioRecorderUtility::NewL(*this);
132 CleanupStack::PushL(recUtil);
134 User::LeaveIfError(file.Replace(fs,filename,EFileWrite));
135 CleanupClosePushL(file);
137 recUtil->OpenFileL(file);
139 INFO_PRINTF1( _L("Initialise CMdaAudioRecorderUtility"));
140 CActiveScheduler::Start();
142 if(iError == KErrNone)
144 iError = KErrTimedOut;
146 INFO_PRINTF1( _L("Record CMdaAudioRecorderUtility"));
147 CActiveScheduler::Start(); // open -> record
153 CleanupStack::PopAndDestroy(2, recUtil); // file, recUtil
157 if (iError == KErrNone)
160 CMdaAudioPlayerUtility* playUtil = CMdaAudioPlayerUtility::NewL(*this);
161 CleanupStack::PushL(playUtil);
162 TRAPD(err, playUtil->OpenFileL(filename));
165 INFO_PRINTF2(_L("Error opening file for playback err = %d"), err);
168 CActiveScheduler::Start();
169 if (iError != KErrNone)
171 INFO_PRINTF2(_L("Error opening file for playback iError = %d"), iError);
175 CActiveScheduler::Start();
177 CleanupStack::PopAndDestroy(playUtil);
179 if (iError != KErrNone)
181 INFO_PRINTF2(_L("Error during playback of recorded file iError=%d"), iError);
187 if( iError == KErrNotSupported )
193 if( iError == KErrNone )
197 User::LeaveIfError(file.Open(fs,filename,EFileRead));
198 CleanupClosePushL(file);
199 User::LeaveIfError(file.Size(size));
205 CleanupStack::PopAndDestroy(); //file
208 CleanupStack::PopAndDestroy(); // fs
210 ERR_PRINTF2( _L("CMdaAudioRecorderUtility completed with error %d"),iError );
211 User::After(KOneSecond);