os/mm/mmlibs/mmfw/tsrc/mmfintegrationtest/SDevSound/SDSCapTestServer/src/CapTestStep0010.cpp
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.
18 #include "CapTestStep0010.h"
20 CSecDevSndTS0010* CSecDevSndTS0010::NewL()
22 CSecDevSndTS0010* self = new (ELeave) CSecDevSndTS0010;
23 CleanupStack::PushL(self);
29 void CSecDevSndTS0010::ConstructL()
34 void CSecDevSndTS0010::StartProcessing(TRequestStatus& aStatus)
37 if ( (iVerdict = DoTestStepPreambleL() ) == EPass)
39 // only do this when DoTestStepPreambleL() pass, if it fails, it means
40 // devsound is not ready for play data yet.
41 iVerdict = DoRecordData();
45 CSecDevSndTS0010::~CSecDevSndTS0010()
49 /******************************************************************************
53 *****************************************************************************/
62 TVerdict CSecDevSndTS0010::DoRecordData()
65 TVerdict initOK = TestInitialize(EMMFStateRecording);
71 TestSetPriority(KDevSoundPriorityHigh);
73 initOK = TestRecordInit();
79 User::RequestComplete(iStatus, KErrNone);
81 TestSetVolume(iMMFDevSound->MaxVolume() / 2);
83 TFileName aFilename = _L("C:\\rectest1.wav");
85 return RecordDataFile(aFilename);
97 TVerdict CSecDevSndTS0010::RecordDataFile(TDesC& aFilename)
99 TInt initOK = KErrNone;
100 TInt aNumSamples = 1;
105 TInt err = fs.Connect();
108 // Could not connect to Filesystem.
109 return EInconclusive;
112 //Create output directory if it doesn't already exist
113 // fs.MkDir(_L("C:\\TSU_MMF_DEVSOUND_SUITE\\Output\\"));
115 err = file.Replace(fs, aFilename, EFileWrite);
120 return EInconclusive;
124 TInt vol = iMMFDevSound->MaxVolume(); // Hacked... Fix this...
127 TInt bufferCount = 0;
128 while (bufferCount < aNumSamples && initOK == KErrNone && iCallbackError == KErrNone)
131 initOK = TestRecordData();
133 //Write buffer to file
134 CMMFDataBuffer* buffer = STATIC_CAST (CMMFDataBuffer*, iBuffer);
135 file.Write(buffer->Data());
143 if (initOK != KErrNone)
148 if (aNumSamples >= 0 && bufferCount != aNumSamples)
164 TVerdict CSecDevSndTS0010::TestInitialize(TMMFState aMode)
166 TFourCC pcm16(KMMFFourCCCodePCM16); //default to pcm16 data type
168 iCallbackError = KErrNone;
169 iExpectedValue = KErrNone;
172 TRAPD(err, iMMFDevSound->InitializeL(*this, pcm16, aMode));
175 return EInconclusive;
179 CActiveScheduler::Start();
181 if (iCallbackError != iExpectedValue)
185 if (iCallbackArray[EInitComplete] != 1)
199 TVerdict CSecDevSndTS0010::TestRecordInit()
203 //get buffer from devsound
204 TRAPD(err, iMMFDevSound->RecordInitL());
205 // Start the active scheduler and catch the callback
206 CActiveScheduler::Start();
213 if (iCallbackArray[EBuffToEmpty] != 1)
217 TInt tot = GetCallbackTotal();
232 TVerdict CSecDevSndTS0010::TestRecordData()
236 iMMFDevSound->RecordData();
237 // Start the active scheduler and catch the callback
238 CActiveScheduler::Start();
240 if (iCallbackArray[EBuffToEmpty] != 1)
242 if (iCallbackArray[EBuffToEmpty] == 0 && iCallbackArray[ERecError] == 1)
244 // DevSound RecordError was called 1 time.
252 TInt tot = GetCallbackTotal();
260 /******************************************************************************
262 * DevSound mixin methods
264 *****************************************************************************/
272 void CSecDevSndTS0010::BufferToBeEmptied (CMMFBuffer* aBuffer)
277 iCallbackError = KErrNone;
281 iCallbackError = KErrNotFound;
283 iCallbackArray[EBuffToEmpty] ++;
284 CActiveScheduler::Stop();
293 void CSecDevSndTS0010::RecordError (TInt aError)
295 if( aError != KErrInUse )
297 // should get interrupted by client
300 iCallbackError = aError;
301 iCallbackArray[ERecError] ++;
302 CActiveScheduler::Stop();