initial import
[picodrive.git] / platform / uiq2 / audio / mediaserver / audio_mediaserver.h
diff --git a/platform/uiq2/audio/mediaserver/audio_mediaserver.h b/platform/uiq2/audio/mediaserver/audio_mediaserver.h
new file mode 100644 (file)
index 0000000..6937a48
--- /dev/null
@@ -0,0 +1,87 @@
+/*******************************************************************\r
+ *\r
+ *     File:           Audio_mediaserver.h\r
+ *\r
+ *     Author:         Peter van Sebille (peter@yipton.net)\r
+ *\r
+ *  Modified/adapted for picodriveN by notaz, 2006\r
+ *\r
+ *  (c) Copyright 2006, notaz\r
+ *     (c) Copyright 2001, Peter van Sebille\r
+ *     All Rights Reserved\r
+ *\r
+ *******************************************************************/\r
+\r
+#ifndef __AUDIO_MEDIASERVER_H\r
+#define __AUDIO_MEDIASERVER_H\r
+\r
+#include <Mda\Common\Audio.h>\r
+#include <MdaAudioOutputStream.h>\r
+\r
+#include "audio.h"\r
+#include "polledas.h"\r
+\r
+const TInt KSoundBuffers = 4;\r
+const TInt KBlockTime = 1000000 / 5; // hardcoded: 5 updates/sec\r
+const TInt KMaxLag = 260000; // max sound lag, lower values increase chanse of underflow\r
+const TInt KMaxUnderflows = 50; // max underflows/API errors we are going allow in a row (to prevent lockups)\r
+\r
+\r
+class TGameAudioEventListener : public MMdaAudioOutputStreamCallback\r
+{\r
+public: // implements MMdaAudioOutputStreamCallback\r
+       void MaoscOpenComplete(TInt aError);\r
+       void MaoscBufferCopied(TInt aError, const TDesC8& );\r
+       void MaoscPlayComplete(TInt aError);\r
+\r
+       TBool                                   iIsOpen;\r
+//     TBool                                   iHasCopied;\r
+       TInt                                    iUnderflowed;\r
+};\r
+\r
+\r
+class CGameAudioMS : public IGameAudio // IGameAudio MUST be specified first!\r
+{\r
+public:        // implements IGameAudio\r
+       TInt16 *NextFrameL();\r
+       TInt16 *DupeFrameL(TInt &aUnderflowed);\r
+       TInt16 *ResumeL();\r
+       void Pause();\r
+       void ChangeVolume(TInt aUp);\r
+\r
+public:\r
+       ~CGameAudioMS();\r
+       CGameAudioMS(TInt aRate, TBool aStereo, TInt aPcmFrames, TInt aBufferedFrames);\r
+       void ConstructL();\r
+       EXPORT_C static CGameAudioMS* NewL(TInt aRate, TBool aStereo, TInt aPcmFrames, TInt aBufferedFrames);\r
+\r
+protected:\r
+       void WriteBlockL();\r
+       void UnderflowedL();\r
+\r
+protected:\r
+       void WaitForOpenToCompleteL();\r
+//     void WaitForCopyToCompleteL();\r
+\r
+       TInt                                    iRate;\r
+       TBool                                   iStereo;\r
+\r
+       CMdaAudioOutputStream   *iMdaAudioOutputStream;\r
+       TMdaAudioDataSettings   iMdaAudioDataSettings;\r
+\r
+       TGameAudioEventListener iListener;\r
+\r
+       CPolledActiveScheduler  *iScheduler;\r
+\r
+       HBufC8*                                 iSoundBuffers[KSoundBuffers+1];\r
+       TInt                                    iBufferedFrames;\r
+       TInt16*                                 iCurrentPosition;\r
+       TInt                                    iCurrentBuffer;\r
+       TInt                                    iFrameCount;\r
+       TInt                                    iPcmFrames;\r
+       CMdaServer*                             iServer;\r
+\r
+       TInt64                                  iTime;\r
+};\r
+\r
+#endif                 /* __AUDIO_MEDIASERVER_H */\r