sl@0: // Copyright (c) 2005-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: // mmfhwdeviceadapter.h sl@0: // sl@0: // sl@0: sl@0: /** sl@0: @file sl@0: @publishedPartner sl@0: @prototype sl@0: @see CMMFHwDevice sl@0: @see MMdfInputPortObserver sl@0: @see MMdfOutputPortObserver sl@0: @see MMdfProcessingUnitObserver sl@0: @see MMdfHwDeviceSetup sl@0: */ sl@0: sl@0: #ifndef HWDEVICEADAPTER_H sl@0: #define HWDEVICEADAPTER_H sl@0: sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: #include sl@0: sl@0: class CMMFBuffer; sl@0: sl@0: /* sl@0: Hardware Device Adapter class that uses Processing Units (and their associated Ports) in sl@0: order to decode and encode audio data. sl@0: */ sl@0: class CMdfHwDeviceAdapter : public CMMFHwDevice, sl@0: public MMdfInputPortObserver, sl@0: public MMdfOutputPortObserver, sl@0: public MMdfProcessingUnitObserver, sl@0: public MMdfHwDeviceSetup sl@0: { sl@0: public: sl@0: /* sl@0: The current state of the Hardware Device Adapter. sl@0: */ sl@0: enum THwDevAdapterState sl@0: { sl@0: /* sl@0: The PULoader has been loaded. sl@0: */ sl@0: EProcessingUnitLoaderLoaded, sl@0: /* sl@0: The Processing Units have been loaded. sl@0: */ sl@0: EProcessingUnitLoaded, sl@0: /* sl@0: The Processing Units are currently being initialised. sl@0: */ sl@0: EProcessingUnitInitializing, sl@0: /* sl@0: The Processing Units are currently in the idle state. sl@0: */ sl@0: EProcessingUnitIdle, sl@0: /* sl@0: The Processing Units are currently in the executing state. sl@0: */ sl@0: EProcessingUnitExecuting, sl@0: /* sl@0: The Processing Units are currently in the paused state. sl@0: */ sl@0: EProcessingUnitPaused sl@0: }; sl@0: sl@0: public: sl@0: static CMdfHwDeviceAdapter* NewL(); sl@0: sl@0: // from CMMFHwDevice sl@0: TInt Start(TDeviceFunc aFuncCmd, TDeviceFlow aFlowCmd); sl@0: TInt Stop(); sl@0: TInt Pause(); sl@0: TInt Init(THwDeviceInitParams& aDevInfo); sl@0: TAny* CustomInterface(TUid aInterfaceId); sl@0: TInt ThisHwBufferFilled(CMMFBuffer& aFillBufferPtr); sl@0: TInt ThisHwBufferEmptied(CMMFBuffer& aEmptyBufferPtr); sl@0: TInt SetConfig(TTaskConfig& aConfig); sl@0: TInt StopAndDeleteCodec(); sl@0: TInt DeleteCodec(); sl@0: ~CMdfHwDeviceAdapter(); sl@0: sl@0: // from MMdfInputPortObserver sl@0: void MipoWriteDataComplete(const MMdfInputPort* aPu, CMMFBuffer* aBuffer, TInt aErrorCode); sl@0: void MipoDisconnectTunnelComplete(const MMdfInputPort* aPu, TInt aErrorCode); sl@0: void MipoRestartTunnelComplete(const MMdfInputPort* aPu, TInt aErrorCode); sl@0: sl@0: // from MMdfOutputPortObserver sl@0: void MopoReadDataComplete(const MMdfOutputPort* aPu, CMMFBuffer* aBuffer, TInt aErrorCode); sl@0: void MopoDisconnectTunnelComplete(const MMdfOutputPort* aPu, TInt aErrorCode); sl@0: void MopoRestartTunnelComplete(const MMdfOutputPort* aPu, TInt aErrorCode); sl@0: sl@0: // from MMdfProcessingUnitObserver sl@0: void InitializeComplete(const CMdfProcessingUnit* aPu, TInt aErrorCode); sl@0: void ExecuteComplete(const CMdfProcessingUnit* aPu, TInt aErrorCode); sl@0: sl@0: // from MMdfHwDeviceSetup sl@0: void SetDataTypesL(TFourCC aSrcType, TFourCC aDestType); sl@0: sl@0: // CMdfHwDeviceAdapter sl@0: void GetState(THwDevAdapterState& aState) const; sl@0: sl@0: protected: sl@0: /* sl@0: Hardware Device Adapter panics raised as a result of a programming error. sl@0: */ sl@0: enum THwDeviceAdapterPanics sl@0: { sl@0: /* sl@0: Raised when the Codec Processing Unit has not been initialised. sl@0: @see CMdfHwDeviceAdapter::CustomInterface sl@0: @see CMdfHwDeviceAdapter::SetDataTypesL sl@0: */ sl@0: EPanicCodecNotSet sl@0: }; sl@0: sl@0: private: sl@0: CMdfHwDeviceAdapter(); sl@0: void ConstructL(); sl@0: TInt CreateBuffers(); sl@0: TInt StartEncode(); sl@0: TInt StartDecode(); sl@0: TInt InitializeEncode(); sl@0: TInt InitializeDecode(); sl@0: TInt StartExecuting(); sl@0: void StopHwDevice(TInt error); sl@0: private: sl@0: enum TPUType sl@0: { sl@0: EPcmPu, sl@0: ESourceSinkPu sl@0: }; sl@0: CMdfPuLoader* iPuLoader; sl@0: TUid iPuLoaderDtorKey; sl@0: MMdfInputPort* iCodecInputPort; sl@0: MMdfOutputPort* iCodecOutputPort; sl@0: MMdfInputPort* iSinkInputPort; sl@0: MMdfOutputPort* iSourceOutputPort; sl@0: CMdfProcessingUnit* iCodecPU; sl@0: CMdfProcessingUnit* iAudioDevicePU; sl@0: THwDevAdapterState iState; sl@0: TBool iPCMPUCallbackComplete; sl@0: TBool iSourceSinkPUCallbackComplete; sl@0: TBool iSourceSinkPuMopoStopCompleted; sl@0: TBool iPCMPuMopoStopCompleted; sl@0: TBool iPCMPuMipoStopCompleted; sl@0: TBool iStopping; sl@0: TInt iInitError; sl@0: TInt iExecuteError; sl@0: CMMFBuffer* iInputBuffer; sl@0: CMMFBuffer* iOutputBuffer; sl@0: TInt iInputPortBufferData; sl@0: TInt iOutputPortBufferData; sl@0: CActiveSchedulerWait* iActiveWait; sl@0: TDeviceFunc iFuncCmd; sl@0: TFourCC iFirstFourCC; sl@0: TFourCC iSecondFourCC; sl@0: }; sl@0: sl@0: #endif // HWDEVICEADAPTER_H