|
1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // mmfhwdeviceadapter.h |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file |
|
20 @publishedPartner |
|
21 @prototype |
|
22 @see CMMFHwDevice |
|
23 @see MMdfInputPortObserver |
|
24 @see MMdfOutputPortObserver |
|
25 @see MMdfProcessingUnitObserver |
|
26 @see MMdfHwDeviceSetup |
|
27 */ |
|
28 |
|
29 #ifndef HWDEVICEADAPTER_H |
|
30 #define HWDEVICEADAPTER_H |
|
31 |
|
32 #include <mdf/mdfinputport.h> |
|
33 #include <mdf/mdfoutputport.h> |
|
34 #include <mdf/mdfprocessingunit.h> |
|
35 #include <mdf/mdfpuloader.h> |
|
36 #include <mmf/server/mmfhwdevice.h> |
|
37 #include <mmf/server/mmfdatabuffer.h> |
|
38 #include <mmf/server/mmfhwdevicesetup.h> |
|
39 #include <mmf/common/mmfutilities.h> |
|
40 |
|
41 class CMMFBuffer; |
|
42 |
|
43 /* |
|
44 Hardware Device Adapter class that uses Processing Units (and their associated Ports) in |
|
45 order to decode and encode audio data. |
|
46 */ |
|
47 class CMdfHwDeviceAdapter : public CMMFHwDevice, |
|
48 public MMdfInputPortObserver, |
|
49 public MMdfOutputPortObserver, |
|
50 public MMdfProcessingUnitObserver, |
|
51 public MMdfHwDeviceSetup |
|
52 { |
|
53 public: |
|
54 /* |
|
55 The current state of the Hardware Device Adapter. |
|
56 */ |
|
57 enum THwDevAdapterState |
|
58 { |
|
59 /* |
|
60 The PULoader has been loaded. |
|
61 */ |
|
62 EProcessingUnitLoaderLoaded, |
|
63 /* |
|
64 The Processing Units have been loaded. |
|
65 */ |
|
66 EProcessingUnitLoaded, |
|
67 /* |
|
68 The Processing Units are currently being initialised. |
|
69 */ |
|
70 EProcessingUnitInitializing, |
|
71 /* |
|
72 The Processing Units are currently in the idle state. |
|
73 */ |
|
74 EProcessingUnitIdle, |
|
75 /* |
|
76 The Processing Units are currently in the executing state. |
|
77 */ |
|
78 EProcessingUnitExecuting, |
|
79 /* |
|
80 The Processing Units are currently in the paused state. |
|
81 */ |
|
82 EProcessingUnitPaused |
|
83 }; |
|
84 |
|
85 public: |
|
86 static CMdfHwDeviceAdapter* NewL(); |
|
87 |
|
88 // from CMMFHwDevice |
|
89 TInt Start(TDeviceFunc aFuncCmd, TDeviceFlow aFlowCmd); |
|
90 TInt Stop(); |
|
91 TInt Pause(); |
|
92 TInt Init(THwDeviceInitParams& aDevInfo); |
|
93 TAny* CustomInterface(TUid aInterfaceId); |
|
94 TInt ThisHwBufferFilled(CMMFBuffer& aFillBufferPtr); |
|
95 TInt ThisHwBufferEmptied(CMMFBuffer& aEmptyBufferPtr); |
|
96 TInt SetConfig(TTaskConfig& aConfig); |
|
97 TInt StopAndDeleteCodec(); |
|
98 TInt DeleteCodec(); |
|
99 ~CMdfHwDeviceAdapter(); |
|
100 |
|
101 // from MMdfInputPortObserver |
|
102 void MipoWriteDataComplete(const MMdfInputPort* aPu, CMMFBuffer* aBuffer, TInt aErrorCode); |
|
103 void MipoDisconnectTunnelComplete(const MMdfInputPort* aPu, TInt aErrorCode); |
|
104 void MipoRestartTunnelComplete(const MMdfInputPort* aPu, TInt aErrorCode); |
|
105 |
|
106 // from MMdfOutputPortObserver |
|
107 void MopoReadDataComplete(const MMdfOutputPort* aPu, CMMFBuffer* aBuffer, TInt aErrorCode); |
|
108 void MopoDisconnectTunnelComplete(const MMdfOutputPort* aPu, TInt aErrorCode); |
|
109 void MopoRestartTunnelComplete(const MMdfOutputPort* aPu, TInt aErrorCode); |
|
110 |
|
111 // from MMdfProcessingUnitObserver |
|
112 void InitializeComplete(const CMdfProcessingUnit* aPu, TInt aErrorCode); |
|
113 void ExecuteComplete(const CMdfProcessingUnit* aPu, TInt aErrorCode); |
|
114 |
|
115 // from MMdfHwDeviceSetup |
|
116 void SetDataTypesL(TFourCC aSrcType, TFourCC aDestType); |
|
117 |
|
118 // CMdfHwDeviceAdapter |
|
119 void GetState(THwDevAdapterState& aState) const; |
|
120 |
|
121 protected: |
|
122 /* |
|
123 Hardware Device Adapter panics raised as a result of a programming error. |
|
124 */ |
|
125 enum THwDeviceAdapterPanics |
|
126 { |
|
127 /* |
|
128 Raised when the Codec Processing Unit has not been initialised. |
|
129 @see CMdfHwDeviceAdapter::CustomInterface |
|
130 @see CMdfHwDeviceAdapter::SetDataTypesL |
|
131 */ |
|
132 EPanicCodecNotSet |
|
133 }; |
|
134 |
|
135 private: |
|
136 CMdfHwDeviceAdapter(); |
|
137 void ConstructL(); |
|
138 TInt CreateBuffers(); |
|
139 TInt StartEncode(); |
|
140 TInt StartDecode(); |
|
141 TInt InitializeEncode(); |
|
142 TInt InitializeDecode(); |
|
143 TInt StartExecuting(); |
|
144 void StopHwDevice(TInt error); |
|
145 private: |
|
146 enum TPUType |
|
147 { |
|
148 EPcmPu, |
|
149 ESourceSinkPu |
|
150 }; |
|
151 CMdfPuLoader* iPuLoader; |
|
152 TUid iPuLoaderDtorKey; |
|
153 MMdfInputPort* iCodecInputPort; |
|
154 MMdfOutputPort* iCodecOutputPort; |
|
155 MMdfInputPort* iSinkInputPort; |
|
156 MMdfOutputPort* iSourceOutputPort; |
|
157 CMdfProcessingUnit* iCodecPU; |
|
158 CMdfProcessingUnit* iAudioDevicePU; |
|
159 THwDevAdapterState iState; |
|
160 TBool iPCMPUCallbackComplete; |
|
161 TBool iSourceSinkPUCallbackComplete; |
|
162 TBool iSourceSinkPuMopoStopCompleted; |
|
163 TBool iPCMPuMopoStopCompleted; |
|
164 TBool iPCMPuMipoStopCompleted; |
|
165 TBool iStopping; |
|
166 TInt iInitError; |
|
167 TInt iExecuteError; |
|
168 CMMFBuffer* iInputBuffer; |
|
169 CMMFBuffer* iOutputBuffer; |
|
170 TInt iInputPortBufferData; |
|
171 TInt iOutputPortBufferData; |
|
172 CActiveSchedulerWait* iActiveWait; |
|
173 TDeviceFunc iFuncCmd; |
|
174 TFourCC iFirstFourCC; |
|
175 TFourCC iSecondFourCC; |
|
176 }; |
|
177 |
|
178 #endif // HWDEVICEADAPTER_H |