os/mm/mmlibs/mmfw/tsrc/mmfunittest/DevSoundTest/CIPlugins/src/gettimestampstestdevice.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 "gettimestampstestdevice.h"
20 /*****************************************************************************/
23 CMMFHwDevice* CGetTimestampsTestDevice::NewL()
25 CGetTimestampsTestDevice* self = new(ELeave) CGetTimestampsTestDevice();
26 CleanupStack::PushL(self);
28 CleanupStack::Pop(self);
32 /*****************************************************************************/
33 CGetTimestampsTestDevice::~CGetTimestampsTestDevice()
37 /*****************************************************************************/
38 CGetTimestampsTestDevice::CGetTimestampsTestDevice()
42 /*****************************************************************************/
43 void CGetTimestampsTestDevice::ConstructL()
47 /*****************************************************************************/
48 TInt CGetTimestampsTestDevice::Start(TDeviceFunc /*aFuncCmd*/, TDeviceFlow /*aFlowCmd*/)
53 /*****************************************************************************/
54 TInt CGetTimestampsTestDevice::Stop()
59 /*****************************************************************************/
60 TInt CGetTimestampsTestDevice::Pause()
65 /*****************************************************************************/
66 TInt CGetTimestampsTestDevice::Init(THwDeviceInitParams& /*aDevInfo*/)
71 /*****************************************************************************/
72 TAny* CGetTimestampsTestDevice::CustomInterface(TUid aInterfaceId)
74 MMMFGetTimestamps* interface = NULL;
76 // DevSound initialisation requires something to be returned for both of
77 // these two uids: KMmfPlaySettingsCustomInterface, KMmfRecordSettingsCustomInterface
78 if ((aInterfaceId == KUidGetTimestamps) || // This interface
79 (aInterfaceId.iUid == KMmfPlaySettingsCustomInterface) ||
80 (aInterfaceId.iUid == KMmfRecordSettingsCustomInterface))
88 /*****************************************************************************/
89 TInt CGetTimestampsTestDevice::ThisHwBufferFilled(CMMFBuffer& /*aFillBufferPtr*/)
94 /*****************************************************************************/
95 TInt CGetTimestampsTestDevice::ThisHwBufferEmptied(CMMFBuffer& /*aEmptyBufferPtr*/)
100 /*****************************************************************************/
101 TInt CGetTimestampsTestDevice::SetConfig(TTaskConfig& /*aConfig*/)
106 /*****************************************************************************/
107 TInt CGetTimestampsTestDevice::StopAndDeleteCodec()
112 /*****************************************************************************/
113 TInt CGetTimestampsTestDevice::DeleteCodec()
118 /*****************************************************************************/
119 CMMFSwCodec& CGetTimestampsTestDevice::Codec()
124 /*****************************************************************************/
125 TInt CGetTimestampsTestDevice::MmgtSetRecordSystemTimestampsEnabled(TBool aEnable)
127 TRAPD(err, DoWriteToFileL(aEnable));
131 TInt CGetTimestampsTestDevice::MmgtGetSystemTimestampForBuffer(const TTimeIntervalMicroSeconds& aBufferPosition,
132 TTime& aTimestamp) const
134 // Expected position is...
135 TTimeIntervalMicroSeconds expectedPos = TTimeIntervalMicroSeconds(KTimestampPosition);
136 if (aBufferPosition == expectedPos)
138 // ...found so return the expected value.
139 aTimestamp = KTimestampValue;
148 void CGetTimestampsTestDevice::DoWriteToFileL(TBool aEnable)
151 CleanupClosePushL(fs);
152 User::LeaveIfError(fs.Connect());
155 CleanupClosePushL(file);
157 // File doesn't yet exist
158 // It is the responsibility of the calling test function to delete the file after use
159 User::LeaveIfError(file.Create(fs, KCITestFileName, EFileWrite));
160 TBuf8<KMaxCITestFileDataLength> outputBuf;
161 outputBuf.Num(aEnable);
162 User::LeaveIfError(file.Write(outputBuf));
163 CleanupStack::PopAndDestroy(2); // fs, file