PageRenderTime 32ms CodeModel.GetById 16ms app.highlight 10ms RepoModel.GetById 2ms app.codeStats 0ms

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