MusicPlayer.h 902 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*
  2. * Copyright (c) 2011 Nokia Corporation.
  3. */
  4. #ifndef __MUSICPLAYER_H__
  5. #define __MUSICPLAYER_H__
  6. #include "AudioInterfaces.h"
  7. #ifdef USE_OGG
  8. #include "stb_vorbis.h"
  9. //#define STB_VORBIS_HEADER_ONLY
  10. //#include "stb_vorbis.c"
  11. #define STB_BUFSIZE (256*1024)
  12. #endif
  13. #ifdef USE_MP3
  14. #include "mpg123.h"
  15. #endif
  16. class MusicPlayer : public GF::IAudioSource
  17. {
  18. public:
  19. MusicPlayer();
  20. ~MusicPlayer();
  21. bool canBeDestroyed() { return false; }
  22. virtual int pullAudio(short *target, int sampleCount);
  23. virtual void play(const char *filename);
  24. virtual void play(const char *mem, int length);
  25. protected:
  26. #ifdef USE_OGG
  27. stb_vorbis *v;
  28. // temp buffer for ogg decoding
  29. char buf[STB_BUFSIZE];
  30. #endif
  31. #ifdef USE_MP3
  32. mpg123_handle *mh;
  33. int encoding;
  34. bool playing;
  35. #endif
  36. int error;
  37. long rate;
  38. int channels;
  39. };
  40. #endif