1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/boardsupport/haitest/bspsvs/suite/bsp/sound/src/t_mdadevsounddata.cpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,1355 @@
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 +@test
1.23 +@internalComponent
1.24 +
1.25 +This contains CT_MdaDevSoundData
1.26 +*/
1.27 +
1.28 +// User includes
1.29 +#include "t_mdadevsounddata.h"
1.30 +#include "t_sounddriverserver.h"
1.31 +
1.32 +/*@{*/
1.33 +/// Parameters
1.34 +
1.35 +_LIT(KSoundFormatsSupportedObject, "SoundFormatsSupportedObject");
1.36 +_LIT(KCurrentSoundFormatObject, "CurrentSoundFormatObject");
1.37 +
1.38 +_LIT(KUUnit, "unit");
1.39 +_LIT(KUUnitEnum, "UnitEnum");
1.40 +_LIT(KUToFile, "to_file");
1.41 +_LIT(KUBlockSize, "block_size");
1.42 +_LIT(KUVersion, "version");
1.43 +
1.44 +_LIT(KUFromFile, "from_file");
1.45 +_LIT(KUDataSize, "data_size");
1.46 +_LIT(KUVolumeExpected, "volume_expected");
1.47 +_LIT(KUVolume, "volume");
1.48 +_LIT(KUBytesPlayed, "bytes_played");
1.49 +_LIT(KUCancel, "cancel");
1.50 +_LIT(KUFlush, "flush");
1.51 +
1.52 +_LIT(KUSoundLevel, "sound_level");
1.53 +_LIT(KUSoundLevelExpected, "sound_level_expected");
1.54 +
1.55 +_LIT(KUFileToDelete, "file_to_delete");
1.56 +
1.57 +_LIT(KLDDName, "ldd");
1.58 +_LIT(KPDDName, "pdd");
1.59 +
1.60 +
1.61 +
1.62 +/*@{*/
1.63 +/// Commands
1.64 +_LIT(KCmdUtilityDeleteFile, "utilityDeleteFile");
1.65 +
1.66 +_LIT(KCmdRecordData, "RecordData");
1.67 +_LIT(KCmdCancelRecordData, "CancelRecordData");
1.68 +_LIT(KCmdFlushRecordBuffer, "FlushRecordBuffer");
1.69 +_LIT(KCmdRecordLevel, "RecordLevel");
1.70 +_LIT(KCmdSetRecordLevel, "SetRecordLevel");
1.71 +_LIT(KCmdNotifyRecordError, "NotifyRecordError");
1.72 +_LIT(KCmdCancelNotifyRecordError, "CancelNotifyRecordError");
1.73 +
1.74 +_LIT(KCmdPlayVolume, "PlayVolume");
1.75 +_LIT(KCmdSetPlayVolume, "SetPlayVolume");
1.76 +_LIT(KCmdPlayData, "PlayData");
1.77 +_LIT(KCmdCancelPlayData, "CancelPlayData");
1.78 +_LIT(KCmdFlushPlayBuffer, "FlushPlayBuffer");
1.79 +_LIT(KCmdNotifyPlayError, "NotifyPlayError");
1.80 +_LIT(KCmdCancelNotifyPlayError, "CancelNotifyPlayError");
1.81 +
1.82 +_LIT(KCmdBytesPlayed, "BytesPlayed");
1.83 +_LIT(KCmdResetBytesPlayed, "ResetBytesPlayed");
1.84 +_LIT(KCmdPausePlayBuffer, "PausePlayBuffer");
1.85 +_LIT(KCmdResumePlaying, "ResumePlaying");
1.86 +
1.87 +_LIT(KCmdPlayFormatsSupported, "PlayFormatsSupported");
1.88 +_LIT(KCmdGetPlayFormat, "GetPlayFormat");
1.89 +_LIT(KCmdSetPlayFormat, "SetPlayFormat");
1.90 +_LIT(KCmdRecordFormatsSupported, "RecordFormatsSupported");
1.91 +_LIT(KCmdGetRecordFormat, "GetRecordFormat");
1.92 +_LIT(KCmdSetRecordFormat, "SetRecordFormat");
1.93 +
1.94 +_LIT(KCmdNew, "new");
1.95 +_LIT(KCmdOpen, "Open");
1.96 +_LIT(KCmdClose, "Close");
1.97 +_LIT(KCmdDestructor, "~");
1.98 +_LIT(KCmdIsMdaSound, "IsMdaSound");
1.99 +_LIT(KCmdVersionRequired, "VersionRequired");
1.100 +/*@}*/
1.101 +
1.102 +/**
1.103 + * Two phase constructor
1.104 + */
1.105 +CT_MdaDevSoundData* CT_MdaDevSoundData::NewL(RMdaDevSound* aServerStore)
1.106 + {
1.107 + CT_MdaDevSoundData* ret = new (ELeave) CT_MdaDevSoundData(aServerStore);
1.108 + CleanupStack::PushL(ret);
1.109 + ret->ConstructL();
1.110 + CleanupStack::Pop(ret);
1.111 + return ret;
1.112 + }
1.113 +
1.114 +/**
1.115 + * Protected constructor. First phase construction
1.116 + */
1.117 +CT_MdaDevSoundData::CT_MdaDevSoundData(RMdaDevSound* aServerStore)
1.118 + :iServerStore(aServerStore)
1.119 + {
1.120 + }
1.121 +
1.122 +/**
1.123 +* Protected constructor. Second phase construction
1.124 +*/
1.125 +void CT_MdaDevSoundData::ConstructL()
1.126 + {
1.127 + }
1.128 +
1.129 +/**
1.130 + * Destructor.
1.131 + */
1.132 +CT_MdaDevSoundData::~CT_MdaDevSoundData()
1.133 + {
1.134 + DoCleanup();
1.135 +
1.136 + iNotifyPlayError.ResetAndDestroy();
1.137 + iNotifyRecordError.ResetAndDestroy();
1.138 + iPlay.ResetAndDestroy();
1.139 + iRecord.ResetAndDestroy();
1.140 + }
1.141 +
1.142 +/**
1.143 + * Contains cleanup implementation
1.144 + */
1.145 +void CT_MdaDevSoundData::DoCleanup()
1.146 + {
1.147 + if(iMdaDevSound)
1.148 + {
1.149 + INFO_PRINTF1(_L("Deleting current RMdaDevSound"));
1.150 + delete iMdaDevSound;
1.151 + iMdaDevSound = NULL;
1.152 + }
1.153 + }
1.154 +
1.155 +/**
1.156 + * Return a pointer to the object that the data wraps
1.157 + *
1.158 + * @return pointer to the object that the data wraps
1.159 + */
1.160 +TAny* CT_MdaDevSoundData::GetObject()
1.161 + {
1.162 + return iMdaDevSound;
1.163 + }
1.164 +
1.165 +/**
1.166 + * Set the wrapped data object with new value
1.167 + */
1.168 +void CT_MdaDevSoundData::SetObjectL( TAny* aAny )
1.169 + {
1.170 + DoCleanup();
1.171 + iMdaDevSound = static_cast<RMdaDevSound*> ( aAny );
1.172 + *iServerStore = *iMdaDevSound;
1.173 + }
1.174 +
1.175 +/**
1.176 + * Clear the wrapped data object pointer w/o de-initialization
1.177 + */
1.178 +void CT_MdaDevSoundData::DisownObjectL()
1.179 + {
1.180 + iMdaDevSound = NULL;
1.181 + iServerStore->SetHandle(KNullHandle);
1.182 + }
1.183 +
1.184 +/**
1.185 + * Return static cleanup function
1.186 + */
1.187 +inline TCleanupOperation CT_MdaDevSoundData::CleanupOperation()
1.188 + {
1.189 + return CleanupOperation;
1.190 + }
1.191 +
1.192 +/**
1.193 + * Static cleanup function
1.194 + */
1.195 +void CT_MdaDevSoundData::CleanupOperation( TAny* aAny )
1.196 + {
1.197 + RMdaDevSound* sound = static_cast<RMdaDevSound*> ( aAny );
1.198 + delete sound;
1.199 + }
1.200 +
1.201 +/**
1.202 + * Process a command read from the ini file
1.203 + *
1.204 + * @param aCommand the command to process
1.205 + * @param aSection the entry in the ini file requiring the command to be processed
1.206 + *
1.207 + * @return ETrue if the command is processed
1.208 + */
1.209 +TBool CT_MdaDevSoundData::DoCommandL(const TTEFFunction& aCommand, const TTEFSectionName& aSection, const TInt aAsyncErrorIndex)
1.210 + {
1.211 + TBool ret=ETrue;
1.212 + if (aCommand == KCmdNew)
1.213 + {
1.214 + DoCmdNewL();
1.215 + }
1.216 + else if (aCommand == KCmdClose)
1.217 + {
1.218 + DoCmdClose();
1.219 + }
1.220 + else if (aCommand == KCmdDestructor)
1.221 + {
1.222 + DoCmdDestructor();
1.223 + }
1.224 + else if (aCommand == KCmdOpen)
1.225 + {
1.226 + DoCmdOpen(aSection);
1.227 + }
1.228 + else if (aCommand == KCmdIsMdaSound)
1.229 + {
1.230 + DoCmdIsMdaSound();
1.231 + }
1.232 + else if (aCommand == KCmdVersionRequired)
1.233 + {
1.234 + DoCmdVersionRequired(aSection);
1.235 + }
1.236 + else if (aCommand == KCmdPlayFormatsSupported)
1.237 + {
1.238 + DoCmdPlayFormatsSupportedL(aSection);
1.239 + }
1.240 + else if (aCommand == KCmdGetPlayFormat)
1.241 + {
1.242 + DoCmdGetPlayFormatL(aSection);
1.243 + }
1.244 + else if (aCommand == KCmdSetPlayFormat)
1.245 + {
1.246 + DoCmdSetPlayFormatL(aSection);
1.247 + }
1.248 + else if (aCommand == KCmdRecordFormatsSupported)
1.249 + {
1.250 + DoCmdRecordFormatsSupportedL(aSection);
1.251 + }
1.252 + else if (aCommand == KCmdGetRecordFormat)
1.253 + {
1.254 + DoCmdGetRecordFormatL(aSection);
1.255 + }
1.256 + else if (aCommand == KCmdSetRecordFormat)
1.257 + {
1.258 + DoCmdSetRecordFormatL(aSection);
1.259 + }
1.260 + else if (aCommand == KCmdPlayVolume)
1.261 + {
1.262 + DoCmdPlayVolume(aSection);
1.263 + }
1.264 + else if (aCommand == KCmdSetPlayVolume)
1.265 + {
1.266 + DoCmdSetPlayVolume(aSection);
1.267 + }
1.268 + else if (aCommand == KCmdPlayData)
1.269 + {
1.270 + DoCmdPlayDataL(aSection, aAsyncErrorIndex);
1.271 + }
1.272 + else if (aCommand == KCmdCancelPlayData)
1.273 + {
1.274 + DoCmdCancelPlayData();
1.275 + }
1.276 + else if (aCommand == KCmdFlushPlayBuffer)
1.277 + {
1.278 + DoCmdFlushPlayBuffer();
1.279 + }
1.280 + else if (aCommand == KCmdFlushPlayBuffer)
1.281 + {
1.282 + DoCmdNotifyPlayErrorL(aAsyncErrorIndex);
1.283 + }
1.284 + else if (aCommand == KCmdFlushPlayBuffer)
1.285 + {
1.286 + DoCmdCancelNotifyPlayError();
1.287 + }
1.288 + else if (aCommand == KCmdNotifyPlayError)
1.289 + {
1.290 + DoCmdNotifyPlayErrorL(aAsyncErrorIndex);
1.291 + }
1.292 + else if (aCommand == KCmdCancelNotifyPlayError)
1.293 + {
1.294 + DoCmdCancelNotifyPlayError();
1.295 + }
1.296 + else if (aCommand == KCmdBytesPlayed)
1.297 + {
1.298 + DoCmdBytesPlayed(aSection);
1.299 + }
1.300 + else if (aCommand == KCmdResetBytesPlayed)
1.301 + {
1.302 + DoCmdResetBytesPlayed();
1.303 + }
1.304 + else if (aCommand == KCmdPausePlayBuffer)
1.305 + {
1.306 + DoCmdPausePlayBuffer();
1.307 + }
1.308 + else if (aCommand == KCmdResumePlaying)
1.309 + {
1.310 + DoCmdResumePlaying();
1.311 + }
1.312 + else if (aCommand == KCmdRecordData)
1.313 + {
1.314 + DoCmdRecordDataL(aSection, aAsyncErrorIndex);
1.315 + }
1.316 + else if (aCommand == KCmdCancelRecordData)
1.317 + {
1.318 + DoCmdCancelRecordData();
1.319 + }
1.320 + else if (aCommand == KCmdFlushRecordBuffer)
1.321 + {
1.322 + DoCmdFlushRecordBuffer();
1.323 + }
1.324 + else if (aCommand == KCmdRecordLevel)
1.325 + {
1.326 + DoCmdRecordLevel(aSection);
1.327 + }
1.328 + else if (aCommand == KCmdSetRecordLevel)
1.329 + {
1.330 + DoCmdSetRecordLevel(aSection);
1.331 + }
1.332 + else if (aCommand == KCmdNotifyRecordError)
1.333 + {
1.334 + DoCmdNotifyRecordErrorL(aAsyncErrorIndex);
1.335 + }
1.336 + else if (aCommand == KCmdCancelNotifyRecordError)
1.337 + {
1.338 + DoCmdCancelNotifyRecordError();
1.339 + }
1.340 + else if (aCommand == KCmdUtilityDeleteFile)
1.341 + {
1.342 + DoCmdUtilityDeleteFileL(aSection);
1.343 + }
1.344 + else
1.345 + {
1.346 + ret=CDataWrapperBase::DoCommandL(aCommand, aSection, aAsyncErrorIndex);
1.347 + }
1.348 +
1.349 + return ret;
1.350 + }
1.351 +
1.352 +/**
1.353 + * Creates new RMdaDevSound class instance
1.354 + */
1.355 +void CT_MdaDevSoundData::DoCmdNewL()
1.356 + {
1.357 + INFO_PRINTF1(_L("Create new RMdaDevSound class instance"));
1.358 +
1.359 + //Deletes previous RMdaDevsound class instance if it was already created.
1.360 + DoCleanup();
1.361 +
1.362 + // do create
1.363 + TRAPD(err, iMdaDevSound = new (ELeave) RMdaDevSound());
1.364 + if ( err!=KErrNone )
1.365 + {
1.366 + ERR_PRINTF2(_L("new error %d"), err);
1.367 + SetError( err );
1.368 + }
1.369 + }
1.370 +
1.371 +/**
1.372 + * Close RMdaDevSound handle
1.373 + */
1.374 +void CT_MdaDevSoundData::DoCmdClose()
1.375 + {
1.376 + INFO_PRINTF1(_L("Closing RMdaDevSound"));
1.377 + iServerStore->SetHandle(KNullHandle);
1.378 + iMdaDevSound->Close();
1.379 + }
1.380 +
1.381 +/**
1.382 + * Destroy RMdaDevSound the object
1.383 + */
1.384 +void CT_MdaDevSoundData::DoCmdDestructor()
1.385 + {
1.386 + INFO_PRINTF1(_L("Destroying the RMdaDevSound object"));
1.387 + //close RMdaDevSound first
1.388 + iServerStore->SetHandle(KNullHandle);
1.389 + iMdaDevSound->Close();
1.390 + DoCleanup();
1.391 + }
1.392 +
1.393 +/**
1.394 + * Connects a client to the sound driver server
1.395 + *
1.396 + * @param aSection section name which contains unit
1.397 + * KUUnit - unit to open
1.398 + *
1.399 + * @return void
1.400 + *
1.401 + * @leave no
1.402 + */
1.403 +void CT_MdaDevSoundData::DoCmdOpen(const TDesC& aSection)
1.404 + {
1.405 + //Loading device drivers
1.406 + TPtrC lddName;
1.407 + TPtrC pddName;
1.408 + if(GET_OPTIONAL_STRING_PARAMETER(KLDDName(), aSection, lddName) &&
1.409 + GET_OPTIONAL_STRING_PARAMETER(KPDDName(), aSection, pddName))
1.410 + {
1.411 + TInt err = TSoundUtil::LoadSoundDrivers(lddName, pddName);
1.412 + if( (err != KErrNone) && (err != KErrAlreadyExists ))
1.413 + {
1.414 + ERR_PRINTF4(_L("Open() -> LoadSoundDrivers(%S, %S) error %d"), &lddName, &pddName, err);
1.415 + SetError( err );
1.416 + }
1.417 + }
1.418 + //Finish Loading device drivers
1.419 +
1.420 + TInt unit = KNullUnit;
1.421 + TPtrC unitName;
1.422 + if (GET_OPTIONAL_STRING_PARAMETER(KUUnit(), aSection, unitName))
1.423 + {
1.424 + GetHexFromConfig(KUUnitEnum(), unitName, unit );
1.425 + }
1.426 + TInt err = iMdaDevSound->Open(unit);
1.427 + *iServerStore = *iMdaDevSound;
1.428 + INFO_PRINTF2(_L("Call Open(unit = %d)"), unit);
1.429 +
1.430 + if ( err!=KErrNone )
1.431 + {
1.432 + ERR_PRINTF2(_L("Open() error %d"), err);
1.433 + SetError( err );
1.434 + }
1.435 + }
1.436 +
1.437 +
1.438 +
1.439 +
1.440 +/**
1.441 + * Checks if driver is MdaSound
1.442 + */
1.443 +void CT_MdaDevSoundData::DoCmdIsMdaSound()
1.444 + {
1.445 + INFO_PRINTF1(_L("CT_MdaDevSoundData::DoCmdIsMdaSound Called"));
1.446 +
1.447 + TInt err = iMdaDevSound->IsMdaSound();
1.448 + if(err!=KErrNone)
1.449 + {
1.450 + ERR_PRINTF2(_L("IsMdaSound() error %d"), err);
1.451 + SetError(err);
1.452 + }
1.453 +
1.454 + }
1.455 +
1.456 +/**
1.457 + * Checks driver version required
1.458 + *
1.459 + * @param aSection section name with expected version
1.460 + * KUVersion - version expected
1.461 + *
1.462 + * @return void
1.463 + *
1.464 + * @leave no
1.465 + */
1.466 +void CT_MdaDevSoundData::DoCmdVersionRequired(const TDesC& aSection)
1.467 + {
1.468 + INFO_PRINTF1(_L("CT_MdaDevSoundData::VersionRequired Called"));
1.469 +
1.470 + TVersion version = iMdaDevSound->VersionRequired();
1.471 + TPtrC versionNameFromSystem = version.Name();
1.472 + TPtrC versionName;
1.473 + if(GET_MANDATORY_STRING_PARAMETER(KUVersion(), aSection, versionName))
1.474 + {
1.475 + if(versionNameFromSystem != versionName)
1.476 + {
1.477 + ERR_PRINTF1(_L("iMdaDevSound->VersionRequired() != expected"));
1.478 + ERR_PRINTF3(_L("version.Name()=%S, expected=%S"), &versionNameFromSystem, &versionName);
1.479 + SetBlockResult(EFail);
1.480 + }
1.481 + else
1.482 + {
1.483 + INFO_PRINTF1(_L("iMdaDevSound->VersionRequired() == expected"));
1.484 + }
1.485 + }
1.486 +
1.487 + }
1.488 +
1.489 +/**
1.490 + * Gets PlayFormatsSupported
1.491 + *
1.492 + * @param aSection Section name which contains SoundFormatsSupported
1.493 + * object name
1.494 + * KSoundFormatsSupportedObject - SoundFormatsSupported
1.495 + * object name
1.496 + *
1.497 + * @return void
1.498 + *
1.499 + * @leave System wide error
1.500 + */
1.501 +void CT_MdaDevSoundData::DoCmdPlayFormatsSupportedL(const TDesC& aSection)
1.502 + {
1.503 + INFO_PRINTF1(_L("Getting PlayFormatsSupported!"));
1.504 +
1.505 + TPtrC objectName;
1.506 + if (GET_MANDATORY_STRING_PARAMETER(KSoundFormatsSupportedObject, aSection, objectName))
1.507 + {
1.508 + RMdaDevSound::TSoundFormatsSupported* soundFormat = static_cast<RMdaDevSound::TSoundFormatsSupported*>(GetDataObjectL(objectName));
1.509 + RMdaDevSound::TSoundFormatsSupportedBuf soundFormatsSupportedBuf(*soundFormat);
1.510 + iMdaDevSound->PlayFormatsSupported(soundFormatsSupportedBuf);
1.511 + *soundFormat = soundFormatsSupportedBuf();
1.512 + }
1.513 + }
1.514 +
1.515 +/**
1.516 + * Gets current PlayFormat
1.517 + *
1.518 + * @param aSection Section name which contains CurrentSoundFormat
1.519 + * object name
1.520 + * KCurrentSoundFormatObject - CurrentSoundFormat
1.521 + * object name
1.522 + *
1.523 + * @return void
1.524 + *
1.525 + * @leave System wide error
1.526 + */
1.527 +void CT_MdaDevSoundData::DoCmdGetPlayFormatL(const TDesC& aSection)
1.528 + {
1.529 + INFO_PRINTF1(_L("Getting PlayFormat!"));
1.530 +
1.531 + TPtrC objectName;
1.532 + if (GET_MANDATORY_STRING_PARAMETER(KCurrentSoundFormatObject, aSection, objectName))
1.533 + {
1.534 + RMdaDevSound::TCurrentSoundFormat* soundFormat = static_cast<RMdaDevSound::TCurrentSoundFormat*>(GetDataObjectL(objectName));
1.535 + RMdaDevSound::TCurrentSoundFormatBuf currentSoundFormatBuf(*soundFormat);
1.536 + iMdaDevSound->GetPlayFormat(currentSoundFormatBuf);
1.537 + *soundFormat = currentSoundFormatBuf();
1.538 + }
1.539 + }
1.540 +
1.541 +/**
1.542 + * Sets current PlayFormat
1.543 + *
1.544 + * @param aSection Section name which contains CurrentSoundFormat
1.545 + * object name
1.546 + * KCurrentSoundFormatObject - CurrentSoundFormat
1.547 + * object name
1.548 + *
1.549 + * @return void
1.550 + *
1.551 + * @leave System wide error
1.552 + */
1.553 +void CT_MdaDevSoundData::DoCmdSetPlayFormatL(const TDesC& aSection)
1.554 + {
1.555 + INFO_PRINTF1(_L("Setting PlayFormat!"));
1.556 +
1.557 + TPtrC objectName;
1.558 + if (GET_MANDATORY_STRING_PARAMETER(KCurrentSoundFormatObject, aSection, objectName))
1.559 + {
1.560 + RMdaDevSound::TCurrentSoundFormat* soundFormat = static_cast<RMdaDevSound::TCurrentSoundFormat*>(GetDataObjectL(objectName));
1.561 + RMdaDevSound::TCurrentSoundFormatBuf currentSoundFormatBuf(*soundFormat);
1.562 + TInt err = iMdaDevSound->SetPlayFormat(currentSoundFormatBuf);
1.563 + if(err != KErrNone)
1.564 + {
1.565 + ERR_PRINTF2(_L("error in SetPlayFormatL %d"), err);
1.566 + SetError( err );
1.567 + }
1.568 + else
1.569 + {
1.570 + *soundFormat = currentSoundFormatBuf();
1.571 + }
1.572 + }
1.573 + }
1.574 +
1.575 +/**
1.576 + * Gets RecordFormatsSupported
1.577 + *
1.578 + * @param aSection Section name which contains SoundFormatsSupported
1.579 + * object name
1.580 + * KSoundFormatsSupportedObject - SoundFormatsSupported
1.581 + * object name
1.582 + *
1.583 + * @return void
1.584 + *
1.585 + * @leave System wide error
1.586 + */
1.587 +void CT_MdaDevSoundData::DoCmdRecordFormatsSupportedL(const TDesC& aSection)
1.588 + {
1.589 + INFO_PRINTF1(_L("Getting RecordFormatsSupported!"));
1.590 +
1.591 + TPtrC objectName;
1.592 + if (GET_MANDATORY_STRING_PARAMETER(KSoundFormatsSupportedObject, aSection, objectName))
1.593 + {
1.594 + RMdaDevSound::TSoundFormatsSupported* soundFormat = static_cast<RMdaDevSound::TSoundFormatsSupported*>(GetDataObjectL(objectName));
1.595 + RMdaDevSound::TSoundFormatsSupportedBuf soundFormatsSupportedBuf(*soundFormat);
1.596 + iMdaDevSound->RecordFormatsSupported(soundFormatsSupportedBuf);
1.597 + *soundFormat = soundFormatsSupportedBuf();
1.598 + }
1.599 + }
1.600 +
1.601 +/**
1.602 + * Gets current RecordFormat
1.603 + *
1.604 + * @param aSection Section name which contains CurrentSoundFormat
1.605 + * object name
1.606 + * KCurrentSoundFormatObject - CurrentSoundFormat
1.607 + * object name
1.608 + *
1.609 + * @return void
1.610 + *
1.611 + * @leave System wide error
1.612 + */
1.613 +void CT_MdaDevSoundData::DoCmdGetRecordFormatL(const TDesC& aSection)
1.614 + {
1.615 + INFO_PRINTF1(_L("Getting RecordFormat!"));
1.616 +
1.617 + TPtrC objectName;
1.618 + if (GET_MANDATORY_STRING_PARAMETER(KCurrentSoundFormatObject, aSection, objectName))
1.619 + {
1.620 + RMdaDevSound::TCurrentSoundFormat* soundFormat = static_cast<RMdaDevSound::TCurrentSoundFormat*>(GetDataObjectL(objectName));
1.621 + RMdaDevSound::TCurrentSoundFormatBuf currentSoundFormatBuf(*soundFormat);
1.622 + iMdaDevSound->GetRecordFormat(currentSoundFormatBuf);
1.623 + *soundFormat = currentSoundFormatBuf();
1.624 + }
1.625 + }
1.626 +
1.627 +/**
1.628 + * Sets current RecordFormat
1.629 + *
1.630 + * @param aSection Section name which contains CurrentSoundFormat
1.631 + * object name
1.632 + * KCurrentSoundFormatObject - CurrentSoundFormat
1.633 + * object name
1.634 + *
1.635 + * @return void
1.636 + *
1.637 + * @leave System wide error
1.638 + */
1.639 +void CT_MdaDevSoundData::DoCmdSetRecordFormatL(const TDesC& aSection)
1.640 + {
1.641 + INFO_PRINTF1(_L("Setting RecordFormat!"));
1.642 +
1.643 + TPtrC objectName;
1.644 + if (GET_MANDATORY_STRING_PARAMETER(KCurrentSoundFormatObject, aSection, objectName))
1.645 + {
1.646 + RMdaDevSound::TCurrentSoundFormat* soundFormat = static_cast<RMdaDevSound::TCurrentSoundFormat*>(GetDataObjectL(objectName));
1.647 + RMdaDevSound::TCurrentSoundFormatBuf currentSoundFormatBuf(*soundFormat);
1.648 + TInt err = iMdaDevSound->SetRecordFormat(currentSoundFormatBuf);
1.649 + if(err != KErrNone)
1.650 + {
1.651 + ERR_PRINTF2(_L("error in SetRecordFormatL %d"), err);
1.652 + SetError( err );
1.653 + }
1.654 + else
1.655 + {
1.656 + *soundFormat = currentSoundFormatBuf();
1.657 + }
1.658 + }
1.659 + }
1.660 +
1.661 +/**
1.662 + * Gets current PlayVolume
1.663 + *
1.664 + * @param aSection Section name which contains expected value
1.665 + * KUVolumeExpected - expected volume level
1.666 + *
1.667 + * @return void
1.668 + *
1.669 + * @leave no
1.670 + */
1.671 +void CT_MdaDevSoundData::DoCmdPlayVolume(const TDesC& aSection)
1.672 + {
1.673 + TInt volume = 0;
1.674 + INFO_PRINTF2(_L("calling PlayVolume(), value before execution = %d"), volume);
1.675 + volume = iMdaDevSound->PlayVolume();
1.676 +
1.677 + TInt expected;
1.678 + if (GET_OPTIONAL_INT_PARAMETER(KUVolumeExpected(), aSection, expected))
1.679 + {
1.680 + if(volume != expected)
1.681 + {
1.682 + ERR_PRINTF3(_L("Expected result != volume, expected = %d, volume = %d"),
1.683 + expected, volume);
1.684 + SetBlockResult(EFail);
1.685 + }
1.686 + else
1.687 + {
1.688 + INFO_PRINTF2(_L("volume = %d"), volume);
1.689 + }
1.690 + }
1.691 + else
1.692 + {
1.693 + INFO_PRINTF2(_L("volume = %d"), volume);
1.694 + }
1.695 + }
1.696 +
1.697 +/**
1.698 + * Sets current PlayVolume
1.699 + *
1.700 + * @param aSection Section name which contains value to set
1.701 + * KUVolume - volume to set
1.702 + *
1.703 + * @return void
1.704 + *
1.705 + * @leave no
1.706 + */
1.707 +void CT_MdaDevSoundData::DoCmdSetPlayVolume(const TDesC& aSection)
1.708 + {
1.709 + TInt volume = 0;
1.710 + INFO_PRINTF2(_L("calling SetPlayVolume(), value before execution = %d"), volume);
1.711 + if (GET_OPTIONAL_INT_PARAMETER(KUVolume(), aSection, volume))
1.712 + {
1.713 + iMdaDevSound->SetPlayVolume(volume);
1.714 + INFO_PRINTF2(_L("after execution value = %d"), volume);
1.715 + }
1.716 + else
1.717 + {
1.718 + INFO_PRINTF2(_L("volume after execution = %d"), volume);
1.719 + }
1.720 + }
1.721 +
1.722 +/**
1.723 + * Play audio from file. DoCmdPlayDataL is asynchronous function
1.724 + *
1.725 + * @param aSection Section name which can contain values to set
1.726 + * KUDataSize - data size,
1.727 + * KUFromFile - file name to play,
1.728 + * KUBlockSize - block size
1.729 + *
1.730 + *
1.731 + * @return void
1.732 + *
1.733 + * @leave System wide error
1.734 + */
1.735 +void CT_MdaDevSoundData::DoCmdPlayDataL(const TDesC& aSection,
1.736 + const TInt aAsyncErrorIndex)
1.737 + {
1.738 + INFO_PRINTF1(_L("calling PlayData()"));
1.739 +
1.740 + CT_SoundActiveCallback* active = CT_SoundActiveCallback::NewL(*this);
1.741 + iPlay.Append(active);
1.742 +
1.743 + active->iSoundData = new(ELeave) TSoundUtil::RAudioBuffer();
1.744 + TSoundUtil::RAudioBuffer* soundData = active->iSoundData;
1.745 +
1.746 + TInt dataSize = TSoundUtil::KAudioBufferMaxSize;
1.747 + GET_OPTIONAL_INT_PARAMETER(KUDataSize, aSection, dataSize);
1.748 + soundData->Close();
1.749 + soundData->CreateL(dataSize);
1.750 +
1.751 + TPtrC fileName;
1.752 + TInt err = KErrNone;
1.753 + if (GET_OPTIONAL_STRING_PARAMETER(KUFromFile, aSection, fileName))
1.754 + {
1.755 + err = soundData->LoadAudioDataL(fileName);
1.756 + if (err)
1.757 + {
1.758 + SetBlockResult(EFail);
1.759 + ERR_PRINTF2(_L("Audio file loading failed with error code %d"), err);
1.760 + }
1.761 + }
1.762 +
1.763 + if (!err)
1.764 + {
1.765 + active->SetSection(aSection);
1.766 + IncOutstanding();
1.767 +
1.768 + TInt blockSize = TSoundUtil::KDefaultBlockSize;
1.769 + GET_OPTIONAL_INT_PARAMETER(KUBlockSize, aSection, blockSize);
1.770 + blockSize = Min(blockSize, soundData->Length());
1.771 + active->iBufferBlock.Set(&soundData->operator[](0), blockSize, blockSize);
1.772 + iMdaDevSound->PlayData(active->iStatus, active->iBufferBlock);
1.773 + active->Activate(aAsyncErrorIndex);
1.774 + TBool stopPlay = EFalse;
1.775 + if (GET_OPTIONAL_BOOL_PARAMETER(KUCancel, aSection, stopPlay))
1.776 + {
1.777 + if ( stopPlay )
1.778 + {
1.779 + iMdaDevSound->CancelPlayData();
1.780 + INFO_PRINTF1(_L("CancelPlayData() executed"));
1.781 + }
1.782 + }
1.783 + if (GET_OPTIONAL_BOOL_PARAMETER(KUFlush, aSection, stopPlay))
1.784 + {
1.785 + if ( stopPlay )
1.786 + {
1.787 + iMdaDevSound->FlushPlayBuffer();
1.788 + INFO_PRINTF1(_L("FlushPlayBuffer() executed"));
1.789 + }
1.790 + }
1.791 + }
1.792 + }
1.793 +
1.794 +/**
1.795 + * Cancel playing
1.796 + */
1.797 +void CT_MdaDevSoundData::DoCmdCancelPlayData()
1.798 + {
1.799 + INFO_PRINTF1(_L("calling CancelPlayData()"));
1.800 +
1.801 + if (iPlay.Count() > 0)
1.802 + {
1.803 + INFO_PRINTF2(_L("CancelPlayData called on active object with iStatus == %d"),
1.804 + iPlay[iPlay.Count() - 1]->iStatus.Int());
1.805 + }
1.806 + else
1.807 + {
1.808 + INFO_PRINTF1(_L("No active objects found"));
1.809 + }
1.810 +
1.811 + iMdaDevSound->CancelPlayData();
1.812 + }
1.813 +
1.814 +/**
1.815 + * Flush play buffer
1.816 + */
1.817 +void CT_MdaDevSoundData::DoCmdFlushPlayBuffer()
1.818 + {
1.819 + INFO_PRINTF1(_L("calling FlushPlayBuffer()"));
1.820 +
1.821 + if (iPlay.Count() > 0)
1.822 + {
1.823 + INFO_PRINTF2(_L("FLushPlayBuffer called on active object with iStatus == %d"),
1.824 + iPlay[iPlay.Count() - 1]->iStatus.Int());
1.825 + }
1.826 + else
1.827 + {
1.828 + INFO_PRINTF1(_L("No active objects found"));
1.829 + }
1.830 +
1.831 + iMdaDevSound->FlushPlayBuffer();
1.832 + }
1.833 +
1.834 +/**
1.835 + * Asynchronous function that starts notifying play error
1.836 + */
1.837 +void CT_MdaDevSoundData::DoCmdNotifyPlayErrorL(const TInt aAsyncErrorIndex)
1.838 + {
1.839 + INFO_PRINTF1(_L("calling NotifyPlayError()"));
1.840 +
1.841 + CActiveCallback* active = CActiveCallback::NewL(*this);
1.842 + iNotifyPlayError.Append(active);
1.843 + iMdaDevSound->NotifyPlayError(active->iStatus);
1.844 +
1.845 + //acitvate callback object
1.846 + active->Activate(aAsyncErrorIndex);
1.847 + IncOutstanding();
1.848 + }
1.849 +
1.850 +/**
1.851 + * Cancel notifying play error
1.852 + */
1.853 +void CT_MdaDevSoundData::DoCmdCancelNotifyPlayError()
1.854 + {
1.855 + INFO_PRINTF1(_L("calling CancelNotifyPlayError()"));
1.856 +
1.857 + iMdaDevSound->CancelNotifyPlayError();
1.858 + }
1.859 +
1.860 +/**
1.861 + * Gets bytes played
1.862 + *
1.863 + * @param aSection Section name which can contain expected value
1.864 + * KUBytesPlayed - bytes played
1.865 + *
1.866 + * @return void
1.867 + *
1.868 + * @leave no
1.869 + */
1.870 +void CT_MdaDevSoundData::DoCmdBytesPlayed(const TDesC& aSection)
1.871 + {
1.872 + INFO_PRINTF1(_L("calling BytesPlayed()"));
1.873 +
1.874 + TInt bytesPlayed = iMdaDevSound->BytesPlayed();
1.875 + INFO_PRINTF2(_L("Bytes played: %d"), bytesPlayed);
1.876 +
1.877 + TInt expected = 0;
1.878 + if (GET_OPTIONAL_INT_PARAMETER(KUBytesPlayed, aSection, expected))
1.879 + {
1.880 + if (expected != bytesPlayed)
1.881 + {
1.882 + ERR_PRINTF3(_L("Bytes played %d != %d expected"), bytesPlayed, expected);
1.883 + SetBlockResult(EFail);
1.884 + }
1.885 + }
1.886 + }
1.887 +
1.888 +/**
1.889 + * Resets bytes played
1.890 + */
1.891 +void CT_MdaDevSoundData::DoCmdResetBytesPlayed()
1.892 + {
1.893 + INFO_PRINTF1(_L("calling ResetBytesPlayed()"));
1.894 +
1.895 + iMdaDevSound->ResetBytesPlayed();
1.896 + }
1.897 +
1.898 +/**
1.899 + * Pause playing
1.900 + */
1.901 +void CT_MdaDevSoundData::DoCmdPausePlayBuffer()
1.902 + {
1.903 + INFO_PRINTF1(_L("calling PausePlayBuffer()"));
1.904 +
1.905 + iMdaDevSound->PausePlayBuffer();
1.906 + }
1.907 +
1.908 +/**
1.909 + * Resume playing
1.910 + */
1.911 +void CT_MdaDevSoundData::DoCmdResumePlaying()
1.912 + {
1.913 + INFO_PRINTF1(_L("calling ResumePlaying()"));
1.914 +
1.915 + iMdaDevSound->ResumePlaying();
1.916 + }
1.917 +
1.918 +/**
1.919 + * DoCmdRecordDataL is asynchronous function to record audio.
1.920 + *
1.921 + * @param aSection Section name which can contain value to set
1.922 + * KUDataSize - data size to record,
1.923 + * KUToFile - file to record audio,
1.924 + * KUBlockSize - block size
1.925 + *
1.926 + * @return void
1.927 + *
1.928 + * @leave System wide error
1.929 + */
1.930 +void CT_MdaDevSoundData::DoCmdRecordDataL(const TDesC& aSection, const TInt aAsyncErrorIndex)
1.931 + {
1.932 + INFO_PRINTF1(_L("calling RecordData()"));
1.933 +
1.934 + CT_SoundActiveCallback* active = CT_SoundActiveCallback::NewL(*this);
1.935 + iRecord.Append(active);
1.936 +
1.937 + active->iSoundData = new(ELeave) TSoundUtil::RAudioBuffer();
1.938 + TSoundUtil::RAudioBuffer* soundData = active->iSoundData;
1.939 +
1.940 + TInt dataSize = TSoundUtil::KAudioBufferMaxSize;
1.941 + GET_OPTIONAL_INT_PARAMETER(KUDataSize, aSection, dataSize);
1.942 + soundData->Close();
1.943 + soundData->CreateL(dataSize);
1.944 + soundData->SetLength(dataSize);
1.945 +
1.946 + TInt blockSize = TSoundUtil::KDefaultBlockSize;
1.947 + GET_OPTIONAL_INT_PARAMETER(KUBlockSize, aSection, blockSize);
1.948 + active->iBufferBlock.Set(&soundData->operator[](0), 0, Min(blockSize, soundData->Length()));
1.949 + iMdaDevSound->RecordData(active->iStatus, active->iBufferBlock);
1.950 +
1.951 + active->SetSection(aSection);
1.952 + IncOutstanding();
1.953 + active->Activate(aAsyncErrorIndex);
1.954 + TBool stopRecord = EFalse;
1.955 + if (GET_OPTIONAL_BOOL_PARAMETER(KUCancel, aSection, stopRecord))
1.956 + {
1.957 + if ( stopRecord )
1.958 + {
1.959 + iMdaDevSound->CancelPlayData();
1.960 + INFO_PRINTF1(_L("CancelRecordData() executed"));
1.961 + }
1.962 + }
1.963 + if (GET_OPTIONAL_BOOL_PARAMETER(KUFlush, aSection, stopRecord))
1.964 + {
1.965 + if ( stopRecord )
1.966 + {
1.967 + iMdaDevSound->FlushRecordBuffer();
1.968 + INFO_PRINTF1(_L("FlushRecordBuffer() executed"));
1.969 + }
1.970 + }
1.971 + }
1.972 +
1.973 +/**
1.974 + * Cancels recording in progress
1.975 + */
1.976 +void CT_MdaDevSoundData::DoCmdCancelRecordData()
1.977 + {
1.978 + INFO_PRINTF1(_L("calling CancelRecordData()"));
1.979 +
1.980 + if (iRecord.Count() > 0)
1.981 + {
1.982 + INFO_PRINTF2(_L("CancelRecordData called on active object with iStatus == %d"),
1.983 + iRecord[iRecord.Count() - 1]->iStatus.Int());
1.984 + }
1.985 + else
1.986 + {
1.987 + INFO_PRINTF1(_L("No active objects found"));
1.988 + }
1.989 +
1.990 + iMdaDevSound->CancelRecordData();
1.991 + }
1.992 +
1.993 +/**
1.994 + * Flushes record buffer
1.995 + */
1.996 +void CT_MdaDevSoundData::DoCmdFlushRecordBuffer()
1.997 + {
1.998 + INFO_PRINTF1(_L("calling FlushRecordBuffer()"));
1.999 +
1.1000 + if (iRecord.Count() > 0)
1.1001 + {
1.1002 + INFO_PRINTF2(_L("FlushRecordBuffer called on active object with iStatus == %d"),
1.1003 + iRecord[iRecord.Count() - 1]->iStatus.Int());
1.1004 + }
1.1005 + else
1.1006 + {
1.1007 + INFO_PRINTF1(_L("No active objects found"));
1.1008 + }
1.1009 +
1.1010 + iMdaDevSound->FlushRecordBuffer();
1.1011 + }
1.1012 +
1.1013 +/**
1.1014 + * Gets record volume level
1.1015 + *
1.1016 + * @param aSection Section name which can contain expected value
1.1017 + * KUSoundLevelExpected - expected sound level
1.1018 + *
1.1019 + * @return void
1.1020 + *
1.1021 + * @leave no
1.1022 + */
1.1023 +void CT_MdaDevSoundData::DoCmdRecordLevel(const TDesC& aSection)
1.1024 + {
1.1025 + TInt level = 0;
1.1026 + INFO_PRINTF1(_L("calling RecordLevel()"));
1.1027 + level = iMdaDevSound->RecordLevel();
1.1028 +
1.1029 + TInt expected;
1.1030 + if (GET_OPTIONAL_INT_PARAMETER(KUSoundLevelExpected(), aSection, expected))
1.1031 + {
1.1032 + if(level != expected)
1.1033 + {
1.1034 + ERR_PRINTF3(_L("Expected result != level, expected = %d, level = %d"),
1.1035 + expected, level);
1.1036 + SetBlockResult(EFail);
1.1037 + }
1.1038 + else
1.1039 + {
1.1040 + INFO_PRINTF2(_L("level = %d"), level);
1.1041 + }
1.1042 + }
1.1043 + else
1.1044 + {
1.1045 + INFO_PRINTF2(_L("level = %d"), level);
1.1046 + }
1.1047 + }
1.1048 +
1.1049 +/**
1.1050 + * Sets record volume level
1.1051 + *
1.1052 + * @param aSection Section name which can contain value to set
1.1053 + * KUSoundLevel - sound level to set
1.1054 + *
1.1055 + * @return void
1.1056 + *
1.1057 + * @leave no
1.1058 + */
1.1059 +void CT_MdaDevSoundData::DoCmdSetRecordLevel(const TDesC& aSection)
1.1060 + {
1.1061 + TInt level = 0;
1.1062 + INFO_PRINTF2(_L("calling SetRecordLevel(), level before execution = %d"), level);
1.1063 +
1.1064 + if(GET_OPTIONAL_INT_PARAMETER(KUSoundLevel, aSection, level))
1.1065 + {
1.1066 + iMdaDevSound->SetRecordLevel(level);
1.1067 + INFO_PRINTF2(_L("after execution level = %d"), level);
1.1068 + }
1.1069 + else
1.1070 + {
1.1071 + INFO_PRINTF2(_L("level after execution = %d"), level);
1.1072 + }
1.1073 + }
1.1074 +
1.1075 +/**
1.1076 + * DoCmdNotifyRecordErrorL is asynchronous function that starts notifying recording
1.1077 + * error
1.1078 + */
1.1079 +void CT_MdaDevSoundData::DoCmdNotifyRecordErrorL(const TInt aAsyncErrorIndex)
1.1080 + {
1.1081 + INFO_PRINTF1(_L("calling NotifyRecordError()"));
1.1082 +
1.1083 + CActiveCallback* active = CActiveCallback::NewL(*this);
1.1084 + iNotifyRecordError.Append(active);
1.1085 +
1.1086 + iMdaDevSound->NotifyRecordError(active->iStatus);
1.1087 +
1.1088 + //acitvate callback object
1.1089 + active->Activate(aAsyncErrorIndex);
1.1090 + IncOutstanding();
1.1091 + }
1.1092 +
1.1093 +/**
1.1094 + * Cancels notifying recording error
1.1095 + */
1.1096 +void CT_MdaDevSoundData::DoCmdCancelNotifyRecordError()
1.1097 + {
1.1098 + INFO_PRINTF1(_L("calling CancelNotifyRecordError()"));
1.1099 +
1.1100 + iMdaDevSound->CancelNotifyRecordError();
1.1101 + }
1.1102 +
1.1103 +/**
1.1104 + * Deletes file specified
1.1105 + *
1.1106 + * @param aSection Section name which contains file name to delete
1.1107 + * KUFileToDelete - File to delete
1.1108 + *
1.1109 + * @return void
1.1110 + *
1.1111 + * @leave System wide error
1.1112 + */
1.1113 +void CT_MdaDevSoundData::DoCmdUtilityDeleteFileL(const TDesC& aSection)
1.1114 + {
1.1115 + INFO_PRINTF1(_L("DoCmdUtilityDeleteFileL called!"));
1.1116 +
1.1117 + TPtrC file;
1.1118 + if (GET_MANDATORY_STRING_PARAMETER(KUFileToDelete, aSection, file))
1.1119 + {
1.1120 + TInt err;
1.1121 + err = TSoundUtil::DeleteFileL(file);
1.1122 + if(err != KErrNone)
1.1123 + {
1.1124 + ERR_PRINTF2(_L("Deleting file failed with error code %d"), err);
1.1125 + SetBlockResult(EFail);
1.1126 + }
1.1127 + else
1.1128 + {
1.1129 + INFO_PRINTF1(_L("File deleted successfully"));
1.1130 + }
1.1131 + }
1.1132 + }
1.1133 +
1.1134 +/**
1.1135 + * Handle asynchronous events here
1.1136 + */
1.1137 +void CT_MdaDevSoundData::RunL(CActive* aActive, TInt aIndex)
1.1138 + {
1.1139 + INFO_PRINTF1(_L("CT_MdaDevSoundData::RunL Called"));
1.1140 + TBool foundActiveObject = EFalse;
1.1141 + TInt index=0;
1.1142 + TInt count=0;
1.1143 + TBool completed=ETrue;
1.1144 +
1.1145 + // See if it is in iNotifyPlayError
1.1146 + count=iNotifyPlayError.Count();
1.1147 + for( index=0; (index<count) && (!foundActiveObject); ++index )
1.1148 + {
1.1149 + if( aActive == iNotifyPlayError[index] )
1.1150 + {
1.1151 + INFO_PRINTF1(_L("RunL iNotifyPlayError called"));
1.1152 + foundActiveObject = ETrue;
1.1153 + iNotifyPlayError.Remove(index);
1.1154 + }
1.1155 + }
1.1156 +
1.1157 + // See if it is in iNotifyRecordError
1.1158 + count=iNotifyRecordError.Count();
1.1159 + for( index=0; (index<count) && (!foundActiveObject); ++index )
1.1160 + {
1.1161 + if( aActive == iNotifyRecordError[index] )
1.1162 + {
1.1163 + INFO_PRINTF1(_L("RunL iNotifyRecordError called"));
1.1164 + foundActiveObject = ETrue;
1.1165 + iNotifyRecordError.Remove(index);
1.1166 + }
1.1167 + }
1.1168 +
1.1169 + // See if it is in iPlay
1.1170 + count=iPlay.Count();
1.1171 + for( index=0; (index<count) && (!foundActiveObject); ++index )
1.1172 + {
1.1173 + if( aActive == iPlay[index] )
1.1174 + {
1.1175 + foundActiveObject = ETrue;
1.1176 + INFO_PRINTF1(_L("RunL iPlay called"));
1.1177 +
1.1178 + TSoundUtil::RAudioBuffer* soundData = iPlay[index]->iSoundData;
1.1179 +
1.1180 + iPlay[index]->iDataPosition += iPlay[index]->iBufferBlock.Length();
1.1181 + INFO_PRINTF3(_L("Played %d bytes, %d bytes played total"), iPlay[index]->iBufferBlock.Length(),
1.1182 + iPlay[index]->iDataPosition);
1.1183 +
1.1184 + if ( ( iPlay[index]->iDataPosition >= soundData->Length() ) || aActive->iStatus.Int() )
1.1185 + {
1.1186 + iPlay.Remove(index);
1.1187 + }
1.1188 + else
1.1189 + {
1.1190 + TInt blockSize = TSoundUtil::KDefaultBlockSize;
1.1191 + GET_OPTIONAL_INT_PARAMETER(KUBlockSize, *(iPlay[index]->iSection), blockSize);
1.1192 + blockSize = Min(blockSize, soundData->Length() - iPlay[index]->iDataPosition);
1.1193 + iPlay[index]->iBufferBlock.Set(&soundData->operator[](iPlay[index]->iDataPosition), blockSize, blockSize);
1.1194 + iMdaDevSound->PlayData(iPlay[index]->iStatus, iPlay[index]->iBufferBlock);
1.1195 + iPlay[index]->Activate(aIndex);
1.1196 + completed = EFalse;
1.1197 + }
1.1198 + }
1.1199 + }
1.1200 +
1.1201 + // See if it is in iRecord
1.1202 + count=iRecord.Count();
1.1203 + for( index=0; (index<count) && (!foundActiveObject); ++index )
1.1204 + {
1.1205 + if( aActive == iRecord[index] )
1.1206 + {
1.1207 + foundActiveObject = ETrue;
1.1208 + INFO_PRINTF1(_L("RunL iRecord called"));
1.1209 + iRecord[index]->iDataPosition += iRecord[index]->iBufferBlock.Length();
1.1210 + INFO_PRINTF3(_L("Stored %d bytes, %d bytes total"),
1.1211 + iRecord[index]->iBufferBlock.Length(),
1.1212 + iRecord[index]->iDataPosition);
1.1213 +
1.1214 + TSoundUtil::RAudioBuffer* buffer = iRecord[index]->iSoundData;
1.1215 +
1.1216 + TInt err = aActive->iStatus.Int();
1.1217 + if( err == KErrNone )
1.1218 + {
1.1219 + if(iRecord[index]->iDataPosition >= buffer->Length() ||
1.1220 + iRecord[index]->iBufferBlock.Length() == 0)
1.1221 + {
1.1222 + TPtrC fileName;
1.1223 + if(GET_OPTIONAL_STRING_PARAMETER(KUToFile, *(iRecord[index]->iSection), fileName))
1.1224 + {
1.1225 + TInt err;
1.1226 + err = buffer->SaveAudioDataL(fileName);
1.1227 + if (err)
1.1228 + {
1.1229 + SetBlockResult(EFail);
1.1230 + ERR_PRINTF2(_L("Saving to file failed with error code %d"), err);
1.1231 + }
1.1232 + }
1.1233 + iRecord.Remove(index);
1.1234 + }
1.1235 + else
1.1236 + {
1.1237 + TInt blockSize = TSoundUtil::KDefaultBlockSize;
1.1238 + //if specified in INI file get block size
1.1239 + GET_OPTIONAL_INT_PARAMETER(KUBlockSize, *(iRecord[index]->iSection), blockSize);
1.1240 + iRecord[index]->iBufferBlock.Set(&buffer->operator[](iRecord[index]->iDataPosition), 0, Min(blockSize, buffer->Length() - iRecord[index]->iDataPosition));
1.1241 + iMdaDevSound->RecordData(iRecord[index]->iStatus, iRecord[index]->iBufferBlock);
1.1242 + iRecord[index]->Activate(aIndex);
1.1243 + completed = EFalse;
1.1244 + }
1.1245 + }//err == KErrNone
1.1246 + else
1.1247 + {
1.1248 + iRecord.Remove(index);
1.1249 + }
1.1250 + }//aActive == iRecord[index]
1.1251 + }//for
1.1252 +
1.1253 + if( foundActiveObject )
1.1254 + {
1.1255 + if ( completed )
1.1256 + {
1.1257 + if (aActive)
1.1258 + {
1.1259 + TInt err = aActive->iStatus.Int();
1.1260 + if( err != KErrNone )
1.1261 + {
1.1262 + ERR_PRINTF2(_L("RunL Error %d"), err);
1.1263 + SetAsyncError( aIndex, err );
1.1264 + }
1.1265 + }
1.1266 +
1.1267 + // Reset the outstanding request state
1.1268 + delete aActive;
1.1269 + DecOutstanding();
1.1270 + }
1.1271 + }
1.1272 + else
1.1273 + {
1.1274 + ERR_PRINTF1(_L("An unchecked active object completed"));
1.1275 + SetBlockResult(EFail);
1.1276 + }
1.1277 + }
1.1278 +
1.1279 +/**
1.1280 + * Cancels asynchronous events
1.1281 + */
1.1282 +void CT_MdaDevSoundData::DoCancel(CActive* aActive, TInt aIndex)
1.1283 + {
1.1284 + TBool foundActiveObject = EFalse;
1.1285 +
1.1286 + TInt index=0;
1.1287 + TInt count=0;
1.1288 +
1.1289 + // See if it is in iNotifyPlayError
1.1290 + count=iNotifyPlayError.Count();
1.1291 + for( index=0; (index<count) && (!foundActiveObject); ++index )
1.1292 + {
1.1293 + if( aActive == iNotifyPlayError[index] )
1.1294 + {
1.1295 + INFO_PRINTF1(_L("DoCancel iNotifyPlayError called"));
1.1296 + foundActiveObject = ETrue;
1.1297 + iNotifyPlayError.Remove(index);
1.1298 + }
1.1299 + }
1.1300 +
1.1301 + // See if it is in iNotifyRecordError
1.1302 + count=iNotifyRecordError.Count();
1.1303 + for( index=0; (index<count) && (!foundActiveObject); ++index )
1.1304 + {
1.1305 + if( aActive == iNotifyRecordError[index] )
1.1306 + {
1.1307 + INFO_PRINTF1(_L("DoCancel iNotifyRecordError called"));
1.1308 + foundActiveObject = ETrue;
1.1309 + iNotifyRecordError.Remove(index);
1.1310 + }
1.1311 + }
1.1312 +
1.1313 + // See if it is in iPlay
1.1314 + count=iPlay.Count();
1.1315 + for( index=0; (index<count) && (!foundActiveObject); ++index )
1.1316 + {
1.1317 + if( aActive == iPlay[index] )
1.1318 + {
1.1319 + INFO_PRINTF1(_L("DoCancel iPlay called"));
1.1320 + foundActiveObject = ETrue;
1.1321 + iPlay.Remove(index);
1.1322 + }
1.1323 + }
1.1324 +
1.1325 + // See if it is in iRecord
1.1326 + count=iRecord.Count();
1.1327 + for( index=0; (index<count) && (!foundActiveObject); ++index )
1.1328 + {
1.1329 + if( aActive == iRecord[index] )
1.1330 + {
1.1331 + INFO_PRINTF1(_L("DoCancel iRecord called"));
1.1332 + foundActiveObject = ETrue;
1.1333 + iRecord.Remove(index);
1.1334 + }
1.1335 + }
1.1336 +
1.1337 + if( foundActiveObject )
1.1338 + {
1.1339 + if (aActive)
1.1340 + {
1.1341 + TInt err = aActive->iStatus.Int();
1.1342 + if( err != KErrNone )
1.1343 + {
1.1344 + ERR_PRINTF2(_L("DoCancel Error %d"), err);
1.1345 + SetAsyncError( aIndex, err );
1.1346 + }
1.1347 + }
1.1348 +
1.1349 + // Reset the outstanding request state
1.1350 + delete aActive;
1.1351 + DecOutstanding();
1.1352 + }
1.1353 + else
1.1354 + {
1.1355 + ERR_PRINTF1(_L("An unchecked active object canceled"));
1.1356 + SetBlockResult(EFail);
1.1357 + }
1.1358 + }