os/mm/mmlibs/mmfw/tsrc/mmfunittest/DevSoundTest/CIPlugins/src/gettimestampstestdevice.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
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".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 //
    15 
    16 #include <mmf/server/mmfswcodecwrappercustominterfacesuids.hrh>
    17 #include "gettimestampstestdevice.h"
    18 #include "cidefine.h"
    19 
    20 /*****************************************************************************/
    21 // Implementation
    22 
    23 CMMFHwDevice* CGetTimestampsTestDevice::NewL()
    24 	{
    25 	CGetTimestampsTestDevice* self = new(ELeave) CGetTimestampsTestDevice();
    26 	CleanupStack::PushL(self);
    27 	self->ConstructL();
    28 	CleanupStack::Pop(self);
    29 	return self;
    30 	}
    31 
    32 /*****************************************************************************/
    33 CGetTimestampsTestDevice::~CGetTimestampsTestDevice()
    34 	{
    35 	}
    36 
    37 /*****************************************************************************/
    38 CGetTimestampsTestDevice::CGetTimestampsTestDevice()
    39 	{
    40 	}
    41 
    42 /*****************************************************************************/
    43 void CGetTimestampsTestDevice::ConstructL()
    44 	{
    45 	}
    46 	
    47 /*****************************************************************************/
    48 TInt CGetTimestampsTestDevice::Start(TDeviceFunc /*aFuncCmd*/, TDeviceFlow /*aFlowCmd*/) 
    49 	{
    50 	return 0;
    51 	}
    52 
    53 /*****************************************************************************/
    54 TInt CGetTimestampsTestDevice::Stop()
    55 	{
    56 	return 0;
    57 	}
    58 	
    59 /*****************************************************************************/
    60 TInt CGetTimestampsTestDevice::Pause()
    61 	{
    62 	return 0;
    63 	}
    64 
    65 /*****************************************************************************/		
    66 TInt CGetTimestampsTestDevice::Init(THwDeviceInitParams& /*aDevInfo*/)
    67 	{
    68 	return 0;
    69 	}
    70 	
    71 /*****************************************************************************/	
    72 TAny* CGetTimestampsTestDevice::CustomInterface(TUid aInterfaceId)
    73 	{
    74 	MMMFGetTimestamps* interface = NULL;
    75 
    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))
    81 		{
    82 		interface = this;
    83 		}	
    84 
    85 	return interface;
    86 	}
    87 
    88 /*****************************************************************************/
    89 TInt CGetTimestampsTestDevice::ThisHwBufferFilled(CMMFBuffer& /*aFillBufferPtr*/)
    90 	{
    91 	return 0;
    92 	}
    93 	
    94 /*****************************************************************************/	
    95 TInt CGetTimestampsTestDevice::ThisHwBufferEmptied(CMMFBuffer& /*aEmptyBufferPtr*/)
    96 	{
    97 	return 0;
    98 	}
    99 	
   100 /*****************************************************************************/	
   101 TInt CGetTimestampsTestDevice::SetConfig(TTaskConfig& /*aConfig*/)
   102 	{
   103 	return 0;
   104 	}
   105 	
   106 /*****************************************************************************/	
   107 TInt CGetTimestampsTestDevice::StopAndDeleteCodec()
   108 	{
   109 	return 0;
   110 	}
   111 	
   112 /*****************************************************************************/
   113 TInt CGetTimestampsTestDevice::DeleteCodec()
   114 	{
   115 	return 0;
   116 	}
   117 
   118 /*****************************************************************************/
   119 CMMFSwCodec& CGetTimestampsTestDevice::Codec()
   120 	{
   121 	return *iCodec;
   122 	}
   123 
   124 /*****************************************************************************/
   125 TInt CGetTimestampsTestDevice::MmgtSetRecordSystemTimestampsEnabled(TBool aEnable)
   126 	{
   127 	TRAPD(err, DoWriteToFileL(aEnable));
   128 	return err;
   129 	}
   130 
   131 TInt CGetTimestampsTestDevice::MmgtGetSystemTimestampForBuffer(const TTimeIntervalMicroSeconds& aBufferPosition,
   132 																TTime& aTimestamp) const
   133 	{
   134 	// Expected position is...
   135 	TTimeIntervalMicroSeconds expectedPos = TTimeIntervalMicroSeconds(KTimestampPosition);
   136 	if (aBufferPosition == expectedPos)
   137 		{
   138 		// ...found so return the expected value.
   139 		aTimestamp = KTimestampValue;
   140 		return KErrNone;
   141 		}
   142 	else
   143 		{
   144 		return KErrArgument;
   145 		}
   146 	}
   147 
   148 void CGetTimestampsTestDevice::DoWriteToFileL(TBool aEnable)
   149 	{
   150 	RFs fs;
   151 	CleanupClosePushL(fs);
   152 	User::LeaveIfError(fs.Connect());
   153 	
   154 	RFile file;
   155 	CleanupClosePushL(file);
   156 	
   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
   164 	}