os/mm/mmhais/a3facl/src/audiostream/logicalaudiostream.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/mm/mmhais/a3facl/src/audiostream/logicalaudiostream.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,221 @@
     1.4 +/*
     1.5 +* Copyright (c) 2004-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 +
    1.23 +#ifndef LOGICALAUDIOSTREAM_H
    1.24 +#define LOGICALAUDIOSTREAM_H
    1.25 +
    1.26 +#include <e32base.h>
    1.27 +#include <a3f/a3f_trace_utils.h>
    1.28 +#include <a3f/audioprocessingunittypeuids.h>
    1.29 +#include <a3f/a3fbase.h>
    1.30 +
    1.31 +#include <a3f/maudioprocessingunitobserver.h>
    1.32 +#include <a3f/maudiostreamobserver.h>
    1.33 +
    1.34 +#include "componentparameters.h"
    1.35 +#include "audiostreammanager.h"
    1.36 +
    1.37 +#include <a3f/msynccisupport.h>
    1.38 +#include "../shared/a3fbackdooraccess.h"
    1.39 +#include "../audiocontext/audiocontext.h"
    1.40 +
    1.41 +// TO BE REMOVED WHEN MMRC SERVER IS READY
    1.42 +#include "mlogicalchain.h"
    1.43 +#include "maudiostreamadaptationobserver.h"
    1.44 +#include "maudiocodecadaptationobserver.h"
    1.45 +
    1.46 +#include <a3f/maudiocodecobserver.h>
    1.47 +
    1.48 +#include "mstreambuffercontrol.h"
    1.49 +
    1.50 +
    1.51 +class MLogicalSettingObserver;
    1.52 +class CLogicalAudioCodec;
    1.53 +class CLogicalAudioGainControl;
    1.54 +class CLogicalBufferSource;
    1.55 +class CLogicalBufferSink;
    1.56 +class CLogicalAudioDeviceSink;
    1.57 +class CLogicalAudioDeviceSource;
    1.58 +
    1.59 +
    1.60 +/**
    1.61 +This is the implementation of audio stream API.
    1.62 +@see MAudioStream
    1.63 +*/
    1.64 +
    1.65 +NONSHARABLE_CLASS(CLogicalAudioStream) :	public CAudioStreamManager,
    1.66 +											public MCustomInterfaceSupport, 
    1.67 +											public MCustomInterfaceSupportObserver, 
    1.68 +											public MAudioStreamAdaptationObserver,
    1.69 +											public MLogicalChain,
    1.70 +											public MAudioCodecObserver,
    1.71 +											public MA3FBackdoorAccessIf
    1.72 +	{
    1.73 +friend class CAudioContext;
    1.74 +
    1.75 +public:
    1.76 +	/**
    1.77 +	Destructor.
    1.78 +	
    1.79 +	Deletes all objects and releases all resource owned by this instance.
    1.80 +	*/
    1.81 +	virtual ~CLogicalAudioStream();
    1.82 +
    1.83 +	// from MAudioStream
    1.84 +	virtual TInt Initialize();
    1.85 +	virtual TInt Load();
    1.86 +	virtual TInt Activate();
    1.87 +	virtual TInt Stop();
    1.88 +	virtual TInt Unload();
    1.89 +	virtual TInt Uninitialize();
    1.90 +	virtual TInt Prime();
    1.91 +	virtual TInt Flush();
    1.92 +
    1.93 +	virtual TInt AddSource(MAudioProcessingUnit* aSource);
    1.94 +	virtual TInt AddSink(MAudioProcessingUnit* aSink);
    1.95 +	virtual TInt AddAudioCodec(MAudioProcessingUnit* aCodec);
    1.96 +	virtual TInt AddGainControl(MAudioProcessingUnit* aGainControl);
    1.97 +	virtual TInt RemoveProcessingUnit(MAudioProcessingUnit* aProcessingUnit);
    1.98 +	virtual TInt ResetStreamTime();
    1.99 +	virtual TInt GetStreamTime(TTimeIntervalMicroSeconds& aStreamTime);
   1.100 +	virtual TAny* Interface(TUid aType);
   1.101 +
   1.102 +	// from MCustomInterfaceSupport
   1.103 +	virtual TInt RequestCustomInterface(TUid aUid, TAny*& aPtr);
   1.104 +	virtual TInt RegisterObserver(MCustomInterfaceSupportObserver& aObserver);
   1.105 +	virtual void UnRegisterObserver(MCustomInterfaceSupportObserver& aObserver); 
   1.106 +
   1.107 +	// from MCustomInterfaceSupportObserver
   1.108 +	virtual void CustomInterfaceRemoval(TUid aInterfaceUid, TAny* aPtr);
   1.109 +
   1.110 +	// from MAudioStreamAdaptationObserver
   1.111 +	void PhysicalAdaptationEvent(TPhysicalEvent aEvent, TInt aError);
   1.112 +	void StateEvent(TInt aReason, TAudioState aNewState);
   1.113 +	void AddProcessingUnitComplete(TUid aType, TInt aError);
   1.114 +	void RemoveProcessingUnitComplete(TUid aType, TInt aError);
   1.115 +	void ProcessingFinished ();
   1.116 +	void FlushComplete (TInt aError);
   1.117 +	
   1.118 +	// from MLogicalChain
   1.119 +	void SetMessageType(TMMRCMessageType aMessageType);
   1.120 +	void ResetMessage();
   1.121 +	TUint MessageType();
   1.122 +	TUid AudioProcessingUnitUid(TInt aIndex);
   1.123 +	TInt AudioProcessingUnitsCount();
   1.124 +	TAudioState StreamState();
   1.125 +	void SetStreamState(TAudioState aState);
   1.126 +	TUid CodecFormat();
   1.127 +	TInt GetSampleRate();
   1.128 +	TUid GetMode();
   1.129 +	TInt Priority();
   1.130 +	void GetVolumeRampParameters(TUid& aRampOperation, TTimeIntervalMicroSeconds& aRampDuration);
   1.131 +	MLogicalChain* CloneL();
   1.132 +	void Release();
   1.133 +	TAny* GetComponent(TUid aType);
   1.134 +
   1.135 +	void CopySettings(const MLogicalChain& aChain);
   1.136 +	void SetAdaptationSource(MMMFBufferSource& aSource);
   1.137 +	void SetAdaptationSink(MMMFBufferSink& aSink);
   1.138 +	void SetAdaptationGainControl(MAudioGainControl& aGain);
   1.139 +	void SetStreamPositionControl(MStreamPositionControl& aControl );
   1.140 +	void SetCustomInterfaceProvider(MCustomInterfaceSupport& aControl);
   1.141 +	void SetCodecConfiguration(RArray<TInt> aSampleRate, RArray<TUid> aMode);
   1.142 +	void SetAdaptationStream(MConfigurationHelper& aStream);
   1.143 +	void SetStreamBufferControl(MStreamBufferControl& aStreamBufferControl);
   1.144 +
   1.145 +	// from MAudioCodecObserver
   1.146 +	void SampleRateSet(TInt aError);
   1.147 +	void ModeSet(TInt aError);
   1.148 +	void GetSupportedSampleRatesComplete (TInt aError);
   1.149 +	void GetSupportedModesComplete (TInt aError);
   1.150 +	
   1.151 +	// from MA3FBackdoorAccessIf
   1.152 +	MAudioContext* AudioContext();
   1.153 +	MAudioStream* AudioStream();
   1.154 +	MAudioProcessingUnit* ProcessingUnit(TUid aType);
   1.155 +
   1.156 +	/**
   1.157 +	Create a new instance.
   1.158 +	
   1.159 +	@param aStream the stream implementation. Ownership of the pointer is transferred to the 
   1.160 +			create CAudioStream object instance.
   1.161 +	@return CAudioStreamComponent* a pointer to the created instance.
   1.162 +	*/
   1.163 +	static CLogicalAudioStream* NewL(TUid aTypeId);
   1.164 +	
   1.165 +	//Get functions for configuration
   1.166 +	void GetSupportedSampleRates(RArray<TInt>& aSupportedRates);
   1.167 +	void GetSupportedModes(RArray<TUid>& aSupportedModes);
   1.168 +	
   1.169 +	virtual void SetParentContext(const CAudioContext& aContext);
   1.170 +	
   1.171 +protected:
   1.172 +	// Internal method
   1.173 +	void MapUidToProcessingUnit(TUid aType, MAudioProcessingUnit*& aInstance);
   1.174 +
   1.175 +	void CopyStreamSettings(const MLogicalChain& aChain);
   1.176 +	void CopyCodecSettings(const MLogicalChain& aChain);
   1.177 +	void CopyGainSettings(const MLogicalChain& aChain);
   1.178 +
   1.179 +private:
   1.180 +
   1.181 +	void ConstructL();
   1.182 +	CLogicalAudioStream();
   1.183 +	TInt DoAddProcessingUnit(MAudioProcessingUnit* aUnit);
   1.184 +
   1.185 +private:
   1.186 +	// Time processed
   1.187 +	TTimeIntervalMicroSeconds iTimeProcessed;
   1.188 +
   1.189 +	// Audio processing units at this context
   1.190 +	RPointerArray<MAudioProcessingUnit>		iAudioProcessingUnits;
   1.191 +	
   1.192 +	// CI observers
   1.193 +	RPointerArray<MCustomInterfaceSupportObserver>	iCISupportObservers;
   1.194 +
   1.195 +	// Stream state
   1.196 +	TAudioState iCurrentState;
   1.197 +	
   1.198 +	TAudioState iRequestState;
   1.199 +
   1.200 +	// MLogical chain variables
   1.201 +	MAudioProcessingUnit*		iCodec;
   1.202 +
   1.203 +	MAudioProcessingUnit*		iGain;
   1.204 +
   1.205 +	// General pointer, useful to manage all the audioprocessingunit
   1.206 +	// never keeps specific information
   1.207 +	MAudioProcessingUnit*		iAudioProcessingUnit;
   1.208 +
   1.209 +	// Adaptation interfaces
   1.210 +	MStreamPositionControl*		iPositionControl;
   1.211 +	MStreamBufferControl*		iStreamBufferControl;
   1.212 +
   1.213 +	MCustomInterfaceSupport*	iInterfaceProvider;
   1.214 +
   1.215 +	// Message type 
   1.216 +	TUint		iMessageType;
   1.217 +
   1.218 +	TInt	iContextPriority;
   1.219 +	
   1.220 +	// handle back to parent context
   1.221 +	CAudioContext* iParentContext;
   1.222 +	};
   1.223 +	
   1.224 +#endif // LOGICALAUDIOSTREAM_H