Fixed bug 948
authorSam Lantinga <slouken@libsdl.org>
Tue, 13 Apr 2010 22:30:19 -0700
changeset 48894b190330355
parent 487 485a29de2b2d
child 489 08eaf23a2284
Fixed bug 948

Simon Howard 2010-02-13 13:57:20 PST

Created an attachment (id=490) [details]
Patch against SDL_mixer 1.2.11 to add MingW32CE support.

Following bug 947, this is a patch against SDL 1.2.11 to make SDL_mixer build
with MingW32CE.

Some notes:

1. Native MIDI is disabled because it is not present on Windows CE
2. I added header/function checks for signal() and setbuf(), which do not exist
on Windows CE.
3. Uses of getenv() have been replaced with SDL_getenv().
4. version.rc is not included in the build, for the same libtool-related
reasons as in the previous bug.
configure.in
effects_internal.c
playmus.c
playwave.c
     1.1 --- a/configure.in	Tue Apr 13 22:28:38 2010 -0700
     1.2 +++ b/configure.in	Tue Apr 13 22:30:19 2010 -0700
     1.3 @@ -112,6 +112,10 @@
     1.4  fi
     1.5      
     1.6  case "$host" in
     1.7 +    *mingw32ce*)
     1.8 +        #VERSION_SOURCES="$srcdir/version.rc"
     1.9 +        EXE=".exe"
    1.10 +	;;
    1.11      *-*-cygwin* | *-*-mingw32*)
    1.12          VERSION_SOURCES="$srcdir/version.rc"
    1.13          EXE=".exe"
    1.14 @@ -343,6 +347,9 @@
    1.15      if test x$enable_music_native_midi = xyes; then
    1.16          use_music_native_midi=no
    1.17          case "$host" in
    1.18 +            *mingw32ce*)
    1.19 +                use_music_native_midi=no
    1.20 +                ;;
    1.21              *-*-cygwin* | *-*-mingw32*)
    1.22                  use_music_native_midi=yes
    1.23                  EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lwinmm"
    1.24 @@ -515,6 +522,9 @@
    1.25      fi
    1.26  fi
    1.27  
    1.28 +AC_CHECK_HEADERS([signal.h], [EXTRA_CFLAGS="$EXTRA_CFLAGS -DHAVE_SIGNAL_H"])
    1.29 +AC_CHECK_FUNCS(setbuf, [EXTRA_CFLAGS="$EXTRA_CFLAGS -DHAVE_SETBUF"])
    1.30 +
    1.31  AC_ARG_ENABLE(music-mp3,
    1.32  AC_HELP_STRING([--enable-music-mp3], [enable MP3 music via smpeg [[default=yes]]]),
    1.33                [], enable_music_mp3=yes)
     2.1 --- a/effects_internal.c	Tue Apr 13 22:28:38 2010 -0700
     2.2 +++ b/effects_internal.c	Tue Apr 13 22:30:19 2010 -0700
     2.3 @@ -30,6 +30,7 @@
     2.4  
     2.5  #include <stdio.h>
     2.6  #include <stdlib.h>
     2.7 +#include "SDL_getenv.h"
     2.8  #include "SDL_mixer.h"
     2.9  
    2.10  #define __MIX_INTERNAL_EFFECT__
    2.11 @@ -41,7 +42,7 @@
    2.12  
    2.13  void _Mix_InitEffects(void)
    2.14  {
    2.15 -    _Mix_effects_max_speed = (getenv(MIX_EFFECTSMAXSPEED) != NULL);
    2.16 +    _Mix_effects_max_speed = (SDL_getenv(MIX_EFFECTSMAXSPEED) != NULL);
    2.17  }
    2.18  
    2.19  void _Mix_DeinitEffects(void)
     3.1 --- a/playmus.c	Tue Apr 13 22:28:38 2010 -0700
     3.2 +++ b/playmus.c	Tue Apr 13 22:30:19 2010 -0700
     3.3 @@ -25,7 +25,10 @@
     3.4  #include <stdlib.h>
     3.5  #include <stdio.h>
     3.6  #include <string.h>
     3.7 +
     3.8 +#ifdef HAVE_SIGNAL_H
     3.9  #include <signal.h>
    3.10 +#endif
    3.11  #ifdef unix
    3.12  #include <unistd.h>
    3.13  #endif
    3.14 @@ -67,25 +70,28 @@
    3.15  
    3.16  	printf("Available commands: (p)ause (r)esume (h)alt volume(v#) > ");
    3.17  	fflush(stdin);
    3.18 -	scanf("%s",buf);
    3.19 -	switch(buf[0]){
    3.20 -	case 'p': case 'P':
    3.21 -		Mix_PauseMusic();
    3.22 -		break;
    3.23 -	case 'r': case 'R':
    3.24 -		Mix_ResumeMusic();
    3.25 -		break;
    3.26 -	case 'h': case 'H':
    3.27 -		Mix_HaltMusic();
    3.28 -		break;
    3.29 -	case 'v': case 'V':
    3.30 -		Mix_VolumeMusic(atoi(buf+1));
    3.31 -		break;
    3.32 +	if (scanf("%s",buf) == 1) {
    3.33 +		switch(buf[0]){
    3.34 +		case 'p': case 'P':
    3.35 +			Mix_PauseMusic();
    3.36 +			break;
    3.37 +		case 'r': case 'R':
    3.38 +			Mix_ResumeMusic();
    3.39 +			break;
    3.40 +		case 'h': case 'H':
    3.41 +			Mix_HaltMusic();
    3.42 +			break;
    3.43 +		case 'v': case 'V':
    3.44 +			Mix_VolumeMusic(atoi(buf+1));
    3.45 +			break;
    3.46 +		}
    3.47  	}
    3.48  	printf("Music playing: %s Paused: %s\n", Mix_PlayingMusic() ? "yes" : "no", 
    3.49  		   Mix_PausedMusic() ? "yes" : "no");
    3.50  }
    3.51  
    3.52 +#ifdef HAVE_SIGNAL_H
    3.53 +
    3.54  void IntHandler(int sig)
    3.55  {
    3.56  	switch (sig) {
    3.57 @@ -95,9 +101,11 @@
    3.58  	}
    3.59  }
    3.60  
    3.61 +#endif
    3.62 +
    3.63  int main(int argc, char *argv[])
    3.64  {
    3.65 -	SDL_RWops *rwfp;
    3.66 +	SDL_RWops *rwfp = NULL;
    3.67  	int audio_rate;
    3.68  	Uint16 audio_format;
    3.69  	int audio_channels;
    3.70 @@ -162,8 +170,10 @@
    3.71  		return(255);
    3.72  	}
    3.73  
    3.74 +#ifdef HAVE_SIGNAL_H
    3.75  	signal(SIGINT, IntHandler);
    3.76  	signal(SIGTERM, CleanUp);
    3.77 +#endif
    3.78  
    3.79  	/* Open the audio device */
    3.80  	if (Mix_OpenAudio(audio_rate, audio_format, audio_channels, audio_buffers) < 0) {
    3.81 @@ -183,7 +193,7 @@
    3.82  	Mix_VolumeMusic(audio_volume);
    3.83  
    3.84  	/* Set the external music player, if any */
    3.85 -	Mix_SetMusicCMD(getenv("MUSIC_CMD"));
    3.86 +	Mix_SetMusicCMD(SDL_getenv("MUSIC_CMD"));
    3.87  
    3.88  	while (argv[i]) {
    3.89  		next_track = 0;
     4.1 --- a/playwave.c	Tue Apr 13 22:28:38 2010 -0700
     4.2 +++ b/playwave.c	Tue Apr 13 22:30:19 2010 -0700
     4.3 @@ -25,7 +25,10 @@
     4.4  #include <stdlib.h>
     4.5  #include <stdio.h>
     4.6  #include <string.h>
     4.7 +
     4.8 +#ifdef HAVE_SIGNAL_H
     4.9  #include <signal.h>
    4.10 +#endif
    4.11  #ifdef unix
    4.12  #include <unistd.h>
    4.13  #endif
    4.14 @@ -363,8 +366,10 @@
    4.15  	int reverse_stereo = 0;
    4.16  	int reverse_sample = 0;
    4.17  
    4.18 +#ifdef HAVE_SETBUF
    4.19  	setbuf(stdout, NULL);    /* rcg06132001 for debugging purposes. */
    4.20  	setbuf(stderr, NULL);    /* rcg06192001 for debugging purposes, too. */
    4.21 +#endif
    4.22  	output_test_warnings();
    4.23  
    4.24  	/* Initialize variables */
    4.25 @@ -411,8 +416,10 @@
    4.26  		fprintf(stderr, "Couldn't initialize SDL: %s\n",SDL_GetError());
    4.27  		return(255);
    4.28  	}
    4.29 +#ifdef HAVE_SIGNAL_H
    4.30  	signal(SIGINT, CleanUp);
    4.31  	signal(SIGTERM, CleanUp);
    4.32 +#endif
    4.33  
    4.34  	/* Open the audio device */
    4.35  	if (Mix_OpenAudio(audio_rate, audio_format, audio_channels, 4096) < 0) {