|
1 /* |
|
2 * Copyright (c) 2002-2005 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #ifndef __MMF_AUDIOOUTPUT_H__ |
|
22 #define __MMF_AUDIOOUTPUT_H__ |
|
23 |
|
24 // Standard EPOC32 includes required by this header file |
|
25 #include <e32base.h> |
|
26 #include <e32std.h> |
|
27 |
|
28 #include <mmf/plugin/mmfaudioiointerfaceuids.hrh> |
|
29 |
|
30 #include <mmf/common/mmfpaniccodes.h> |
|
31 |
|
32 //DevSound |
|
33 #include <mmf/server/sounddevice.h> |
|
34 #include <mmf/common/mmfhelper.h> |
|
35 /** |
|
36 @publishedAll |
|
37 @deprecated |
|
38 */ |
|
39 const TUint KAudioOutputDefaultFrameSize = 0x1000; |
|
40 |
|
41 |
|
42 void Panic(TInt aPanicCode); |
|
43 |
|
44 /** |
|
45 @publishedAll |
|
46 @released |
|
47 |
|
48 Interface class to allow dynamic linkage to CMMFAudioOutput. |
|
49 */ |
|
50 class MMMFAudioOutput : public MDataSink |
|
51 { |
|
52 public: |
|
53 //factory function |
|
54 /** |
|
55 Gets a new audio output object. |
|
56 |
|
57 @param aImplementationUid |
|
58 The implementation UID. |
|
59 @param aInitData |
|
60 The initialisation data. |
|
61 |
|
62 @return The audio output object. |
|
63 */ |
|
64 inline static MMMFAudioOutput* NewAudioOutputL(TUid aImplementationUid, const TDesC8& aInitData); |
|
65 //interface |
|
66 |
|
67 /** |
|
68 Returns the sound device. |
|
69 |
|
70 Accessor function exposing public CMMFDevsound methods. |
|
71 |
|
72 @return A reference to a CMMFDevSound objector. |
|
73 */ |
|
74 virtual CMMFDevSound& SoundDevice() = 0; |
|
75 |
|
76 /** |
|
77 Returns the number of bytes played. |
|
78 |
|
79 @return The number of bytes played. If 16-bit divide this number returned by 2 to get word |
|
80 length. |
|
81 */ |
|
82 virtual TInt BytesPlayed() = 0; |
|
83 |
|
84 /** |
|
85 @deprecated |
|
86 |
|
87 Gets audio from hardware device abstracted MMFDevsound (not used). |
|
88 |
|
89 @param aBuffer |
|
90 The data to read in from a Hardware Device |
|
91 @param aSupplier |
|
92 The MDataSink consuming the data contained in aBuffer. |
|
93 */ |
|
94 virtual void HWEmptyBufferL(CMMFBuffer* aBuffer, MDataSource* aSupplier)=0;//called by a EmptyBufferL if using HW codec |
|
95 protected: |
|
96 //constructor |
|
97 /** |
|
98 Protected constructor. |
|
99 */ |
|
100 MMMFAudioOutput() : MDataSink(KUidMmfAudioOutput) {} |
|
101 }; |
|
102 |
|
103 inline MMMFAudioOutput* MMMFAudioOutput::NewAudioOutputL( TUid aImplementationUid, const TDesC8& aInitData ) |
|
104 { |
|
105 //make sure the cast will be ok by checking the uid is what we expect |
|
106 __ASSERT_ALWAYS(aImplementationUid==KUidMmfAudioOutput, Panic(EMMFAudioOutputPanicBadUID)); |
|
107 MMMFAudioOutput* retPtr = STATIC_CAST(MMMFAudioOutput*, MDataSink::NewSinkL(aImplementationUid, aInitData)); |
|
108 return retPtr; |
|
109 } |
|
110 |
|
111 /** |
|
112 @publishedAll |
|
113 @released |
|
114 |
|
115 The interface into DevSound. |
|
116 |
|
117 Abstract data sink class providing an interface into hardware sound output. |
|
118 |
|
119 Uses CMMFDevSound to access such output. |
|
120 */ |
|
121 class CMMFAudioOutput : public CBase, public MMMFAudioOutput, public MDevSoundObserver |
|
122 |
|
123 { |
|
124 public: |
|
125 static MDataSink* NewSinkL() ; |
|
126 virtual CMMFAudioOutput::~CMMFAudioOutput(); |
|
127 void ConstructL(); |
|
128 |
|
129 //MDataSink mixin implementations |
|
130 virtual TFourCC SinkDataTypeCode(TMediaId aMediaId); //used by data path MDataSource/Sink for codec matching |
|
131 virtual void EmptyBufferL(CMMFBuffer* aBuffer, MDataSource* aSupplier, TMediaId aMediaId);//called by a MDataSource to empty a buffer |
|
132 virtual void BufferFilledL(CMMFBuffer* aBuffer); //called by MDataSource to pass back full buffer to the sink |
|
133 virtual TBool CanCreateSinkBuffer(); |
|
134 virtual CMMFBuffer* CreateSinkBufferL(TMediaId aMediaId, TBool &aReference); |
|
135 virtual TInt SinkThreadLogon(MAsyncEventHandler& aEventHandler); |
|
136 virtual void SinkThreadLogoff(); |
|
137 virtual void SinkPrimeL(); |
|
138 virtual void SinkPauseL(); |
|
139 virtual void SinkPlayL(); |
|
140 virtual void SinkStopL(); |
|
141 virtual void SetSinkPrioritySettings(const TMMFPrioritySettings& aPrioritySettings); |
|
142 virtual void NegotiateL(MDataSource& aSource); |
|
143 // MMMFAudioOutput mixin implementations |
|
144 TInt BytesPlayed(); |
|
145 void HWEmptyBufferL(CMMFBuffer* aBuffer, MDataSource* aSupplier);//called by a EmptyBufferL if using HW codec |
|
146 CMMFDevSound& SoundDevice(); |
|
147 virtual TInt SetSinkDataTypeCode(TFourCC aSinkFourCC, TMediaId aMediaId); |
|
148 |
|
149 //The following DataType() methods should not be used. |
|
150 //They are provided to maintain BC/SC with 7.0s |
|
151 virtual void SetDataTypeL(TFourCC aAudioType); |
|
152 virtual TFourCC DataType() const; |
|
153 |
|
154 protected: |
|
155 virtual void ConstructSinkL( const TDesC8& aInitData ) ; |
|
156 |
|
157 private: |
|
158 inline CMMFAudioOutput() {} |
|
159 |
|
160 void ConfigDevSoundL(); |
|
161 void LoadL(); |
|
162 TInt State(); |
|
163 |
|
164 //MDevSoundObserver mixin implementations |
|
165 virtual void InitializeComplete(TInt aError); |
|
166 virtual void ToneFinished(TInt aError); |
|
167 virtual void BufferToBeFilled(CMMFBuffer* aBuffer); |
|
168 virtual void PlayError(TInt aError); |
|
169 virtual void BufferToBeEmptied(CMMFBuffer* aBuffer); |
|
170 virtual void RecordError(TInt aError); |
|
171 virtual void ConvertError(TInt aError); |
|
172 virtual void DeviceMessage(TUid aMessageType, const TDesC8& aMsg); |
|
173 virtual void SendEventToClient(const TMMFEvent& /*aEvent*/); |
|
174 private: |
|
175 MAsyncEventHandler* iEventHandler; |
|
176 CMMFDevSound* iMMFDevSound; //this is now private to stop stuff "grabbing it" |
|
177 CMMFBuffer* iAudioBuffer; |
|
178 TInt iInitializeState; |
|
179 enum TState |
|
180 { |
|
181 EIdle=0, |
|
182 EDevSoundReady, |
|
183 EPaused |
|
184 }; |
|
185 |
|
186 enum TError |
|
187 { |
|
188 ECantCreateBuffer, |
|
189 EEmptyBuffer, |
|
190 EDevSoundNotLoaded, |
|
191 ERecordNotSupported, |
|
192 EDevSoundError, |
|
193 EUnknown |
|
194 }; |
|
195 |
|
196 MDataSource* iSupplier; |
|
197 TState iState; |
|
198 |
|
199 TBool iFirstBufferSent; |
|
200 TBool iDevSoundLoaded; |
|
201 |
|
202 TError iError; |
|
203 TInt iMMFDevsoundError; |
|
204 TMMFPrioritySettings iPrioritySettings; |
|
205 |
|
206 TUint iSourceSampleRate; |
|
207 TUint iSourceChannels; |
|
208 TFourCC iSourceFourCC; |
|
209 TFourCC iDataTypeCode; |
|
210 CMMFDataBuffer* iDevSoundBuffer; |
|
211 |
|
212 TMMFCapabilities iDevSoundConfig; |
|
213 |
|
214 TBool iNeedsSWConversion; |
|
215 TUint iSWConvertSampleRate; |
|
216 TUint iSWConvertChannels; |
|
217 CMMFChannelAndSampleRateConverterFactory* iChannelAndSampleRateConverterFactory; |
|
218 CMMFChannelAndSampleRateConverter* iChannelAndSampleRateConverter; |
|
219 CMMFDataBuffer* iConvertBuffer; |
|
220 CMMFBuffer* iBufferToEmpty; |
|
221 CActiveSchedulerWait* iActiveSchedulerWait; |
|
222 }; |
|
223 |
|
224 #endif |