1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/mm/mmapitest/devsoundhaitest/src/T_CMMFDevSoundData.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,2156 @@
1.4 +/*
1.5 +* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
1.6 +* All rights reserved.
1.7 +* This component and the accompanying materials are made available
1.8 +* under the terms of "Eclipse Public License v1.0"
1.9 +* which accompanies this distribution, and is available
1.10 +* at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.11 +*
1.12 +* Initial Contributors:
1.13 +* Nokia Corporation - initial contribution.
1.14 +*
1.15 +* Contributors:
1.16 +*
1.17 +* Description:
1.18 +*
1.19 +*/
1.20 +
1.21 +
1.22 +
1.23 +#include "t_cmmfdevsounddata.h"
1.24 +
1.25 +/*@{*/
1.26 +//Constants for HwDevice
1.27 +const TInt KHwDeviceDefaultDataLength = 9;
1.28 +const TInt KFourCCLength = 4;
1.29 +//Supported Input Data Types
1.30 +const TInt KFourCCMaxBitDisplacement = 24;
1.31 +const TInt K8Bits = 8;
1.32 +const TInt KTFourCC = 4;
1.33 +/*@}*/
1.34 +
1.35 +/*@{*/
1.36 +//Command literals
1.37 +_LIT(KCmdNewL, "NewL");
1.38 +_LIT(KCmdNewLLoopL, "NewLLoopL");
1.39 +_LIT(KCmdDestructor, "~");
1.40 +_LIT(KCmdCapabilities, "Capabilities");
1.41 +_LIT(KCmdConfig, "Config");
1.42 +_LIT(KCmdMaxGain, "MaxGain");
1.43 +_LIT(KCmdMaxVolume, "MaxVolume");
1.44 +_LIT(KCmdGetPlayBalanceL, "GetPlayBalanceL");
1.45 +_LIT(KCmdGetRecordBalanceL, "GetRecordBalanceL");
1.46 +_LIT(KCmdGetSupportedInputDataTypesL, "GetSupportedInputDataTypesL");
1.47 +_LIT(KCmdGetSupportedOutputDataTypesL, "GetSupportedOutputDataTypesL");
1.48 +_LIT(KCmdSamplesPlayed, "SamplesPlayed");
1.49 +_LIT(KCmdSamplesRecorded, "SamplesRecorded");
1.50 +_LIT(KCmdVolume, "Volume");
1.51 +_LIT(KCmdGain, "Gain");
1.52 +_LIT(KCmdFixedSequenceCount, "FixedSequenceCount");
1.53 +_LIT(KCmdFixedSequenceName, "FixedSequenceName");
1.54 +_LIT(KCmdSetConfigL, "SetConfigL");
1.55 +_LIT(KCmdSetDTMFLengths, "SetDTMFLengths");
1.56 +_LIT(KCmdSetGain, "SetGain");
1.57 +_LIT(KCmdSetPlayBalanceL, "SetPlayBalanceL");
1.58 +_LIT(KCmdSetPrioritySettings, "SetPrioritySettings");
1.59 +_LIT(KCmdSetRecordBalanceL, "SetRecordBalanceL");
1.60 +_LIT(KCmdSetToneRepeats, "SetToneRepeats");
1.61 +_LIT(KCmdSetVolume, "SetVolume");
1.62 +_LIT(KCmdSetVolumeRamp, "SetVolumeRamp");
1.63 +_LIT(KCmdInitializeL, "InitializeL");
1.64 +_LIT(KCmdPlayDTMFStringL, "PlayDTMFStringL");
1.65 +_LIT(KCmdPlayData, "PlayData");
1.66 +_LIT(KCmdPlayDualToneL, "PlayDualToneL");
1.67 +_LIT(KCmdPlayInitL, "PlayInitL");
1.68 +_LIT(KCmdPlayToneL, "PlayToneL");
1.69 +_LIT(KCmdPlayToneSequenceL, "PlayToneSequenceL");
1.70 +_LIT(KCmdRecordData, "RecordData");
1.71 +_LIT(KCmdRecordInitL, "RecordInitL");
1.72 +_LIT(KCmdStop, "Stop");
1.73 +_LIT(KCmdErrorConceal, "ErrorConceal");
1.74 +_LIT(KCmdSetVolumeLoop, "SetVolumeLoop");
1.75 +/*@}*/
1.76 +
1.77 +/*@{*/
1.78 +//Utility literals
1.79 +_LIT(KCmdUtilityReplaceFile, "ReplaceFile");
1.80 +_LIT(KCmdUtilityOpenFile, "OpenFile");
1.81 +_LIT(KCmdUtilityCloseFile, "CloseFile");
1.82 +_LIT(KCmdUtilityFileStartPosition, "FileStartPosition");
1.83 +/*@}*/
1.84 +
1.85 +/*@{*/
1.86 +//INI Section name literals
1.87 +_LIT(KGainValue, "Gain");
1.88 +_LIT(KVolumeValue, "Volume");
1.89 +_LIT(KLeftPercentage, "LeftPercentage");
1.90 +_LIT(KRightPercentage, "RightPercentage");
1.91 +_LIT(KSequenceNumber, "SequenceNumber");
1.92 +_LIT(KRate, "Rate");
1.93 +_LIT(KEncoding, "Encoding");
1.94 +_LIT(KChannels, "Channels");
1.95 +_LIT(KBufferSize, "BufferSize");
1.96 +_LIT(KToneOnLength, "ToneOnLength");
1.97 +_LIT(KToneOffLength, "ToneOffLength");
1.98 +_LIT(KPause, "Pause");
1.99 +_LIT(KPauseLength, "PauseLength");
1.100 +_LIT(KPriority, "Priority");
1.101 +_LIT(KPreference, "Preference");
1.102 +_LIT(KPriorityState, "PriorityState");
1.103 +_LIT(KRepeatCount, "RepeatCount");
1.104 +_LIT(KRepeatTrailingSilence, "RepeatTrailingSilence");
1.105 +_LIT(KRampDuration, "RampDuration");
1.106 +_LIT(KMode, "Mode");
1.107 +_LIT(KHwDevice, "HwDevice");
1.108 +_LIT(KFourCC, "FourCC");
1.109 +_LIT(KFilename, "Filename");
1.110 +_LIT(KDTMFString, "DTMFString");
1.111 +_LIT(KFrequency, "Frequency");
1.112 +_LIT(KFrequencyOne, "FrequencyOne");
1.113 +_LIT(KFrequencyTwo, "FrequencyTwo");
1.114 +_LIT(KDuration, "Duration");
1.115 +_LIT(KLoop, "Loop");
1.116 +_LIT(KAllowedError, "AllowedError");
1.117 +_LIT(KVolumeList, "VolumeList");
1.118 +_LIT(KVolumeLoop, "VolumeLoop");
1.119 +/*@}*/
1.120 +
1.121 +/*@{*/
1.122 +//Literals for iEnumChannels
1.123 +_LIT(KEMMFStereo, "EMMFStereo");
1.124 +_LIT(KEMMFMono, "EMMFMono");
1.125 +/*@}*/
1.126 +
1.127 +const CDataWrapperBase::TEnumEntryTable CT_CMMFDevSoundData::iEnumChannels[] =
1.128 + {
1.129 + {KEMMFMono, EMMFMono},
1.130 + {KEMMFStereo, EMMFStereo}
1.131 + };
1.132 +
1.133 +/*@{*/
1.134 +//Literals for iEnumSampleRate
1.135 +_LIT(KEMMFSampleRate8000Hz, "EMMFSampleRate8000Hz");
1.136 +_LIT(KEMMFSampleRate11025Hz, "EMMFSampleRate11025Hz");
1.137 +_LIT(KEMMFSampleRate16000Hz, "EMMFSampleRate16000Hz");
1.138 +_LIT(KEMMFSampleRate22050Hz, "EMMFSampleRate22050Hz");
1.139 +_LIT(KEMMFSampleRate32000Hz, "EMMFSampleRate32000Hz");
1.140 +_LIT(KEMMFSampleRate44100Hz, "EMMFSampleRate44100Hz");
1.141 +_LIT(KEMMFSampleRate48000Hz, "EMMFSampleRate48000Hz");
1.142 +_LIT(KEMMFSampleRate88200Hz, "EMMFSampleRate88200Hz");
1.143 +_LIT(KEMMFSampleRate96000Hz, "EMMFSampleRate96000Hz");
1.144 +_LIT(KEMMFSampleRate12000Hz, "EMMFSampleRate12000Hz");
1.145 +_LIT(KEMMFSampleRate24000Hz, "EMMFSampleRate24000Hz");
1.146 +_LIT(KEMMFSampleRate64000Hz, "EMMFSampleRate64000Hz");
1.147 +/*@}*/
1.148 +
1.149 +const CDataWrapperBase::TEnumEntryTable CT_CMMFDevSoundData::iEnumSampleRate[] =
1.150 + {
1.151 + {KEMMFSampleRate8000Hz, EMMFSampleRate8000Hz},
1.152 + {KEMMFSampleRate11025Hz, EMMFSampleRate11025Hz},
1.153 + {KEMMFSampleRate16000Hz, EMMFSampleRate16000Hz},
1.154 + {KEMMFSampleRate22050Hz, EMMFSampleRate22050Hz},
1.155 + {KEMMFSampleRate32000Hz, EMMFSampleRate32000Hz},
1.156 + {KEMMFSampleRate44100Hz, EMMFSampleRate44100Hz},
1.157 + {KEMMFSampleRate48000Hz, EMMFSampleRate48000Hz},
1.158 + {KEMMFSampleRate88200Hz, EMMFSampleRate88200Hz},
1.159 + {KEMMFSampleRate96000Hz, EMMFSampleRate96000Hz},
1.160 + {KEMMFSampleRate12000Hz, EMMFSampleRate12000Hz},
1.161 + {KEMMFSampleRate24000Hz, EMMFSampleRate24000Hz},
1.162 + {KEMMFSampleRate64000Hz, EMMFSampleRate64000Hz}
1.163 + };
1.164 +
1.165 +/*@{*/
1.166 +//Literal for iEnumMode
1.167 +_LIT(KEMMFStateIdle, "EMMFStateIdle");
1.168 +_LIT(KEMMFStatePlaying, "EMMFStatePlaying");
1.169 +_LIT(KEMMFStateTonePlaying, "EMMFStateTonePlaying");
1.170 +_LIT(KEMMFStateRecording, "EMMFStateRecording");
1.171 +_LIT(KEMMFStatePlayingRecording, "EMMFStatePlayingRecording");
1.172 +_LIT(KEMMFStateConverting, "EMMFStateConverting");
1.173 +/*@}*/
1.174 +
1.175 +const CDataWrapperBase::TEnumEntryTable CT_CMMFDevSoundData::iEnumMode[] =
1.176 + {
1.177 + {KEMMFStateIdle, EMMFStateIdle},
1.178 + {KEMMFStatePlaying, EMMFStatePlaying},
1.179 + {KEMMFStateRecording, EMMFStateRecording},
1.180 + {KEMMFStateTonePlaying, EMMFStateTonePlaying},
1.181 + {KEMMFStatePlayingRecording, EMMFStatePlayingRecording},
1.182 + {KEMMFStateConverting, EMMFStateConverting}
1.183 + };
1.184 +
1.185 +/*@{*/
1.186 +//Literals for iEnumInitializeLType
1.187 +_LIT(KEInitializeState, "EInitializeState");
1.188 +_LIT(KEInitializeHwDeviceMode, "EInitializeHwDeviceMode");
1.189 +_LIT(KEInitializeFourCCMode, "EInitializeFourCCMode");
1.190 +/*@}*/
1.191 +
1.192 +enum TMMFInitializeMode
1.193 + {
1.194 + EInitializeState,
1.195 + EInitializeHwDeviceMode,
1.196 + EInitializeFourCCMode
1.197 + };
1.198 +
1.199 +const CDataWrapperBase::TEnumEntryTable CT_CMMFDevSoundData::iEnumInitializeLType[] =
1.200 + {
1.201 + {KEInitializeState, EInitializeState},
1.202 + {KEInitializeHwDeviceMode, EInitializeHwDeviceMode},
1.203 + {KEInitializeFourCCMode, EInitializeFourCCMode}
1.204 + };
1.205 +
1.206 +/**
1.207 + * Two phase constructor
1.208 + *
1.209 + * @leave system wide error
1.210 + */
1.211 +CT_CMMFDevSoundData* CT_CMMFDevSoundData::NewL()
1.212 + {
1.213 + CT_CMMFDevSoundData* ret = new (ELeave) CT_CMMFDevSoundData();
1.214 + CleanupStack::PushL(ret);
1.215 + ret->ConstructL();
1.216 + CleanupStack::Pop(ret);
1.217 + return ret;
1.218 + }
1.219 +
1.220 +/**
1.221 + * Private constructor. First phase construction
1.222 + */
1.223 +CT_CMMFDevSoundData::CT_CMMFDevSoundData()
1.224 + :
1.225 + iDevSound(NULL),
1.226 + iPrioritySettings(),
1.227 + iCapabilities(),
1.228 + iVolumeValue(0),
1.229 + iGainValue(0),
1.230 + iLeftPercentage(0),
1.231 + iRightPercentage(0),
1.232 + iFs(),
1.233 + iToneFile(),
1.234 + iAudiofile(),
1.235 + iBuffer(NULL),
1.236 + iLastSample(0),
1.237 + iPaused(EFalse),
1.238 + iErrorConceal(EFalse),
1.239 + iEndFile(EFalse),
1.240 + iToneSequence(),
1.241 + iRecordErrorIndex(0),
1.242 + iPlayErrorIndex(0),
1.243 + iToneErrorIndex(0),
1.244 + iInitializeErrorIndex(0)
1.245 + {
1.246 + }
1.247 +
1.248 +/**
1.249 + * Second phase construction
1.250 + * @internalComponent
1.251 + * @return N/A
1.252 + * @pre None
1.253 + * @post None
1.254 + * @leave system wide error
1.255 + */
1.256 +void CT_CMMFDevSoundData::ConstructL()
1.257 + {
1.258 + iFs.Connect();
1.259 + }
1.260 +
1.261 +/**
1.262 + * Public destructor
1.263 + */
1.264 +CT_CMMFDevSoundData::~CT_CMMFDevSoundData()
1.265 + {
1.266 + iFs.Close();
1.267 + DestroyData();
1.268 + }
1.269 +
1.270 +/**
1.271 + * Helper Destructor
1.272 + */
1.273 +void CT_CMMFDevSoundData::DestroyData()
1.274 + {
1.275 + if(iDevSound)
1.276 + {
1.277 + delete iDevSound;
1.278 + iDevSound = NULL;
1.279 + }
1.280 + }
1.281 +
1.282 +/**
1.283 + * Return a pointer to the object that the data wraps
1.284 + *
1.285 + * @return pointer to the object that the data wraps
1.286 + */
1.287 +TAny* CT_CMMFDevSoundData::GetObject()
1.288 + {
1.289 + return iDevSound;
1.290 + }
1.291 +
1.292 +/**
1.293 + * Process a command read from the Ini file
1.294 + * @param aCommand - The command to process
1.295 + * @param aSection - The section get from the *.ini file of the project T_Wlan
1.296 + * @param aAsyncErrorIndex - Command index dor async calls to returns errors to
1.297 + * @return TBool - ETrue if the command is process
1.298 + * @leave - system wide error
1.299 + */
1.300 +TBool CT_CMMFDevSoundData::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt aAsyncErrorIndex)
1.301 + {
1.302 + TBool ret = ETrue;
1.303 +
1.304 + if (aCommand == KCmdNewL)
1.305 + {
1.306 + DoCmdNewL();
1.307 + }
1.308 + else if(aCommand == KCmdNewLLoopL)
1.309 + {
1.310 + DoCmdNewLLoopL(aSection);
1.311 + }
1.312 + else if (aCommand == KCmdDestructor)
1.313 + {
1.314 + DoCmdDestructor();
1.315 + }
1.316 + else if (aCommand == KCmdUtilityReplaceFile)
1.317 + {
1.318 + DoCmdUtilityReplaceFile(aSection);
1.319 + }
1.320 + else if (aCommand == KCmdUtilityOpenFile)
1.321 + {
1.322 + DoCmdUtilityOpenFile(aSection);
1.323 + }
1.324 + else if (aCommand == KCmdUtilityCloseFile)
1.325 + {
1.326 + DoCmdUtilityCloseFile();
1.327 + }
1.328 + else if (aCommand == KCmdUtilityFileStartPosition)
1.329 + {
1.330 + DoCmdUtilityFileStartPosition();
1.331 + }
1.332 + else if (aCommand == KCmdCapabilities)
1.333 + {
1.334 + DoCmdCapabilities();
1.335 + }
1.336 + else if (aCommand == KCmdConfig)
1.337 + {
1.338 + DoCmdConfig();
1.339 + }
1.340 + else if (aCommand == KCmdMaxGain)
1.341 + {
1.342 + DoCmdMaxGain(aSection);
1.343 + }
1.344 + else if (aCommand == KCmdMaxVolume)
1.345 + {
1.346 + DoCmdMaxVolume(aSection);
1.347 + }
1.348 + else if (aCommand == KCmdGetPlayBalanceL)
1.349 + {
1.350 + DoCmdGetPlayBalanceL(aSection);
1.351 + }
1.352 + else if (aCommand == KCmdGetRecordBalanceL)
1.353 + {
1.354 + DoCmdGetRecordBalanceL(aSection);
1.355 + }
1.356 + else if (aCommand == KCmdGetSupportedInputDataTypesL)
1.357 + {
1.358 + DoCmdGetSupportedInputDataTypesL();
1.359 + }
1.360 + else if (aCommand == KCmdGetSupportedOutputDataTypesL)
1.361 + {
1.362 + DoCmdGetSupportedOutputDataTypesL();
1.363 + }
1.364 + else if (aCommand == KCmdSamplesPlayed)
1.365 + {
1.366 + DoCmdSamplesPlayed();
1.367 + }
1.368 + else if (aCommand == KCmdSamplesRecorded)
1.369 + {
1.370 + DoCmdSamplesRecorded();
1.371 + }
1.372 + else if (aCommand == KCmdVolume)
1.373 + {
1.374 + DoCmdVolume(aSection);
1.375 + }
1.376 + else if (aCommand == KCmdGain)
1.377 + {
1.378 + DoCmdGain(aSection);
1.379 + }
1.380 + else if (aCommand == KCmdFixedSequenceCount)
1.381 + {
1.382 + DoCmdFixedSequenceCount();
1.383 + }
1.384 + else if (aCommand == KCmdFixedSequenceName)
1.385 + {
1.386 + DoCmdFixedSequenceName(aSection);
1.387 + }
1.388 + else if (aCommand == KCmdSetConfigL)
1.389 + {
1.390 + DoCmdSetConfigL(aSection);
1.391 + }
1.392 + else if (aCommand == KCmdSetDTMFLengths)
1.393 + {
1.394 + DoCmdSetDTMFLengths(aSection);
1.395 + }
1.396 + else if (aCommand == KCmdSetGain)
1.397 + {
1.398 + DoCmdSetGain(aSection);
1.399 + }
1.400 + else if (aCommand == KCmdSetPlayBalanceL)
1.401 + {
1.402 + DoCmdSetPlayBalanceL(aSection);
1.403 + }
1.404 + else if (aCommand == KCmdSetPrioritySettings)
1.405 + {
1.406 + DoCmdSetPrioritySettings(aSection);
1.407 + }
1.408 + else if (aCommand == KCmdSetRecordBalanceL)
1.409 + {
1.410 + DoCmdSetRecordBalanceL(aSection);
1.411 + }
1.412 + else if (aCommand == KCmdSetToneRepeats)
1.413 + {
1.414 + DoCmdSetToneRepeats(aSection);
1.415 + }
1.416 + else if (aCommand == KCmdSetVolume)
1.417 + {
1.418 + DoCmdSetVolume(aSection);
1.419 + }
1.420 + else if (aCommand == KCmdSetVolumeLoop)
1.421 + {
1.422 + DoCmdSetVolumeLoop(aSection);
1.423 + }
1.424 + else if (aCommand == KCmdSetVolumeRamp)
1.425 + {
1.426 + DoCmdSetVolumeRamp(aSection);
1.427 + }
1.428 + else if (aCommand == KCmdInitializeL)
1.429 + {
1.430 + DoCmdInitializeL(aSection,aAsyncErrorIndex);
1.431 + }
1.432 + else if (aCommand == KCmdPlayDTMFStringL)
1.433 + {
1.434 + DoCmdPlayDTMFStringL(aSection, aAsyncErrorIndex);
1.435 + }
1.436 + else if (aCommand == KCmdPlayData)
1.437 + {
1.438 + DoCmdPlayData();
1.439 + }
1.440 + else if (aCommand == KCmdPlayDualToneL)
1.441 + {
1.442 + DoCmdPlayDualToneL(aSection, aAsyncErrorIndex);
1.443 + }
1.444 + else if (aCommand == KCmdPlayInitL)
1.445 + {
1.446 + DoCmdPlayInitL(aAsyncErrorIndex);
1.447 + }
1.448 + else if (aCommand == KCmdPlayToneL)
1.449 + {
1.450 + DoCmdPlayToneL(aSection, aAsyncErrorIndex);
1.451 + }
1.452 + else if (aCommand == KCmdPlayToneSequenceL)
1.453 + {
1.454 + DoCmdPlayToneSequenceL(aSection,aAsyncErrorIndex);
1.455 + }
1.456 + else if (aCommand == KCmdRecordData)
1.457 + {
1.458 + DoCmdRecordData();
1.459 + }
1.460 + else if (aCommand == KCmdRecordInitL)
1.461 + {
1.462 + DoCmdRecordInitL(aAsyncErrorIndex);
1.463 + }
1.464 + else if (aCommand == KCmdStop)
1.465 + {
1.466 + DoCmdStop(aSection);
1.467 + }
1.468 + else if(aCommand == KCmdErrorConceal)
1.469 + {
1.470 + DoCmdUtilityErrorConceal();
1.471 + }
1.472 + else
1.473 + {
1.474 + ERR_PRINTF1(_L("Unknown command."));
1.475 + ret=EFalse;
1.476 + }
1.477 + return ret;
1.478 + }
1.479 +
1.480 +/**
1.481 + * Handles initialization completion event.
1.482 + * CMMFDevSound object calls this function when its InitializeL() function
1.483 + * completes.
1.484 + * @param aError - Error code. KErrNone if successful. Other values are possible
1.485 + * indicating a problem initializing CMMFDevSound object.
1.486 + * @return void
1.487 + */
1.488 +
1.489 +void CT_CMMFDevSoundData::InitializeComplete(TInt aError)
1.490 + {
1.491 + INFO_PRINTF1(_L("*START*CT_CMMFDevSoundData::InitializeComplete"));
1.492 + if(KErrNone != aError)
1.493 + {
1.494 + ERR_PRINTF2(_L("InitializeComplete callback failed with error %d"), aError);
1.495 + SetAsyncError(iInitializeErrorIndex, aError);
1.496 + iInitializeErrorIndex = 0;
1.497 + }
1.498 +
1.499 + DecOutstanding();
1.500 +
1.501 + INFO_PRINTF1(_L("*END*CT_CMMFDevSoundData::InitializeComplete"));
1.502 + }
1.503 +
1.504 +/**
1.505 + * It's needed for playing o converting
1.506 + * @param aBuffer - Buffer into which data should be read. The amount of data that is
1.507 + * needed is specified in CMMFBuffer::RequestSize().
1.508 + */
1.509 +void CT_CMMFDevSoundData::BufferToBeFilled(CMMFBuffer* aBuffer)
1.510 + {
1.511 + if (!aBuffer)
1.512 + {
1.513 + ERR_PRINTF1(_L("BufferToBeFilled callback received a NULL CMMFBuffer!"));
1.514 + SetBlockResult(EFail);
1.515 + }
1.516 + else
1.517 + {
1.518 + TBool dataOk = ETrue;
1.519 + iBuffer = aBuffer;
1.520 + iBuffer->SetLastBuffer(EFalse);
1.521 + CMMFDataBuffer* buffer = static_cast <CMMFDataBuffer*> (iBuffer);
1.522 + if (iPaused)
1.523 + {
1.524 + iPaused=EFalse;
1.525 + TInt error = iAudiofile.Read(iLastSample,buffer->Data());
1.526 + if (error != KErrNone)
1.527 + {
1.528 + ERR_PRINTF2(_L("ERROR : iFile.Read() failed with %d"), error);
1.529 + SetBlockResult(EFail);
1.530 + dataOk = EFalse;
1.531 + }
1.532 + }
1.533 + else
1.534 + {
1.535 + TInt error = iAudiofile.Read(buffer->Data());
1.536 + if (error != KErrNone)
1.537 + {
1.538 + ERR_PRINTF2(_L("ERROR : iFile.Read() failed with %d"), error);
1.539 + SetBlockResult(EFail);
1.540 + dataOk =EFalse;
1.541 + }
1.542 + }
1.543 + if(dataOk)
1.544 + {
1.545 + if (buffer->Data().Length() != buffer->RequestSize())
1.546 + {
1.547 + iBuffer->SetLastBuffer(ETrue);
1.548 + }
1.549 + if (iErrorConceal)
1.550 + {
1.551 + iErrorConceal=EFalse;
1.552 + buffer->Data().Zero();
1.553 + INFO_PRINTF1(_L("buffer->Data().Zero()"));
1.554 + }
1.555 + PlayData();
1.556 + TInt pos=0;
1.557 + iLastSample=iAudiofile.Seek(ESeekCurrent ,pos);
1.558 + INFO_PRINTF2(_L("Number of samples played so far: %d"), pos);
1.559 + iLastSample=pos;
1.560 + }
1.561 + }
1.562 + }
1.563 +
1.564 +/**
1.565 +* Handles play completion or cancel event.
1.566 +*
1.567 +* CMMFDevSound object calls this function when an attempt to play audio sample
1.568 +* has completed, successfully or otherwise.
1.569 +*
1.570 +* @param aError - Error code. The status of playback. KErrUnderflow playing of the
1.571 +* audio sample is complete. KErrAccessDenied the sound device is in
1.572 +* use by another higher priority client.
1.573 +*/
1.574 +void CT_CMMFDevSoundData::PlayError(TInt aError)
1.575 + {
1.576 + INFO_PRINTF1(_L("*START*CT_CMMFDevSoundData::PlayError"));
1.577 +
1.578 + DecOutstanding();
1.579 +
1.580 + if(aError != KErrNone && aError != KErrUnderflow)
1.581 + {
1.582 + ERR_PRINTF2(_L("Playback completed with error %d"), aError);
1.583 + SetAsyncError(iPlayErrorIndex, aError);
1.584 + iPlayErrorIndex = 0;
1.585 + }
1.586 + INFO_PRINTF1(_L("*END*CT_CMMFDevSoundData::PlayError"));
1.587 + }
1.588 +
1.589 +
1.590 +/**
1.591 + * Handles tone play completion event.
1.592 + *
1.593 + *
1.594 + * CMMFDevSound object calls this function when an attempt to play tone has
1.595 + * completed, successfully or otherwise.
1.596 + *
1.597 + * The following are the play tone functions; PlayToneL(), PlayDMTFStringL(),
1.598 + * PlayToneSequenceL(), and PlayFixedSequenceL().
1.599 + *
1.600 + * @param aError - Error code. The status of tone playback. KErrUnderflow playing of
1.601 + * the tone is complete. KErrAccessDenied the sound device is in use by
1.602 + * another higher priority client. KErrCancel playing of the audio
1.603 + * sample is stopped by DevSound client another higher priority client.
1.604 + *
1.605 + */
1.606 +
1.607 +void CT_CMMFDevSoundData::ToneFinished(TInt aError)
1.608 + {
1.609 + INFO_PRINTF1(_L("*START*CT_CMMFDevSoundData::ToneFinished"));
1.610 +
1.611 + DecOutstanding();
1.612 +
1.613 + if(aError != KErrNone)
1.614 + {
1.615 + ERR_PRINTF2(_L("Tone finished with error %d"), aError);
1.616 + SetAsyncError(iToneErrorIndex, aError);
1.617 + iToneErrorIndex = 0;
1.618 + }
1.619 + iToneFile.Close();
1.620 + INFO_PRINTF1(_L("*END*CT_CMMFDevSoundData::ToneFinished"));
1.621 + }
1.622 +
1.623 +/**
1.624 + * Handles CMMFDevSound object's data request event.
1.625 + *
1.626 + * CMMFDevSound object calls this function when the buffer, aBuffer gets filled
1.627 + * while recording or converting. The observer should notify CMMFDevSound
1.628 + * object as quickly as possible after data in the buffer is processed by
1.629 + * calling RecordData(), otherwise the implementation might callback
1.630 + * the function RecordError() on derived class object with error code KErrOverflow.
1.631 + *
1.632 + * @param aBuffer - Buffer containing processed (recorded or converted) data. The amount
1.633 + * of data that is available is specified in CMMFBuffer::RequestSize().
1.634 + */
1.635 +
1.636 +void CT_CMMFDevSoundData::BufferToBeEmptied(CMMFBuffer* aBuffer)
1.637 + {
1.638 + if (!aBuffer)
1.639 + {
1.640 + INFO_PRINTF1(_L("BufferToBeEmptied callback received a NULL CMMFBuffer"));
1.641 + SetBlockResult(EFail);
1.642 + }
1.643 + else
1.644 + {
1.645 + iBuffer = aBuffer;
1.646 + CMMFDataBuffer* buffer = static_cast <CMMFDataBuffer*> (iBuffer);
1.647 + TInt error = iAudiofile.Write(buffer->Data());
1.648 + if(error == KErrNone)
1.649 + {
1.650 + if (!aBuffer->LastBuffer())
1.651 + {
1.652 + RecordData();
1.653 + }
1.654 + else{
1.655 + Stop();
1.656 + }
1.657 + }
1.658 + else
1.659 + {
1.660 + ERR_PRINTF2(_L("iFile.Write() returned the error %d"), error);
1.661 + SetBlockResult(EFail);
1.662 + }
1.663 + }
1.664 + }
1.665 +
1.666 +/**
1.667 + * Stops the ongoing operation (Play, Record, TonePlay, Convert).
1.668 + * This function should be synchronous and invoke no callbacks through MDevSoundObserver.
1.669 + */
1.670 +void CT_CMMFDevSoundData::Stop()
1.671 + {
1.672 + INFO_PRINTF1(_L("*START*CT_CMMFDevSoundData::Stop()"));
1.673 + iDevSound->Stop();
1.674 +
1.675 + DecOutstanding();
1.676 +
1.677 + INFO_PRINTF1(_L("*END*CT_CMMFDevSoundData::Stop()"));
1.678 + }
1.679 +
1.680 +/**
1.681 + * Handles record completion or cancel event.
1.682 + *
1.683 + * CMMFDevSound object calls this function when an attempt to record audio sample
1.684 + * has completed, successfully or otherwise.
1.685 + *
1.686 + * @param aError - Error code. The status of recording. KErrOverflow audio devices
1.687 + * runs out of internal buffer. KErrAccessDenied the sound device is
1.688 + * in use by another higher priority client.
1.689 + *
1.690 + */
1.691 +
1.692 +void CT_CMMFDevSoundData::RecordError(TInt aError)
1.693 + {
1.694 + INFO_PRINTF1(_L("*START*CT_CMMFDevSoundData::RecordError"));
1.695 + if(aError != KErrNone)
1.696 + {
1.697 + ERR_PRINTF2(_L("Record failed with error %d"), aError);
1.698 + SetAsyncError(iRecordErrorIndex , aError);
1.699 + iRecordErrorIndex = 0;
1.700 + }
1.701 + INFO_PRINTF1(_L("*END*CT_CMMFDevSoundData::RecordError"));
1.702 + }
1.703 +
1.704 +
1.705 +/**
1.706 + * Handles conversion completion or cancel event.
1.707 + *
1.708 + * CMMFDevSound object calls this function when an attempt to convert data from
1.709 + * source format to destination format has completed, successfully or otherwise.
1.710 + *
1.711 + * @param aError - Error code. KErrCancel conversion operation is cancelled. KErrNone
1.712 + * conversion is complete. Other values are possible indicating a
1.713 + * problem converting data.
1.714 + */
1.715 +
1.716 +void CT_CMMFDevSoundData::ConvertError(TInt aError)
1.717 + {
1.718 + INFO_PRINTF1(_L("*START*CT_CMMFDevSoundData::ConvertError"));
1.719 + ERR_PRINTF1(_L("Invalid Callback call"));
1.720 + if (aError == KErrNone)
1.721 + {
1.722 + INFO_PRINTF1(_L("Data conversion completed successfully."));
1.723 + }
1.724 + if (aError == KErrCancel)
1.725 + {
1.726 + INFO_PRINTF1(_L("Data conversion operation was cancelled."));
1.727 + }
1.728 + INFO_PRINTF1(_L("*END*CT_CMMFDevSoundData::ConvertError"));
1.729 + }
1.730 +
1.731 +/**
1.732 + * Handles device event.
1.733 + *
1.734 + * CMMFDevSound object calls this function when a message is received from the
1.735 + * audio hardware device.
1.736 + *
1.737 + * @param aMessageType - Defines the type of message. Used to determine how to
1.738 + * interpret the contents of aMsg.
1.739 + * @param aMsg - Message that is packed in the Descriptor format.
1.740 + */
1.741 +
1.742 +
1.743 +void CT_CMMFDevSoundData::DeviceMessage(TUid aMessageType, const TDesC8& aMsg)
1.744 + {
1.745 + INFO_PRINTF1(_L("*START*CT_CMMFDevSoundData::DeviceMessage"));
1.746 + INFO_PRINTF2(_L("Message type: %d"), aMessageType.iUid);
1.747 + INFO_PRINTF2(_L("Message type: %S"), &aMsg);
1.748 + INFO_PRINTF1(_L("*END*CT_CMMFDevSoundData::DeviceMessage"));
1.749 + }
1.750 +
1.751 +
1.752 +/**
1.753 + * Create a new or Replace the existing file
1.754 + *
1.755 + */
1.756 +void CT_CMMFDevSoundData::DoCmdUtilityReplaceFile(const TTEFSectionName& aSection)
1.757 + {
1.758 + INFO_PRINTF1(_L("*START* CT_CMMFDevSoundData::DoCmdUtilityReplaceFile()"));
1.759 + TPtrC fileName;
1.760 + TBool dataOk = ETrue;
1.761 + if (!GetStringFromConfig(aSection, KFilename, fileName))
1.762 + {
1.763 + ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KFilename);
1.764 + SetBlockResult(EFail);
1.765 + dataOk =EFalse;
1.766 + }
1.767 + if(dataOk)
1.768 + {
1.769 + TInt error = iAudiofile.Replace(iFs, fileName, EFileRead);
1.770 + if (error != KErrNone)
1.771 + {
1.772 + ERR_PRINTF2(_L("Could not open input file. Error = %d"), error);
1.773 + SetError(error);
1.774 + }
1.775 + }
1.776 +
1.777 + INFO_PRINTF1(_L("*END* CT_CMMFDevSoundData::DoCmdUtilityReplaceFile()"));
1.778 + }
1.779 +
1.780 +/**
1.781 + * Open a file
1.782 + */
1.783 +void CT_CMMFDevSoundData::DoCmdUtilityOpenFile(const TTEFSectionName& aSection)
1.784 + {
1.785 +
1.786 + INFO_PRINTF1(_L("*START* CT_CMMFDevSoundData::DoCmdUtilityOpenFile()"));
1.787 + TPtrC fileName;
1.788 + TBool dataOk = ETrue;
1.789 + if (!GetStringFromConfig(aSection, KFilename, fileName))
1.790 + {
1.791 + ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KFilename);
1.792 + SetBlockResult(EFail);
1.793 + dataOk =EFalse;
1.794 + }
1.795 + if(dataOk)
1.796 + {
1.797 + TInt error = iAudiofile.Open(iFs, fileName, EFileRead);
1.798 + if (error != KErrNone)
1.799 + {
1.800 + ERR_PRINTF2(_L("Could not open input file. Error = %d"), error);
1.801 + iFs.Close();
1.802 + SetError(error);
1.803 + }
1.804 + }
1.805 + INFO_PRINTF1(_L("*END* CT_CMMFDevSoundData::DoCmdUtilityOpenFile()"));
1.806 + }
1.807 +
1.808 +/**
1.809 + * Close the opened file
1.810 + */
1.811 +void CT_CMMFDevSoundData::DoCmdUtilityCloseFile()
1.812 + {
1.813 + INFO_PRINTF1(_L("*START* CT_CMMFDevSoundData::DoCmdUtilityCloseFile()"));
1.814 + iAudiofile.Close();
1.815 + INFO_PRINTF1(_L("*END* CT_CMMFDevSoundData::DoCmdUtilityCloseFile()"));
1.816 + }
1.817 +
1.818 +/**
1.819 + * Place the the pointer file at the begining
1.820 + *
1.821 + */
1.822 +void CT_CMMFDevSoundData::DoCmdUtilityFileStartPosition()
1.823 + {
1.824 + INFO_PRINTF1(_L("*START* CT_CMMFDevSoundData::DoCmdUtilityFileStartPosition()"));
1.825 + TInt filePosition = 0;
1.826 + TBool dataOk = ETrue;
1.827 + TInt error = iAudiofile.Seek(ESeekStart, filePosition);
1.828 + if (error != KErrNone)
1.829 + {
1.830 + ERR_PRINTF2(_L("Could not set file to the start position. Error = %d"), error);
1.831 + SetError(error);
1.832 + dataOk =EFalse;
1.833 + }
1.834 + if(dataOk)
1.835 + {
1.836 + INFO_PRINTF2(_L("File Position: %d"), filePosition);
1.837 + }
1.838 + INFO_PRINTF1(_L("*END* CT_CMMFDevSoundData::DoCmdUtilityFileStartPosition()"));
1.839 + }
1.840 +
1.841 +
1.842 +/**
1.843 + * Creates "n" instance of CMMFDevSound
1.844 + * @param aSection - Section to read from the ini file
1.845 + * @return void
1.846 + */
1.847 +void CT_CMMFDevSoundData::DoCmdNewLLoopL(const TTEFSectionName&aSection)
1.848 + {
1.849 + INFO_PRINTF1(_L("*START*CT_CMMFDevSoundData::DoCmdNewLLoopL"));
1.850 + CMMFDevSound* devSound = NULL;
1.851 + TBool dataOk = ETrue;
1.852 + TInt loop= 0;
1.853 + if (!GetIntFromConfig(aSection, KLoop, loop))
1.854 + {
1.855 + ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KLoop);
1.856 + SetBlockResult(EFail);
1.857 + dataOk = EFalse;
1.858 + }
1.859 + TInt allowedError=0;
1.860 + if ( !GetIntFromConfig(aSection, KAllowedError, allowedError) )
1.861 + {
1.862 + ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KAllowedError);
1.863 + SetBlockResult(EFail);
1.864 + dataOk = EFalse;
1.865 + }
1.866 + if(dataOk)
1.867 + {
1.868 + for(TInt i=0; i<loop; i++)
1.869 + {
1.870 + TRAPD(error,devSound = CMMFDevSound::NewL());
1.871 + if(error == KErrNone)
1.872 + {
1.873 + INFO_PRINTF2(_L("Instance %d of DevSound was created"),i);
1.874 + CleanupStack::PushL(devSound);
1.875 + iObjectsDevSound.AppendL(devSound);
1.876 + CleanupStack::Pop(devSound);
1.877 + }
1.878 + else if(error == allowedError)
1.879 + {
1.880 + INFO_PRINTF2(_L(" Allowing Error: %d"), error);
1.881 + ERR_PRINTF2(_L(" Could not create CMMFDevSound due to error: %d"), error);
1.882 + i = loop;
1.883 + }
1.884 + else if((error != KErrNone) && (error!=allowedError))
1.885 + {
1.886 + ERR_PRINTF2(_L("> Could not create CMMFDevSound: %d"), error);
1.887 + SetError(error);
1.888 + }
1.889 + }
1.890 + iObjectsDevSound.ResetAndDestroy();
1.891 + INFO_PRINTF2(_L("%d DevSound instances were deleted"),loop);
1.892 + }
1.893 + INFO_PRINTF1(_L("*END*CT_CMMFDevSoundData::DoCmdNewLLoopL"));
1.894 + }
1.895 +
1.896 +
1.897 +/**
1.898 + * Create an instance of CMMFDevSound
1.899 + */
1.900 +void CT_CMMFDevSoundData::DoCmdNewL()
1.901 + {
1.902 + INFO_PRINTF1(_L("*START*CT_CMMFDevSoundData::DoCmdNewL"));
1.903 + DestroyData();
1.904 + TRAPD(error,iDevSound = CMMFDevSound::NewL());
1.905 + if(error!= KErrNone)
1.906 + {
1.907 + ERR_PRINTF2(_L("> Could not create CMMFDevSound: %d"), error);
1.908 + SetError(error);
1.909 + }
1.910 + else
1.911 + {
1.912 + iPaused= EFalse;
1.913 + iErrorConceal = EFalse;
1.914 + }
1.915 + INFO_PRINTF1(_L("*END*CT_CMMFDevSoundData::DoCmdNewL"));
1.916 + }
1.917 +/**
1.918 + * Destroy an instance of CMMFDevSound
1.919 + */
1.920 +
1.921 +void CT_CMMFDevSoundData::DoCmdDestructor()
1.922 + {
1.923 + INFO_PRINTF1(_L("*START*CT_CMMFDevSoundData::DoCmdDestroyData"));
1.924 + DestroyData();
1.925 + INFO_PRINTF1(_L("*END*CT_CMMFDevSoundData::DoCmdDestroyData"));
1.926 + }
1.927 +
1.928 +/**
1.929 + * Show the supported Audio settings ie. encoding, sample rates, mono/stereo operation, buffer
1.930 + * size, etc.
1.931 + * @param none
1.932 + * @return none
1.933 + */
1.934 +void CT_CMMFDevSoundData::DoCmdCapabilities()
1.935 + {
1.936 + INFO_PRINTF1(_L("*START*CT_CMMFDevSoundData::DoCmdCapabilities"));
1.937 + iCapabilities = iDevSound->Capabilities();
1.938 + INFO_PRINTF5(_L("Supported Audio settings: buffsize=%d, channels=0x%x, encoding=0x%x and rate=0x%x"),
1.939 + iCapabilities.iBufferSize,
1.940 + iCapabilities.iChannels,
1.941 + iCapabilities.iEncoding,
1.942 + iCapabilities.iRate);
1.943 + INFO_PRINTF1(_L("*END*CT_CMMFDevSoundData::DoCmdCapabilities"));
1.944 + }
1.945 +
1.946 +
1.947 +/**
1.948 + * Shows the current device configuration.
1.949 + * @params none
1.950 + * @return none
1.951 + */
1.952 +void CT_CMMFDevSoundData::DoCmdConfig()
1.953 + {
1.954 + INFO_PRINTF1(_L("*START*CT_CMMFDevSoundData::DoCmdConfig"));
1.955 + TMMFCapabilities currentConfiguration = iDevSound->Config();
1.956 + INFO_PRINTF5(_L("Current device configuration: buffsize=%d, channels=0x%x, encoding=0x%x and rate=0x%x"),
1.957 + currentConfiguration.iBufferSize,
1.958 + currentConfiguration.iChannels,
1.959 + currentConfiguration.iEncoding,
1.960 + currentConfiguration.iRate);
1.961 + INFO_PRINTF1(_L("*END*CT_CMMFDevSoundData::DoCmdConfig"));
1.962 + }
1.963 +
1.964 +
1.965 +/**
1.966 + * Shows an integer representing the maximum gain the device supports.
1.967 + * This is the maximum value which can be passed to CMMFDevSound::SetGain.
1.968 + * @param aSection - The section to read the params from the ini file
1.969 + * @return none
1.970 + */
1.971 +
1.972 +void CT_CMMFDevSoundData::DoCmdMaxGain(const TTEFSectionName& aSection)
1.973 + {
1.974 + INFO_PRINTF1(_L("*START*CT_CMMFDevSoundData::DoCmdMaxGain"));
1.975 + TBool dataOk = ETrue;
1.976 + TInt expectedGainValue=0;
1.977 + if (!GetIntFromConfig(aSection, KGainValue, expectedGainValue))
1.978 + {
1.979 + ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KGainValue);
1.980 + SetBlockResult(EFail);
1.981 + dataOk = EFalse;
1.982 + }
1.983 + if(dataOk)
1.984 + {
1.985 + iGainValue = iDevSound->MaxGain();
1.986 + INFO_PRINTF2(_L("Retrieved maximum gain value: %d"), iGainValue);
1.987 + if (expectedGainValue != iGainValue)
1.988 + {
1.989 + ERR_PRINTF3(_L("Expected gain value %d is different from retrieved gain value %d"), expectedGainValue, iGainValue);
1.990 + SetBlockResult(EFail);
1.991 + }
1.992 + }
1.993 + INFO_PRINTF1(_L("*END*CT_CMMFDevSoundData::DoCmdMaxGain"));
1.994 + }
1.995 +
1.996 +/**
1.997 + * Shows an integer representing the maximum volume device supports.
1.998 + * This is the maximum value which can be passed to CMMFDevSound::SetVolume.
1.999 + * @param aSection - Section to read params from the ini file
1.1000 + * @return none
1.1001 + */
1.1002 +
1.1003 +void CT_CMMFDevSoundData::DoCmdMaxVolume(const TTEFSectionName& aSection)
1.1004 + {
1.1005 + INFO_PRINTF1(_L("*START*CT_CMMFDevSoundData::DoCmdMaxVolume"));
1.1006 + TBool dataOk = ETrue;
1.1007 + TInt expectedVolumeValue=0;
1.1008 + if(!GetIntFromConfig(aSection, KVolumeValue, expectedVolumeValue))
1.1009 + {
1.1010 + ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KVolumeValue);
1.1011 + SetBlockResult(EFail);
1.1012 + dataOk = EFalse;
1.1013 + }
1.1014 + if(dataOk)
1.1015 + {
1.1016 + iVolumeValue = iDevSound->MaxVolume();
1.1017 + INFO_PRINTF2(_L("Retrieved maximum volume value: %d"), iVolumeValue);
1.1018 + if(expectedVolumeValue != iVolumeValue)
1.1019 + {
1.1020 + ERR_PRINTF3(_L("Expected volume value %d is different from retrieved volume value %d"), expectedVolumeValue, iVolumeValue);
1.1021 + SetBlockResult(EFail);
1.1022 + }
1.1023 + }
1.1024 + INFO_PRINTF1(_L("*END*CT_CMMFDevSoundData::DoCmdMaxVolume"));
1.1025 + }
1.1026 +
1.1027 +/**
1.1028 + * Shows the speaker balance set for playing.
1.1029 + * @param aSection - Section to read params from the ini file
1.1030 + * @return none
1.1031 + */
1.1032 +
1.1033 +void CT_CMMFDevSoundData::DoCmdGetPlayBalanceL(const TTEFSectionName& aSection)
1.1034 + {
1.1035 + INFO_PRINTF1(_L("*START*CT_CMMFDevSoundData::DoCmdGetPlayBalanceL"));
1.1036 + TBool dataOk = ETrue;
1.1037 + TInt expectedLeftPercentage=0;
1.1038 + if (!GetIntFromConfig(aSection, KLeftPercentage, expectedLeftPercentage))
1.1039 + {
1.1040 + ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KLeftPercentage);
1.1041 + SetBlockResult(EFail);
1.1042 + dataOk = EFalse;
1.1043 + }
1.1044 + TInt expectedRightPercentage=0;
1.1045 + if (!GetIntFromConfig(aSection, KRightPercentage, expectedRightPercentage))
1.1046 + {
1.1047 + ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KRightPercentage);
1.1048 + SetBlockResult(EFail);
1.1049 + dataOk = EFalse;
1.1050 + }
1.1051 + if(dataOk)
1.1052 + {
1.1053 + TRAPD(error, iDevSound->GetPlayBalanceL(iLeftPercentage, iRightPercentage));
1.1054 + if (error != KErrNone)
1.1055 + {
1.1056 + ERR_PRINTF2(_L("GetPlayBalanceL left with error %d"), error);
1.1057 + SetError(error);
1.1058 + }
1.1059 + else
1.1060 + {
1.1061 + INFO_PRINTF3(_L("> Retrieved play balance values are left: %d, right:%d"), iLeftPercentage, iRightPercentage);
1.1062 + if (expectedLeftPercentage !=iLeftPercentage)
1.1063 + {
1.1064 + ERR_PRINTF3(_L("Expected left percentage value %d is different from retrieved value %d"), expectedLeftPercentage, iLeftPercentage);
1.1065 + SetBlockResult(EFail);
1.1066 + }
1.1067 + if (expectedRightPercentage !=iRightPercentage)
1.1068 + {
1.1069 + ERR_PRINTF3(_L("Expected right percentage value %d is different from retrieved value %d"), expectedRightPercentage, iRightPercentage);
1.1070 + SetBlockResult(EFail);
1.1071 + }
1.1072 + }
1.1073 + }
1.1074 +
1.1075 + INFO_PRINTF1(_L("*END*CT_CMMFDevSoundData::DoCmdGetPlayBalanceL"));
1.1076 + }
1.1077 +
1.1078 +
1.1079 +/**
1.1080 + * Shows the microphone gain balance set for recording.
1.1081 + * @param aSection - Section to read params from the ini file
1.1082 + * @return none
1.1083 + */
1.1084 +void CT_CMMFDevSoundData::DoCmdGetRecordBalanceL(const TTEFSectionName& aSection)
1.1085 + {
1.1086 + INFO_PRINTF1(_L("*START*CT_CMMFDevSoundData::DoCmdGetRecordBalanceL"));
1.1087 + TBool dataOk = ETrue;
1.1088 + TInt expectedLeftPercentage=0;
1.1089 + if(!GetIntFromConfig(aSection, KLeftPercentage, expectedLeftPercentage))
1.1090 + {
1.1091 + ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KLeftPercentage);
1.1092 + SetBlockResult(EFail);
1.1093 + dataOk = EFalse;
1.1094 + }
1.1095 + TInt expectedRightPercentage=0;
1.1096 + if(!GetIntFromConfig(aSection, KRightPercentage, expectedRightPercentage))
1.1097 + {
1.1098 + ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KRightPercentage);
1.1099 + SetBlockResult(EFail);
1.1100 + dataOk = EFalse;
1.1101 + }
1.1102 + if(dataOk)
1.1103 + {
1.1104 + TRAPD(error, iDevSound->GetRecordBalanceL(iLeftPercentage, iRightPercentage));
1.1105 + if (error != KErrNone)
1.1106 + {
1.1107 + ERR_PRINTF2(_L("GetRecordBalanceL left with error %d"), error);
1.1108 + SetError(error);
1.1109 + }
1.1110 + else
1.1111 + {
1.1112 + INFO_PRINTF3(_L("> Retrieved record balance values are left: %d, right:%d"), iLeftPercentage, iRightPercentage);
1.1113 + if(expectedLeftPercentage !=iLeftPercentage)
1.1114 + {
1.1115 + ERR_PRINTF3(_L("Expected left percentage value %d is different from retrieved value %d"), expectedLeftPercentage, iLeftPercentage);
1.1116 + SetBlockResult(EFail);
1.1117 + }
1.1118 + if(expectedRightPercentage !=iRightPercentage)
1.1119 + {
1.1120 + ERR_PRINTF3(_L("Expected right ercentage value %d is different from retrieved value %d"), expectedRightPercentage, iRightPercentage);
1.1121 + SetBlockResult(EFail);
1.1122 + }
1.1123 + }
1.1124 +
1.1125 + }
1.1126 + INFO_PRINTF1(_L("*END*CT_CMMFDevSoundData::DoCmdGetRecordBalanceL"));
1.1127 + }
1.1128 +
1.1129 +/**
1.1130 + * Shows a list of the supported input datatypes that can be sent to DevSound for playing audio.
1.1131 + * The datatypes returned are those that the DevSound supports given the priority settings passed
1.1132 + * in aPrioritySettings.
1.1133 + * @params none
1.1134 + * @return none
1.1135 + */
1.1136 +void CT_CMMFDevSoundData::DoCmdGetSupportedInputDataTypesL()
1.1137 + {
1.1138 + TUid outputUid= {0x0};
1.1139 + INFO_PRINTF1(_L("*START*CT_CMMFDevSoundData::DoCmdGetSupportedInputDataTypesL"));
1.1140 + RArray< TFourCC > supportedDataTypes;
1.1141 + TRAPD(error, iDevSound->GetSupportedInputDataTypesL(supportedDataTypes, iPrioritySettings));
1.1142 + if (error != KErrNone)
1.1143 + {
1.1144 + ERR_PRINTF2(_L("GetSupportedInputDataTypesL left with error %d"), error);
1.1145 + SetError(error);
1.1146 + }
1.1147 + else
1.1148 + {
1.1149 + INFO_PRINTF1(_L("List of the supported input datatypes that can be sent to DevSound for playing audio."));
1.1150 + for (TInt i=0; i<supportedDataTypes.Count(); i++)
1.1151 + {
1.1152 + TFourCC fourCC = supportedDataTypes[i];
1.1153 + TBuf<4> name;
1.1154 + for(TInt j=0; j<= KFourCCMaxBitDisplacement; j+=K8Bits)
1.1155 + {
1.1156 + name.Append((TUint8)(fourCC.FourCC() >> j));
1.1157 + }
1.1158 + INFO_PRINTF3(_L("Supported Input Data types: 0x%x %S "), fourCC.FourCC(), &name);
1.1159 + UtilityFourCCToHwDeviceUidL(name,EDecoder, outputUid);
1.1160 + if(outputUid.iUid != 0)
1.1161 + {
1.1162 + INFO_PRINTF3(_L("\nHwDevice Uid=0x%08x for %S"),outputUid.iUid,&name);
1.1163 + }
1.1164 + else
1.1165 + {
1.1166 + INFO_PRINTF1(_L("Not Found"));
1.1167 + }
1.1168 + }
1.1169 + supportedDataTypes.Reset();
1.1170 + }
1.1171 + INFO_PRINTF1(_L("*END*CT_CMMFDevSoundData::DoCmdGetSupportedInputDataTypesL"));
1.1172 + }
1.1173 +
1.1174 +/**
1.1175 + * Shows a list of the supported output dataypes that can be received from DevSound for
1.1176 + * recording audio. The datatypes returned are those that the DevSound supports given the priority
1.1177 + * settings passed in aPrioritySettings.
1.1178 + * @param none
1.1179 + * @return none
1.1180 + */
1.1181 +void CT_CMMFDevSoundData::DoCmdGetSupportedOutputDataTypesL()
1.1182 + {
1.1183 + TUid outputUid= {0x0};
1.1184 + INFO_PRINTF1(_L("*START*CT_CMMFDevSoundData::DoCmdGetSupportedOutputDataTypesL"));
1.1185 + RArray< TFourCC > supportedDataTypes;
1.1186 + TRAPD(error, iDevSound->GetSupportedOutputDataTypesL(supportedDataTypes, iPrioritySettings));
1.1187 + if (error != KErrNone)
1.1188 + {
1.1189 + ERR_PRINTF2(_L("GetSupportedOutputDataTypesL left with error %d"), error);
1.1190 + SetError(error);
1.1191 + }
1.1192 + else
1.1193 + {
1.1194 + INFO_PRINTF1(_L("List of the supported output dataypes that can be received from DevSound for recording audio."));
1.1195 + for (TInt i=0; i<supportedDataTypes.Count(); i++)
1.1196 + {
1.1197 + TFourCC fourCC = supportedDataTypes[i];
1.1198 + TBuf<4> name;
1.1199 + for(TInt j=0; j<=KFourCCMaxBitDisplacement; j+=K8Bits)
1.1200 + {
1.1201 + name.Append((TUint8)(fourCC.FourCC() >> j));
1.1202 + }
1.1203 + INFO_PRINTF3(_L("Supported Output Data types: 0x%x %S "), fourCC.FourCC(), &name);
1.1204 + UtilityFourCCToHwDeviceUidL(name, EEncoder, outputUid);
1.1205 + if(outputUid.iUid != 0)
1.1206 + {
1.1207 + INFO_PRINTF3(_L("\nHwDevice Uid=0x%08x for %S"),outputUid.iUid,&name);
1.1208 + }
1.1209 + else
1.1210 + {
1.1211 + INFO_PRINTF1(_L("Not Found"));
1.1212 + }
1.1213 + }
1.1214 + supportedDataTypes.Reset();
1.1215 + }
1.1216 + INFO_PRINTF1(_L("*END*CT_CMMFDevSoundData::DoCmdGetSupportedOutputDataTypesL"));
1.1217 + }
1.1218 +
1.1219 +/**
1.1220 + * Shows the number of samples played
1.1221 + * @param none
1.1222 + * @return none
1.1223 + */
1.1224 +void CT_CMMFDevSoundData::DoCmdSamplesPlayed()
1.1225 + {
1.1226 + INFO_PRINTF1(_L("*START*CT_CMMFDevSoundData::DoCmdSamplesPlayed"));
1.1227 + INFO_PRINTF2(_L("Number of samples played so far: %d"),iDevSound->SamplesPlayed());
1.1228 + INFO_PRINTF1(_L("*END*CT_CMMFDevSoundData::DoCmdSamplesPlayed"));
1.1229 + }
1.1230 +
1.1231 +/**
1.1232 + * Shows the number of samples recorded
1.1233 + * @param none
1.1234 + * @return none
1.1235 + */
1.1236 +void CT_CMMFDevSoundData::DoCmdSamplesRecorded()
1.1237 + {
1.1238 + INFO_PRINTF1(_L("*START*CT_CMMFDevSoundData::DoCmdSamplesRecorded"));
1.1239 + INFO_PRINTF2(_L("Number of samples recorded so far: %d"), iDevSound->SamplesRecorded());
1.1240 + INFO_PRINTF1(_L("*END*CT_CMMFDevSoundData::DoCmdSamplesRecorded"));
1.1241 + }
1.1242 +
1.1243 +/**
1.1244 + * Shows an integer representing the current volume.
1.1245 + * @param aSection - Section to read param from the ini file
1.1246 + * @return none
1.1247 + */
1.1248 +void CT_CMMFDevSoundData::DoCmdVolume(const TTEFSectionName& aSection)
1.1249 + {
1.1250 + INFO_PRINTF1(_L("*START*CT_CMMFDevSoundData::DoCmdVolume"));
1.1251 + TBool dataOk = ETrue;
1.1252 + TInt expectedVolumeValue=0;
1.1253 + if(!GetIntFromConfig(aSection, KVolumeValue, expectedVolumeValue))
1.1254 + {
1.1255 + ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KVolumeValue);
1.1256 + SetBlockResult(EFail);
1.1257 + dataOk = EFalse;
1.1258 + }
1.1259 + if(dataOk)
1.1260 + {
1.1261 + iVolumeValue = iDevSound->Volume();
1.1262 + INFO_PRINTF2(_L("Retrieved volume value: %d"), iVolumeValue);
1.1263 + if(expectedVolumeValue != iVolumeValue)
1.1264 + {
1.1265 + ERR_PRINTF3(_L("Expected volume value %d is different from retrieved volume value %d"), expectedVolumeValue, iVolumeValue);
1.1266 + SetBlockResult(EFail);
1.1267 + }
1.1268 + }
1.1269 + INFO_PRINTF1(_L("*END*CT_CMMFDevSoundData::DoCmdVolume"));
1.1270 + }
1.1271 +
1.1272 +/**
1.1273 + * Shows an integer representing the current gain.
1.1274 + * @param aSection - Section to read param from the ini file
1.1275 + * @return none
1.1276 + */
1.1277 +void CT_CMMFDevSoundData::DoCmdGain(const TTEFSectionName& aSection)
1.1278 + {
1.1279 + INFO_PRINTF1(_L("*START*CT_CMMFDevSoundData::DoCmdGain"));
1.1280 + TBool dataOk = ETrue;
1.1281 + TInt expectedGainValue=0;
1.1282 + if(!GetIntFromConfig(aSection, KGainValue, expectedGainValue))
1.1283 + {
1.1284 + ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KGainValue);
1.1285 + SetBlockResult(EFail);
1.1286 + dataOk = EFalse;
1.1287 + }
1.1288 + if(dataOk)
1.1289 + {
1.1290 + iGainValue = iDevSound->Gain();
1.1291 + INFO_PRINTF2(_L("Retrieved gain value: %d"), iGainValue);
1.1292 + if(expectedGainValue != iGainValue)
1.1293 + {
1.1294 + ERR_PRINTF3(_L("Expected gain value %d is different from retrieved gain value %d"), expectedGainValue, iGainValue);
1.1295 + SetBlockResult(EFail);
1.1296 + }
1.1297 + }
1.1298 + INFO_PRINTF1(_L("*END*CT_CMMFDevSoundData::DoCmdGain"));
1.1299 + }
1.1300 +
1.1301 +/**
1.1302 + * Shows the number of available pre-defined tone sequences
1.1303 + * @param none
1.1304 + * @return none
1.1305 + */
1.1306 +void CT_CMMFDevSoundData::DoCmdFixedSequenceCount()
1.1307 + {
1.1308 + INFO_PRINTF1(_L("*START*CT_CMMFDevSoundData::DoCmdFixedSequenceCount"));
1.1309 + INFO_PRINTF2(_L("Number of available pre-defined tone sequences: %d"), iDevSound->FixedSequenceCount());
1.1310 + INFO_PRINTF1(_L("*END*CT_CMMFDevSoundData::DoCmdFixedSequenceCount"));
1.1311 + }
1.1312 +
1.1313 +/**
1.1314 + * Shows the name assigned to a specific pre-defined tone sequence.
1.1315 + * This is the number of the fixed sequence supported by DevSound by default.
1.1316 + * @param aSection - Section to read params from the ini file
1.1317 + * @return none
1.1318 + */
1.1319 +void CT_CMMFDevSoundData::DoCmdFixedSequenceName(const TTEFSectionName& aSection)
1.1320 + {
1.1321 + INFO_PRINTF1(_L("*START*CT_CMMFDevSoundData::DoCmdFixedSequenceName"));
1.1322 + TBool dataOk =ETrue;
1.1323 + TInt sequenceNumber=0;
1.1324 + if(!GetIntFromConfig(aSection, KSequenceNumber, sequenceNumber))
1.1325 + {
1.1326 + ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KSequenceNumber);
1.1327 + SetBlockResult(EFail);
1.1328 + dataOk =EFalse;
1.1329 + }
1.1330 + if(dataOk)
1.1331 + {
1.1332 + INFO_PRINTF2(_L("Name assigned to a specific pre-defined tone sequence returned: %S"),
1.1333 + &iDevSound->FixedSequenceName(sequenceNumber));
1.1334 + }
1.1335 + INFO_PRINTF1(_L("*END*CT_CMMFDevSoundData::DoCmdFixedSequenceName"));
1.1336 + }
1.1337 +
1.1338 +
1.1339 +/**
1.1340 + * Configure CMMFDevSound object with the settings in aConfig.
1.1341 + * Use this to set sampling rate, encoding and mono/stereo.
1.1342 + * @param aSection - Section to read params from the ini file
1.1343 + * @return none
1.1344 + */
1.1345 +void CT_CMMFDevSoundData::DoCmdSetConfigL(const TTEFSectionName& aSection)
1.1346 + {
1.1347 + INFO_PRINTF1(_L("*START*CT_CMMFDevSoundData::DoCmdSetConfigL"));
1.1348 +
1.1349 + TInt rate=0;
1.1350 + INFO_PRINTF1(_L("To use default values run Capabilities before SetConfigL"));
1.1351 + if (!GetEnumFromConfig(aSection, KRate, iEnumSampleRate, rate))
1.1352 + {
1.1353 + INFO_PRINTF2(_L("Rate value was not overwritten, using default value %d."), iCapabilities.iRate);
1.1354 + }
1.1355 + else
1.1356 + {
1.1357 + iCapabilities.iRate = rate;
1.1358 + }
1.1359 +
1.1360 + TInt encoding=0;
1.1361 + if (!GetIntFromConfig(aSection, KEncoding, encoding))
1.1362 + {
1.1363 + INFO_PRINTF2(_L("Encoding value was not overwritten, using default value %d."), iCapabilities.iEncoding);
1.1364 + }
1.1365 + else
1.1366 + {
1.1367 + iCapabilities.iEncoding = encoding;
1.1368 + }
1.1369 +
1.1370 + TInt channels=0;
1.1371 + if (!GetEnumFromConfig(aSection, KChannels, iEnumChannels, channels))
1.1372 + {
1.1373 + INFO_PRINTF2(_L("Channels value was not overwritten, using default value %d ."), iCapabilities.iChannels);
1.1374 + }
1.1375 + else
1.1376 + {
1.1377 + iCapabilities.iChannels = channels;
1.1378 + }
1.1379 +
1.1380 + TInt bufferSize=0;
1.1381 + if (!GetIntFromConfig(aSection, KBufferSize, bufferSize))
1.1382 + {
1.1383 + INFO_PRINTF2(_L("BufferSize value was not overwritten, using default value %d"), iCapabilities.iBufferSize);
1.1384 + }
1.1385 + else
1.1386 + {
1.1387 + iCapabilities.iBufferSize = bufferSize;
1.1388 + }
1.1389 + TRAPD(error,iDevSound->SetConfigL(iCapabilities))
1.1390 + if(error != KErrNone)
1.1391 + {
1.1392 + ERR_PRINTF2(_L("SetConfigL left with error %d"), error);
1.1393 + SetError(error);
1.1394 + }
1.1395 + INFO_PRINTF1(_L("*END*CT_CMMFDevSoundData::DoCmdSetConfigL"));
1.1396 + }
1.1397 +
1.1398 +
1.1399 +/**
1.1400 + * Defines the duration of tone on, tone off and tone pause to be used during the
1.1401 + * DTMF tone playback operation.
1.1402 + * Supported only during tone playing.
1.1403 + * @param aSection - Section to read param from the ini file
1.1404 + * @return none
1.1405 + */
1.1406 +void CT_CMMFDevSoundData::DoCmdSetDTMFLengths(const TTEFSectionName& aSection)
1.1407 + {
1.1408 + INFO_PRINTF1(_L("*START*CT_CMMFDevSoundData::DoCmdSetDTMFLengths"));
1.1409 + TInt time=0;
1.1410 + TBool dataOk = ETrue;
1.1411 + if (!GetIntFromConfig(aSection, KToneOnLength, time))
1.1412 + {
1.1413 + ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KToneOnLength);
1.1414 + SetBlockResult(EFail);
1.1415 + dataOk = EFalse;
1.1416 + }
1.1417 + TTimeIntervalMicroSeconds32 toneOnLength(time);
1.1418 +
1.1419 + if (!GetIntFromConfig(aSection, KToneOffLength, time))
1.1420 + {
1.1421 + ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KToneOffLength);
1.1422 + SetBlockResult(EFail);
1.1423 + dataOk = EFalse;
1.1424 + }
1.1425 + TTimeIntervalMicroSeconds32 toneOffLength(time);
1.1426 +
1.1427 + if (!GetIntFromConfig(aSection, KPauseLength, time))
1.1428 + {
1.1429 + ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KPauseLength);
1.1430 + SetBlockResult(EFail);
1.1431 + dataOk = EFalse;
1.1432 + }
1.1433 + TTimeIntervalMicroSeconds32 pauseLength(time);
1.1434 + if(dataOk)
1.1435 + {
1.1436 + iDevSound->SetDTMFLengths(toneOnLength, toneOffLength, pauseLength);
1.1437 + }
1.1438 + INFO_PRINTF1(_L("*END*CT_CMMFDevSoundData::DoCmdSetDTMFLengths"));
1.1439 + }
1.1440 +
1.1441 +
1.1442 +/**
1.1443 + * Changes the current recording gain to a specified value.
1.1444 + * The gain can be changed before or during recording and is effective
1.1445 + * immediately.
1.1446 + * @params aSection - Section to read param from the ini file
1.1447 + */
1.1448 +void CT_CMMFDevSoundData::DoCmdSetGain(const TTEFSectionName& aSection)
1.1449 + {
1.1450 + INFO_PRINTF1(_L("*START*CT_CMMFDevSoundData::DoCmdSetGain"));
1.1451 + TInt gainValue = iGainValue;
1.1452 + if(!GetIntFromConfig(aSection, KGainValue, gainValue))
1.1453 + {
1.1454 + INFO_PRINTF1(_L("The Gain value was not found in the ini file, using default value"));
1.1455 + }
1.1456 + INFO_PRINTF2(_L("Setting gain value to %d"), gainValue);
1.1457 + iDevSound->SetGain(gainValue);
1.1458 + INFO_PRINTF1(_L("*END*CT_CMMFDevSoundData::DoCmdSetGain"));
1.1459 + }
1.1460 +
1.1461 +/**
1.1462 + * Sets the speaker balance for playing.
1.1463 + * The speaker balance can be changed before or during playback and is
1.1464 + * effective immediately.
1.1465 + * @param aSection - The section to read params from the ini file
1.1466 + * @return none
1.1467 + */
1.1468 +void CT_CMMFDevSoundData::DoCmdSetPlayBalanceL(const TTEFSectionName& aSection)
1.1469 + {
1.1470 + INFO_PRINTF1(_L("*START*CT_CMMFDevSoundData::DoCmdSetPlayBalanceL"));
1.1471 + TInt leftPercentage = iLeftPercentage;
1.1472 + if(!GetIntFromConfig(aSection, KLeftPercentage, leftPercentage))
1.1473 + {
1.1474 + INFO_PRINTF1(_L("The Left percentage was not found in the ini file, using default value"));
1.1475 + }
1.1476 + TInt rightPercentage = iRightPercentage;
1.1477 + if(!GetIntFromConfig(aSection, KRightPercentage, rightPercentage))
1.1478 + {
1.1479 + INFO_PRINTF1(_L("The Right percentage was not found in the ini file, using default value"));
1.1480 + }
1.1481 + INFO_PRINTF3(_L("Setting play balance to left: %d, right: %d values"), leftPercentage, rightPercentage);
1.1482 + TRAPD(error, iDevSound->SetPlayBalanceL(leftPercentage, rightPercentage));
1.1483 + if(error != KErrNone)
1.1484 + {
1.1485 + ERR_PRINTF2(_L("SetPlayBalanceL left with error %d"), error);
1.1486 + SetError(error);
1.1487 + }
1.1488 + INFO_PRINTF1(_L("*END*CT_CMMFDevSoundData::DoCmdSetPlayBalanceL"));
1.1489 + }
1.1490 +
1.1491 +/**
1.1492 + * Defines the priority settings that should be used for this instance.
1.1493 + * @param aSection - Section to read params from the ini file
1.1494 + * @return none
1.1495 + */
1.1496 +void CT_CMMFDevSoundData::DoCmdSetPrioritySettings(const TTEFSectionName& aSection)
1.1497 + {
1.1498 + INFO_PRINTF1(_L("*START*CT_CMMFDevSoundData::DoCmdSetPrioritySettings"));
1.1499 + TBool dataOk = ETrue;
1.1500 + if(!GetIntFromConfig(aSection, KPriority, iPrioritySettings.iPriority))
1.1501 + {
1.1502 + ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KPriority);
1.1503 + SetBlockResult(EFail);
1.1504 + dataOk = EFalse;
1.1505 + }
1.1506 + TInt preference=0;
1.1507 + if (!GetHexFromConfig(aSection, KPreference, preference))
1.1508 + {
1.1509 + ERR_PRINTF2(_L("%S parameter was not found in INI file"), &KPreference);
1.1510 + SetBlockResult(EFail);
1.1511 + dataOk = EFalse;
1.1512 + }
1.1513 + iPrioritySettings.iPref = (TMdaPriorityPreference)preference;
1.1514 + TInt state=0;
1.1515 + if (!GetEnumFromConfig(aSection, KPriorityState, iEnumMode, state))
1.1516 + {
1.1517 + ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KPriorityState);
1.1518 + SetBlockResult(EFail);
1.1519 + dataOk = EFalse;
1.1520 + }
1.1521 + iPrioritySettings.iState = (TMMFState)state;
1.1522 + if(dataOk)
1.1523 + {
1.1524 + iDevSound->SetPrioritySettings(iPrioritySettings);
1.1525 + }
1.1526 + INFO_PRINTF1(_L("*END*CT_CMMFDevSoundData::DoCmdSetPrioritySettings"));
1.1527 + }
1.1528 +
1.1529 +/**
1.1530 + * Sets the microphone gain balance for recording.
1.1531 + * The microphone gain balance can be changed before or during recording and
1.1532 + * is effective immediately.
1.1533 + * @param aSection - Section to read params from the ini file
1.1534 + * @return none
1.1535 + */
1.1536 +void CT_CMMFDevSoundData::DoCmdSetRecordBalanceL(const TTEFSectionName& aSection)
1.1537 + {
1.1538 + INFO_PRINTF1(_L("*START*CT_CMMFDevSoundData::DoCmdSetRecordBalanceL"));
1.1539 + TInt leftPercentage = iLeftPercentage;
1.1540 + if (!GetIntFromConfig(aSection, KLeftPercentage, leftPercentage))
1.1541 + {
1.1542 + INFO_PRINTF1(_L("The Left value was not found in the ini file, using default value"));
1.1543 + }
1.1544 + TInt rightPercentage = iRightPercentage;
1.1545 + if (!GetIntFromConfig(aSection, KRightPercentage, rightPercentage))
1.1546 + {
1.1547 + INFO_PRINTF1(_L("The Right value was not found in the ini file, using default value"));
1.1548 + }
1.1549 + INFO_PRINTF3(_L("Setting record balance to left: %d, right: %d values"), leftPercentage, rightPercentage);
1.1550 + TRAPD(error, iDevSound->SetRecordBalanceL(leftPercentage, rightPercentage));
1.1551 + if (KErrNone != error)
1.1552 + {
1.1553 + ERR_PRINTF2(_L("SetRecordBalanceL left with error %d"), error);
1.1554 + SetError(error);
1.1555 + }
1.1556 + INFO_PRINTF1(_L("*END*CT_CMMFDevSoundData::DoCmdSetRecordBalanceL"));
1.1557 + }
1.1558 +
1.1559 +/**
1.1560 + * Defines the number of times the audio is to be repeated during the tone
1.1561 + * playback operation.
1.1562 + * A period of silence can follow each playing of a tone. The tone playing can
1.1563 + * be repeated indefinitely.
1.1564 + * @param aSection - Section to read params from the ini file
1.1565 + * @return none
1.1566 + */
1.1567 +void CT_CMMFDevSoundData::DoCmdSetToneRepeats(const TTEFSectionName& aSection)
1.1568 + {
1.1569 + INFO_PRINTF1(_L("*START*CT_CMMFDevSoundData::DoCmdSetToneRepeats"));
1.1570 + TInt repeatCount=0;
1.1571 + TBool dataOk = ETrue;
1.1572 + if (!GetIntFromConfig(aSection, KRepeatCount, repeatCount))
1.1573 + {
1.1574 + ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KRepeatCount);
1.1575 + SetBlockResult(EFail);
1.1576 + dataOk = EFalse;
1.1577 + }
1.1578 +
1.1579 + TInt tempValue=0;
1.1580 + if (!GetIntFromConfig(aSection, KRepeatTrailingSilence, tempValue))
1.1581 + {
1.1582 + ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KRepeatTrailingSilence);
1.1583 + SetBlockResult(EFail);
1.1584 + dataOk = EFalse;
1.1585 + }
1.1586 + TTimeIntervalMicroSeconds repeatTrailingSilence(tempValue);
1.1587 +
1.1588 + if(dataOk)
1.1589 + {
1.1590 + iDevSound->SetToneRepeats(repeatCount, repeatTrailingSilence);
1.1591 + }
1.1592 + INFO_PRINTF1(_L("*END*CT_CMMFDevSoundData::DoCmdSetToneRepeats"));
1.1593 + }
1.1594 +
1.1595 +/**
1.1596 + * Defines the period over which the volume level is to rise smoothly from
1.1597 + * nothing to the normal volume level.
1.1598 + * The function is only available while the tone is playing.
1.1599 + * @param aSection - Section to read params from the ini file
1.1600 + * @return none
1.1601 + */
1.1602 +void CT_CMMFDevSoundData::DoCmdSetVolume(const TTEFSectionName& aSection)
1.1603 + {
1.1604 + INFO_PRINTF1(_L("*START*CT_CMMFDevSoundData::DoCmdSetVolume"));
1.1605 + TInt volume = iVolumeValue;
1.1606 + if(!GetIntFromConfig(aSection, KVolumeValue, volume))
1.1607 + {
1.1608 + INFO_PRINTF1(_L("The Volume value was not found in the ini file, using default value"));
1.1609 + }
1.1610 + INFO_PRINTF2(_L("Setting volume value to %d"), volume);
1.1611 + iDevSound->SetVolume(volume);
1.1612 + INFO_PRINTF1(_L("*END*CT_CMMFDevSoundData::DoCmdSetVolume"));
1.1613 + }
1.1614 +
1.1615 +/**
1.1616 + * Defines the loop over which the volume level is to rise smoothly from
1.1617 + * nothing to the normal volume level.
1.1618 + * @param aSection - Section to read params from the ini file
1.1619 + * @return none
1.1620 + */
1.1621 +void CT_CMMFDevSoundData::DoCmdSetVolumeLoop(const TTEFSectionName& aSection)
1.1622 + {
1.1623 + INFO_PRINTF1(_L("*START*CT_CMMFDevSoundData::DoCmdSetVolumeLoop"));
1.1624 + TInt volLoop=0;
1.1625 + TBool dataOk = ETrue;
1.1626 + if (!GetIntFromConfig(aSection, KVolumeLoop, volLoop))
1.1627 + {
1.1628 + ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KVolumeLoop);
1.1629 + SetBlockResult(EFail);
1.1630 + dataOk = EFalse;
1.1631 + }
1.1632 + if(dataOk)
1.1633 + {
1.1634 + TPtrC parVolume;
1.1635 + TInt volumeValue=0;
1.1636 + RPointerArray<HBufC> volumeList;
1.1637 + for (TInt i=0; i<volLoop; i++)
1.1638 + {
1.1639 + if (!GetArrayRectFromConfig(aSection, KVolumeList, volumeList))
1.1640 + {
1.1641 + ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KVolumeList);
1.1642 + volumeList.ResetAndDestroy();
1.1643 + SetBlockResult(EFail);
1.1644 + dataOk = EFalse;
1.1645 + }
1.1646 + if(dataOk)
1.1647 + {
1.1648 + for (TInt j=0; j<volumeList.Count(); j++)
1.1649 + {
1.1650 + parVolume.Set(*volumeList[j]);
1.1651 + TLex lex(parVolume);
1.1652 + TInt error = lex.Val(volumeValue);
1.1653 + if (error != KErrNone)
1.1654 + {
1.1655 + ERR_PRINTF2(_L("Obtaining volume value failed with error %d"), error);
1.1656 + SetError(error);
1.1657 + volumeList.ResetAndDestroy();
1.1658 + }
1.1659 + else
1.1660 + {
1.1661 + INFO_PRINTF3(_L("Setting volume number %d in the iteration number %d"), j, i);
1.1662 + iDevSound->SetVolume(volumeValue);
1.1663 + }
1.1664 + }
1.1665 + }
1.1666 + }
1.1667 + volumeList.ResetAndDestroy();
1.1668 + }
1.1669 + INFO_PRINTF1(_L("*END*CT_CMMFDevSoundData::DoCmdSetVolumeLoop"));
1.1670 + }
1.1671 +
1.1672 +/**
1.1673 + * Defines the period over which the volume level is to rise smoothly from
1.1674 + * nothing to the normal volume level.
1.1675 + * The function is only available while the tone is playing.
1.1676 + * @param aSection - Section to read param from the ini file
1.1677 + * @return none
1.1678 + */
1.1679 +void CT_CMMFDevSoundData::DoCmdSetVolumeRamp(const TTEFSectionName& aSection)
1.1680 + {
1.1681 + INFO_PRINTF1(_L("*START*CT_CMMFDevSoundData::DoCmdSetVolumeRamp"));
1.1682 + TInt tempValue=0;
1.1683 + TBool dataOk = ETrue;
1.1684 + if (!GetIntFromConfig(aSection, KRampDuration, tempValue))
1.1685 + {
1.1686 + ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KRampDuration);
1.1687 + SetBlockResult(EFail);
1.1688 + dataOk = EFalse;
1.1689 + }
1.1690 + TTimeIntervalMicroSeconds rampDuration(tempValue);
1.1691 +
1.1692 + if(dataOk)
1.1693 + {
1.1694 + iDevSound->SetVolumeRamp(rampDuration);
1.1695 + }
1.1696 + INFO_PRINTF1(_L("*END*CT_CMMFDevSoundData::DoCmdSetVolumeRamp"));
1.1697 + }
1.1698 +
1.1699 +/**
1.1700 + * Initializes DevSound object for the mode aMode for processing audio data
1.1701 + * with hardware device aHWDev and supporting FourCC.
1.1702 + * Too Initializes CMMFDevSound object to play and record PCM16 raw audio data
1.1703 + * with sampling rate of 8 KHz.
1.1704 + * @param aSection - Section to read params from the ini file
1.1705 + */
1.1706 +void CT_CMMFDevSoundData::DoCmdInitializeL(const TTEFSectionName& aSection, const TInt aAsyncErrorIndex)
1.1707 + {
1.1708 + INFO_PRINTF1(_L("*START*CT_CMMFDevSoundData::DoCmdInitializeL"));
1.1709 + TBool dataOk = ETrue;
1.1710 + TInt mode=0;
1.1711 + if (!GetEnumFromConfig(aSection, KMode, iEnumMode, mode))
1.1712 + {
1.1713 + ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KMode);
1.1714 + SetBlockResult(EFail);
1.1715 + dataOk = EFalse;
1.1716 + }
1.1717 + else
1.1718 + {
1.1719 + TInt hwDeviceInt=0;
1.1720 + if (!GetHexFromConfig(aSection, KHwDevice, hwDeviceInt))
1.1721 + {
1.1722 + INFO_PRINTF2(_L("%S parameter was not found in INI file"), &KHwDevice);
1.1723 + TPtrC fourCCIniString;
1.1724 + if (!GetStringFromConfig(aSection, KFourCC, fourCCIniString))
1.1725 + {
1.1726 + INFO_PRINTF2(_L("%S parameter was not found in INI file"), &KFourCC);
1.1727 + if (dataOk)
1.1728 + {
1.1729 + INFO_PRINTF1(_L("Initializing DevSound with overload: void InitializeL(MDevSoundObserver &aDevSoundObserver, TMMFState aMode)"));
1.1730 + TRAPD(error, iDevSound->InitializeL(*this, (TMMFState)mode));
1.1731 + if(KErrNone != error)
1.1732 + {
1.1733 + ERR_PRINTF2(_L("InitializeL(aMDevSoundObserver, mode) left with error %d"), error);
1.1734 + SetError(error);
1.1735 + }
1.1736 + }
1.1737 + }
1.1738 + else
1.1739 + {
1.1740 + if (fourCCIniString.Length() > KTFourCC)
1.1741 + {
1.1742 + ERR_PRINTF2(_L("FourCC obtained from INI file exceeded the valid length in %d"), fourCCIniString.Length());
1.1743 + SetBlockResult(EFail);
1.1744 + dataOk = EFalse;
1.1745 + }
1.1746 + if (dataOk)
1.1747 + {
1.1748 + TBuf<256> fourCCString;
1.1749 + fourCCString.Copy(fourCCIniString);
1.1750 + while (fourCCString.Length() < KTFourCC)
1.1751 + {
1.1752 + fourCCString.Insert(0, _L(" "));
1.1753 + }
1.1754 + TFourCC fourCC;
1.1755 + fourCC = TFourCC(fourCCString[3] << 24 | fourCCString[2] << 16 | fourCCString[1] << 8 | fourCCString[0]);
1.1756 + INFO_PRINTF1(_L("Initializing DevSound with overload: void InitializeL(MDevSoundObserver &aDevSoundObserver, TFourCC aDesiredFourCC, TMMFState aMode)"));
1.1757 + TRAPD(error, iDevSound->InitializeL(*this, fourCC, (TMMFState)mode));
1.1758 + if(KErrNone!=error)
1.1759 + {
1.1760 + ERR_PRINTF2(_L("InitializeL(aMDevSoundObserver, fourCC, mode) left with error %d"), error);
1.1761 + ERR_PRINTF2(_L(" %S Not supported in this device"), &fourCCString);
1.1762 + SetError(error);
1.1763 + SetBlockResult(EFail);
1.1764 + }
1.1765 + }
1.1766 + }
1.1767 + }
1.1768 + else
1.1769 + {
1.1770 + if (dataOk)
1.1771 + {
1.1772 + TUid hwDevice;
1.1773 + hwDevice.iUid = hwDeviceInt;
1.1774 + INFO_PRINTF1(_L("Initializing DevSound with overload: void InitializeL(MDevSoundObserver &aDevSoundObserver, TUid aHWDev, TMMFState aMode)"));
1.1775 + TRAPD(error, iDevSound->InitializeL(*this, hwDevice, (TMMFState)mode));
1.1776 + if(KErrNone != error)
1.1777 + {
1.1778 + ERR_PRINTF2(_L("InitializeL(aMDevSoundObserver, hwDevice, mode) left with error %d"), error);
1.1779 + SetError(error);
1.1780 + }
1.1781 + }
1.1782 + }
1.1783 + }
1.1784 +
1.1785 + if (dataOk)
1.1786 + {
1.1787 + IncOutstanding();
1.1788 + iInitializeErrorIndex = aAsyncErrorIndex;
1.1789 + }
1.1790 + INFO_PRINTF1(_L("*END*CT_CMMFDevSoundData::DoCmdInitializeL"));
1.1791 + }
1.1792 +
1.1793 +
1.1794 +/**
1.1795 + * Initializes the audio device and starts playing the DTMF string aDTMFString.
1.1796 + * @param aSection - Section to read param from the ini file
1.1797 + * @return none
1.1798 + */
1.1799 +void CT_CMMFDevSoundData::DoCmdPlayDTMFStringL(const TTEFSectionName& aSection, const TInt aAsyncErrorIndex)
1.1800 + {
1.1801 + INFO_PRINTF1(_L("*START*CT_CMMFDevSoundData::DoCmdPlayDTMFStringL"));
1.1802 + TBool dataOk = ETrue;
1.1803 + TPtrC dtmfString;
1.1804 + if (!GetStringFromConfig(aSection, KDTMFString, dtmfString) )
1.1805 + {
1.1806 + ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KDTMFString);
1.1807 + SetBlockResult(EFail);
1.1808 + dataOk = EFalse;
1.1809 + }
1.1810 + if(dataOk)
1.1811 + {
1.1812 + TRAPD( error, iDevSound->PlayDTMFStringL(dtmfString) );
1.1813 + if(error != KErrNone)
1.1814 + {
1.1815 + ERR_PRINTF2(_L("Play DTMF string failed with error: %d "), error);
1.1816 + SetError(error);
1.1817 + }
1.1818 + else
1.1819 + {
1.1820 + iToneErrorIndex = aAsyncErrorIndex;
1.1821 + IncOutstanding();
1.1822 + }
1.1823 + }
1.1824 +
1.1825 + INFO_PRINTF1(_L("*END*CT_CMMFDevSoundData::DoCmdPlayDTMFStringL"));
1.1826 + }
1.1827 +
1.1828 +/**
1.1829 + * Plays data in the buffer at the current volume.
1.1830 + * @param
1.1831 + * @return
1.1832 + */
1.1833 +void CT_CMMFDevSoundData::DoCmdPlayData()
1.1834 + {
1.1835 + INFO_PRINTF1(_L("*START*CT_CMMFDevSoundData::DoCmdPlayData"));
1.1836 + PlayData();
1.1837 + INFO_PRINTF1(_L("*END*CT_CMMFDevSoundData::DoCmdPlayData"));
1.1838 + }
1.1839 +
1.1840 +/**
1.1841 + * Helper for the DoCmdPlayData command
1.1842 + */
1.1843 +void CT_CMMFDevSoundData::PlayData()
1.1844 + {
1.1845 + INFO_PRINTF1(_L("CT_CMMFDevSoundData::PlayData()"));
1.1846 + iDevSound->PlayData();
1.1847 + }
1.1848 +
1.1849 +/**
1.1850 + * Initializes audio device and starts playing a dual tone.
1.1851 + * The generated tone consists of two sine waves of different frequencies summed together.
1.1852 + * Dual Tone is played with the specified frequencies and for the specified duration.
1.1853 + * @param aSection - Section to read params from the ini file.
1.1854 + * @return none
1.1855 + */
1.1856 +void CT_CMMFDevSoundData::DoCmdPlayDualToneL(const TTEFSectionName& aSection , const TInt aAsyncErrorIndex)
1.1857 + {
1.1858 + INFO_PRINTF1(_L("*START*CT_CMMFDevSoundData::DoCmdPlayDualToneL"));
1.1859 + TBool dataOk = ETrue;
1.1860 + TInt frequencyOne=0;
1.1861 + if (!GetIntFromConfig(aSection, KFrequencyOne, frequencyOne) )
1.1862 + {
1.1863 + ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KFrequencyOne);
1.1864 + SetBlockResult(EFail);
1.1865 + dataOk = EFalse;
1.1866 + }
1.1867 +
1.1868 + TInt frequencyTwo=0;
1.1869 + if (!GetIntFromConfig(aSection, KFrequencyTwo, frequencyTwo) )
1.1870 + {
1.1871 + ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KFrequencyTwo);
1.1872 + SetBlockResult(EFail);
1.1873 + dataOk = EFalse;
1.1874 + }
1.1875 +
1.1876 + TInt duration=0;
1.1877 + if (!GetIntFromConfig(aSection, KDuration, duration) )
1.1878 + {
1.1879 + ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KDuration);
1.1880 + SetBlockResult(EFail);
1.1881 + dataOk = EFalse;
1.1882 + }
1.1883 + if(dataOk)
1.1884 + {
1.1885 + TRAPD( error, iDevSound->PlayDualToneL(frequencyOne, frequencyTwo, duration) );
1.1886 + if(error != KErrNone)
1.1887 + {
1.1888 + ERR_PRINTF2(_L("Play dual tone failed with error %d"), error);
1.1889 + SetError(error);
1.1890 + }
1.1891 + else
1.1892 + {
1.1893 + iToneErrorIndex = aAsyncErrorIndex;
1.1894 + IncOutstanding();
1.1895 + }
1.1896 + }
1.1897 +
1.1898 + INFO_PRINTF1(_L("*END*CT_CMMFDevSoundData::DoCmdPlayDualToneL"));
1.1899 + }
1.1900 +
1.1901 +
1.1902 +/**
1.1903 + * Initializes the audio device and starts the play process.
1.1904 + *
1.1905 + * This function queries and acquires the audio policy before initializing audio device. If there was
1.1906 + * an error during policy initialization, PlayError() function will be called on the observer with
1.1907 + * error code KErrAccessDenied, otherwise BufferToBeFilled() function will be called with a buffer
1.1908 + * reference. After reading data into the buffer reference passed, the client should call PlayData() to play data.
1.1909 + *
1.1910 + * The amount of data that can be played is specified in CMMFBuffer::RequestSize(). Any data that is read into
1.1911 + * buffer beyond this size will be ignored.
1.1912 + * @param none
1.1913 + * @return none
1.1914 + */
1.1915 +void CT_CMMFDevSoundData::DoCmdPlayInitL(const TInt aAsyncErrorIndex)
1.1916 + {
1.1917 + INFO_PRINTF1(_L("*START*CT_CMMFDevSoundData::DoCmdPlayInitL"));
1.1918 + TRAPD(error, iDevSound->PlayInitL());
1.1919 + if (error != KErrNone)
1.1920 + {
1.1921 + ERR_PRINTF2(_L("PlayInitL left with error %d"), error);
1.1922 + SetError(error);
1.1923 + }
1.1924 + else
1.1925 + {
1.1926 + iPlayErrorIndex = aAsyncErrorIndex;
1.1927 + IncOutstanding();
1.1928 + }
1.1929 + INFO_PRINTF1(_L("*END*CT_CMMFDevSoundData::DoCmdPlayInitL"));
1.1930 + }
1.1931 +
1.1932 +/**
1.1933 + * Initializes the audio device and starts playing a tone. The tone is played with the
1.1934 + * frequency and duration specified.
1.1935 + * @param aSection - Section to read params from the ini file
1.1936 + * @return none
1.1937 + */
1.1938 +void CT_CMMFDevSoundData::DoCmdPlayToneL(const TTEFSectionName& aSection , const TInt aAsyncErrorIndex)
1.1939 + {
1.1940 + INFO_PRINTF1(_L("*START*CT_CMMFDevSoundData::DoCmdPlayToneL"));
1.1941 + TBool dataOk = ETrue;
1.1942 + TInt frequency=0;
1.1943 + if (!GetIntFromConfig(aSection, KFrequency, frequency))
1.1944 + {
1.1945 + ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KFrequency);
1.1946 + SetBlockResult(EFail);
1.1947 + dataOk = EFalse;
1.1948 + }
1.1949 +
1.1950 + TInt duration=0;
1.1951 + if (!GetIntFromConfig(aSection, KDuration, duration))
1.1952 + {
1.1953 + ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KDuration);
1.1954 + SetBlockResult(EFail);
1.1955 + dataOk = EFalse;
1.1956 + }
1.1957 + if(dataOk)
1.1958 + {
1.1959 + TRAPD(error, iDevSound->PlayToneL(frequency, duration));
1.1960 + if (error != KErrNone)
1.1961 + {
1.1962 + ERR_PRINTF2(_L("Play tone failed with error %d"), error);
1.1963 + SetError(error);
1.1964 + }
1.1965 + else
1.1966 + {
1.1967 + iToneErrorIndex = aAsyncErrorIndex;
1.1968 + IncOutstanding();
1.1969 + }
1.1970 + }
1.1971 + INFO_PRINTF1(_L("*END*CT_CMMFDevSoundData::DoCmdPlayToneL"));
1.1972 + }
1.1973 +
1.1974 +/**
1.1975 + * Initializes the audio device and starts playing a tone sequence.
1.1976 + * @param aSection - Section to read param from the ini file
1.1977 + * @return none
1.1978 + */
1.1979 +void CT_CMMFDevSoundData::DoCmdPlayToneSequenceL(const TTEFSectionName& aSection , const TInt aAsyncErrorIndex)
1.1980 + {
1.1981 + INFO_PRINTF1(_L("*START*CT_CMMFDevSoundData::DoCmdPlayToneSequenceL"));
1.1982 + TBool dataOk = ETrue;
1.1983 + TPtrC toneFileParameter;
1.1984 + if (!GetStringFromConfig(aSection, KFilename, toneFileParameter))
1.1985 + {
1.1986 + ERR_PRINTF2(_L("Error in getting parameter %S from INI file"), &KFilename);
1.1987 + SetBlockResult(EFail);
1.1988 + dataOk = EFalse;
1.1989 + }
1.1990 + if(dataOk)
1.1991 + {
1.1992 + TInt error = iToneFile.Open(iFs, toneFileParameter, EFileRead);
1.1993 + if (error != KErrNone)
1.1994 + {
1.1995 + ERR_PRINTF2(_L("Open file failed with error %d"), error);
1.1996 + SetError(EFail);
1.1997 + }
1.1998 + else
1.1999 + {
1.2000 + error = iToneFile.Read(iToneSequence);
1.2001 + if (error != KErrNone)
1.2002 + {
1.2003 + ERR_PRINTF2(_L("Read file failed with error %d"), error);
1.2004 + SetError(EFail);
1.2005 + }
1.2006 + else
1.2007 + {
1.2008 + TRAP(error, iDevSound->PlayToneSequenceL(iToneSequence));
1.2009 + if (error != KErrNone)
1.2010 + {
1.2011 + ERR_PRINTF2(_L("Play tone sequence failed with error %d"), error);
1.2012 + SetError(error);
1.2013 + }
1.2014 + else
1.2015 + {
1.2016 + iToneErrorIndex = aAsyncErrorIndex;
1.2017 + IncOutstanding();
1.2018 + }
1.2019 + }
1.2020 + }
1.2021 + }
1.2022 + INFO_PRINTF1(_L("*END*CT_CMMFDevSoundData::DoCmdPlayToneSequenceL"));
1.2023 + }
1.2024 +
1.2025 +/**
1.2026 + * Contine the process of recording.
1.2027 + *
1.2028 + * Once the buffer is filled with recorded data, the Observer gets a reference to the buffer along
1.2029 + * with the callback function BufferToBeEmptied(). After processing the buffer (copying over to a
1.2030 + * different buffer or writing to file) the client should call this function to continue the
1.2031 + * recording process.
1.2032 + * @param none
1.2033 + * @return none
1.2034 + */
1.2035 +void CT_CMMFDevSoundData::DoCmdRecordData()
1.2036 + {
1.2037 + INFO_PRINTF1(_L("*START*CT_CMMFDevSoundData::DoCmdRecordData"));
1.2038 + RecordData();
1.2039 + INFO_PRINTF1(_L("*END*CT_CMMFDevSoundData::DoCmdRecordData"));
1.2040 + }
1.2041 +
1.2042 +/**
1.2043 + * Helper method to DoCmdRecordData command
1.2044 + */
1.2045 +void CT_CMMFDevSoundData::RecordData()
1.2046 + {
1.2047 + iDevSound->RecordData();
1.2048 + }
1.2049 +
1.2050 +/**
1.2051 + * Initializes audio device and starts the recording process.
1.2052 + *
1.2053 + * This command queries and acquires the audio policy before initializing audio device. If there
1.2054 + * was an error during policy initialization, RecordError() function will be called on the observer
1.2055 + * with error code KErrAccessDenied, otherwise BufferToBeEmptied() function will be called with a
1.2056 + * buffer reference. This buffer contains recorded or encoded data. After processing data in the
1.2057 + * buffer reference passed, the client should call RecordData() to continue recording process.
1.2058 + *
1.2059 + * The amount of data that is available is specified in CMMFBuffer::RequestSize().
1.2060 + * @param none
1.2061 + * @return none
1.2062 + */
1.2063 +void CT_CMMFDevSoundData::DoCmdRecordInitL(const TInt aAsyncErrorIndex)
1.2064 + {
1.2065 + INFO_PRINTF1(_L("*START*CT_CMMFDevSoundData::DoCmdRecordInitL"));
1.2066 + iRecordErrorIndex = aAsyncErrorIndex;
1.2067 + TRAPD(error, iDevSound->RecordInitL());
1.2068 + if (error != KErrNone)
1.2069 + {
1.2070 + ERR_PRINTF2(_L("RecordInitL left with error %d"), error);
1.2071 + SetError(error);
1.2072 + }
1.2073 + INFO_PRINTF1(_L("*END*CT_CMMFDevSoundData::DoCmdRecordInitL"));
1.2074 + }
1.2075 +
1.2076 +
1.2077 +/**
1.2078 + * Conceal an error
1.2079 + * @param none
1.2080 + * @return none
1.2081 + */
1.2082 +void CT_CMMFDevSoundData::DoCmdUtilityErrorConceal()
1.2083 + {
1.2084 + INFO_PRINTF1(_L("*START*CT_CMMFDevSoundData::DoCmdErrorConceal"));
1.2085 + iErrorConceal=ETrue;
1.2086 + INFO_PRINTF1(_L("*END*CT_CMMFDevSoundData::DoCmdErrorConceal"));
1.2087 + }
1.2088 +
1.2089 +/**
1.2090 + * Stop an audio file
1.2091 + * @param none
1.2092 + * @return none
1.2093 + */
1.2094 +void CT_CMMFDevSoundData::DoCmdStop(const TTEFSectionName& aSection)
1.2095 + {
1.2096 + INFO_PRINTF1(_L("*START*CT_CMMFDevSoundData::DoCmdStop"));
1.2097 + TBool pause;
1.2098 + if(!GetBoolFromConfig(aSection,KPause,pause))
1.2099 + {
1.2100 + INFO_PRINTF1(_L("The DoCmdStop command will be execute"));
1.2101 + pause = EFalse;
1.2102 + }
1.2103 + iPaused=pause;
1.2104 + if(iPaused)
1.2105 + {
1.2106 + INFO_PRINTF1(_L("a Pause was required"));
1.2107 + }
1.2108 + Stop();
1.2109 + INFO_PRINTF1(_L("*END*CT_CMMFDevSoundData::DoCmdStop"));
1.2110 + }
1.2111 +
1.2112 +
1.2113 +
1.2114 +
1.2115 +/**
1.2116 + * Utility for get the HwDevice for play and recording
1.2117 + */
1.2118 +
1.2119 +void CT_CMMFDevSoundData::UtilityFourCCToHwDeviceUidL(const TDesC& aFourCC, THwDeviceType aType, TUid& aHwDeviceUid)
1.2120 + {
1.2121 + TPtrC8 fourCCPtr(0,0);
1.2122 + TPtrC8 fourCCP16Ptr(0,0);
1.2123 + RImplInfoPtrArray impArray;
1.2124 + CleanupResetAndDestroyPushL(impArray);
1.2125 + REComSession::ListImplementationsL(TUid::Uid(KMmfUidPluginInterfaceHwDevice), impArray);
1.2126 + TBuf<KHwDeviceDefaultDataLength> datatype;
1.2127 + for(TInt i = 0; i < impArray.Count(); ++i)
1.2128 + {
1.2129 + CImplementationInformation& entry = *(impArray[i]);
1.2130 + // Validate lenght
1.2131 + if (entry.DataType().Length() == KHwDeviceDefaultDataLength)
1.2132 + {
1.2133 + INFO_PRINTF2(_L("Implementation UID=0x%08x"),entry.ImplementationUid());
1.2134 + datatype.Copy(entry.DataType());
1.2135 + INFO_PRINTF2(_L("Default data (fourCCs)=%S"), &datatype);
1.2136 + // Extract FourCC
1.2137 + if(aType == EDecoder)
1.2138 + {
1.2139 + fourCCPtr.Set(entry.DataType().Left(KFourCCLength));
1.2140 + fourCCP16Ptr.Set(entry.DataType().Right(KFourCCLength));
1.2141 + }
1.2142 + else if (aType == EEncoder)
1.2143 + {
1.2144 + fourCCPtr.Set(entry.DataType().Right(KFourCCLength));
1.2145 + fourCCP16Ptr.Set(entry.DataType().Left(KFourCCLength));
1.2146 + }
1.2147 + // Compare FourCC
1.2148 + TBuf16<4> foundFourCC;
1.2149 + foundFourCC.Copy(fourCCPtr);
1.2150 + if(aFourCC.CompareF(foundFourCC) == 0)
1.2151 + {
1.2152 + aHwDeviceUid = entry.ImplementationUid();
1.2153 + break;
1.2154 + }
1.2155 + }
1.2156 + }
1.2157 + CleanupStack::PopAndDestroy(&impArray);
1.2158 + REComSession::FinalClose();
1.2159 + }