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.
sl@0
     1
// Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
//
sl@0
    15
sl@0
    16
#include <mmf/server/mmfswcodecwrappercustominterfacesuids.hrh>
sl@0
    17
#include "bufferframesconfigtestdevice.h"
sl@0
    18
#include "cidefine.h"
sl@0
    19
sl@0
    20
/*****************************************************************************/
sl@0
    21
// Implementation
sl@0
    22
sl@0
    23
CMMFHwDevice* CBufferFramesConfigTestDevice::NewL()
sl@0
    24
	{
sl@0
    25
	CBufferFramesConfigTestDevice* self = new(ELeave) CBufferFramesConfigTestDevice();
sl@0
    26
	CleanupStack::PushL(self);
sl@0
    27
	self->ConstructL();
sl@0
    28
	CleanupStack::Pop(self);
sl@0
    29
	return self;
sl@0
    30
	}
sl@0
    31
sl@0
    32
/*****************************************************************************/
sl@0
    33
CBufferFramesConfigTestDevice::~CBufferFramesConfigTestDevice()
sl@0
    34
	{
sl@0
    35
	}
sl@0
    36
sl@0
    37
/*****************************************************************************/
sl@0
    38
CBufferFramesConfigTestDevice::CBufferFramesConfigTestDevice()
sl@0
    39
	{
sl@0
    40
	}
sl@0
    41
sl@0
    42
/*****************************************************************************/
sl@0
    43
void CBufferFramesConfigTestDevice::ConstructL()
sl@0
    44
	{
sl@0
    45
	}
sl@0
    46
	
sl@0
    47
/*****************************************************************************/
sl@0
    48
TInt CBufferFramesConfigTestDevice::Start(TDeviceFunc /*aFuncCmd*/, TDeviceFlow /*aFlowCmd*/) 
sl@0
    49
	{
sl@0
    50
	return 0;
sl@0
    51
	}
sl@0
    52
sl@0
    53
/*****************************************************************************/
sl@0
    54
TInt CBufferFramesConfigTestDevice::Stop()
sl@0
    55
	{
sl@0
    56
	return 0;
sl@0
    57
	}
sl@0
    58
	
sl@0
    59
/*****************************************************************************/
sl@0
    60
TInt CBufferFramesConfigTestDevice::Pause()
sl@0
    61
	{
sl@0
    62
	return 0;
sl@0
    63
	}
sl@0
    64
sl@0
    65
/*****************************************************************************/		
sl@0
    66
TInt CBufferFramesConfigTestDevice::Init(THwDeviceInitParams& /*aDevInfo*/)
sl@0
    67
	{
sl@0
    68
	return 0;
sl@0
    69
	}
sl@0
    70
	
sl@0
    71
/*****************************************************************************/	
sl@0
    72
TAny* CBufferFramesConfigTestDevice::CustomInterface(TUid aInterfaceId)
sl@0
    73
	{
sl@0
    74
	MMMFBufferFramesConfig* interface = NULL;
sl@0
    75
sl@0
    76
	// DevSound initialisation requires something to be returned for both of
sl@0
    77
	// these two uids: KMmfPlaySettingsCustomInterface, KMmfRecordSettingsCustomInterface
sl@0
    78
	if ((aInterfaceId == KUidBufferFramesConfig) || // This interface
sl@0
    79
		(aInterfaceId.iUid == KMmfPlaySettingsCustomInterface) ||
sl@0
    80
		(aInterfaceId.iUid == KMmfRecordSettingsCustomInterface))
sl@0
    81
		{
sl@0
    82
		interface = this;
sl@0
    83
		}
sl@0
    84
		
sl@0
    85
	return interface;
sl@0
    86
	}
sl@0
    87
sl@0
    88
/*****************************************************************************/
sl@0
    89
TInt CBufferFramesConfigTestDevice::ThisHwBufferFilled(CMMFBuffer& /*aFillBufferPtr*/)
sl@0
    90
	{
sl@0
    91
	return 0;
sl@0
    92
	}
sl@0
    93
	
sl@0
    94
/*****************************************************************************/	
sl@0
    95
TInt CBufferFramesConfigTestDevice::ThisHwBufferEmptied(CMMFBuffer& /*aEmptyBufferPtr*/)
sl@0
    96
	{
sl@0
    97
	return 0;
sl@0
    98
	}
sl@0
    99
	
sl@0
   100
/*****************************************************************************/	
sl@0
   101
TInt CBufferFramesConfigTestDevice::SetConfig(TTaskConfig& /*aConfig*/)
sl@0
   102
	{
sl@0
   103
	return 0;
sl@0
   104
	}
sl@0
   105
	
sl@0
   106
/*****************************************************************************/	
sl@0
   107
TInt CBufferFramesConfigTestDevice::StopAndDeleteCodec()
sl@0
   108
	{
sl@0
   109
	return 0;
sl@0
   110
	}
sl@0
   111
	
sl@0
   112
/*****************************************************************************/
sl@0
   113
TInt CBufferFramesConfigTestDevice::DeleteCodec()
sl@0
   114
	{
sl@0
   115
	return 0;
sl@0
   116
	}
sl@0
   117
sl@0
   118
/*****************************************************************************/
sl@0
   119
CMMFSwCodec& CBufferFramesConfigTestDevice::Codec()
sl@0
   120
	{
sl@0
   121
	return *iCodec;
sl@0
   122
	}
sl@0
   123
sl@0
   124
/*****************************************************************************/
sl@0
   125
TInt CBufferFramesConfigTestDevice::MmbfcSetNumberOfFramesPerInputBuffer(TInt aFrameCount, TInt aSamplesPerFrame)
sl@0
   126
	{
sl@0
   127
	TRAPD(err, DoWriteToFileL(aFrameCount, aSamplesPerFrame));
sl@0
   128
	return err;
sl@0
   129
	}
sl@0
   130
sl@0
   131
TInt CBufferFramesConfigTestDevice::MmbfcSetNumberOfFramesPerOutputBuffer(TInt aFrameCount, TInt aSamplesPerFrame)
sl@0
   132
	{
sl@0
   133
	TRAPD(err, DoWriteToFileL(aFrameCount, aSamplesPerFrame));
sl@0
   134
	return err;
sl@0
   135
	}
sl@0
   136
sl@0
   137
void CBufferFramesConfigTestDevice::DoWriteToFileL(TInt aFrameCount, TInt aSamplesPerFrame)															
sl@0
   138
	{
sl@0
   139
	RFs fs;
sl@0
   140
	CleanupClosePushL(fs);
sl@0
   141
	User::LeaveIfError(fs.Connect());
sl@0
   142
	
sl@0
   143
	RFile file;
sl@0
   144
	CleanupClosePushL(file);
sl@0
   145
	
sl@0
   146
	// File doesn't yet exist
sl@0
   147
	// It is the responsibility of the calling test function to delete the file after use
sl@0
   148
	User::LeaveIfError(file.Create(fs, KCITestFileName, EFileWrite));
sl@0
   149
	TBuf8<KMaxCITestFileTimeDataLength> outputBuf;
sl@0
   150
	outputBuf.Num(aFrameCount);
sl@0
   151
	outputBuf.Append(' ');
sl@0
   152
	outputBuf.AppendNum(aSamplesPerFrame);
sl@0
   153
	User::LeaveIfError(file.Write(outputBuf));
sl@0
   154
	CleanupStack::PopAndDestroy(2); // fs, file
sl@0
   155
	}
sl@0
   156
sl@0
   157