|
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 // |
|
15 |
|
16 #ifndef AUDIODEVICE_H |
|
17 #define AUDIODEVICE_H |
|
18 |
|
19 #include <e32msgqueue.h> |
|
20 #include <mdf/mdfprocessingunit.h> |
|
21 #include <mdf/mdfinputport.h> |
|
22 #include <mdf/mdfoutputport.h> |
|
23 #include <mmf/server/mmfhwdevicesetup.h> |
|
24 #include <mdf/mdfcommon.h> |
|
25 |
|
26 #ifdef SYMBIAN_MDF_SHAREDCHUNK_SOUNDDRIVER |
|
27 #include "mdasoundadapter.h" |
|
28 #else |
|
29 #include <mdasound.h> |
|
30 #endif |
|
31 |
|
32 class CMMFBuffer; |
|
33 |
|
34 /* |
|
35 Audio Sink/Source processing unit |
|
36 */ |
|
37 class CAudioDevice : public CMdfProcessingUnit |
|
38 { |
|
39 public: |
|
40 /* |
|
41 Audio Sink/Source input port |
|
42 */ |
|
43 class CInputPort: public CActive, |
|
44 public MMdfInputPort, |
|
45 public MPlayCustomInterface |
|
46 { |
|
47 public: |
|
48 static CInputPort* NewL(CAudioDevice& aParent); |
|
49 |
|
50 // from MMdfInputPort |
|
51 TInt MipConfigure(const TPuConfig& aConfiguration); |
|
52 TInt MipGetConfig(TPuConfig& aConfigurationSetup); |
|
53 void MipInitialize(); |
|
54 void MipSetObserver(const MMdfInputPortObserver& aInputPortObserver); |
|
55 CMMFBuffer* MipCreateBuffer(TInt aBufferSize); |
|
56 TInt MipUseBuffer(CMMFBuffer& aBuffer); |
|
57 TInt MipFreeBuffer(CMMFBuffer* aBuffer); |
|
58 TInt MipTunnelRequest(const MMdfOutputPort& aOutputPortToBeConnectedTo, |
|
59 TTunnelFlags& aTunnelFlags, TSupplierType& aSupplierType); |
|
60 void MipWriteData(CMMFBuffer& aBuffer); |
|
61 void MipDisconnectTunnel(); |
|
62 void MipRestartTunnel(); |
|
63 TBool MipIsTunnelled() const; |
|
64 TInt MipIndex() const; |
|
65 TUint32 MipBufferSize() const; |
|
66 TInt MipCreateCustomInterface(TUid aUid); |
|
67 TAny* MipCustomInterface(TUid aUid); |
|
68 |
|
69 // from MPlayCustomInterface |
|
70 void SetVolume(TUint aVolume); |
|
71 TUint Volume(); |
|
72 TUint BytesPlayed(); |
|
73 void SetVolumeRamp(const TTimeIntervalMicroSeconds& aRampDuration); |
|
74 TTimeIntervalMicroSeconds& VolumeRamp(); |
|
75 TInt SampleRate(); |
|
76 TInt Channels(); |
|
77 |
|
78 // from CActive |
|
79 void RunL(); |
|
80 void DoCancel(); |
|
81 |
|
82 // CInputPort |
|
83 void Execute(); |
|
84 void Pause(); |
|
85 void Stop(); |
|
86 ~CInputPort(); |
|
87 |
|
88 private: |
|
89 explicit CInputPort(CAudioDevice& aParent); |
|
90 void ConstructL(); |
|
91 private: |
|
92 CMMFBuffer* iCurrentBuffer; |
|
93 CAudioDevice& iParent; |
|
94 MMdfOutputPort* iPortConnectedTo; |
|
95 RPointerArray<CMMFBuffer> iBuffers; |
|
96 MMdfInputPortObserver* iObserver; |
|
97 TInt iSampleRate; |
|
98 TInt iChannels; |
|
99 TBool iInterleaved; |
|
100 TUint iVolume; |
|
101 TTimeIntervalMicroSeconds iRampDuration; |
|
102 TUint iBytesPlayed; |
|
103 TBool iPaused; |
|
104 TBool iStopped; |
|
105 TUint iBufferSize; |
|
106 }; |
|
107 /* |
|
108 Audio Sink/Source output port |
|
109 */ |
|
110 class COutputPort: public CActive, |
|
111 public MMdfOutputPort, |
|
112 public MRecordCustomInterface |
|
113 { |
|
114 public: |
|
115 static COutputPort* NewL(CAudioDevice& aParent); |
|
116 |
|
117 // from MMdfOutputPort |
|
118 TInt MopConfigure(const TPuConfig& aConfiguration); |
|
119 TInt MopGetConfig(TPuConfig& aConfigurationSetup); |
|
120 void MopInitialize(); |
|
121 void MopSetObserver(const MMdfOutputPortObserver& aOutputPortObserver); |
|
122 CMMFBuffer* MopCreateBuffer(TInt aBufferSize); |
|
123 TInt MopUseBuffer(CMMFBuffer& aBuffer); |
|
124 TInt MopFreeBuffer(CMMFBuffer* aBuffer); |
|
125 TInt MopTunnelRequest(const MMdfInputPort& aInputPortToBeConnectedTo, |
|
126 TTunnelFlags& aTunnelFlags, TSupplierType& aSupplierType); |
|
127 void MopReadData(CMMFBuffer& aBuffer); |
|
128 void MopDisconnectTunnel(); |
|
129 void MopRestartTunnel(); |
|
130 TBool MopIsTunnelled() const; |
|
131 TInt MopIndex() const; |
|
132 TUint32 MopBufferSize() const; |
|
133 TInt MopCreateCustomInterface(TUid aUid); |
|
134 TAny* MopCustomInterface(TUid aUid); |
|
135 |
|
136 // from MRecordCustomInterface |
|
137 void SetGain(TUint aGain); |
|
138 TUint Gain(); |
|
139 TUint BytesRecorded(); |
|
140 TInt SampleRate(); |
|
141 TInt Channels(); |
|
142 |
|
143 // from CActive |
|
144 void RunL(); |
|
145 void DoCancel(); |
|
146 |
|
147 // COutputPort |
|
148 ~COutputPort(); |
|
149 void Execute(); |
|
150 void Pause(); |
|
151 void Stop(); |
|
152 |
|
153 private: |
|
154 explicit COutputPort(CAudioDevice& aParent); |
|
155 void ConstructL(); |
|
156 private: |
|
157 CMMFBuffer* iCurrentBuffer; |
|
158 CAudioDevice& iParent; |
|
159 RPointerArray<CMMFBuffer> iBuffers; |
|
160 MMdfOutputPortObserver* iObserver; |
|
161 MMdfInputPort* iPortConnectedTo; |
|
162 TInt iSampleRate; |
|
163 TInt iChannels; |
|
164 TBool iInterleaved; |
|
165 TUint iGain; |
|
166 TUint iBytesRecorded; |
|
167 TBool iPaused; |
|
168 TUint iBufferSize; |
|
169 }; |
|
170 public: |
|
171 static CAudioDevice* NewL(); |
|
172 // from CMdfProcessingUnit |
|
173 TInt Create(const MMdfProcessingUnitObserver& aProcessingUnitObserver); |
|
174 TInt GetInputPorts(RPointerArray<MMdfInputPort>& aComponentInputPorts); |
|
175 TInt GetOutputPorts(RPointerArray<MMdfOutputPort>& aComponentOutputPorts); |
|
176 TInt Configure(const TPuConfig& aConfigurationSetup); |
|
177 TInt GetConfig(TPuConfig& aConfigurationSetup); |
|
178 void Initialize(); |
|
179 void Execute (); |
|
180 TInt Pause (); |
|
181 void Stop (); |
|
182 TProcessingUnitState State(); |
|
183 TInt CreateCustomInterface(TUid aUid); |
|
184 TAny* CustomInterface(TUid aUid); |
|
185 |
|
186 // CAudioDevice |
|
187 RMdaDevSound& SoundDevice(); |
|
188 MMdfProcessingUnitObserver* Observer(); |
|
189 ~CAudioDevice(); |
|
190 |
|
191 private: |
|
192 CAudioDevice(); |
|
193 void ConstructL(); |
|
194 private: |
|
195 CInputPort* iInputPort; |
|
196 COutputPort* iOutputPort; |
|
197 RMdaDevSound iSoundDevice; |
|
198 MMdfProcessingUnitObserver* iObserver; |
|
199 TProcessingUnitState iState; |
|
200 }; |
|
201 |
|
202 #endif // AUDIODEVICE_H |