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 <mmf/plugin/mmfcontrollerimplementationuids.hrh>
18 #include "TestPlayerUtils.h"
19 #include "OpenFileByHandle7905.h"
24 CTestMmfAclntOpenFile7905::CTestMmfAclntOpenFile7905(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 CTestMmfAclntOpenFile7905* CTestMmfAclntOpenFile7905::NewL(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, const TTestFormat aFormat, const TBool aCreateFile)
40 CTestMmfAclntOpenFile7905* self = new (ELeave) CTestMmfAclntOpenFile7905(aTestName,aSectName,aKeyName,aFormat,aCreateFile);
44 CTestMmfAclntOpenFile7905* CTestMmfAclntOpenFile7905::NewLC(const TDesC& aTestName, const TDesC& aSectName,const TDesC& aKeyName, const TTestFormat aFormat, const TBool aCreateFile)
46 CTestMmfAclntOpenFile7905* self = CTestMmfAclntOpenFile7905::NewLC(aTestName,aSectName,aKeyName,aFormat,aCreateFile);
47 CleanupStack::PushL(self);
51 void CTestMmfAclntOpenFile7905::MoscoStateChangeEvent(CBase* /*aObject*/, TInt /*aPreviousState*/, TInt /*aCurrentState*/, TInt aErrorCode)
54 INFO_PRINTF1( _L("CTestMmfAclntOpenFile7905 : MMdaObjectStateChangeObserver Callback for CMdaAudioRecorderUtility complete"));
55 INFO_PRINTF2( _L("iError %d "), iError);
57 CActiveScheduler::Stop();
60 // Audio utility callbacks
61 void CTestMmfAclntOpenFile7905::MapcInitComplete(TInt aError, const TTimeIntervalMicroSeconds& /*aDuration*/)
64 CActiveScheduler::Stop();
67 void CTestMmfAclntOpenFile7905::MapcPlayComplete(TInt aError)
70 CActiveScheduler::Stop();
73 // Audio output stream callbacks
74 void CTestMmfAclntOpenFile7905::MaoscOpenComplete(TInt aError)
77 CActiveScheduler::Stop();
80 void CTestMmfAclntOpenFile7905::MaoscBufferCopied(TInt aError, const TDesC8& /*aBuffer*/)
83 CActiveScheduler::Stop();
86 void CTestMmfAclntOpenFile7905::MaoscPlayComplete(TInt aError)
89 CActiveScheduler::Stop();
93 TVerdict CTestMmfAclntOpenFile7905::DoTestStepPreambleL()
97 SetupFormatL(iTestFormat);
99 if((ret == EInconclusive) || (ret == EFail))
102 return CTestMmfAclntStep::DoTestStepPreambleL();
106 * Open a file based clip and record
108 #define KInvalidAudioController 0xA0A0A0A0
110 TVerdict CTestMmfAclntOpenFile7905::DoTestStepL()
112 INFO_PRINTF1( _L("TestRecorder : Record File"));
113 TVerdict ret = EFail;
114 iError = KErrTimedOut;
119 User::LeaveIfError(fs.Connect());
120 CleanupClosePushL(fs);
121 User::LeaveIfError(fs.ShareProtected());
124 if(!GetStringFromConfig(iSectName, iKeyName, filename))
126 return EInconclusive;
129 CMdaAudioRecorderUtility* recUtil = CMdaAudioRecorderUtility::NewL(*this);
130 CleanupStack::PushL(recUtil);
132 TUid invalidAudioController;
133 invalidAudioController.iUid = KInvalidAudioController;
135 User::LeaveIfError(file.Replace(fs,filename,EFileWrite));
136 CleanupClosePushL(file);
138 recUtil->OpenFileL(file, invalidAudioController, KNullUid, KNullUid, KFourCCNULL);
140 INFO_PRINTF1( _L("Initialise CMdaAudioRecorderUtility"));
141 CActiveScheduler::Start();
143 if( iError == KErrNotFound )
148 if(iError == KErrNone)
150 iError = KErrTimedOut;
152 INFO_PRINTF1( _L("Record CMdaAudioRecorderUtility"));
153 CActiveScheduler::Start(); // open -> record
155 User::After(KFiveSeconds);
159 CleanupStack::PopAndDestroy(2, recUtil);
163 if (iError == KErrNone)
165 if (filename.Right(4).Compare(_L(".wav"))==0)
168 CMdaAudioPlayerUtility* playUtil = CMdaAudioPlayerUtility::NewL(*this);
169 CleanupStack::PushL(playUtil);
170 TRAPD(err, playUtil->OpenFileL(filename));
173 INFO_PRINTF2(_L("Error opening file for playback err = %d"), err);
176 CActiveScheduler::Start();
177 if (iError != KErrNone)
179 INFO_PRINTF2(_L("Error opening file for playback iError = %d"), iError);
184 CActiveScheduler::Start();
186 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);