sl@0: // Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // SoundDeviceBody.inl sl@0: // Initializes DevSound object for the mode aMode for processing audio data sl@0: // with hardware device aHWDev. sl@0: // On completion of Initialization, the observer will be notified via call back sl@0: // InitializeComplete(). sl@0: // Leaves on failure. sl@0: // @param "MDevSoundObserver& aDevSoundObserver" sl@0: // A reference to DevSound Observer instance. sl@0: // @param "TUid aHWDev" sl@0: // CMMFHwDevice implementation identifier. sl@0: // @param "TMMFState aMode" sl@0: // Mode for which this object will be used. sl@0: // sl@0: // sl@0: sl@0: inline void CMMFDevSoundClientImp::InitializeL(MDevSoundObserver& aDevSoundObserver, TUid aHWDev, TMMFState aMode) sl@0: { sl@0: TInt initError = KErrNone; sl@0: iDevSoundObserver = &aDevSoundObserver; sl@0: sl@0: // Need to set up an init complete event and message handler sl@0: // prior to calling InitializeL() sl@0: if (iICHandler) sl@0: { sl@0: iICHandler->CancelReceiveEvents(); sl@0: } sl@0: else sl@0: { sl@0: iICHandler = CMMFInitializeCompleteHandler::NewL(iDevSoundProxy, *iDevSoundObserver); sl@0: } sl@0: iICHandler->ReceiveEvents(); sl@0: sl@0: initError = iDevSoundProxy->InitializeL(aHWDev, aMode); sl@0: sl@0: if (initError) sl@0: { sl@0: iDevSoundObserver->InitializeComplete(initError); sl@0: User::Leave(initError); sl@0: } sl@0: sl@0: if(iBTBFHandler) sl@0: { sl@0: iBTBFHandler->CancelReceiveEvents(); sl@0: } sl@0: else sl@0: { sl@0: iBTBFHandler = CMMFBufferToBeFilledHandler::NewL(iDevSoundProxy, *iDevSoundObserver); sl@0: } sl@0: iBTBFHandler->ReceiveEvents(); sl@0: sl@0: sl@0: if(iPEHandler) sl@0: { sl@0: iPEHandler->CancelReceiveEvents(); sl@0: } sl@0: else sl@0: { sl@0: iPEHandler = CMMFPlayErrorHandler::NewL(iDevSoundProxy, *iDevSoundObserver); sl@0: } sl@0: iPEHandler->ReceiveEvents(); sl@0: sl@0: sl@0: if(iREHandler) sl@0: { sl@0: iREHandler->CancelReceiveEvents(); sl@0: } sl@0: else sl@0: { sl@0: iREHandler = CMMFRecordErrorHandler::NewL(iDevSoundProxy, *iDevSoundObserver); sl@0: } sl@0: iREHandler->ReceiveEvents(); sl@0: sl@0: sl@0: if(iTFHandler) sl@0: { sl@0: iTFHandler->CancelReceiveEvents(); sl@0: } sl@0: else sl@0: { sl@0: iTFHandler = CMMFToneFinishedHandler::NewL(iDevSoundProxy, *iDevSoundObserver); sl@0: } sl@0: iTFHandler->ReceiveEvents(); sl@0: sl@0: sl@0: if(iBTBEHandler) sl@0: { sl@0: iBTBEHandler->CancelReceiveEvents(); sl@0: } sl@0: else sl@0: { sl@0: iBTBEHandler = CMMFBufferToBeEmptiedHandler::NewL(iDevSoundProxy, *iDevSoundObserver); sl@0: } sl@0: iBTBEHandler->ReceiveEvents(); sl@0: sl@0: sl@0: if(iSETCHandler) sl@0: { sl@0: iSETCHandler->CancelReceiveEvents(); sl@0: } sl@0: else sl@0: { sl@0: iSETCHandler = CMMFSendEventToClientHandler::NewL(iDevSoundProxy, *iDevSoundObserver); sl@0: } sl@0: iSETCHandler->ReceiveEvents(); sl@0: } sl@0: sl@0: sl@0: sl@0: /* sl@0: * sl@0: * Initializes DevSound object for the mode aMode for processing audio data sl@0: * using an array of Hardware devices identified by aHWDevArray identifier sl@0: * array. The hardware devices are chained together with data flow starting sl@0: * with first array element. sl@0: * sl@0: * On completion of Initialization, the observer will be notified via call back sl@0: * InitializeComplete(). sl@0: * sl@0: * Leaves on failure. sl@0: * sl@0: * @param "MDevSoundObserver& aDevSoundObserver" sl@0: * A reference to DevSound Observer instance. sl@0: * sl@0: * @param "CArrayPtr aHWDevArray" sl@0: * Array of CMMFHwDevice implementation identifiers. sl@0: * sl@0: * @param "TMMFState aMode" sl@0: * Mode for which this object will be used. sl@0: * sl@0: */ sl@0: inline void CMMFDevSoundClientImp::InitializeL(MDevSoundObserver& /*aDevSoundObserver*/, sl@0: CArrayPtr /*aHWDevArray*/, TMMFState /*aMode*/) sl@0: { sl@0: User::Leave(KErrNotSupported); sl@0: } sl@0: sl@0: /* sl@0: * sl@0: * Initializes DevSound object for the mode aMode for processing audio data sl@0: * with hardware device supporting FourCC aDesiredFourCC. sl@0: * sl@0: * On completion of Initialization, the observer will be notified via call back sl@0: * InitializeComplete(). sl@0: * sl@0: * Leaves on failure. sl@0: * sl@0: * @param "MDevSoundObserver& aDevSoundObserver" sl@0: * A reference to DevSound Observer instance. sl@0: * sl@0: * @param "TFourCC aDesiredFourCC" sl@0: * CMMFHwDevice implementation FourCC. sl@0: * sl@0: * @param "TMMFState aMode" sl@0: * Mode for which this object will be used. sl@0: * sl@0: */ sl@0: inline void CMMFDevSoundClientImp::InitializeL(MDevSoundObserver& aDevSoundObserver, sl@0: TFourCC aDesiredFourCC, TMMFState aMode) sl@0: { sl@0: TInt initError = KErrNone; sl@0: iDevSoundObserver = &aDevSoundObserver; sl@0: sl@0: // Need to set up an init complete event and message handler sl@0: // prior to calling InitializeL() sl@0: if (iICHandler) sl@0: { sl@0: iICHandler->CancelReceiveEvents(); sl@0: } sl@0: else sl@0: { sl@0: iICHandler = CMMFInitializeCompleteHandler::NewL(iDevSoundProxy, *iDevSoundObserver); sl@0: } sl@0: iICHandler->ReceiveEvents(); sl@0: sl@0: initError = iDevSoundProxy->InitializeL(aDesiredFourCC, aMode); sl@0: sl@0: if (initError) sl@0: { sl@0: iDevSoundObserver->InitializeComplete(initError); sl@0: User::Leave(initError); sl@0: } sl@0: sl@0: if(iBTBFHandler) sl@0: { sl@0: iBTBFHandler->CancelReceiveEvents(); sl@0: } sl@0: else sl@0: { sl@0: iBTBFHandler = CMMFBufferToBeFilledHandler::NewL(iDevSoundProxy, *iDevSoundObserver); sl@0: } sl@0: iBTBFHandler->ReceiveEvents(); sl@0: sl@0: sl@0: if(iPEHandler) sl@0: { sl@0: iPEHandler->CancelReceiveEvents(); sl@0: } sl@0: else sl@0: { sl@0: iPEHandler = CMMFPlayErrorHandler::NewL(iDevSoundProxy, *iDevSoundObserver); sl@0: } sl@0: iPEHandler->ReceiveEvents(); sl@0: sl@0: sl@0: if(iREHandler) sl@0: { sl@0: iREHandler->CancelReceiveEvents(); sl@0: } sl@0: else sl@0: { sl@0: iREHandler = CMMFRecordErrorHandler::NewL(iDevSoundProxy, *iDevSoundObserver); sl@0: } sl@0: iREHandler->ReceiveEvents(); sl@0: sl@0: sl@0: if(iTFHandler) sl@0: { sl@0: iTFHandler->CancelReceiveEvents(); sl@0: } sl@0: else sl@0: { sl@0: iTFHandler = CMMFToneFinishedHandler::NewL(iDevSoundProxy, *iDevSoundObserver); sl@0: } sl@0: iTFHandler->ReceiveEvents(); sl@0: sl@0: sl@0: if(iBTBEHandler) sl@0: { sl@0: iBTBEHandler->CancelReceiveEvents(); sl@0: } sl@0: else sl@0: { sl@0: iBTBEHandler = CMMFBufferToBeEmptiedHandler::NewL(iDevSoundProxy, *iDevSoundObserver); sl@0: } sl@0: iBTBEHandler->ReceiveEvents(); sl@0: sl@0: sl@0: if(iSETCHandler) sl@0: { sl@0: iSETCHandler->CancelReceiveEvents(); sl@0: } sl@0: else sl@0: { sl@0: iSETCHandler = CMMFSendEventToClientHandler::NewL(iDevSoundProxy, *iDevSoundObserver); sl@0: } sl@0: iSETCHandler->ReceiveEvents(); sl@0: sl@0: } sl@0: sl@0: /* sl@0: * sl@0: * Returns the supported Audio settings. sl@0: * sl@0: * @return "TMMFCapabilities" sl@0: * Device settings. sl@0: * sl@0: */ sl@0: inline TMMFCapabilities CMMFDevSoundClientImp::Capabilities() sl@0: { sl@0: return iDevSoundProxy->Capabilities(); sl@0: } sl@0: sl@0: /* sl@0: * sl@0: * Returns the current audio settings. sl@0: * sl@0: * @return "TMMFCapabilities" sl@0: * Device settings. sl@0: * sl@0: */ sl@0: inline TMMFCapabilities CMMFDevSoundClientImp::Config() const sl@0: { sl@0: return iDevSoundProxy->Config(); sl@0: } sl@0: sl@0: /* sl@0: * sl@0: * Returns an integer representing the maximum volume. sl@0: * sl@0: * This is the maximum value which can be passed to CMMFDevSound::SetVolume. sl@0: * sl@0: * @return "TInt" sl@0: * The maximum volume. This value is platform dependent but is always sl@0: * greater than or equal to one. sl@0: * sl@0: */ sl@0: inline TInt CMMFDevSoundClientImp::MaxVolume() sl@0: { sl@0: return iDevSoundProxy->MaxVolume(); sl@0: } sl@0: sl@0: /* sl@0: * sl@0: * Returns an integer representing the current volume. sl@0: * sl@0: * @return "TInt" sl@0: * The current volume level. sl@0: * sl@0: */ sl@0: inline TInt CMMFDevSoundClientImp::Volume() sl@0: { sl@0: return iDevSoundProxy->Volume(); sl@0: } sl@0: sl@0: /* sl@0: * sl@0: * Returns an integer representing the maximum gain. sl@0: * sl@0: * This is the maximum value which can be passed to CMMFDevSound::SetGain. sl@0: * sl@0: * @return "TInt" sl@0: * The maximum gain. This value is platform dependent but is always sl@0: * greater than or equal to one. sl@0: * sl@0: */ sl@0: inline TInt CMMFDevSoundClientImp::MaxGain() sl@0: { sl@0: return iDevSoundProxy->MaxGain(); sl@0: } sl@0: sl@0: /* sl@0: * sl@0: * Returns an integer representing the current gain. sl@0: * sl@0: * @return "TInt" sl@0: * The current gain level. sl@0: * sl@0: */ sl@0: inline TInt CMMFDevSoundClientImp::Gain() sl@0: { sl@0: return iDevSoundProxy->Gain(); sl@0: } sl@0: sl@0: /* sl@0: * sl@0: * Returns the speaker balance set for playing. sl@0: * sl@0: * Leaves on failure. sl@0: * sl@0: * @param "TInt& aLeftPercentage" sl@0: * On return contains the left speaker volume percentage. sl@0: * sl@0: * @param "TInt& aRightPercentage" sl@0: * On return contains the right speaker volume percentage. sl@0: * sl@0: */ sl@0: inline void CMMFDevSoundClientImp::GetPlayBalanceL(TInt& aLeftPercentage, TInt& aRightPercentage) sl@0: { sl@0: iDevSoundProxy->GetPlayBalanceL(aLeftPercentage, aRightPercentage); sl@0: } sl@0: sl@0: /* sl@0: * sl@0: * Returns the microphone gain balance set for recording. sl@0: * sl@0: * Leaves on failure. sl@0: * sl@0: * @param "TInt& aLeftPercentage" sl@0: * On return contains the left microphone gain percentage. sl@0: * sl@0: * @param "TInt& aRightPercentage" sl@0: * On return contains the right microphone gain percentage. sl@0: * sl@0: */ sl@0: inline void CMMFDevSoundClientImp::GetRecordBalanceL(TInt& aLeftPercentage, TInt& aRightPercentage) sl@0: { sl@0: iDevSoundProxy->GetRecordBalanceL(aLeftPercentage, aRightPercentage); sl@0: } sl@0: sl@0: /* sl@0: * sl@0: * Contine the process of recording. Once the buffer is filled with recorded sl@0: * data, the Observer gets reference to buffer along with callback sl@0: * BufferToBeEmptied(). After processing the buffer (copying over to a sl@0: * different buffer or writing to file) the client should call this sl@0: * method to continue recording process. sl@0: * sl@0: */ sl@0: inline void CMMFDevSoundClientImp::RecordData() sl@0: { sl@0: ASSERT(iDevSoundObserver); sl@0: iDevSoundProxy->RecordData(); sl@0: } sl@0: sl@0: /* sl@0: * sl@0: * Defines the number of times the audio is to be repeated during the tone sl@0: * playback operation. sl@0: * sl@0: * A period of silence can follow each playing of tone. The tone playing can sl@0: * be repeated indefinitely. sl@0: * sl@0: * @param "TInt aRepeatCount" sl@0: * The number of times the tone, together with the trailing silence, sl@0: * is to be repeated. If this is set to KMdaRepeatForever, then the sl@0: * tone, together with the trailing silence, is repeated indefinitely sl@0: * or until Stop() is called. If this is set to zero, then the tone is sl@0: * not repeated. sl@0: * sl@0: * Supported only during tone playing. sl@0: * sl@0: */ sl@0: inline void CMMFDevSoundClientImp::SetToneRepeats(TInt aRepeatCount, sl@0: const TTimeIntervalMicroSeconds& aRepeatTrailingSilence) sl@0: { sl@0: iDevSoundProxy->SetToneRepeats(aRepeatCount, aRepeatTrailingSilence); sl@0: } sl@0: sl@0: /* sl@0: * sl@0: * Defines the priority settings that should be used for this instance. sl@0: * sl@0: * @param "const TMMFPrioritySettings& aPrioritySettings" sl@0: * An class type representing the client's priority, priority sl@0: * preference and state. sl@0: * sl@0: */ sl@0: inline void CMMFDevSoundClientImp::SetPrioritySettings(const TMMFPrioritySettings& aPrioritySettings) sl@0: { sl@0: iDevSoundProxy->SetPrioritySettings(aPrioritySettings); sl@0: } sl@0: sl@0: /* sl@0: * sl@0: * Initializes and starts conversion process. Once the process is initiated, sl@0: * observer's call back method BufferToBeFilled() is called with reference to sl@0: * the buffer into which source format data is to be read. sl@0: * sl@0: * The maximum size of data (in bytes) that can be converted is specified in sl@0: * CMMFBuffer::RequestSize(). Any data that is read into buffer beyond this sl@0: * size will be ignored. sl@0: * sl@0: * Leaves on failure. sl@0: * @prototype sl@0: */ sl@0: inline void CMMFDevSoundClientImp::ConvertInitL() sl@0: { sl@0: iDevSoundProxy->ConvertInitL(); sl@0: } sl@0: sl@0: /* sl@0: * sl@0: * Converts the data in the buffer from source format to destination format. sl@0: * After the data is converted to destination format, a reference to the buffer sl@0: * containing data in destination format is passed in the observer call back sl@0: * method BufferToBeEmptied(). sl@0: * sl@0: * The amount of data contained in buffer is specified in sl@0: * CMMFBuffer::RequestSize(). sl@0: * @prototype sl@0: */ sl@0: inline void CMMFDevSoundClientImp::ConvertData() sl@0: { sl@0: iDevSoundProxy->ConvertData(); sl@0: } sl@0: sl@0: // No custom interfaces are supported sp return NULL. sl@0: inline TAny* CMMFDevSoundClientImp::CustomInterface(TUid aInterfaceId) sl@0: { sl@0: if(aInterfaceId == KMmfUidDevSoundAudioResourceCustomInterface) sl@0: { sl@0: MAutoPauseResumeSupport* result = this; sl@0: return result; sl@0: } sl@0: if(aInterfaceId == KMmfUidDevSoundAudioClientThreadInfoCustomInterface) sl@0: { sl@0: MAudioClientThreadInfo* result = this; sl@0: return result; sl@0: } sl@0: return iDevSoundProxy->CustomInterface(aInterfaceId); sl@0: } sl@0: sl@0: /* sl@0: * sl@0: * Returns the number of available pre-defined tone sequences. sl@0: * sl@0: * This is the number of fixed sequence supported by DevSound by default. sl@0: * sl@0: * @return "TInt" sl@0: * The fixed sequence count. This value is implementation dependent sl@0: * but is always greater than or equal to zero. sl@0: * sl@0: */ sl@0: inline TInt CMMFDevSoundClientImp::FixedSequenceCount() sl@0: { sl@0: sl@0: return iDevSoundProxy->FixedSequenceCount(); sl@0: } sl@0: sl@0: /* sl@0: * sl@0: * Returns the name assigned to a specific pre-defined tone sequence. sl@0: * sl@0: * This is the number of fixed sequence supported by DevSound by default. sl@0: * sl@0: * The function raises a panic if sequence number specified invalid. sl@0: * sl@0: * @return "TDesC&" sl@0: * A reference to a Descriptor containing the fixed sequence sl@0: * name indexed by aSequenceNumber. sl@0: * sl@0: * @param "TInt aSequenceNumber" sl@0: * The index identifying the specific pre-defined tone sequence. Index sl@0: * values are relative to zero. sl@0: * This can be any value from zero to the value returned by a call to sl@0: * CMdaAudioPlayerUtility::FixedSequenceCount() - 1. sl@0: * The function raises a panic if sequence number is not within this sl@0: * range. sl@0: * sl@0: */ sl@0: inline const TDesC& CMMFDevSoundClientImp::FixedSequenceName(TInt aSequenceNumber) sl@0: { sl@0: return iDevSoundProxy->FixedSequenceName(aSequenceNumber); sl@0: } sl@0: