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