1 /*******************************************************************
\r
3 * File: Audio_mediaserver.h
\r
5 * Author: Peter van Sebille (peter@yipton.net)
\r
7 * Modified/adapted for picodriveN by notaz, 2006
\r
9 * (c) Copyright 2006, notaz
\r
10 * (c) Copyright 2001, Peter van Sebille
\r
11 * All Rights Reserved
\r
13 *******************************************************************/
\r
15 #ifndef __AUDIO_MEDIASERVER_H
\r
16 #define __AUDIO_MEDIASERVER_H
\r
18 #include <Mda\Common\Audio.h>
\r
19 #include <MdaAudioOutputStream.h>
\r
22 #include "polledas.h"
\r
24 const TInt KSoundBuffers = 4;
\r
25 const TInt KBlockTime = 1000000 / 5; // hardcoded: 5 updates/sec
\r
26 const TInt KMaxLag = 260000; // max sound lag, lower values increase chanse of underflow
\r
27 const TInt KMaxUnderflows = 50; // max underflows/API errors we are going allow in a row (to prevent lockups)
\r
30 class TGameAudioEventListener : public MMdaAudioOutputStreamCallback
\r
32 public: // implements MMdaAudioOutputStreamCallback
\r
33 void MaoscOpenComplete(TInt aError);
\r
34 void MaoscBufferCopied(TInt aError, const TDesC8& );
\r
35 void MaoscPlayComplete(TInt aError);
\r
38 // TBool iHasCopied;
\r
43 class CGameAudioMS : public IGameAudio // IGameAudio MUST be specified first!
\r
45 public: // implements IGameAudio
\r
46 TInt16 *NextFrameL();
\r
47 TInt16 *DupeFrameL(TInt &aUnderflowed);
\r
50 void ChangeVolume(TInt aUp);
\r
54 CGameAudioMS(TInt aRate, TBool aStereo, TInt aPcmFrames, TInt aBufferedFrames);
\r
56 EXPORT_C static CGameAudioMS* NewL(TInt aRate, TBool aStereo, TInt aPcmFrames, TInt aBufferedFrames);
\r
60 void UnderflowedL();
\r
63 void WaitForOpenToCompleteL();
\r
64 // void WaitForCopyToCompleteL();
\r
69 CMdaAudioOutputStream *iMdaAudioOutputStream;
\r
70 TMdaAudioDataSettings iMdaAudioDataSettings;
\r
72 TGameAudioEventListener iListener;
\r
74 CPolledActiveScheduler *iScheduler;
\r
76 HBufC8* iSoundBuffers[KSoundBuffers+1];
\r
77 TInt iBufferedFrames;
\r
78 TInt16* iCurrentPosition;
\r
79 TInt iCurrentBuffer;
\r
82 CMdaServer* iServer;
\r
87 #endif /* __AUDIO_MEDIASERVER_H */
\r