From b22ef134aee1255a028c64600f4b2d68c2d81581 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Sun, 19 May 2002 20:47:22 +0000 Subject: [PATCH] Sam Lantinga - Sun May 19 13:46:29 PDT 2002 * Added a function to query the music format: Mix_GetMusicType() --- CHANGES | 4 +++- SDL_mixer.h | 15 +++++++++++++++ music.c | 28 ++++++++++++++++++++-------- 3 files changed, 38 insertions(+), 9 deletions(-) diff --git a/CHANGES b/CHANGES index 405375de..3017e418 100644 --- a/CHANGES +++ b/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 diff --git a/SDL_mixer.h b/SDL_mixer.h index 46529bf0..26e0ab34 100644 --- a/SDL_mixer.h +++ b/SDL_mixer.h @@ -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; @@ -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. diff --git a/music.c b/music.c index db03a359..e8bf9e6f 100644 --- a/music.c +++ b/music.c @@ -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; @@ -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)