1 // Copyright (c) 2002-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 the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 #ifndef __MMF_AUDIOOUTPUT_H__
17 #define __MMF_AUDIOOUTPUT_H__
19 // Standard EPOC32 includes required by this header file
23 #include <mmfaudioiointerfaceuids.hrh>
25 #include <mmf/common/mmfpaniccodes.h>
28 #include <mmf/server/sounddevice.h>
34 const TUint KAudioOutputDefaultFrameSize = 0x1000;
37 void Panic(TInt aPanicCode);
43 Interface class to allow dynamic linkage to CMMFAudioOutput.
45 class MMMFAudioOutput : public MDataSink
50 Gets a new audio output object.
52 @param aImplementationUid
53 The implementation UID.
55 The initialisation data.
57 @return The audio output object.
59 inline static MMMFAudioOutput* NewAudioOutputL(TUid aImplementationUid, const TDesC8& aInitData);
63 Returns the sound device.
65 Accessor function exposing public CMMFDevsound methods.
67 @return A reference to a CMMFDevSound objector.
69 virtual CMMFDevSound& SoundDevice() = 0;
72 Returns the number of bytes played.
74 @return The number of bytes played. If 16-bit divide this number returned by 2 to get word
77 virtual TInt BytesPlayed() = 0;
82 Gets audio from hardware device abstracted MMFDevsound (not used).
85 The data to read in from a Hardware Device
87 The MDataSink consuming the data contained in aBuffer.
89 virtual void HWEmptyBufferL(CMMFBuffer* aBuffer, MDataSource* aSupplier)=0;//called by a EmptyBufferL if using HW codec
93 Protected constructor.
95 MMMFAudioOutput() : MDataSink(KUidMmfAudioOutput) {}
98 inline MMMFAudioOutput* MMMFAudioOutput::NewAudioOutputL( TUid aImplementationUid, const TDesC8& aInitData )
100 //make sure the cast will be ok by checking the uid is what we expect
101 __ASSERT_ALWAYS(aImplementationUid==KUidMmfAudioOutput, Panic(EMMFAudioOutputPanicBadUID));
102 MMMFAudioOutput* retPtr = STATIC_CAST(MMMFAudioOutput*, MDataSink::NewSinkL(aImplementationUid, aInitData));
110 The interface into DevSound.
112 Abstract data sink class providing an interface into hardware sound output.
114 Uses CMMFDevSound to access such output.
116 class CMMFAudioOutput : public CBase, public MMMFAudioOutput, public MDevSoundObserver
120 static MDataSink* NewSinkL() ;
121 virtual CMMFAudioOutput::~CMMFAudioOutput();
124 //MDataSink mixin implementations
125 virtual TFourCC SinkDataTypeCode(TMediaId aMediaId); //used by data path MDataSource/Sink for codec matching
126 virtual void EmptyBufferL(CMMFBuffer* aBuffer, MDataSource* aSupplier, TMediaId aMediaId);//called by a MDataSource to empty a buffer
127 virtual void BufferFilledL(CMMFBuffer* aBuffer); //called by MDataSource to pass back full buffer to the sink
128 virtual TBool CanCreateSinkBuffer();
129 virtual CMMFBuffer* CreateSinkBufferL(TMediaId aMediaId, TBool &aReference);
130 virtual TInt SinkThreadLogon(MAsyncEventHandler& aEventHandler);
131 virtual void SinkThreadLogoff();
132 virtual void SinkPrimeL();
133 virtual void SinkPauseL();
134 virtual void SinkPlayL();
135 virtual void SinkStopL();
136 virtual void SetSinkPrioritySettings(const TMMFPrioritySettings& aPrioritySettings);
137 virtual void NegotiateL(MDataSource& aSource);
138 // MMMFAudioOutput mixin implementations
140 void HWEmptyBufferL(CMMFBuffer* aBuffer, MDataSource* aSupplier);//called by a EmptyBufferL if using HW codec
141 CMMFDevSound& SoundDevice();
142 virtual TInt SetSinkDataTypeCode(TFourCC aSinkFourCC, TMediaId aMediaId);
144 //The following DataType() methods should not be used.
145 //They are provided to maintain BC/SC with 7.0s
146 virtual void SetDataTypeL(TFourCC aAudioType);
147 virtual TFourCC DataType() const;
150 virtual void ConstructSinkL( const TDesC8& aInitData ) ;
153 inline CMMFAudioOutput() {}
155 void ConfigDevSoundL();
159 //MDevSoundObserver mixin implementations
160 virtual void InitializeComplete(TInt aError);
161 virtual void ToneFinished(TInt aError);
162 virtual void BufferToBeFilled(CMMFBuffer* aBuffer);
163 virtual void PlayError(TInt aError);
164 virtual void BufferToBeEmptied(CMMFBuffer* aBuffer);
165 virtual void RecordError(TInt aError);
166 virtual void ConvertError(TInt aError);
167 virtual void DeviceMessage(TUid aMessageType, const TDesC8& aMsg);
168 virtual void SendEventToClient(const TMMFEvent& /*aEvent*/);
171 virtual TBool IsResumeSupported();
174 MAsyncEventHandler* iEventHandler;
175 CMMFDevSound* iMMFDevSound; //this is now private to stop stuff "grabbing it"
176 CMMFBuffer* iAudioBuffer;
177 TInt iInitializeState;
195 MDataSource* iSupplier;
198 TBool iCanSendBuffers;
200 TBool iDevSoundLoaded;
203 TInt iMMFDevsoundError;
204 TMMFPrioritySettings iPrioritySettings;
206 TUint iSourceSampleRate;
207 TUint iSourceChannels;
208 TFourCC iSourceFourCC;
209 TFourCC iDataTypeCode;
210 CMMFDataBuffer* iDevSoundBuffer;
212 TMMFCapabilities iDevSoundConfig;
214 TBool iNeedsSWConversion;
215 TUint iSWConvertSampleRate;
216 TUint iSWConvertChannels;
217 CMMFChannelAndSampleRateConverterFactory* iChannelAndSampleRateConverterFactory;
218 CMMFChannelAndSampleRateConverter* iChannelAndSampleRateConverter;
219 CMMFDataBuffer* iConvertBuffer;
220 CMMFBuffer* iBufferToEmpty;
221 CActiveSchedulerWait* iActiveSchedulerWait;