os/mm/mmlibs/mmfw/tsrc/mmfunittest/DevSoundTest/CIPlugins/src/bufferframesconfigtestdevice.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 "bufferframesconfigtestdevice.h"
    18 #include "cidefine.h"
    19 
    20 /*****************************************************************************/
    21 // Implementation
    22 
    23 CMMFHwDevice* CBufferFramesConfigTestDevice::NewL()
    24 	{
    25 	CBufferFramesConfigTestDevice* self = new(ELeave) CBufferFramesConfigTestDevice();
    26 	CleanupStack::PushL(self);
    27 	self->ConstructL();
    28 	CleanupStack::Pop(self);
    29 	return self;
    30 	}
    31 
    32 /*****************************************************************************/
    33 CBufferFramesConfigTestDevice::~CBufferFramesConfigTestDevice()
    34 	{
    35 	}
    36 
    37 /*****************************************************************************/
    38 CBufferFramesConfigTestDevice::CBufferFramesConfigTestDevice()
    39 	{
    40 	}
    41 
    42 /*****************************************************************************/
    43 void CBufferFramesConfigTestDevice::ConstructL()
    44 	{
    45 	}
    46 	
    47 /*****************************************************************************/
    48 TInt CBufferFramesConfigTestDevice::Start(TDeviceFunc /*aFuncCmd*/, TDeviceFlow /*aFlowCmd*/) 
    49 	{
    50 	return 0;
    51 	}
    52 
    53 /*****************************************************************************/
    54 TInt CBufferFramesConfigTestDevice::Stop()
    55 	{
    56 	return 0;
    57 	}
    58 	
    59 /*****************************************************************************/
    60 TInt CBufferFramesConfigTestDevice::Pause()
    61 	{
    62 	return 0;
    63 	}
    64 
    65 /*****************************************************************************/		
    66 TInt CBufferFramesConfigTestDevice::Init(THwDeviceInitParams& /*aDevInfo*/)
    67 	{
    68 	return 0;
    69 	}
    70 	
    71 /*****************************************************************************/	
    72 TAny* CBufferFramesConfigTestDevice::CustomInterface(TUid aInterfaceId)
    73 	{
    74 	MMMFBufferFramesConfig* interface = NULL;
    75 
    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))
    81 		{
    82 		interface = this;
    83 		}
    84 		
    85 	return interface;
    86 	}
    87 
    88 /*****************************************************************************/
    89 TInt CBufferFramesConfigTestDevice::ThisHwBufferFilled(CMMFBuffer& /*aFillBufferPtr*/)
    90 	{
    91 	return 0;
    92 	}
    93 	
    94 /*****************************************************************************/	
    95 TInt CBufferFramesConfigTestDevice::ThisHwBufferEmptied(CMMFBuffer& /*aEmptyBufferPtr*/)
    96 	{
    97 	return 0;
    98 	}
    99 	
   100 /*****************************************************************************/	
   101 TInt CBufferFramesConfigTestDevice::SetConfig(TTaskConfig& /*aConfig*/)
   102 	{
   103 	return 0;
   104 	}
   105 	
   106 /*****************************************************************************/	
   107 TInt CBufferFramesConfigTestDevice::StopAndDeleteCodec()
   108 	{
   109 	return 0;
   110 	}
   111 	
   112 /*****************************************************************************/
   113 TInt CBufferFramesConfigTestDevice::DeleteCodec()
   114 	{
   115 	return 0;
   116 	}
   117 
   118 /*****************************************************************************/
   119 CMMFSwCodec& CBufferFramesConfigTestDevice::Codec()
   120 	{
   121 	return *iCodec;
   122 	}
   123 
   124 /*****************************************************************************/
   125 TInt CBufferFramesConfigTestDevice::MmbfcSetNumberOfFramesPerInputBuffer(TInt aFrameCount, TInt aSamplesPerFrame)
   126 	{
   127 	TRAPD(err, DoWriteToFileL(aFrameCount, aSamplesPerFrame));
   128 	return err;
   129 	}
   130 
   131 TInt CBufferFramesConfigTestDevice::MmbfcSetNumberOfFramesPerOutputBuffer(TInt aFrameCount, TInt aSamplesPerFrame)
   132 	{
   133 	TRAPD(err, DoWriteToFileL(aFrameCount, aSamplesPerFrame));
   134 	return err;
   135 	}
   136 
   137 void CBufferFramesConfigTestDevice::DoWriteToFileL(TInt aFrameCount, TInt aSamplesPerFrame)															
   138 	{
   139 	RFs fs;
   140 	CleanupClosePushL(fs);
   141 	User::LeaveIfError(fs.Connect());
   142 	
   143 	RFile file;
   144 	CleanupClosePushL(file);
   145 	
   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
   155 	}
   156 
   157