Skip to content

Commit

Permalink
Fixed bug 948
Browse files Browse the repository at this point in the history
 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.
  • Loading branch information
slouken committed Apr 14, 2010
1 parent 2758de3 commit 24076d5
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 17 deletions.
10 changes: 10 additions & 0 deletions configure.in
Expand Up @@ -112,6 +112,10 @@ if test x$enable_dependency_tracking = xyes; then
fi

case "$host" in
*mingw32ce*)
#VERSION_SOURCES="$srcdir/version.rc"
EXE=".exe"
;;
*-*-cygwin* | *-*-mingw32*)
VERSION_SOURCES="$srcdir/version.rc"
EXE=".exe"
Expand Down Expand Up @@ -343,6 +347,9 @@ AC_HELP_STRING([--enable-music-native-midi], [enable native MIDI music output [[
if test x$enable_music_native_midi = xyes; then
use_music_native_midi=no
case "$host" in
*mingw32ce*)
use_music_native_midi=no
;;
*-*-cygwin* | *-*-mingw32*)
use_music_native_midi=yes
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lwinmm"
Expand Down Expand Up @@ -515,6 +522,9 @@ int main( int argc, char *argv[] ) {
fi
fi

AC_CHECK_HEADERS([signal.h], [EXTRA_CFLAGS="$EXTRA_CFLAGS -DHAVE_SIGNAL_H"])
AC_CHECK_FUNCS(setbuf, [EXTRA_CFLAGS="$EXTRA_CFLAGS -DHAVE_SETBUF"])

AC_ARG_ENABLE(music-mp3,
AC_HELP_STRING([--enable-music-mp3], [enable MP3 music via smpeg [[default=yes]]]),
[], enable_music_mp3=yes)
Expand Down
3 changes: 2 additions & 1 deletion effects_internal.c
Expand Up @@ -30,6 +30,7 @@

#include <stdio.h>
#include <stdlib.h>
#include "SDL_getenv.h"
#include "SDL_mixer.h"

#define __MIX_INTERNAL_EFFECT__
Expand All @@ -41,7 +42,7 @@ int _Mix_effects_max_speed = 0;

void _Mix_InitEffects(void)
{
_Mix_effects_max_speed = (getenv(MIX_EFFECTSMAXSPEED) != NULL);
_Mix_effects_max_speed = (SDL_getenv(MIX_EFFECTSMAXSPEED) != NULL);
}

void _Mix_DeinitEffects(void)
Expand Down
42 changes: 26 additions & 16 deletions playmus.c
Expand Up @@ -25,7 +25,10 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

#ifdef HAVE_SIGNAL_H
#include <signal.h>
#endif
#ifdef unix
#include <unistd.h>
#endif
Expand Down Expand Up @@ -67,25 +70,28 @@ void Menu(void)

printf("Available commands: (p)ause (r)esume (h)alt volume(v#) > ");
fflush(stdin);
scanf("%s",buf);
switch(buf[0]){
case 'p': case 'P':
Mix_PauseMusic();
break;
case 'r': case 'R':
Mix_ResumeMusic();
break;
case 'h': case 'H':
Mix_HaltMusic();
break;
case 'v': case 'V':
Mix_VolumeMusic(atoi(buf+1));
break;
if (scanf("%s",buf) == 1) {
switch(buf[0]){
case 'p': case 'P':
Mix_PauseMusic();
break;
case 'r': case 'R':
Mix_ResumeMusic();
break;
case 'h': case 'H':
Mix_HaltMusic();
break;
case 'v': case 'V':
Mix_VolumeMusic(atoi(buf+1));
break;
}
}
printf("Music playing: %s Paused: %s\n", Mix_PlayingMusic() ? "yes" : "no",
Mix_PausedMusic() ? "yes" : "no");
}

#ifdef HAVE_SIGNAL_H

void IntHandler(int sig)
{
switch (sig) {
Expand All @@ -95,9 +101,11 @@ void IntHandler(int sig)
}
}

#endif

int main(int argc, char *argv[])
{
SDL_RWops *rwfp;
SDL_RWops *rwfp = NULL;
int audio_rate;
Uint16 audio_format;
int audio_channels;
Expand Down Expand Up @@ -162,8 +170,10 @@ int main(int argc, char *argv[])
return(255);
}

#ifdef HAVE_SIGNAL_H
signal(SIGINT, IntHandler);
signal(SIGTERM, CleanUp);
#endif

/* Open the audio device */
if (Mix_OpenAudio(audio_rate, audio_format, audio_channels, audio_buffers) < 0) {
Expand All @@ -183,7 +193,7 @@ int main(int argc, char *argv[])
Mix_VolumeMusic(audio_volume);

/* Set the external music player, if any */
Mix_SetMusicCMD(getenv("MUSIC_CMD"));
Mix_SetMusicCMD(SDL_getenv("MUSIC_CMD"));

while (argv[i]) {
next_track = 0;
Expand Down
7 changes: 7 additions & 0 deletions playwave.c
Expand Up @@ -25,7 +25,10 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>

#ifdef HAVE_SIGNAL_H
#include <signal.h>
#endif
#ifdef unix
#include <unistd.h>
#endif
Expand Down Expand Up @@ -363,8 +366,10 @@ int main(int argc, char *argv[])
int reverse_stereo = 0;
int reverse_sample = 0;

#ifdef HAVE_SETBUF
setbuf(stdout, NULL); /* rcg06132001 for debugging purposes. */
setbuf(stderr, NULL); /* rcg06192001 for debugging purposes, too. */
#endif
output_test_warnings();

/* Initialize variables */
Expand Down Expand Up @@ -411,8 +416,10 @@ int main(int argc, char *argv[])
fprintf(stderr, "Couldn't initialize SDL: %s\n",SDL_GetError());
return(255);
}
#ifdef HAVE_SIGNAL_H
signal(SIGINT, CleanUp);
signal(SIGTERM, CleanUp);
#endif

/* Open the audio device */
if (Mix_OpenAudio(audio_rate, audio_format, audio_channels, 4096) < 0) {
Expand Down

0 comments on commit 24076d5

Please sign in to comment.