Sam Lantinga - Sun May 19 13:46:29 PDT 2002
authorSam Lantinga <slouken@libsdl.org>
Sun, 19 May 2002 20:47:22 +0000
changeset 1770108822670c8
parent 176 fa3cf3b26af4
child 178 de35197ea52a
Sam Lantinga - Sun May 19 13:46:29 PDT 2002
* Added a function to query the music format: Mix_GetMusicType()
CHANGES
SDL_mixer.h
music.c
     1.1 --- a/CHANGES	Sun May 19 20:37:48 2002 +0000
     1.2 +++ b/CHANGES	Sun May 19 20:47:22 2002 +0000
     1.3 @@ -1,6 +1,8 @@
     1.4  
     1.5  1.2.4:
     1.6 -Sam Lantinga Sat May 18 12:45:16 PDT 2002
     1.7 +Sam Lantinga - Sun May 19 13:46:29 PDT 2002
     1.8 + * Added a function to query the music format: Mix_GetMusicType()
     1.9 +Sam Lantinga - Sat May 18 12:45:16 PDT 2002
    1.10   * Added a function to load audio data from memory: Mix_QuickLoad_RAW()
    1.11  Sam Lantinga - Thu May 16 11:26:46 PDT 2002
    1.12   * Cleaned up threading issues in the music playback code
     2.1 --- a/SDL_mixer.h	Sun May 19 20:37:48 2002 +0000
     2.2 +++ b/SDL_mixer.h	Sun May 19 20:47:22 2002 +0000
     2.3 @@ -91,6 +91,16 @@
     2.4  	MIX_FADING_IN
     2.5  } Mix_Fading;
     2.6  
     2.7 +typedef enum {
     2.8 +	MUS_NONE,
     2.9 +	MUS_CMD,
    2.10 +	MUS_WAV,
    2.11 +	MUS_MOD,
    2.12 +	MUS_MID,
    2.13 +	MUS_OGG,
    2.14 +	MUS_MP3
    2.15 +} Mix_MusicType;
    2.16 +
    2.17  /* The internal format for a music chunk interpreted via mikmod */
    2.18  typedef struct _Mix_Music Mix_Music;
    2.19  
    2.20 @@ -131,6 +141,11 @@
    2.21  extern DECLSPEC void SDLCALL Mix_FreeChunk(Mix_Chunk *chunk);
    2.22  extern DECLSPEC void SDLCALL Mix_FreeMusic(Mix_Music *music);
    2.23  
    2.24 +/* Find out the music format of a mixer music, or the currently playing
    2.25 +   music, if 'music' is NULL.
    2.26 +*/
    2.27 +extern DECLSPEC Mix_MusicType Mix_GetMusicType(const Mix_Music *music);
    2.28 +
    2.29  /* Set a function that is called after all mixing is performed.
    2.30     This can be used to provide real-time visual display of the audio stream
    2.31     or add a custom mixer filter for the stream data.
     3.1 --- a/music.c	Sun May 19 20:37:48 2002 +0000
     3.2 +++ b/music.c	Sun May 19 20:47:22 2002 +0000
     3.3 @@ -87,14 +87,7 @@
     3.4  static int music_swap16;
     3.5  
     3.6  struct _Mix_Music {
     3.7 -	enum {
     3.8 -		MUS_CMD,
     3.9 -		MUS_WAV,
    3.10 -		MUS_MOD,
    3.11 -		MUS_MID,
    3.12 -		MUS_OGG,
    3.13 -		MUS_MP3
    3.14 -	} type;
    3.15 +	Mix_MusicType type;
    3.16  	union {
    3.17  #ifdef CMD_MUSIC
    3.18  		MusicCMD *cmd;
    3.19 @@ -589,6 +582,25 @@
    3.20  	}
    3.21  }
    3.22  
    3.23 +/* Find out the music format of a mixer music, or the currently playing
    3.24 +   music, if 'music' is NULL.
    3.25 +*/
    3.26 +Mix_MusicType Mix_GetMusicType(const Mix_Music *music)
    3.27 +{
    3.28 +	Mix_MusicType type = MUS_NONE;
    3.29 +
    3.30 +	if ( music ) {
    3.31 +		type = music->type;
    3.32 +	} else {
    3.33 +		SDL_LockAudio();
    3.34 +		if ( music_playing ) {
    3.35 +			type = music_playing->type;
    3.36 +		}
    3.37 +		SDL_UnlockAudio();
    3.38 +	}
    3.39 +	return(type);
    3.40 +}
    3.41 +
    3.42  /* Play a music chunk.  Returns 0, or -1 if there was an error.
    3.43   */
    3.44  static int music_internal_play(Mix_Music *music, double position)