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>
17 #include "TestPlayerUtils.h"
18 #include "OpenFileByHandle7906.h"
25 CTestMmfAclntOpenFile7906::CTestMmfAclntOpenFile7906(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 CTestMmfAclntOpenFile7906* CTestMmfAclntOpenFile7906::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, const TTestFormat aFormat, const TBool aCreateFile)
41 CTestMmfAclntOpenFile7906* self = new (ELeave) CTestMmfAclntOpenFile7906(aTestName,aSectName,aKeyName,aFormat,aCreateFile);
45 CTestMmfAclntOpenFile7906* CTestMmfAclntOpenFile7906::NewLC(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, const TTestFormat aFormat, const TBool aCreateFile)
47 CTestMmfAclntOpenFile7906* self = CTestMmfAclntOpenFile7906::NewLC(aTestName,aSectName,aKeyName,aFormat,aCreateFile);
48 CleanupStack::PushL(self);
52 void CTestMmfAclntOpenFile7906::MoscoStateChangeEvent(CBase* /*aObject*/, TInt /*aPreviousState*/, TInt /*aCurrentState*/, TInt aErrorCode)
55 INFO_PRINTF1( _L("CTestMmfAclntOpenFile7906 : MMdaObjectStateChangeObserver Callback for CMdaAudioRecorderUtility complete"));
56 INFO_PRINTF2( _L("iError %d "), iError);
58 CActiveScheduler::Stop();
61 // Audio utility callbacks
62 void CTestMmfAclntOpenFile7906::MapcInitComplete(TInt aError, const TTimeIntervalMicroSeconds& /*aDuration*/)
65 CActiveScheduler::Stop();
68 void CTestMmfAclntOpenFile7906::MapcPlayComplete(TInt aError)
71 CActiveScheduler::Stop();
74 // Audio output stream callbacks
75 void CTestMmfAclntOpenFile7906::MaoscOpenComplete(TInt aError)
78 CActiveScheduler::Stop();
81 void CTestMmfAclntOpenFile7906::MaoscBufferCopied(TInt aError, const TDesC8& /*aBuffer*/)
84 CActiveScheduler::Stop();
87 void CTestMmfAclntOpenFile7906::MaoscPlayComplete(TInt aError)
90 CActiveScheduler::Stop();
94 TVerdict CTestMmfAclntOpenFile7906::DoTestStepPreambleL()
98 SetupFormatL(iTestFormat);
100 if((ret == EInconclusive) || (ret == EFail))
105 return CTestMmfAclntStep::DoTestStepPreambleL();
109 * Open a file based clip and record
111 TVerdict CTestMmfAclntOpenFile7906::DoTestStepL()
113 INFO_PRINTF1( _L("TestRecorder : Record File"));
114 TVerdict ret = EFail;
115 iError = KErrTimedOut;
120 User::LeaveIfError(fs.Connect());
121 CleanupClosePushL(fs);
122 User::LeaveIfError(fs.ShareProtected());
125 if(!GetStringFromConfig(iSectName, iKeyName, filename))
127 return EInconclusive;
130 CMdaAudioRecorderUtility* recUtil = CMdaAudioRecorderUtility::NewL(*this);
131 CleanupStack::PushL(recUtil);
133 TUid audioController = TUid::Uid(KMmfUidControllerAudio);
135 TFourCC invalidDataType(0xAA, 0xAA, 0xAA, 0xAA);
137 User::LeaveIfError(file.Replace(fs,filename,EFileWrite));
138 CleanupClosePushL(file);
140 recUtil->OpenFileL(file, audioController, KNullUid, KNullUid, invalidDataType);
142 INFO_PRINTF1( _L("Initialise CMdaAudioRecorderUtility"));
143 CActiveScheduler::Start();
145 if( iError == KErrNotSupported )
150 if(iError == KErrNone)
152 iError = KErrTimedOut;
154 INFO_PRINTF1( _L("Record CMdaAudioRecorderUtility"));
155 CActiveScheduler::Start(); // open -> record
162 CleanupStack::PopAndDestroy(2, recUtil); // file, recUtil
166 if (iError == KErrNone)
168 if (filename.Right(4).Compare(_L(".wav"))==0)
171 CMdaAudioPlayerUtility* playUtil = CMdaAudioPlayerUtility::NewL(*this);
172 CleanupStack::PushL(playUtil);
173 TRAPD(err, playUtil->OpenFileL(filename));
176 INFO_PRINTF2(_L("Error opening file for playback err = %d"), err);
179 CActiveScheduler::Start();
180 if (iError != KErrNone)
182 INFO_PRINTF2(_L("Error opening file for playback iError = %d"), iError);
186 CActiveScheduler::Start();
187 CleanupStack::PopAndDestroy(playUtil);
188 if (iError != KErrNone)
190 INFO_PRINTF2(_L("Error during playback of recorded file iError=%d"), iError);
196 if( iError == KErrNone )
200 User::LeaveIfError(file.Open(fs,filename,EFileRead));
201 CleanupClosePushL(file);
202 User::LeaveIfError(file.Size(size));
208 CleanupStack::PopAndDestroy(); //file
211 CleanupStack::PopAndDestroy(); // fs
213 ERR_PRINTF2( _L("CMdaAudioRecorderUtility completed with error %d"),iError );
214 User::After(KOneSecond);