os/mm/mmlibs/mmfw/tsrc/mmfunittest/DevSoundTest/CIPlugins/src/bufferframesconfigtestdevice.cpp
First public contribution.
1 // Copyright (c) 2007-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/server/mmfswcodecwrappercustominterfacesuids.hrh>
17 #include "bufferframesconfigtestdevice.h"
20 /*****************************************************************************/
23 CMMFHwDevice* CBufferFramesConfigTestDevice::NewL()
25 CBufferFramesConfigTestDevice* self = new(ELeave) CBufferFramesConfigTestDevice();
26 CleanupStack::PushL(self);
28 CleanupStack::Pop(self);
32 /*****************************************************************************/
33 CBufferFramesConfigTestDevice::~CBufferFramesConfigTestDevice()
37 /*****************************************************************************/
38 CBufferFramesConfigTestDevice::CBufferFramesConfigTestDevice()
42 /*****************************************************************************/
43 void CBufferFramesConfigTestDevice::ConstructL()
47 /*****************************************************************************/
48 TInt CBufferFramesConfigTestDevice::Start(TDeviceFunc /*aFuncCmd*/, TDeviceFlow /*aFlowCmd*/)
53 /*****************************************************************************/
54 TInt CBufferFramesConfigTestDevice::Stop()
59 /*****************************************************************************/
60 TInt CBufferFramesConfigTestDevice::Pause()
65 /*****************************************************************************/
66 TInt CBufferFramesConfigTestDevice::Init(THwDeviceInitParams& /*aDevInfo*/)
71 /*****************************************************************************/
72 TAny* CBufferFramesConfigTestDevice::CustomInterface(TUid aInterfaceId)
74 MMMFBufferFramesConfig* interface = NULL;
76 // DevSound initialisation requires something to be returned for both of
77 // these two uids: KMmfPlaySettingsCustomInterface, KMmfRecordSettingsCustomInterface
78 if ((aInterfaceId == KUidBufferFramesConfig) || // This interface
79 (aInterfaceId.iUid == KMmfPlaySettingsCustomInterface) ||
80 (aInterfaceId.iUid == KMmfRecordSettingsCustomInterface))
88 /*****************************************************************************/
89 TInt CBufferFramesConfigTestDevice::ThisHwBufferFilled(CMMFBuffer& /*aFillBufferPtr*/)
94 /*****************************************************************************/
95 TInt CBufferFramesConfigTestDevice::ThisHwBufferEmptied(CMMFBuffer& /*aEmptyBufferPtr*/)
100 /*****************************************************************************/
101 TInt CBufferFramesConfigTestDevice::SetConfig(TTaskConfig& /*aConfig*/)
106 /*****************************************************************************/
107 TInt CBufferFramesConfigTestDevice::StopAndDeleteCodec()
112 /*****************************************************************************/
113 TInt CBufferFramesConfigTestDevice::DeleteCodec()
118 /*****************************************************************************/
119 CMMFSwCodec& CBufferFramesConfigTestDevice::Codec()
124 /*****************************************************************************/
125 TInt CBufferFramesConfigTestDevice::MmbfcSetNumberOfFramesPerInputBuffer(TInt aFrameCount, TInt aSamplesPerFrame)
127 TRAPD(err, DoWriteToFileL(aFrameCount, aSamplesPerFrame));
131 TInt CBufferFramesConfigTestDevice::MmbfcSetNumberOfFramesPerOutputBuffer(TInt aFrameCount, TInt aSamplesPerFrame)
133 TRAPD(err, DoWriteToFileL(aFrameCount, aSamplesPerFrame));
137 void CBufferFramesConfigTestDevice::DoWriteToFileL(TInt aFrameCount, TInt aSamplesPerFrame)
140 CleanupClosePushL(fs);
141 User::LeaveIfError(fs.Connect());
144 CleanupClosePushL(file);
146 // File doesn't yet exist
147 // It is the responsibility of the calling test function to delete the file after use
148 User::LeaveIfError(file.Create(fs, KCITestFileName, EFileWrite));
149 TBuf8<KMaxCITestFileTimeDataLength> outputBuf;
150 outputBuf.Num(aFrameCount);
151 outputBuf.Append(' ');
152 outputBuf.AppendNum(aSamplesPerFrame);
153 User::LeaveIfError(file.Write(outputBuf));
154 CleanupStack::PopAndDestroy(2); // fs, file