Skip to content

Commit

Permalink
Sam Lantinga - Sun May 19 13:46:29 PDT 2002
Browse files Browse the repository at this point in the history
 * Added a function to query the music format: Mix_GetMusicType()
  • Loading branch information
slouken committed May 19, 2002
1 parent 4ecf81f commit b22ef13
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 9 deletions.
4 changes: 3 additions & 1 deletion CHANGES
@@ -1,6 +1,8 @@

1.2.4:
Sam Lantinga Sat May 18 12:45:16 PDT 2002
Sam Lantinga - Sun May 19 13:46:29 PDT 2002
* Added a function to query the music format: Mix_GetMusicType()
Sam Lantinga - Sat May 18 12:45:16 PDT 2002
* Added a function to load audio data from memory: Mix_QuickLoad_RAW()
Sam Lantinga - Thu May 16 11:26:46 PDT 2002
* Cleaned up threading issues in the music playback code
Expand Down
15 changes: 15 additions & 0 deletions SDL_mixer.h
Expand Up @@ -91,6 +91,16 @@ typedef enum {
MIX_FADING_IN
} Mix_Fading;

typedef enum {
MUS_NONE,
MUS_CMD,
MUS_WAV,
MUS_MOD,
MUS_MID,
MUS_OGG,
MUS_MP3
} Mix_MusicType;

/* The internal format for a music chunk interpreted via mikmod */
typedef struct _Mix_Music Mix_Music;

Expand Down Expand Up @@ -131,6 +141,11 @@ extern DECLSPEC Mix_Chunk * SDLCALL Mix_QuickLoad_RAW(Uint8 *mem, Uint32 len);
extern DECLSPEC void SDLCALL Mix_FreeChunk(Mix_Chunk *chunk);
extern DECLSPEC void SDLCALL Mix_FreeMusic(Mix_Music *music);

/* Find out the music format of a mixer music, or the currently playing
music, if 'music' is NULL.
*/
extern DECLSPEC Mix_MusicType Mix_GetMusicType(const Mix_Music *music);

/* Set a function that is called after all mixing is performed.
This can be used to provide real-time visual display of the audio stream
or add a custom mixer filter for the stream data.
Expand Down
28 changes: 20 additions & 8 deletions music.c
Expand Up @@ -87,14 +87,7 @@ static int music_swap8;
static int music_swap16;

struct _Mix_Music {
enum {
MUS_CMD,
MUS_WAV,
MUS_MOD,
MUS_MID,
MUS_OGG,
MUS_MP3
} type;
Mix_MusicType type;
union {
#ifdef CMD_MUSIC
MusicCMD *cmd;
Expand Down Expand Up @@ -589,6 +582,25 @@ void Mix_FreeMusic(Mix_Music *music)
}
}

/* Find out the music format of a mixer music, or the currently playing
music, if 'music' is NULL.
*/
Mix_MusicType Mix_GetMusicType(const Mix_Music *music)
{
Mix_MusicType type = MUS_NONE;

if ( music ) {
type = music->type;
} else {
SDL_LockAudio();
if ( music_playing ) {
type = music_playing->type;
}
SDL_UnlockAudio();
}
return(type);
}

/* Play a music chunk. Returns 0, or -1 if there was an error.
*/
static int music_internal_play(Mix_Music *music, double position)
Expand Down

0 comments on commit b22ef13

Please sign in to comment.