admin@999
|
1 |
/*
|
admin@999
|
2 |
SDL_mixer: An audio mixer library based on the SDL library
|
admin@999
|
3 |
Copyright (C) 1997-2019 Sam Lantinga <slouken@libsdl.org>
|
admin@999
|
4 |
|
admin@999
|
5 |
This software is provided 'as-is', without any express or implied
|
admin@999
|
6 |
warranty. In no event will the authors be held liable for any damages
|
admin@999
|
7 |
arising from the use of this software.
|
admin@999
|
8 |
|
admin@999
|
9 |
Permission is granted to anyone to use this software for any purpose,
|
admin@999
|
10 |
including commercial applications, and to alter it and redistribute it
|
admin@999
|
11 |
freely, subject to the following restrictions:
|
admin@999
|
12 |
|
admin@999
|
13 |
1. The origin of this software must not be misrepresented; you must not
|
admin@999
|
14 |
claim that you wrote the original software. If you use this software
|
admin@999
|
15 |
in a product, an acknowledgment in the product documentation would be
|
admin@999
|
16 |
appreciated but is not required.
|
admin@999
|
17 |
2. Altered source versions must be plainly marked as such, and must not be
|
admin@999
|
18 |
misrepresented as being the original software.
|
admin@999
|
19 |
3. This notice may not be removed or altered from any source distribution.
|
admin@999
|
20 |
*/
|
admin@999
|
21 |
#include "SDL_mixer.h"
|
admin@999
|
22 |
|
admin@999
|
23 |
#ifndef MUSIC_H_
|
admin@999
|
24 |
#define MUSIC_H_
|
admin@999
|
25 |
|
admin@999
|
26 |
/* Supported music APIs, in order of preference */
|
admin@999
|
27 |
|
admin@999
|
28 |
typedef enum
|
admin@999
|
29 |
{
|
admin@999
|
30 |
MIX_MUSIC_CMD,
|
admin@999
|
31 |
MIX_MUSIC_WAVE,
|
admin@999
|
32 |
MIX_MUSIC_MODPLUG,
|
admin@999
|
33 |
MIX_MUSIC_MIKMOD,
|
admin@999
|
34 |
MIX_MUSIC_FLUIDSYNTH,
|
admin@999
|
35 |
MIX_MUSIC_TIMIDITY,
|
admin@999
|
36 |
MIX_MUSIC_NATIVEMIDI,
|
admin@999
|
37 |
MIX_MUSIC_OGG,
|
admin@999
|
38 |
MIX_MUSIC_MPG123,
|
admin@999
|
39 |
MIX_MUSIC_MAD,
|
admin@999
|
40 |
MIX_MUSIC_FLAC,
|
admin@999
|
41 |
MIX_MUSIC_OPUS,
|
admin@999
|
42 |
MIX_MUSIC_LAST
|
admin@999
|
43 |
} Mix_MusicAPI;
|
admin@999
|
44 |
|
admin@999
|
45 |
|
admin@999
|
46 |
/* Music API implementation */
|
admin@999
|
47 |
|
admin@999
|
48 |
typedef struct
|
admin@999
|
49 |
{
|
admin@999
|
50 |
const char *tag;
|
admin@999
|
51 |
Mix_MusicAPI api;
|
admin@999
|
52 |
Mix_MusicType type;
|
admin@999
|
53 |
SDL_bool loaded;
|
admin@999
|
54 |
SDL_bool opened;
|
admin@999
|
55 |
|
admin@999
|
56 |
/* Load the library */
|
admin@999
|
57 |
int (*Load)(void);
|
admin@999
|
58 |
|
admin@999
|
59 |
/* Initialize for the audio output */
|
admin@999
|
60 |
int (*Open)(const SDL_AudioSpec *spec);
|
admin@999
|
61 |
|
admin@999
|
62 |
/* Create a music object from an SDL_RWops stream
|
admin@999
|
63 |
* If the function returns NULL, 'src' will be freed if needed by the caller.
|
admin@999
|
64 |
*/
|
admin@999
|
65 |
void *(*CreateFromRW)(SDL_RWops *src, int freesrc);
|
admin@999
|
66 |
|
admin@999
|
67 |
/* Create a music object from a file, if SDL_RWops are not supported */
|
admin@999
|
68 |
void *(*CreateFromFile)(const char *file);
|
admin@999
|
69 |
|
admin@999
|
70 |
/* Set the volume */
|
admin@999
|
71 |
void (*SetVolume)(void *music, int volume);
|
admin@999
|
72 |
|
admin@999
|
73 |
/* Start playing music from the beginning with an optional loop count */
|
admin@999
|
74 |
int (*Play)(void *music, int play_count);
|
admin@999
|
75 |
|
admin@999
|
76 |
/* Returns SDL_TRUE if music is still playing */
|
admin@999
|
77 |
SDL_bool (*IsPlaying)(void *music);
|
admin@999
|
78 |
|
admin@999
|
79 |
/* Get music data, returns the number of bytes left */
|
admin@999
|
80 |
int (*GetAudio)(void *music, void *data, int bytes);
|
admin@999
|
81 |
|
admin@999
|
82 |
/* Seek to a play position (in seconds) */
|
admin@999
|
83 |
int (*Seek)(void *music, double position);
|
admin@999
|
84 |
|
uso@1090
|
85 |
/* Get Music duration in ms */
|
uso@1090
|
86 |
double (*Duration)(void *music);
|
uso@1090
|
87 |
|
admin@999
|
88 |
/* Pause playing music */
|
admin@999
|
89 |
void (*Pause)(void *music);
|
admin@999
|
90 |
|
admin@999
|
91 |
/* Resume playing music */
|
admin@999
|
92 |
void (*Resume)(void *music);
|
admin@999
|
93 |
|
admin@999
|
94 |
/* Stop playing music */
|
admin@999
|
95 |
void (*Stop)(void *music);
|
admin@999
|
96 |
|
admin@999
|
97 |
/* Delete a music object */
|
admin@999
|
98 |
void (*Delete)(void *music);
|
admin@999
|
99 |
|
admin@999
|
100 |
/* Close the library and clean up */
|
admin@999
|
101 |
void (*Close)(void);
|
admin@999
|
102 |
|
admin@999
|
103 |
/* Unload the library */
|
admin@999
|
104 |
void (*Unload)(void);
|
admin@999
|
105 |
|
admin@999
|
106 |
} Mix_MusicInterface;
|
admin@999
|
107 |
|
admin@999
|
108 |
|
admin@999
|
109 |
extern int get_num_music_interfaces(void);
|
admin@999
|
110 |
extern Mix_MusicInterface *get_music_interface(int index);
|
admin@999
|
111 |
extern Mix_MusicType detect_music_type(SDL_RWops *src);
|
admin@999
|
112 |
extern SDL_bool load_music_type(Mix_MusicType type);
|
admin@999
|
113 |
extern SDL_bool open_music_type(Mix_MusicType type);
|
admin@999
|
114 |
extern SDL_bool has_music(Mix_MusicType type);
|
admin@999
|
115 |
extern void open_music(const SDL_AudioSpec *spec);
|
admin@999
|
116 |
extern int music_pcm_getaudio(void *context, void *data, int bytes, int volume,
|
admin@999
|
117 |
int (*GetSome)(void *context, void *data, int bytes, SDL_bool *done));
|
admin@999
|
118 |
extern void SDLCALL music_mixer(void *udata, Uint8 *stream, int len);
|
admin@999
|
119 |
extern void close_music(void);
|
admin@999
|
120 |
extern void unload_music(void);
|
admin@999
|
121 |
|
admin@999
|
122 |
extern char *music_cmd;
|
admin@999
|
123 |
extern SDL_AudioSpec music_spec;
|
admin@999
|
124 |
|
admin@999
|
125 |
#endif /* MUSIC_H_ */
|
admin@999
|
126 |
|
admin@999
|
127 |
/* vi: set ts=4 sw=4 expandtab: */
|