Update contrib.
1 // Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // SoundDeviceBody.inl
15 // Initializes DevSound object for the mode aMode for processing audio data
16 // with hardware device aHWDev.
17 // On completion of Initialization, the observer will be notified via call back
18 // InitializeComplete().
20 // @param "MDevSoundObserver& aDevSoundObserver"
21 // A reference to DevSound Observer instance.
22 // @param "TUid aHWDev"
23 // CMMFHwDevice implementation identifier.
24 // @param "TMMFState aMode"
25 // Mode for which this object will be used.
29 inline void CMMFDevSoundClientImp::InitializeL(MDevSoundObserver& aDevSoundObserver, TUid aHWDev, TMMFState aMode)
31 TInt initError = KErrNone;
32 iDevSoundObserver = &aDevSoundObserver;
34 // Need to set up an init complete event and message handler
35 // prior to calling InitializeL()
38 iICHandler->CancelReceiveEvents();
42 iICHandler = CMMFInitializeCompleteHandler::NewL(iDevSoundProxy, *iDevSoundObserver);
44 iICHandler->ReceiveEvents();
46 initError = iDevSoundProxy->InitializeL(aHWDev, aMode);
50 iDevSoundObserver->InitializeComplete(initError);
51 User::Leave(initError);
56 iBTBFHandler->CancelReceiveEvents();
60 iBTBFHandler = CMMFBufferToBeFilledHandler::NewL(iDevSoundProxy, *iDevSoundObserver);
62 iBTBFHandler->ReceiveEvents();
67 iPEHandler->CancelReceiveEvents();
71 iPEHandler = CMMFPlayErrorHandler::NewL(iDevSoundProxy, *iDevSoundObserver);
73 iPEHandler->ReceiveEvents();
78 iREHandler->CancelReceiveEvents();
82 iREHandler = CMMFRecordErrorHandler::NewL(iDevSoundProxy, *iDevSoundObserver);
84 iREHandler->ReceiveEvents();
89 iTFHandler->CancelReceiveEvents();
93 iTFHandler = CMMFToneFinishedHandler::NewL(iDevSoundProxy, *iDevSoundObserver);
95 iTFHandler->ReceiveEvents();
100 iBTBEHandler->CancelReceiveEvents();
104 iBTBEHandler = CMMFBufferToBeEmptiedHandler::NewL(iDevSoundProxy, *iDevSoundObserver);
106 iBTBEHandler->ReceiveEvents();
111 iSETCHandler->CancelReceiveEvents();
115 iSETCHandler = CMMFSendEventToClientHandler::NewL(iDevSoundProxy, *iDevSoundObserver);
117 iSETCHandler->ReceiveEvents();
124 * Initializes DevSound object for the mode aMode for processing audio data
125 * using an array of Hardware devices identified by aHWDevArray identifier
126 * array. The hardware devices are chained together with data flow starting
127 * with first array element.
129 * On completion of Initialization, the observer will be notified via call back
130 * InitializeComplete().
134 * @param "MDevSoundObserver& aDevSoundObserver"
135 * A reference to DevSound Observer instance.
137 * @param "CArrayPtr<TUid> aHWDevArray"
138 * Array of CMMFHwDevice implementation identifiers.
140 * @param "TMMFState aMode"
141 * Mode for which this object will be used.
144 inline void CMMFDevSoundClientImp::InitializeL(MDevSoundObserver& /*aDevSoundObserver*/,
145 CArrayPtr<TUid> /*aHWDevArray*/, TMMFState /*aMode*/)
147 User::Leave(KErrNotSupported);
152 * Initializes DevSound object for the mode aMode for processing audio data
153 * with hardware device supporting FourCC aDesiredFourCC.
155 * On completion of Initialization, the observer will be notified via call back
156 * InitializeComplete().
160 * @param "MDevSoundObserver& aDevSoundObserver"
161 * A reference to DevSound Observer instance.
163 * @param "TFourCC aDesiredFourCC"
164 * CMMFHwDevice implementation FourCC.
166 * @param "TMMFState aMode"
167 * Mode for which this object will be used.
170 inline void CMMFDevSoundClientImp::InitializeL(MDevSoundObserver& aDevSoundObserver,
171 TFourCC aDesiredFourCC, TMMFState aMode)
173 TInt initError = KErrNone;
174 iDevSoundObserver = &aDevSoundObserver;
176 // Need to set up an init complete event and message handler
177 // prior to calling InitializeL()
180 iICHandler->CancelReceiveEvents();
184 iICHandler = CMMFInitializeCompleteHandler::NewL(iDevSoundProxy, *iDevSoundObserver);
186 iICHandler->ReceiveEvents();
188 initError = iDevSoundProxy->InitializeL(aDesiredFourCC, aMode);
192 iDevSoundObserver->InitializeComplete(initError);
193 User::Leave(initError);
198 iBTBFHandler->CancelReceiveEvents();
202 iBTBFHandler = CMMFBufferToBeFilledHandler::NewL(iDevSoundProxy, *iDevSoundObserver);
204 iBTBFHandler->ReceiveEvents();
209 iPEHandler->CancelReceiveEvents();
213 iPEHandler = CMMFPlayErrorHandler::NewL(iDevSoundProxy, *iDevSoundObserver);
215 iPEHandler->ReceiveEvents();
220 iREHandler->CancelReceiveEvents();
224 iREHandler = CMMFRecordErrorHandler::NewL(iDevSoundProxy, *iDevSoundObserver);
226 iREHandler->ReceiveEvents();
231 iTFHandler->CancelReceiveEvents();
235 iTFHandler = CMMFToneFinishedHandler::NewL(iDevSoundProxy, *iDevSoundObserver);
237 iTFHandler->ReceiveEvents();
242 iBTBEHandler->CancelReceiveEvents();
246 iBTBEHandler = CMMFBufferToBeEmptiedHandler::NewL(iDevSoundProxy, *iDevSoundObserver);
248 iBTBEHandler->ReceiveEvents();
253 iSETCHandler->CancelReceiveEvents();
257 iSETCHandler = CMMFSendEventToClientHandler::NewL(iDevSoundProxy, *iDevSoundObserver);
259 iSETCHandler->ReceiveEvents();
265 * Returns the supported Audio settings.
267 * @return "TMMFCapabilities"
271 inline TMMFCapabilities CMMFDevSoundClientImp::Capabilities()
273 return iDevSoundProxy->Capabilities();
278 * Returns the current audio settings.
280 * @return "TMMFCapabilities"
284 inline TMMFCapabilities CMMFDevSoundClientImp::Config() const
286 return iDevSoundProxy->Config();
291 * Returns an integer representing the maximum volume.
293 * This is the maximum value which can be passed to CMMFDevSound::SetVolume.
296 * The maximum volume. This value is platform dependent but is always
297 * greater than or equal to one.
300 inline TInt CMMFDevSoundClientImp::MaxVolume()
302 return iDevSoundProxy->MaxVolume();
307 * Returns an integer representing the current volume.
310 * The current volume level.
313 inline TInt CMMFDevSoundClientImp::Volume()
315 return iDevSoundProxy->Volume();
320 * Returns an integer representing the maximum gain.
322 * This is the maximum value which can be passed to CMMFDevSound::SetGain.
325 * The maximum gain. This value is platform dependent but is always
326 * greater than or equal to one.
329 inline TInt CMMFDevSoundClientImp::MaxGain()
331 return iDevSoundProxy->MaxGain();
336 * Returns an integer representing the current gain.
339 * The current gain level.
342 inline TInt CMMFDevSoundClientImp::Gain()
344 return iDevSoundProxy->Gain();
349 * Returns the speaker balance set for playing.
353 * @param "TInt& aLeftPercentage"
354 * On return contains the left speaker volume percentage.
356 * @param "TInt& aRightPercentage"
357 * On return contains the right speaker volume percentage.
360 inline void CMMFDevSoundClientImp::GetPlayBalanceL(TInt& aLeftPercentage, TInt& aRightPercentage)
362 iDevSoundProxy->GetPlayBalanceL(aLeftPercentage, aRightPercentage);
367 * Returns the microphone gain balance set for recording.
371 * @param "TInt& aLeftPercentage"
372 * On return contains the left microphone gain percentage.
374 * @param "TInt& aRightPercentage"
375 * On return contains the right microphone gain percentage.
378 inline void CMMFDevSoundClientImp::GetRecordBalanceL(TInt& aLeftPercentage, TInt& aRightPercentage)
380 iDevSoundProxy->GetRecordBalanceL(aLeftPercentage, aRightPercentage);
385 * Contine the process of recording. Once the buffer is filled with recorded
386 * data, the Observer gets reference to buffer along with callback
387 * BufferToBeEmptied(). After processing the buffer (copying over to a
388 * different buffer or writing to file) the client should call this
389 * method to continue recording process.
392 inline void CMMFDevSoundClientImp::RecordData()
394 ASSERT(iDevSoundObserver);
395 iDevSoundProxy->RecordData();
400 * Defines the number of times the audio is to be repeated during the tone
401 * playback operation.
403 * A period of silence can follow each playing of tone. The tone playing can
404 * be repeated indefinitely.
406 * @param "TInt aRepeatCount"
407 * The number of times the tone, together with the trailing silence,
408 * is to be repeated. If this is set to KMdaRepeatForever, then the
409 * tone, together with the trailing silence, is repeated indefinitely
410 * or until Stop() is called. If this is set to zero, then the tone is
413 * Supported only during tone playing.
416 inline void CMMFDevSoundClientImp::SetToneRepeats(TInt aRepeatCount,
417 const TTimeIntervalMicroSeconds& aRepeatTrailingSilence)
419 iDevSoundProxy->SetToneRepeats(aRepeatCount, aRepeatTrailingSilence);
424 * Defines the priority settings that should be used for this instance.
426 * @param "const TMMFPrioritySettings& aPrioritySettings"
427 * An class type representing the client's priority, priority
428 * preference and state.
431 inline void CMMFDevSoundClientImp::SetPrioritySettings(const TMMFPrioritySettings& aPrioritySettings)
433 iDevSoundProxy->SetPrioritySettings(aPrioritySettings);
438 * Initializes and starts conversion process. Once the process is initiated,
439 * observer's call back method BufferToBeFilled() is called with reference to
440 * the buffer into which source format data is to be read.
442 * The maximum size of data (in bytes) that can be converted is specified in
443 * CMMFBuffer::RequestSize(). Any data that is read into buffer beyond this
444 * size will be ignored.
449 inline void CMMFDevSoundClientImp::ConvertInitL()
451 iDevSoundProxy->ConvertInitL();
456 * Converts the data in the buffer from source format to destination format.
457 * After the data is converted to destination format, a reference to the buffer
458 * containing data in destination format is passed in the observer call back
459 * method BufferToBeEmptied().
461 * The amount of data contained in buffer is specified in
462 * CMMFBuffer::RequestSize().
465 inline void CMMFDevSoundClientImp::ConvertData()
467 iDevSoundProxy->ConvertData();
470 // No custom interfaces are supported sp return NULL.
471 inline TAny* CMMFDevSoundClientImp::CustomInterface(TUid aInterfaceId)
473 if(aInterfaceId == KMmfUidDevSoundAudioResourceCustomInterface)
475 MAutoPauseResumeSupport* result = this;
478 if(aInterfaceId == KMmfUidDevSoundAudioClientThreadInfoCustomInterface)
480 MAudioClientThreadInfo* result = this;
483 return iDevSoundProxy->CustomInterface(aInterfaceId);
488 * Returns the number of available pre-defined tone sequences.
490 * This is the number of fixed sequence supported by DevSound by default.
493 * The fixed sequence count. This value is implementation dependent
494 * but is always greater than or equal to zero.
497 inline TInt CMMFDevSoundClientImp::FixedSequenceCount()
500 return iDevSoundProxy->FixedSequenceCount();
505 * Returns the name assigned to a specific pre-defined tone sequence.
507 * This is the number of fixed sequence supported by DevSound by default.
509 * The function raises a panic if sequence number specified invalid.
512 * A reference to a Descriptor containing the fixed sequence
513 * name indexed by aSequenceNumber.
515 * @param "TInt aSequenceNumber"
516 * The index identifying the specific pre-defined tone sequence. Index
517 * values are relative to zero.
518 * This can be any value from zero to the value returned by a call to
519 * CMdaAudioPlayerUtility::FixedSequenceCount() - 1.
520 * The function raises a panic if sequence number is not within this
524 inline const TDesC& CMMFDevSoundClientImp::FixedSequenceName(TInt aSequenceNumber)
526 return iDevSoundProxy->FixedSequenceName(aSequenceNumber);