os/mm/mmdevicefw/mdf/src/audio/HwDeviceAdapter/mdfhwdeviceadapter.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/mm/mmdevicefw/mdf/src/audio/HwDeviceAdapter/mdfhwdeviceadapter.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,178 @@
     1.4 +// Copyright (c) 2005-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 +// mmfhwdeviceadapter.h
    1.18 +// 
    1.19 +//
    1.20 +
    1.21 +/**
    1.22 + @file
    1.23 + @publishedPartner
    1.24 + @prototype
    1.25 + @see CMMFHwDevice
    1.26 + @see MMdfInputPortObserver
    1.27 + @see MMdfOutputPortObserver
    1.28 + @see MMdfProcessingUnitObserver
    1.29 + @see MMdfHwDeviceSetup
    1.30 +*/
    1.31 +
    1.32 +#ifndef HWDEVICEADAPTER_H
    1.33 +#define HWDEVICEADAPTER_H
    1.34 +
    1.35 +#include <mdf/mdfinputport.h>
    1.36 +#include <mdf/mdfoutputport.h>
    1.37 +#include <mdf/mdfprocessingunit.h>
    1.38 +#include <mdf/mdfpuloader.h>
    1.39 +#include <mmf/server/mmfhwdevice.h>
    1.40 +#include <mmf/server/mmfdatabuffer.h>
    1.41 +#include <mmf/server/mmfhwdevicesetup.h>
    1.42 +#include <mmf/common/mmfutilities.h>
    1.43 +
    1.44 +class CMMFBuffer;
    1.45 +
    1.46 +/*
    1.47 +Hardware Device Adapter class that uses Processing Units (and their associated Ports) in
    1.48 +order to decode and encode audio data.
    1.49 +*/
    1.50 +class CMdfHwDeviceAdapter : public CMMFHwDevice,
    1.51 +				    		public MMdfInputPortObserver,
    1.52 +				    		public MMdfOutputPortObserver,
    1.53 +				    		public MMdfProcessingUnitObserver,
    1.54 +				    		public MMdfHwDeviceSetup
    1.55 +	{
    1.56 +public:	
    1.57 +	/*
    1.58 +	The current state of the Hardware Device Adapter.
    1.59 +	*/
    1.60 +	enum THwDevAdapterState
    1.61 +		{
    1.62 +		/*
    1.63 +		The PULoader has been loaded.
    1.64 +		*/
    1.65 +		EProcessingUnitLoaderLoaded,
    1.66 +		/*
    1.67 +		The Processing Units have been loaded.
    1.68 +		*/
    1.69 +		EProcessingUnitLoaded,
    1.70 +		/*
    1.71 +		The Processing Units are currently being initialised.
    1.72 +		*/
    1.73 +		EProcessingUnitInitializing,
    1.74 +		/*
    1.75 +		The Processing Units are currently in the idle state.
    1.76 +		*/
    1.77 +		EProcessingUnitIdle,
    1.78 +		/*
    1.79 +		The Processing Units are currently in the executing state.
    1.80 +		*/
    1.81 +		EProcessingUnitExecuting,
    1.82 +		/*
    1.83 +		The Processing Units are currently in the paused state.
    1.84 +		*/
    1.85 +		EProcessingUnitPaused		
    1.86 +		};	
    1.87 +	
    1.88 +public:
    1.89 +	static CMdfHwDeviceAdapter* NewL();
    1.90 +	
    1.91 +	// from CMMFHwDevice
    1.92 +	TInt Start(TDeviceFunc aFuncCmd, TDeviceFlow aFlowCmd);
    1.93 +	TInt Stop();
    1.94 +	TInt Pause();
    1.95 +	TInt Init(THwDeviceInitParams& aDevInfo);
    1.96 +	TAny* CustomInterface(TUid aInterfaceId);
    1.97 +	TInt ThisHwBufferFilled(CMMFBuffer& aFillBufferPtr);
    1.98 +	TInt ThisHwBufferEmptied(CMMFBuffer& aEmptyBufferPtr);
    1.99 +	TInt SetConfig(TTaskConfig& aConfig);
   1.100 +	TInt StopAndDeleteCodec();
   1.101 +	TInt DeleteCodec();	
   1.102 +	~CMdfHwDeviceAdapter();
   1.103 +	
   1.104 +	// from MMdfInputPortObserver
   1.105 +	void MipoWriteDataComplete(const MMdfInputPort* aPu, CMMFBuffer* aBuffer, TInt aErrorCode);
   1.106 +	void MipoDisconnectTunnelComplete(const MMdfInputPort* aPu, TInt aErrorCode);
   1.107 +	void MipoRestartTunnelComplete(const MMdfInputPort* aPu, TInt aErrorCode);
   1.108 +	
   1.109 +	// from MMdfOutputPortObserver
   1.110 +	void MopoReadDataComplete(const MMdfOutputPort* aPu, CMMFBuffer* aBuffer, TInt aErrorCode);
   1.111 +	void MopoDisconnectTunnelComplete(const MMdfOutputPort* aPu, TInt aErrorCode);
   1.112 +	void MopoRestartTunnelComplete(const MMdfOutputPort* aPu, TInt aErrorCode);
   1.113 +	
   1.114 +	// from MMdfProcessingUnitObserver
   1.115 +	void InitializeComplete(const CMdfProcessingUnit* aPu, TInt aErrorCode);
   1.116 +	void ExecuteComplete(const CMdfProcessingUnit* aPu, TInt aErrorCode);
   1.117 +	
   1.118 +	// from MMdfHwDeviceSetup	
   1.119 +	void SetDataTypesL(TFourCC aSrcType, TFourCC aDestType);
   1.120 +	
   1.121 +	// CMdfHwDeviceAdapter
   1.122 +	void GetState(THwDevAdapterState& aState) const;
   1.123 +	
   1.124 +protected:
   1.125 +	/*
   1.126 +	Hardware Device Adapter panics raised as a result of a programming error.
   1.127 +	*/	
   1.128 +	enum THwDeviceAdapterPanics
   1.129 +		{
   1.130 +		/*
   1.131 +		Raised when the Codec Processing Unit has not been initialised.
   1.132 +		@see CMdfHwDeviceAdapter::CustomInterface
   1.133 +		@see CMdfHwDeviceAdapter::SetDataTypesL
   1.134 +		*/
   1.135 +		EPanicCodecNotSet
   1.136 +		};	
   1.137 +	
   1.138 +private:
   1.139 +	CMdfHwDeviceAdapter();
   1.140 +	void ConstructL();
   1.141 +	TInt CreateBuffers();
   1.142 +	TInt StartEncode();
   1.143 +	TInt StartDecode();
   1.144 +	TInt InitializeEncode();
   1.145 +	TInt InitializeDecode();
   1.146 +	TInt StartExecuting();
   1.147 +	void StopHwDevice(TInt error);
   1.148 +private:
   1.149 +	enum TPUType
   1.150 +		{
   1.151 +		EPcmPu,
   1.152 +		ESourceSinkPu
   1.153 +		};
   1.154 +	CMdfPuLoader* iPuLoader;
   1.155 +	TUid iPuLoaderDtorKey;
   1.156 +	MMdfInputPort* iCodecInputPort;
   1.157 +	MMdfOutputPort* iCodecOutputPort;
   1.158 +	MMdfInputPort* iSinkInputPort;
   1.159 +	MMdfOutputPort* iSourceOutputPort;
   1.160 +	CMdfProcessingUnit* iCodecPU;
   1.161 +	CMdfProcessingUnit* iAudioDevicePU;
   1.162 +	THwDevAdapterState iState;
   1.163 +	TBool iPCMPUCallbackComplete;
   1.164 +	TBool iSourceSinkPUCallbackComplete;
   1.165 +	TBool iSourceSinkPuMopoStopCompleted;
   1.166 +	TBool iPCMPuMopoStopCompleted;
   1.167 +	TBool iPCMPuMipoStopCompleted;
   1.168 +	TBool iStopping;
   1.169 +	TInt iInitError;
   1.170 +	TInt iExecuteError;
   1.171 +	CMMFBuffer* iInputBuffer;
   1.172 +	CMMFBuffer* iOutputBuffer;
   1.173 +	TInt iInputPortBufferData;	
   1.174 +	TInt iOutputPortBufferData;
   1.175 +	CActiveSchedulerWait* iActiveWait;
   1.176 +	TDeviceFunc iFuncCmd;
   1.177 +	TFourCC iFirstFourCC;
   1.178 +	TFourCC iSecondFourCC;
   1.179 +	};
   1.180 +	
   1.181 +#endif // HWDEVICEADAPTER_H