Update contrib.
1 // Copyright (c) 2003-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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 #ifndef TONEDATAPATH_H
17 #define TONEDATAPATH_H
20 #include "mdasoundadapter.h"
21 #include <mmf/server/mmfdatabuffer.h>
22 #include "tonehwdevice.h"
24 //message from tonedatapath to hw device observer
25 //to tell it to update the bytes played
26 #define KToneHwDeviceObserverUpdateBytesPlayed 0x101FE2A4
28 class MMMFHwDeviceObserver;
35 Panic codes for the Tone Data Path
37 enum TToneDataPathPanicCode
39 /** Codec wrapper did not create an internal datapath
43 /** Codec wrapper does not have a device handle
47 /** Codec wrapper codec returns non existant process result
51 /** Sound driver returns unexpected buffer
58 * Active object used by the CToneDataPath to send data to the sound
59 * driver This particular active object encapsulates the asynchronous play
60 * function, where a buffer of data is sent to the WINS audio device, and the
61 * active object's RunL is called when the buffer has been consumed by the
65 class CToneDataPathPlayer : public CActive
68 CToneDataPathPlayer(CToneDataPath& aParent, TInt aPriority);
69 ~CToneDataPathPlayer();
72 void PlayData(const CMMFDataBuffer& aData);
75 virtual TInt RunError(TInt aError);
76 virtual void DoCancel();
77 virtual void Error(TInt aError);
79 CToneDataPath& iParent;
80 const CMMFDataBuffer* iDataFromSource;
85 * Active object used by CToneDataPath to listening for error messages
86 * from the WINS audio device. If this object's RunL is called, playback has
87 * been terminated for some reason. The active object then
88 * notifies its parent the datapath, so that proper cleanup and client
89 * notification can occur.
92 class CToneSoundDevPlayErrorReceiver : public CActive
95 CToneSoundDevPlayErrorReceiver(CToneDataPath& aParent, TInt aPriority);
96 ~CToneSoundDevPlayErrorReceiver();
100 virtual void DoCancel();
102 CToneDataPath& iParent;
106 class CToneDataPath : public CBase,
107 public MIgnoreUnderflowEventsCustomInterface
111 enum TToneDataPathState
118 static CToneDataPath* NewL();
120 TInt SetObserver(MMMFHwDeviceObserver& aHwObserver);
121 TInt AddCodec(CToneCodec& aCodec);
125 RMdaDevSound& Device();
126 void BufferFilledL(CMMFDataBuffer& aBuffer);
127 void BufferEmptiedL(const CMMFDataBuffer& aBuffer);
128 void SoundDeviceException(TInt aError);
129 TToneDataPathState State() {return iState;};
131 virtual void IgnoreUnderflowEvents();
132 virtual TAny* CustomInterface(TUid aInterface);
137 inline void Panic(TInt aPanicCode);
139 void FillSourceBufferL();
140 void FillSoundDeviceBufferL();
142 #ifdef __CYCLE_MMF_DATABUFFERS__
143 CMMFDataBuffer* CycleAudioBuffer(CMMFDataBuffer* aBuffer);
146 #ifdef __USE_MMF_TRANSFERBUFFERS__
147 CMMFTransferBuffer* CreateTransferBufferL(TUint aBufferSize, CMMFTransferBuffer* aOldBuffer);
150 #ifdef __USE_MMF_PTRBUFFERS__
151 CMMFPtrBuffer* CreatePtrBufferL(TUint aBufferSize);
155 TToneDataPathState iState;
156 MMMFHwDeviceObserver* iHwDeviceObserver;
158 CToneDataPathPlayer* iAudioPlayer;
159 CToneSoundDevPlayErrorReceiver* iSoundDeviceErrorReceiver;
160 RMdaDevSound iSoundDevice;
161 CMMFDataBuffer* iSourceBuffer;
162 CMMFDataBuffer* iSoundDeviceBuffer;
163 TBool iNoMoreSourceData;
164 TBool iSinkCanReceive;
165 TUint iSourceBufferSize;
166 TUint iSoundDevBufferSize;
167 TBool iRampAudioSample;
169 TTimeIntervalMicroSeconds iVolumeRamp;
176 TBool iIgnoreUnderflow;
178 #ifdef __USE_MMF_TRANSFERBUFFERS__
179 RTransferBuffer* iTransferBuffer;
180 RTransferWindow* iTransferWindow;
183 #ifdef __USE_MMF_PTRBUFFERS__
184 HBufC8* iPtrBufferMemoryBlock;
193 inline void CToneDataPath::Panic(TInt aPanicCode)
195 _LIT(KTonePanicCategory, "ToneDataPath");
196 User::Panic(KTonePanicCategory, aPanicCode);
199 #endif //TONEDATAPATH_H