1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/mm/devsound/sounddevbt/PlatSec/src/SoundDevice/BtSoundDeviceBody.inl Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,528 @@
1.4 +// Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +// SoundDeviceBody.inl
1.18 +// Initializes DevSound object for the mode aMode for processing audio data
1.19 +// with hardware device aHWDev.
1.20 +// On completion of Initialization, the observer will be notified via call back
1.21 +// InitializeComplete().
1.22 +// Leaves on failure.
1.23 +// @param "MDevSoundObserver& aDevSoundObserver"
1.24 +// A reference to DevSound Observer instance.
1.25 +// @param "TUid aHWDev"
1.26 +// CMMFHwDevice implementation identifier.
1.27 +// @param "TMMFState aMode"
1.28 +// Mode for which this object will be used.
1.29 +//
1.30 +//
1.31 +
1.32 +inline void CMMFDevSoundClientImp::InitializeL(MDevSoundObserver& aDevSoundObserver, TUid aHWDev, TMMFState aMode)
1.33 + {
1.34 + TInt initError = KErrNone;
1.35 + iDevSoundObserver = &aDevSoundObserver;
1.36 +
1.37 + // Need to set up an init complete event and message handler
1.38 + // prior to calling InitializeL()
1.39 + if (iICHandler)
1.40 + {
1.41 + iICHandler->CancelReceiveEvents();
1.42 + }
1.43 + else
1.44 + {
1.45 + iICHandler = CMMFInitializeCompleteHandler::NewL(iDevSoundProxy, *iDevSoundObserver);
1.46 + }
1.47 + iICHandler->ReceiveEvents();
1.48 +
1.49 + initError = iDevSoundProxy->InitializeL(aHWDev, aMode);
1.50 +
1.51 + if (initError)
1.52 + {
1.53 + iDevSoundObserver->InitializeComplete(initError);
1.54 + User::Leave(initError);
1.55 + }
1.56 +
1.57 + if(iBTBFHandler)
1.58 + {
1.59 + iBTBFHandler->CancelReceiveEvents();
1.60 + }
1.61 + else
1.62 + {
1.63 + iBTBFHandler = CMMFBufferToBeFilledHandler::NewL(iDevSoundProxy, *iDevSoundObserver);
1.64 + }
1.65 + iBTBFHandler->ReceiveEvents();
1.66 +
1.67 +
1.68 + if(iPEHandler)
1.69 + {
1.70 + iPEHandler->CancelReceiveEvents();
1.71 + }
1.72 + else
1.73 + {
1.74 + iPEHandler = CMMFPlayErrorHandler::NewL(iDevSoundProxy, *iDevSoundObserver);
1.75 + }
1.76 + iPEHandler->ReceiveEvents();
1.77 +
1.78 +
1.79 + if(iREHandler)
1.80 + {
1.81 + iREHandler->CancelReceiveEvents();
1.82 + }
1.83 + else
1.84 + {
1.85 + iREHandler = CMMFRecordErrorHandler::NewL(iDevSoundProxy, *iDevSoundObserver);
1.86 + }
1.87 + iREHandler->ReceiveEvents();
1.88 +
1.89 +
1.90 + if(iTFHandler)
1.91 + {
1.92 + iTFHandler->CancelReceiveEvents();
1.93 + }
1.94 + else
1.95 + {
1.96 + iTFHandler = CMMFToneFinishedHandler::NewL(iDevSoundProxy, *iDevSoundObserver);
1.97 + }
1.98 + iTFHandler->ReceiveEvents();
1.99 +
1.100 +
1.101 + if(iBTBEHandler)
1.102 + {
1.103 + iBTBEHandler->CancelReceiveEvents();
1.104 + }
1.105 + else
1.106 + {
1.107 + iBTBEHandler = CMMFBufferToBeEmptiedHandler::NewL(iDevSoundProxy, *iDevSoundObserver);
1.108 + }
1.109 + iBTBEHandler->ReceiveEvents();
1.110 +
1.111 +
1.112 + if(iSETCHandler)
1.113 + {
1.114 + iSETCHandler->CancelReceiveEvents();
1.115 + }
1.116 + else
1.117 + {
1.118 + iSETCHandler = CMMFSendEventToClientHandler::NewL(iDevSoundProxy, *iDevSoundObserver);
1.119 + }
1.120 + iSETCHandler->ReceiveEvents();
1.121 + }
1.122 +
1.123 +
1.124 +
1.125 +/*
1.126 + *
1.127 + * Initializes DevSound object for the mode aMode for processing audio data
1.128 + * using an array of Hardware devices identified by aHWDevArray identifier
1.129 + * array. The hardware devices are chained together with data flow starting
1.130 + * with first array element.
1.131 + *
1.132 + * On completion of Initialization, the observer will be notified via call back
1.133 + * InitializeComplete().
1.134 + *
1.135 + * Leaves on failure.
1.136 + *
1.137 + * @param "MDevSoundObserver& aDevSoundObserver"
1.138 + * A reference to DevSound Observer instance.
1.139 + *
1.140 + * @param "CArrayPtr<TUid> aHWDevArray"
1.141 + * Array of CMMFHwDevice implementation identifiers.
1.142 + *
1.143 + * @param "TMMFState aMode"
1.144 + * Mode for which this object will be used.
1.145 + *
1.146 + */
1.147 +inline void CMMFDevSoundClientImp::InitializeL(MDevSoundObserver& /*aDevSoundObserver*/,
1.148 + CArrayPtr<TUid> /*aHWDevArray*/, TMMFState /*aMode*/)
1.149 + {
1.150 + User::Leave(KErrNotSupported);
1.151 + }
1.152 +
1.153 +/*
1.154 + *
1.155 + * Initializes DevSound object for the mode aMode for processing audio data
1.156 + * with hardware device supporting FourCC aDesiredFourCC.
1.157 + *
1.158 + * On completion of Initialization, the observer will be notified via call back
1.159 + * InitializeComplete().
1.160 + *
1.161 + * Leaves on failure.
1.162 + *
1.163 + * @param "MDevSoundObserver& aDevSoundObserver"
1.164 + * A reference to DevSound Observer instance.
1.165 + *
1.166 + * @param "TFourCC aDesiredFourCC"
1.167 + * CMMFHwDevice implementation FourCC.
1.168 + *
1.169 + * @param "TMMFState aMode"
1.170 + * Mode for which this object will be used.
1.171 + *
1.172 + */
1.173 +inline void CMMFDevSoundClientImp::InitializeL(MDevSoundObserver& aDevSoundObserver,
1.174 + TFourCC aDesiredFourCC, TMMFState aMode)
1.175 + {
1.176 + TInt initError = KErrNone;
1.177 + iDevSoundObserver = &aDevSoundObserver;
1.178 +
1.179 + // Need to set up an init complete event and message handler
1.180 + // prior to calling InitializeL()
1.181 + if (iICHandler)
1.182 + {
1.183 + iICHandler->CancelReceiveEvents();
1.184 + }
1.185 + else
1.186 + {
1.187 + iICHandler = CMMFInitializeCompleteHandler::NewL(iDevSoundProxy, *iDevSoundObserver);
1.188 + }
1.189 + iICHandler->ReceiveEvents();
1.190 +
1.191 + initError = iDevSoundProxy->InitializeL(aDesiredFourCC, aMode);
1.192 +
1.193 + if (initError)
1.194 + {
1.195 + iDevSoundObserver->InitializeComplete(initError);
1.196 + User::Leave(initError);
1.197 + }
1.198 +
1.199 + if(iBTBFHandler)
1.200 + {
1.201 + iBTBFHandler->CancelReceiveEvents();
1.202 + }
1.203 + else
1.204 + {
1.205 + iBTBFHandler = CMMFBufferToBeFilledHandler::NewL(iDevSoundProxy, *iDevSoundObserver);
1.206 + }
1.207 + iBTBFHandler->ReceiveEvents();
1.208 +
1.209 +
1.210 + if(iPEHandler)
1.211 + {
1.212 + iPEHandler->CancelReceiveEvents();
1.213 + }
1.214 + else
1.215 + {
1.216 + iPEHandler = CMMFPlayErrorHandler::NewL(iDevSoundProxy, *iDevSoundObserver);
1.217 + }
1.218 + iPEHandler->ReceiveEvents();
1.219 +
1.220 +
1.221 + if(iREHandler)
1.222 + {
1.223 + iREHandler->CancelReceiveEvents();
1.224 + }
1.225 + else
1.226 + {
1.227 + iREHandler = CMMFRecordErrorHandler::NewL(iDevSoundProxy, *iDevSoundObserver);
1.228 + }
1.229 + iREHandler->ReceiveEvents();
1.230 +
1.231 +
1.232 + if(iTFHandler)
1.233 + {
1.234 + iTFHandler->CancelReceiveEvents();
1.235 + }
1.236 + else
1.237 + {
1.238 + iTFHandler = CMMFToneFinishedHandler::NewL(iDevSoundProxy, *iDevSoundObserver);
1.239 + }
1.240 + iTFHandler->ReceiveEvents();
1.241 +
1.242 +
1.243 + if(iBTBEHandler)
1.244 + {
1.245 + iBTBEHandler->CancelReceiveEvents();
1.246 + }
1.247 + else
1.248 + {
1.249 + iBTBEHandler = CMMFBufferToBeEmptiedHandler::NewL(iDevSoundProxy, *iDevSoundObserver);
1.250 + }
1.251 + iBTBEHandler->ReceiveEvents();
1.252 +
1.253 +
1.254 + if(iSETCHandler)
1.255 + {
1.256 + iSETCHandler->CancelReceiveEvents();
1.257 + }
1.258 + else
1.259 + {
1.260 + iSETCHandler = CMMFSendEventToClientHandler::NewL(iDevSoundProxy, *iDevSoundObserver);
1.261 + }
1.262 + iSETCHandler->ReceiveEvents();
1.263 +
1.264 + }
1.265 +
1.266 +/*
1.267 + *
1.268 + * Returns the supported Audio settings.
1.269 + *
1.270 + * @return "TMMFCapabilities"
1.271 + * Device settings.
1.272 + *
1.273 + */
1.274 +inline TMMFCapabilities CMMFDevSoundClientImp::Capabilities()
1.275 + {
1.276 + return iDevSoundProxy->Capabilities();
1.277 + }
1.278 +
1.279 +/*
1.280 + *
1.281 + * Returns the current audio settings.
1.282 + *
1.283 + * @return "TMMFCapabilities"
1.284 + * Device settings.
1.285 + *
1.286 + */
1.287 +inline TMMFCapabilities CMMFDevSoundClientImp::Config() const
1.288 + {
1.289 + return iDevSoundProxy->Config();
1.290 + }
1.291 +
1.292 +/*
1.293 + *
1.294 + * Returns an integer representing the maximum volume.
1.295 + *
1.296 + * This is the maximum value which can be passed to CMMFDevSound::SetVolume.
1.297 + *
1.298 + * @return "TInt"
1.299 + * The maximum volume. This value is platform dependent but is always
1.300 + * greater than or equal to one.
1.301 + *
1.302 + */
1.303 +inline TInt CMMFDevSoundClientImp::MaxVolume()
1.304 + {
1.305 + return iDevSoundProxy->MaxVolume();
1.306 + }
1.307 +
1.308 +/*
1.309 + *
1.310 + * Returns an integer representing the current volume.
1.311 + *
1.312 + * @return "TInt"
1.313 + * The current volume level.
1.314 + *
1.315 + */
1.316 +inline TInt CMMFDevSoundClientImp::Volume()
1.317 + {
1.318 + return iDevSoundProxy->Volume();
1.319 + }
1.320 +
1.321 +/*
1.322 + *
1.323 + * Returns an integer representing the maximum gain.
1.324 + *
1.325 + * This is the maximum value which can be passed to CMMFDevSound::SetGain.
1.326 + *
1.327 + * @return "TInt"
1.328 + * The maximum gain. This value is platform dependent but is always
1.329 + * greater than or equal to one.
1.330 + *
1.331 + */
1.332 +inline TInt CMMFDevSoundClientImp::MaxGain()
1.333 + {
1.334 + return iDevSoundProxy->MaxGain();
1.335 + }
1.336 +
1.337 +/*
1.338 + *
1.339 + * Returns an integer representing the current gain.
1.340 + *
1.341 + * @return "TInt"
1.342 + * The current gain level.
1.343 + *
1.344 + */
1.345 +inline TInt CMMFDevSoundClientImp::Gain()
1.346 + {
1.347 + return iDevSoundProxy->Gain();
1.348 + }
1.349 +
1.350 +/*
1.351 + *
1.352 + * Returns the speaker balance set for playing.
1.353 + *
1.354 + * Leaves on failure.
1.355 + *
1.356 + * @param "TInt& aLeftPercentage"
1.357 + * On return contains the left speaker volume percentage.
1.358 + *
1.359 + * @param "TInt& aRightPercentage"
1.360 + * On return contains the right speaker volume percentage.
1.361 + *
1.362 + */
1.363 +inline void CMMFDevSoundClientImp::GetPlayBalanceL(TInt& aLeftPercentage, TInt& aRightPercentage)
1.364 + {
1.365 + iDevSoundProxy->GetPlayBalanceL(aLeftPercentage, aRightPercentage);
1.366 + }
1.367 +
1.368 +/*
1.369 + *
1.370 + * Returns the microphone gain balance set for recording.
1.371 + *
1.372 + * Leaves on failure.
1.373 + *
1.374 + * @param "TInt& aLeftPercentage"
1.375 + * On return contains the left microphone gain percentage.
1.376 + *
1.377 + * @param "TInt& aRightPercentage"
1.378 + * On return contains the right microphone gain percentage.
1.379 + *
1.380 + */
1.381 +inline void CMMFDevSoundClientImp::GetRecordBalanceL(TInt& aLeftPercentage, TInt& aRightPercentage)
1.382 + {
1.383 + iDevSoundProxy->GetRecordBalanceL(aLeftPercentage, aRightPercentage);
1.384 + }
1.385 +
1.386 +/*
1.387 + *
1.388 + * Contine the process of recording. Once the buffer is filled with recorded
1.389 + * data, the Observer gets reference to buffer along with callback
1.390 + * BufferToBeEmptied(). After processing the buffer (copying over to a
1.391 + * different buffer or writing to file) the client should call this
1.392 + * method to continue recording process.
1.393 + *
1.394 + */
1.395 +inline void CMMFDevSoundClientImp::RecordData()
1.396 + {
1.397 + ASSERT(iDevSoundObserver);
1.398 + iDevSoundProxy->RecordData();
1.399 + }
1.400 +
1.401 +/*
1.402 + *
1.403 + * Defines the number of times the audio is to be repeated during the tone
1.404 + * playback operation.
1.405 + *
1.406 + * A period of silence can follow each playing of tone. The tone playing can
1.407 + * be repeated indefinitely.
1.408 + *
1.409 + * @param "TInt aRepeatCount"
1.410 + * The number of times the tone, together with the trailing silence,
1.411 + * is to be repeated. If this is set to KMdaRepeatForever, then the
1.412 + * tone, together with the trailing silence, is repeated indefinitely
1.413 + * or until Stop() is called. If this is set to zero, then the tone is
1.414 + * not repeated.
1.415 + *
1.416 + * Supported only during tone playing.
1.417 + *
1.418 + */
1.419 +inline void CMMFDevSoundClientImp::SetToneRepeats(TInt aRepeatCount,
1.420 + const TTimeIntervalMicroSeconds& aRepeatTrailingSilence)
1.421 + {
1.422 + iDevSoundProxy->SetToneRepeats(aRepeatCount, aRepeatTrailingSilence);
1.423 + }
1.424 +
1.425 +/*
1.426 + *
1.427 + * Defines the priority settings that should be used for this instance.
1.428 + *
1.429 + * @param "const TMMFPrioritySettings& aPrioritySettings"
1.430 + * An class type representing the client's priority, priority
1.431 + * preference and state.
1.432 + *
1.433 + */
1.434 +inline void CMMFDevSoundClientImp::SetPrioritySettings(const TMMFPrioritySettings& aPrioritySettings)
1.435 + {
1.436 + iDevSoundProxy->SetPrioritySettings(aPrioritySettings);
1.437 + }
1.438 +
1.439 +/*
1.440 + *
1.441 + * Initializes and starts conversion process. Once the process is initiated,
1.442 + * observer's call back method BufferToBeFilled() is called with reference to
1.443 + * the buffer into which source format data is to be read.
1.444 + *
1.445 + * The maximum size of data (in bytes) that can be converted is specified in
1.446 + * CMMFBuffer::RequestSize(). Any data that is read into buffer beyond this
1.447 + * size will be ignored.
1.448 + *
1.449 + * Leaves on failure.
1.450 + * @prototype
1.451 + */
1.452 +inline void CMMFDevSoundClientImp::ConvertInitL()
1.453 + {
1.454 + iDevSoundProxy->ConvertInitL();
1.455 + }
1.456 +
1.457 +/*
1.458 + *
1.459 + * Converts the data in the buffer from source format to destination format.
1.460 + * After the data is converted to destination format, a reference to the buffer
1.461 + * containing data in destination format is passed in the observer call back
1.462 + * method BufferToBeEmptied().
1.463 + *
1.464 + * The amount of data contained in buffer is specified in
1.465 + * CMMFBuffer::RequestSize().
1.466 + * @prototype
1.467 + */
1.468 +inline void CMMFDevSoundClientImp::ConvertData()
1.469 + {
1.470 + iDevSoundProxy->ConvertData();
1.471 + }
1.472 +
1.473 +// No custom interfaces are supported sp return NULL.
1.474 +inline TAny* CMMFDevSoundClientImp::CustomInterface(TUid aInterfaceId)
1.475 + {
1.476 + if(aInterfaceId == KMmfUidDevSoundAudioResourceCustomInterface)
1.477 + {
1.478 + MAutoPauseResumeSupport* result = this;
1.479 + return result;
1.480 + }
1.481 + if(aInterfaceId == KMmfUidDevSoundAudioClientThreadInfoCustomInterface)
1.482 + {
1.483 + MAudioClientThreadInfo* result = this;
1.484 + return result;
1.485 + }
1.486 + return iDevSoundProxy->CustomInterface(aInterfaceId);
1.487 + }
1.488 +
1.489 +/*
1.490 + *
1.491 + * Returns the number of available pre-defined tone sequences.
1.492 + *
1.493 + * This is the number of fixed sequence supported by DevSound by default.
1.494 + *
1.495 + * @return "TInt"
1.496 + * The fixed sequence count. This value is implementation dependent
1.497 + * but is always greater than or equal to zero.
1.498 + *
1.499 + */
1.500 +inline TInt CMMFDevSoundClientImp::FixedSequenceCount()
1.501 + {
1.502 +
1.503 + return iDevSoundProxy->FixedSequenceCount();
1.504 + }
1.505 +
1.506 +/*
1.507 + *
1.508 + * Returns the name assigned to a specific pre-defined tone sequence.
1.509 + *
1.510 + * This is the number of fixed sequence supported by DevSound by default.
1.511 + *
1.512 + * The function raises a panic if sequence number specified invalid.
1.513 + *
1.514 + * @return "TDesC&"
1.515 + * A reference to a Descriptor containing the fixed sequence
1.516 + * name indexed by aSequenceNumber.
1.517 + *
1.518 + * @param "TInt aSequenceNumber"
1.519 + * The index identifying the specific pre-defined tone sequence. Index
1.520 + * values are relative to zero.
1.521 + * This can be any value from zero to the value returned by a call to
1.522 + * CMdaAudioPlayerUtility::FixedSequenceCount() - 1.
1.523 + * The function raises a panic if sequence number is not within this
1.524 + * range.
1.525 + *
1.526 + */
1.527 +inline const TDesC& CMMFDevSoundClientImp::FixedSequenceName(TInt aSequenceNumber)
1.528 + {
1.529 + return iDevSoundProxy->FixedSequenceName(aSequenceNumber);
1.530 + }
1.531 +