diff -r 000000000000 -r bde4ae8d615e os/mm/mmhais/refacladapt/src/audiostream/audiostream.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/os/mm/mmhais/refacladapt/src/audiostream/audiostream.h Fri Jun 15 03:10:57 2012 +0200 @@ -0,0 +1,165 @@ +/* +* Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: +* +* Description: +* +*/ + + +#ifndef AUDIOSTREAM_H +#define AUDIOSTREAM_H + +#include +#include +#include +#include +#include "audiostreamadaptation.h" +#include "maudiocodecadaptationobserver.h" +#include "mconfigurationhelper.h" +#include "mstreambuffercontrol.h" + +class CAudioCodec; +class CAudioStream; +class CAudioDeviceSource; +class CAudioDeviceSink; +class CBufferSink; +class CBufferSource; +class CAudioGainControl; +class CFourCCConvertor; +class MAudioStreamAdaptationObserver; +class MInputPort; +class MOutputPort; +class MAudioCodecObserver; + + +#include "mlogicalchain.h" + +class CLogicalAudioStream; + +///// + // This is the implementation of audio stream adaptation. + /// + +class CAudioStream : public CAudioStreamAdaptation, + public MAudioCodecAdaptationObserver, + public MConfigurationHelper, + public MStreamBufferControl, + public MFlushHandlerObserver + { +public: + + ///// + // Create a new instance. + // + // @param aStream the stream implementation. Ownership of the pointer is transferred to the create CAudioStream object instance. + // @return CAudioStreamComponent* a pointer to the created instance. + /// + static CAudioStream* NewL(); + + ///// + // Destructor. + // + // Deletes all objects and releases all resource owned by this instance. + /// + virtual ~CAudioStream(); + + // From CAudioStreamAdaptation + TInt RegisterAudioStreamObserver(MAudioStreamAdaptationObserver& aObserver); + void UnregisterAudioStreamObserver(MAudioStreamAdaptationObserver& aObserver); + void UnregisterAllAudioStreamObserver(); + void SetFourCC(const CFourCCConvertor& aFourCCConvertor); + + TInt Message(MLogicalChain& aCurrentChain, MLogicalChain& aDesiredChain, MAudioContext& aContext, TInt aFlags); + + // from class MAudioCodecAdaptationObserver + void AllBuffersProcessed(); + void ProcessingUnitError(TInt aError); + TInt RegisterAudioCodecObserver(MAudioCodecObserver& aObserver); + void UnregisterAudioCodecObserver(MAudioCodecObserver& aObserver); + void GetSupportedAModesComplete(TInt aError); + void GetSupportedARatesComplete(TInt aError); + + // from base clase MStreamBufferControl + TInt FlushBuffers(); + + // from class MFlushHandlerObserver + void FlushComplete(TInt aError); +protected: + // from base clase MConfigurationhelper + TInt GetSupportedModes(RArray& aSupportedModes); + TInt GetSupportedSampleRates(RArray& aSupportedRates); + +private: + TInt CreateDataPath(); + + TInt DemolishDataPath(); + + TInt ChangeState(TAudioState aPreviousState, TAudioState aTargetState); + + TAny* GetComponent(TUid aType); + + TInt CreatePhysicalComponents(MLogicalChain& aDesiredChain); + + void DeletePhysicalComponents(); + + void ConstructL(); + + CAudioStream(); + +private: + // Flags + TBool iIsCodecConfig; + + // Components + MLogicalChain* iDesiredChain; + + MLogicalChain* iCurrentChain; + + MAudioContext* iAudioContext; + + CAudioCodec* iCodec; + + CBufferSource* iBufferSource; + + CBufferSink* iBufferSink; + + CAudioDeviceSource* iDeviceSource; + + CAudioDeviceSink* iDeviceSink; + + CAudioGainControl* iGainControl; + + // Not owned + CFourCCConvertor* iFourCCConvertor; + + TInt iSampleRateConfig; + + TUid iModeConfig; + + TAudioState iCurrentStreamState; + + TAudioState iDesiredStreamState; + + // Observers + RPointerArray iAudioStreamObservers; + + RPointerArray iAudioCodecObservers; + + MOutputPort* iOutputport; // remove ports when changing to Uninitialized + + MInputPort* iInputport; + + TTimeIntervalMicroSeconds iTimeProcessed; + }; + +#endif // AUDIOSTREAM_H__