audio_mediaserver.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /*******************************************************************
  2. *
  3. * File: Audio_mediaserver.h
  4. *
  5. * Author: Peter van Sebille (peter@yipton.net)
  6. *
  7. * Modified/adapted for picodriveN by notaz, 2006
  8. *
  9. * (c) Copyright 2006, notaz
  10. * (c) Copyright 2001, Peter van Sebille
  11. * All Rights Reserved
  12. *
  13. *******************************************************************/
  14. #ifndef __AUDIO_MEDIASERVER_H
  15. #define __AUDIO_MEDIASERVER_H
  16. #include <mda/common/audio.h>
  17. #include <mdaaudiooutputstream.h>
  18. //#include "audio.h"
  19. #include "PolledAS.h"
  20. const TInt KSoundBuffers = 4;
  21. class TGameAudioEventListener : public MMdaAudioOutputStreamCallback
  22. {
  23. public: // implements MMdaAudioOutputStreamCallback
  24. void MaoscOpenComplete(TInt aError);
  25. void MaoscBufferCopied(TInt aError, const TDesC8& );
  26. void MaoscPlayComplete(TInt aError);
  27. TBool iIsOpen;
  28. // TBool iHasCopied;
  29. TInt iUnderflowed;
  30. TInt iLastError;
  31. };
  32. class CGameAudioMS // : public IGameAudio // IGameAudio MUST be specified first!
  33. {
  34. public: // implements IGameAudio
  35. TInt16 *NextFrameL(TInt aPcmFrames);
  36. TInt16 *ResumeL();
  37. void Pause();
  38. TInt ChangeVolume(TInt aUp);
  39. public:
  40. ~CGameAudioMS();
  41. CGameAudioMS(TInt aRate, TBool aStereo, TInt aWritesPerSec, TInt aVolume);
  42. static CGameAudioMS* NewL(TInt aRate, TBool aStereo, TInt aWritesPerSec, TInt aVolume);
  43. protected:
  44. void WriteBlockL();
  45. void UnderflowedL();
  46. void ConstructL();
  47. protected:
  48. void WaitForOpenToCompleteL();
  49. TInt iRate;
  50. TBool iStereo;
  51. CMdaAudioOutputStream *iMdaAudioOutputStream;
  52. TMdaAudioDataSettings iMdaAudioDataSettings;
  53. TGameAudioEventListener iListener;
  54. CPolledActiveScheduler *iScheduler;
  55. HBufC8* iSoundBuffers[KSoundBuffers];
  56. TInt iWritesPerSec; // fps, may be more actual writes
  57. TInt iMaxWriteSamples; // max samples per write
  58. TInt16* iCurrentPosition;
  59. TInt iCurrentBuffer; // active buffer
  60. TInt iCurrentBufferSize; // bytes filled in buffer
  61. TInt iBufferSize;
  62. CMdaServer* iServer;
  63. TInt64 iTime;
  64. TInt iVolume;
  65. };
  66. #endif /* __AUDIO_MEDIASERVER_H */