/project/jni/sdl_mixer/music_mad.h

https://github.com/aichunyu/FFPlayer · C Header · 74 lines · 42 code · 11 blank · 21 comment · 0 complexity · ae0b2d58f509dfcb202fe9cf5c206afa MD5 · raw file

  1. /*
  2. SDL_mixer: An audio mixer library based on the SDL library
  3. Copyright (C) 1997-2009 Sam Lantinga
  4. This library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Library General Public
  6. License as published by the Free Software Foundation; either
  7. version 2 of the License, or (at your option) any later version.
  8. This library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Library General Public License for more details.
  12. You should have received a copy of the GNU Library General Public
  13. License along with this library; if not, write to the Free
  14. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  15. Sam Lantinga
  16. slouken@libsdl.org
  17. */
  18. #ifdef MP3_MAD_MUSIC
  19. #include "mad.h"
  20. #include "SDL_rwops.h"
  21. #include "SDL_audio.h"
  22. #include "SDL_mixer.h"
  23. #define MAD_INPUT_BUFFER_SIZE (5*8192)
  24. #define MAD_OUTPUT_BUFFER_SIZE 8192
  25. enum {
  26. MS_input_eof = 0x0001,
  27. MS_input_error = 0x0001,
  28. MS_decode_eof = 0x0002,
  29. MS_decode_error = 0x0004,
  30. MS_error_flags = 0x000f,
  31. MS_playing = 0x0100,
  32. MS_cvt_decoded = 0x0200,
  33. };
  34. typedef struct {
  35. SDL_RWops *rw;
  36. SDL_bool freerw;
  37. struct mad_stream stream;
  38. struct mad_frame frame;
  39. struct mad_synth synth;
  40. int frames_read;
  41. mad_timer_t next_frame_start;
  42. int volume;
  43. int status;
  44. int output_begin, output_end;
  45. SDL_AudioSpec mixer;
  46. SDL_AudioCVT cvt;
  47. unsigned char input_buffer[MAD_INPUT_BUFFER_SIZE + MAD_BUFFER_GUARD];
  48. unsigned char output_buffer[MAD_OUTPUT_BUFFER_SIZE];
  49. } mad_data;
  50. mad_data *mad_openFile(const char *filename, SDL_AudioSpec *mixer);
  51. mad_data *mad_openFileRW(SDL_RWops *rw, SDL_AudioSpec *mixer);
  52. void mad_closeFile(mad_data *mp3_mad);
  53. void mad_start(mad_data *mp3_mad);
  54. void mad_stop(mad_data *mp3_mad);
  55. int mad_isPlaying(mad_data *mp3_mad);
  56. int mad_getSamples(mad_data *mp3_mad, Uint8 *stream, int len);
  57. void mad_seek(mad_data *mp3_mad, double position);
  58. void mad_setVolume(mad_data *mp3_mad, int volume);
  59. #endif