1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/mm/mmlibs/mmfw/inc/mmf/server/MmfAudioOutput.h Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,225 @@
1.4 +// Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
1.5 +// All rights reserved.
1.6 +// This component and the accompanying materials are made available
1.7 +// under the terms of "Eclipse Public License v1.0"
1.8 +// which accompanies this distribution, and is available
1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
1.10 +//
1.11 +// Initial Contributors:
1.12 +// Nokia Corporation - initial contribution.
1.13 +//
1.14 +// Contributors:
1.15 +//
1.16 +// Description:
1.17 +//
1.18 +
1.19 +#ifndef __MMF_AUDIOOUTPUT_H__
1.20 +#define __MMF_AUDIOOUTPUT_H__
1.21 +
1.22 +// Standard EPOC32 includes required by this header file
1.23 +#include <e32base.h>
1.24 +#include <e32std.h>
1.25 +
1.26 +
1.27 +#include <mmf/common/mmfpaniccodes.h>
1.28 +
1.29 +//DevSound
1.30 +#include <mmf/server/sounddevice.h>
1.31 +
1.32 +/**
1.33 +@publishedAll
1.34 +@deprecated
1.35 +*/
1.36 +const TUint KAudioOutputDefaultFrameSize = 0x1000;
1.37 +
1.38 +
1.39 +void Panic(TInt aPanicCode);
1.40 +
1.41 +/**
1.42 +@publishedAll
1.43 +@released
1.44 +
1.45 +Interface class to allow dynamic linkage to CMMFAudioOutput.
1.46 +*/
1.47 +class MMMFAudioOutput : public MDataSink
1.48 + {
1.49 +public:
1.50 + //factory function
1.51 + /**
1.52 + Gets a new audio output object.
1.53 +
1.54 + @param aImplementationUid
1.55 + The implementation UID.
1.56 + @param aInitData
1.57 + The initialisation data.
1.58 +
1.59 + @return The audio output object.
1.60 + */
1.61 + inline static MMMFAudioOutput* NewAudioOutputL(TUid aImplementationUid, const TDesC8& aInitData);
1.62 + //interface
1.63 +
1.64 + /**
1.65 + Returns the sound device.
1.66 +
1.67 + Accessor function exposing public CMMFDevsound methods.
1.68 +
1.69 + @return A reference to a CMMFDevSound objector.
1.70 + */
1.71 + virtual CMMFDevSound& SoundDevice() = 0;
1.72 +
1.73 + /**
1.74 + Returns the number of bytes played.
1.75 +
1.76 + @return The number of bytes played. If 16-bit divide this number returned by 2 to get word
1.77 + length.
1.78 + */
1.79 + virtual TInt BytesPlayed() = 0;
1.80 +
1.81 + /**
1.82 + @deprecated
1.83 +
1.84 + Gets audio from hardware device abstracted MMFDevsound (not used).
1.85 +
1.86 + @param aBuffer
1.87 + The data to read in from a Hardware Device
1.88 + @param aSupplier
1.89 + The MDataSink consuming the data contained in aBuffer.
1.90 + */
1.91 + virtual void HWEmptyBufferL(CMMFBuffer* aBuffer, MDataSource* aSupplier)=0;//called by a EmptyBufferL if using HW codec
1.92 +protected:
1.93 + //constructor
1.94 + /**
1.95 + Protected constructor.
1.96 + */
1.97 + MMMFAudioOutput() : MDataSink(KUidMmfAudioOutput) {}
1.98 + };
1.99 +
1.100 +inline MMMFAudioOutput* MMMFAudioOutput::NewAudioOutputL( TUid aImplementationUid, const TDesC8& aInitData )
1.101 + {
1.102 + //make sure the cast will be ok by checking the uid is what we expect
1.103 + __ASSERT_ALWAYS(aImplementationUid==KUidMmfAudioOutput, Panic(EMMFAudioOutputPanicBadUID));
1.104 + MMMFAudioOutput* retPtr = STATIC_CAST(MMMFAudioOutput*, MDataSink::NewSinkL(aImplementationUid, aInitData));
1.105 + return retPtr;
1.106 + }
1.107 +
1.108 +/**
1.109 +@publishedAll
1.110 +@released
1.111 +
1.112 +The interface into DevSound.
1.113 +
1.114 +Abstract data sink class providing an interface into hardware sound output.
1.115 +
1.116 +Uses CMMFDevSound to access such output.
1.117 +*/
1.118 +class CMMFChannelAndSampleRateConverterFactory;
1.119 +class CMMFChannelAndSampleRateConverter;
1.120 +class CMMFAudioOutput : public CBase, public MMMFAudioOutput, public MDevSoundObserver
1.121 +
1.122 + {
1.123 +public:
1.124 + static MDataSink* NewSinkL() ;
1.125 + virtual ~CMMFAudioOutput();
1.126 + void ConstructL();
1.127 +
1.128 + //MDataSink mixin implementations
1.129 + virtual TFourCC SinkDataTypeCode(TMediaId aMediaId); //used by data path MDataSource/Sink for codec matching
1.130 + virtual void EmptyBufferL(CMMFBuffer* aBuffer, MDataSource* aSupplier, TMediaId aMediaId);//called by a MDataSource to empty a buffer
1.131 + virtual void BufferFilledL(CMMFBuffer* aBuffer); //called by MDataSource to pass back full buffer to the sink
1.132 + virtual TBool CanCreateSinkBuffer();
1.133 + virtual CMMFBuffer* CreateSinkBufferL(TMediaId aMediaId, TBool &aReference);
1.134 + virtual TInt SinkThreadLogon(MAsyncEventHandler& aEventHandler);
1.135 + virtual void SinkThreadLogoff();
1.136 + virtual void SinkPrimeL();
1.137 + virtual void SinkPauseL();
1.138 + virtual void SinkPlayL();
1.139 + virtual void SinkStopL();
1.140 + virtual void SetSinkPrioritySettings(const TMMFPrioritySettings& aPrioritySettings);
1.141 + virtual void NegotiateL(MDataSource& aSource);
1.142 + // MMMFAudioOutput mixin implementations
1.143 + TInt BytesPlayed();
1.144 + void HWEmptyBufferL(CMMFBuffer* aBuffer, MDataSource* aSupplier);//called by a EmptyBufferL if using HW codec
1.145 + CMMFDevSound& SoundDevice();
1.146 + virtual TInt SetSinkDataTypeCode(TFourCC aSinkFourCC, TMediaId aMediaId);
1.147 +
1.148 + //The following DataType() methods should not be used.
1.149 + //They are provided to maintain BC/SC with 7.0s
1.150 + virtual void SetDataTypeL(TFourCC aAudioType);
1.151 + virtual TFourCC DataType() const;
1.152 +
1.153 +protected:
1.154 + virtual void ConstructSinkL( const TDesC8& aInitData ) ;
1.155 +
1.156 +private:
1.157 + inline CMMFAudioOutput() {}
1.158 +
1.159 + void ConfigDevSoundL();
1.160 + void LoadL();
1.161 + TInt State();
1.162 +
1.163 + //MDevSoundObserver mixin implementations
1.164 + virtual void InitializeComplete(TInt aError);
1.165 + virtual void ToneFinished(TInt aError);
1.166 + virtual void BufferToBeFilled(CMMFBuffer* aBuffer);
1.167 + virtual void PlayError(TInt aError);
1.168 + virtual void BufferToBeEmptied(CMMFBuffer* aBuffer);
1.169 + virtual void RecordError(TInt aError);
1.170 + virtual void ConvertError(TInt aError);
1.171 + virtual void DeviceMessage(TUid aMessageType, const TDesC8& aMsg);
1.172 + virtual void SendEventToClient(const TMMFEvent& /*aEvent*/);
1.173 +
1.174 +public:
1.175 + virtual TBool IsResumeSupported();
1.176 +
1.177 +private:
1.178 + MAsyncEventHandler* iEventHandler;
1.179 + CMMFDevSound* iMMFDevSound; //this is now private to stop stuff "grabbing it"
1.180 + CMMFBuffer* iAudioBuffer;
1.181 + TInt iInitializeState;
1.182 + enum TState
1.183 + {
1.184 + EIdle=0,
1.185 + EDevSoundReady,
1.186 + EPaused
1.187 + };
1.188 +
1.189 + enum TError
1.190 + {
1.191 + ECantCreateBuffer,
1.192 + EEmptyBuffer,
1.193 + EDevSoundNotLoaded,
1.194 + ERecordNotSupported,
1.195 + EDevSoundError,
1.196 + EUnknown
1.197 + };
1.198 +
1.199 + MDataSource* iSupplier;
1.200 + TState iState;
1.201 +
1.202 + TBool iCanSendBuffers;
1.203 + TBool iPlayStarted;
1.204 + TBool iDevSoundLoaded;
1.205 +
1.206 + TError iError;
1.207 + TInt iMMFDevsoundError;
1.208 + TMMFPrioritySettings iPrioritySettings;
1.209 +
1.210 + TUint iSourceSampleRate;
1.211 + TUint iSourceChannels;
1.212 + TFourCC iSourceFourCC;
1.213 + TFourCC iDataTypeCode;
1.214 + CMMFDataBuffer* iDevSoundBuffer;
1.215 +
1.216 + TMMFCapabilities iDevSoundConfig;
1.217 +
1.218 + TBool iNeedsSWConversion;
1.219 + TUint iSWConvertSampleRate;
1.220 + TUint iSWConvertChannels;
1.221 + CMMFChannelAndSampleRateConverterFactory* iChannelAndSampleRateConverterFactory;
1.222 + CMMFChannelAndSampleRateConverter* iChannelAndSampleRateConverter;
1.223 + CMMFDataBuffer* iConvertBuffer;
1.224 + CMMFBuffer* iBufferToEmpty;
1.225 + CActiveSchedulerWait* iActiveSchedulerWait;
1.226 + };
1.227 +
1.228 +#endif