os/boardsupport/haitest/bspsvs/suite/bsp/sound/src/t_soundformatssupporteddata.cpp
Update contrib.
2 * Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of "Eclipse Public License v1.0"
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
22 This contains CT_SoundFormatsSupportedData
26 #include "t_soundformatssupporteddata.h"
27 #include "sound_util.h"
32 _LIT(KCmdDestructor, "~");
33 _LIT(KCmd_iMinRate_get, "imin_rate_get");
34 _LIT(KCmd_iMaxRate_get, "imax_rate_get");
35 _LIT(KCmd_iChannels_get, "ichannels_get");
36 _LIT(KCmd_iMinBufferSize_get, "imin_buffer_size_get");
37 _LIT(KCmd_iMaxBufferSize_get, "imax_buffer_size_get");
38 _LIT(KCmd_iMinVolume_get, "imin_volume_get");
39 _LIT(KCmd_iMaxVolume_get, "imax_volume_get");
40 _LIT(KCmd_iEncodings_get, "iencodings_get");
44 _LIT(KMinRateExpected, "min_rate_expected");
45 _LIT(KMaxRateExpected, "max_rate_expected");
46 _LIT(KChannelsExpected, "channels_expected");
47 _LIT(KMinBufferSizeExpected, "min_buffer_size_expected");
48 _LIT(KMaxBufferSizeExpected, "max_buffer_size_expected");
49 _LIT(KMinVolumeExpected, "min_volume_expected");
50 _LIT(KMaxVolumeExpected, "max_volume_expected");
51 _LIT(KEncodingsExpected, "encodings_expected");
54 _LIT(KLogNew, "New object created successfully");
55 _LIT(KLogNewError, "Error creating new object, error code=%d");
58 * Two phase constructor
60 CT_SoundFormatsSupportedData* CT_SoundFormatsSupportedData::NewL()
62 CT_SoundFormatsSupportedData* ret=new (ELeave) CT_SoundFormatsSupportedData();
63 CleanupStack::PushL(ret);
65 CleanupStack::Pop(ret);
70 * Constructor. First phase construction
72 CT_SoundFormatsSupportedData::CT_SoundFormatsSupportedData()
74 , iFormatsSupported(NULL)
79 * Second phase construction
81 void CT_SoundFormatsSupportedData::ConstructL()
88 CT_SoundFormatsSupportedData::~CT_SoundFormatsSupportedData()
94 * Helper for cleanup operation
96 void CT_SoundFormatsSupportedData::DoCleanup()
98 delete iFormatsSupported;
99 iFormatsSupported=NULL;
103 * Return a pointer to the object that the data wraps
105 * @return pointer to the object that the data wraps
107 TAny* CT_SoundFormatsSupportedData::GetObject()
109 return iFormatsSupported;
113 * Set the wrapped data object with new value
115 void CT_SoundFormatsSupportedData::SetObjectL(TAny* aAny)
118 iFormatsSupported=static_cast<RMdaDevSound::TSoundFormatsSupported*>(aAny);
122 * Clear the wrapped data object pointer w/o de-initialization
124 void CT_SoundFormatsSupportedData::DisownObjectL()
126 iFormatsSupported=NULL;
130 * Return static cleanup function
132 inline TCleanupOperation CT_SoundFormatsSupportedData::CleanupOperation()
134 return CleanupOperation;
138 * Static cleanup function
140 void CT_SoundFormatsSupportedData::CleanupOperation( TAny* aAny )
142 RMdaDevSound::TSoundFormatsSupported* format = static_cast<RMdaDevSound::TSoundFormatsSupported*> ( aAny );
147 * Process a command read from the ini file
149 * @param aDataWrapper test step requiring command to be processed
150 * @param aCommand the command to process
151 * @param aSection the entry in the ini file requiring the command to be processed
153 * @return ETrue if the command is processed
155 TBool CT_SoundFormatsSupportedData::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt aAsyncErrorIndex)
158 if ( aCommand==KCmdNew )
162 else if ( aCommand==KCmdDestructor )
166 else if ( aCommand==KCmd_iMinRate_get )
168 DoCmd_iMinRate_get(aSection);
170 else if ( aCommand==KCmd_iMaxRate_get )
172 DoCmd_iMaxRate_get(aSection);
174 else if ( aCommand==KCmd_iChannels_get )
176 DoCmd_iChannels_get(aSection);
178 else if ( aCommand==KCmd_iMinBufferSize_get )
180 DoCmd_iMinBufferSize_get(aSection);
182 else if ( aCommand==KCmd_iMaxBufferSize_get )
184 DoCmd_iMaxBufferSize_get(aSection);
186 else if ( aCommand==KCmd_iMinVolume_get )
188 DoCmd_iMinVolume_get(aSection);
190 else if ( aCommand==KCmd_iMaxVolume_get )
192 DoCmd_iMaxVolume_get(aSection);
194 else if ( aCommand==KCmd_iEncodings_get )
196 DoCmd_iEncodings_getL(aSection);
200 ret=CDataWrapperBase::DoCommandL(aCommand, aSection, aAsyncErrorIndex);
207 * Creates new instance of TSoundFormatsSupported
209 void CT_SoundFormatsSupportedData::DoCmdNew()
212 TRAPD(err, iFormatsSupported = new (ELeave) RMdaDevSound::TSoundFormatsSupported());
215 ERR_PRINTF2(KLogNewError, err);
220 INFO_PRINTF1(KLogNew);
225 * Performs cleanup operation
227 void CT_SoundFormatsSupportedData::DoCmdDestructor()
235 * @param aSection section name where expected value can be read
236 * KMinRateExpected - min rate expected
242 void CT_SoundFormatsSupportedData::DoCmd_iMinRate_get(const TDesC& aSection)
245 if (GET_OPTIONAL_INT_PARAMETER(KMinRateExpected(), aSection, expected))
247 if(iFormatsSupported->iMinRate != expected)
249 ERR_PRINTF3(_L("Expected result != iMinRate, expected=%d, iMinRate=%d"), expected, iFormatsSupported->iMinRate);
250 SetBlockResult(EFail);
254 INFO_PRINTF3(_L("iMinRate == expected, iMinRate=%d, expected=%d"), iFormatsSupported->iMinRate, expected);
259 INFO_PRINTF2(_L("iMinRate=%d"), iFormatsSupported->iMinRate);
266 * @param aSection section name where expected value can be read
267 * KMaxRateExpected - max rate expected
273 void CT_SoundFormatsSupportedData::DoCmd_iMaxRate_get(const TDesC& aSection)
276 if (GET_OPTIONAL_INT_PARAMETER(KMaxRateExpected(), aSection, expected))
278 if(iFormatsSupported->iMaxRate != expected)
280 ERR_PRINTF3(_L("Expected result != iMaxRate, expected=%d, iMaxRate=%d"), expected, iFormatsSupported->iMaxRate);
281 SetBlockResult(EFail);
285 INFO_PRINTF3(_L("iMaxRate == expected, iMaxRate=%d, expected=%d"), iFormatsSupported->iMaxRate, expected);
290 INFO_PRINTF2(_L("iMaxRate=%d"), iFormatsSupported->iMaxRate);
295 * Gets iMinBufferSize
297 * @param aSection section name where expected value can be read
298 * KMinBufferSizeExpected - min buffer size expected
304 void CT_SoundFormatsSupportedData::DoCmd_iMinBufferSize_get(const TDesC& aSection)
307 if (GET_OPTIONAL_INT_PARAMETER(KMinBufferSizeExpected(), aSection, expected))
309 if(iFormatsSupported->iMinBufferSize != expected)
311 ERR_PRINTF3(_L("Expected result != iMinBufferSize, expected=%d, iMinBufferSize=%d"), expected, iFormatsSupported->iMinBufferSize);
312 SetBlockResult(EFail);
316 INFO_PRINTF3(_L("iMinBufferSize == expected, iMinBufferSize=%d, expected=%d"), iFormatsSupported->iMinBufferSize, expected);
321 INFO_PRINTF2(_L("iMinBufferSize=%d"), iFormatsSupported->iMinBufferSize);
326 * Gets iMaxBufferSize
328 * @param aSection section name where expected value can be read
329 * KMaxBufferSizeExpected - max buffer size expected
335 void CT_SoundFormatsSupportedData::DoCmd_iMaxBufferSize_get(const TDesC& aSection)
338 if (GET_OPTIONAL_INT_PARAMETER(KMaxBufferSizeExpected(), aSection, expected))
340 if(iFormatsSupported->iMaxBufferSize != expected)
342 ERR_PRINTF3(_L("Expected result != iMaxBufferSize, expected=%d, iMaxBufferSize=%d"), expected, iFormatsSupported->iMaxBufferSize);
343 SetBlockResult(EFail);
347 INFO_PRINTF3(_L("iMaxBufferSize == expected, iMaxBufferSize=%d, expected=%d"), iFormatsSupported->iMaxBufferSize, expected);
352 INFO_PRINTF2(_L("iMaxBufferSize=%d"), iFormatsSupported->iMaxBufferSize);
359 * @param aSection section name where expected value can be read
360 * KMinVolumeExpected - min volume expected
366 void CT_SoundFormatsSupportedData::DoCmd_iMinVolume_get(const TDesC& aSection)
369 if (GET_OPTIONAL_INT_PARAMETER(KMinVolumeExpected(), aSection, expected))
371 if(iFormatsSupported->iMinVolume != expected)
373 ERR_PRINTF3(_L("Expected result != iMinVolume, expected=%d, iMinVolume=%d"), expected, iFormatsSupported->iMinVolume);
374 SetBlockResult(EFail);
378 INFO_PRINTF3(_L("iMinVolume == expected, iMinVolume=%d, expected=%d"), iFormatsSupported->iMinVolume, expected);
383 INFO_PRINTF2(_L("iMinVolume=%d"), iFormatsSupported->iMinVolume);
390 * @param aSection section name where expected value can be read
391 * KMaxVolumeExpected - max volume expected
397 void CT_SoundFormatsSupportedData::DoCmd_iMaxVolume_get(const TDesC& aSection)
400 if (GET_OPTIONAL_INT_PARAMETER(KMaxVolumeExpected(), aSection, expected))
402 if(iFormatsSupported->iMaxVolume != expected)
404 ERR_PRINTF3(_L("Expected result != iMaxVolume, expected=%d, iMaxVolume=%d"), expected, iFormatsSupported->iMaxVolume);
405 SetBlockResult(EFail);
409 INFO_PRINTF3(_L("iMaxVolume == expected, iMaxVolume=%d, expected=%d"), iFormatsSupported->iMaxVolume, expected);
414 INFO_PRINTF2(_L("iMaxVolume=%d"), iFormatsSupported->iMaxVolume);
421 * @param aSection section name where expected value can be read
422 * KChannelsExpected - channels expected
428 void CT_SoundFormatsSupportedData::DoCmd_iChannels_get(const TDesC& aSection)
431 if (GET_OPTIONAL_INT_PARAMETER(KChannelsExpected(), aSection, expected))
433 if(iFormatsSupported->iChannels != expected)
435 ERR_PRINTF3(_L("Expected result != iChannels, expected=%d, iChannels=%d"), expected, iFormatsSupported->iChannels);
436 SetBlockResult(EFail);
440 INFO_PRINTF3(_L("iChannels == expected, iChannels=%d, expected=%d"), iFormatsSupported->iChannels, expected);
445 INFO_PRINTF2(_L("iChannels=%d"), iFormatsSupported->iChannels);
452 * @param aSection section name where expected value can be read
453 * KEncodingsExpected - encodings expected
457 * @leave System wide error
459 void CT_SoundFormatsSupportedData::DoCmd_iEncodings_getL(const TDesC& aSection)
462 if(GetOrFromConfig(aSection, KEncodingsExpected(), TSoundUtil::iEnumTableSoundEncoding, expEncoding ))
464 TUint encodings = iFormatsSupported->iEncodings;
465 if(encodings != expEncoding)
467 ERR_PRINTF3(_L("iEncodings != expected result! iEncodings=0x%x, expected result=0x%x"), encodings, expEncoding);
468 SetBlockResult(EFail);
472 INFO_PRINTF3(_L("iEncodings == expected result!, iEncodings=0x%x, expected=0x%x"), encodings, expEncoding);
477 INFO_PRINTF2(_L("iEncodings=%d"), iFormatsSupported->iEncodings);