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 <mmf/plugin/mmfcontrollerimplementationuids.hrh>
18 #include <mmf/plugin/mmfcontrollerimplementationuids.hrh>
19 #include "TestPlayerUtils.h"
20 #include "OpenFileByHandle7904.h"
25 CTestMmfAclntOpenFile7904::CTestMmfAclntOpenFile7904(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, const TTestFormat aFormat, const TBool aCreateFile)
28 // store the name of this test case
29 // this is the name that is used by the script file
30 // Each test step initialises it's own name
31 iTestStepName = aTestName;
32 iHeapSize = 200000; // playback part of test loads whole sound file into buffer, so need large heap
33 iSectName = aSectName;
35 iTestFormat = aFormat;
36 iCreateFile = aCreateFile;
39 CTestMmfAclntOpenFile7904* CTestMmfAclntOpenFile7904::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, const TTestFormat aFormat, const TBool aCreateFile)
41 CTestMmfAclntOpenFile7904* self = new (ELeave) CTestMmfAclntOpenFile7904(aTestName,aSectName,aKeyName,aFormat,aCreateFile);
45 CTestMmfAclntOpenFile7904* CTestMmfAclntOpenFile7904::NewLC(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, const TTestFormat aFormat, const TBool aCreateFile)
47 CTestMmfAclntOpenFile7904* self = CTestMmfAclntOpenFile7904::NewLC(aTestName,aSectName,aKeyName,aFormat,aCreateFile);
48 CleanupStack::PushL(self);
52 void CTestMmfAclntOpenFile7904::MoscoStateChangeEvent(CBase* /*aObject*/, TInt /*aPreviousState*/, TInt /*aCurrentState*/, TInt aErrorCode)
55 INFO_PRINTF1( _L("CTestMmfAclntOpenFile7904 : MMdaObjectStateChangeObserver Callback for CMdaAudioRecorderUtility complete"));
56 INFO_PRINTF2( _L("iError %d "), iError);
58 CActiveScheduler::Stop();
61 // Audio utility callbacks
62 void CTestMmfAclntOpenFile7904::MapcInitComplete(TInt aError, const TTimeIntervalMicroSeconds& /*aDuration*/)
65 CActiveScheduler::Stop();
68 void CTestMmfAclntOpenFile7904::MapcPlayComplete(TInt aError)
71 CActiveScheduler::Stop();
74 // Audio output stream callbacks
75 void CTestMmfAclntOpenFile7904::MaoscOpenComplete(TInt aError)
78 CActiveScheduler::Stop();
81 void CTestMmfAclntOpenFile7904::MaoscBufferCopied(TInt aError, const TDesC8& /*aBuffer*/)
84 CActiveScheduler::Stop();
87 void CTestMmfAclntOpenFile7904::MaoscPlayComplete(TInt aError)
90 CActiveScheduler::Stop();
94 TVerdict CTestMmfAclntOpenFile7904::DoTestStepPreambleL()
98 SetupFormatL(iTestFormat);
100 if((ret == EInconclusive) || (ret == EFail))
103 return CTestMmfAclntStep::DoTestStepPreambleL();
107 * Open a file based clip and record
109 TVerdict CTestMmfAclntOpenFile7904::DoTestStepL()
111 INFO_PRINTF1( _L("TestRecorder : Record File"));
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))
125 return EInconclusive;
128 CMdaAudioRecorderUtility* recUtil = CMdaAudioRecorderUtility::NewL(*this);
129 CleanupStack::PushL(recUtil);
131 TUid audioController = TUid::Uid(KMmfUidControllerAudio);
133 User::LeaveIfError(file.Replace(fs,filename,EFileWrite));
134 CleanupClosePushL(file);
136 recUtil->OpenFileL(file, audioController, KNullUid, KNullUid, KFourCCNULL);
138 INFO_PRINTF1( _L("Initialise CMdaAudioRecorderUtility"));
139 CActiveScheduler::Start();
141 if(iError == KErrNone)
143 iError = KErrTimedOut;
145 INFO_PRINTF1( _L("Record CMdaAudioRecorderUtility"));
146 CActiveScheduler::Start(); // open -> record
152 CleanupStack::PopAndDestroy(2, recUtil); // file, recUtil
156 if (iError == KErrNone)
158 if (filename.Right(4).Compare(_L(".wav"))==0)
161 CMdaAudioPlayerUtility* playUtil = CMdaAudioPlayerUtility::NewL(*this);
162 CleanupStack::PushL(playUtil);
163 TRAPD(err, playUtil->OpenFileL(filename));
166 INFO_PRINTF2(_L("Error opening file for playback err = %d"), err);
169 CActiveScheduler::Start();
170 if (iError != KErrNone)
172 INFO_PRINTF2(_L("Error opening file for playback iError = %d"), iError);
176 CActiveScheduler::Start();
177 CleanupStack::PopAndDestroy(playUtil);
178 if (iError != KErrNone)
180 INFO_PRINTF2(_L("Error during playback of recorded file iError=%d"), iError);
186 if( iError == KErrNone )
190 User::LeaveIfError(file.Open(fs,filename,EFileRead));
191 CleanupClosePushL(file);
192 User::LeaveIfError(file.Size(size));
198 CleanupStack::PopAndDestroy(); //file
201 CleanupStack::PopAndDestroy(&fs); // fs
203 ERR_PRINTF2( _L("CMdaAudioRecorderUtility completed with error %d"),iError );
204 User::After(KOneSecond);