Skip to content

Commit

Permalink
Fixed bug #877
Browse files Browse the repository at this point in the history
 Mike Frysinger      2009-11-05 09:11:43 PST

the current code assumes "unix" means fork() exists.  this doesnt work for
no-mmu linux systems as fork() cant be implemented.

simple enough to add fork/vfork tests to configure and let the rest of the code
key off of CMD_MUSIC like normal -- no more needing to hardcode unix/mac-os-x
defines in the source.
  • Loading branch information
slouken committed Nov 6, 2009
1 parent 8d632b6 commit fe18ede
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 13 deletions.
20 changes: 16 additions & 4 deletions configure.in
Expand Up @@ -180,10 +180,22 @@ dnl Check command-line options

AC_ARG_ENABLE([music-cmd],
AC_HELP_STRING([--enable-music-cmd], [support an external music player [[default=yes]]]),
[], [enable_music_cmd=yes])
if test x$enable_music_cmd = xyes; then
SOURCES="$SOURCES $srcdir/music_cmd.c"
EXTRA_CFLAGS="$EXTRA_CFLAGS -DCMD_MUSIC"
[], [enable_music_cmd=detect])
if test "x$enable_music_cmd" != xno; then
AC_CHECK_FUNCS([fork vfork])
if test "x$ac_cv_func_fork" = "xyes"; then
EXTRA_CFLAGS="$EXTRA_CFLAGS -DHAVE_FORK"
elif test "x$ac_cv_func_vfork" = "xyes"; then
EXTRA_CFLAGS="$EXTRA_CFLAGS -DHAVE_VFORK"
elif test "x$enable_music_cmd" = "xyes"; then
AC_MSG_ERROR([external music player not available on your platform])
else
enable_music_cmd=no
fi
if test "x$enable_music_cmd" != xno; then
SOURCES="$SOURCES $srcdir/music_cmd.c"
EXTRA_CFLAGS="$EXTRA_CFLAGS -DCMD_MUSIC"
fi
fi

AC_ARG_ENABLE([music-wave],
Expand Down
5 changes: 0 additions & 5 deletions music.c
Expand Up @@ -32,11 +32,6 @@

#include "SDL_mixer.h"

/* The music command hack is UNIX specific */
#ifndef unix
#undef CMD_MUSIC
#endif

#ifdef CMD_MUSIC
#include "music_cmd.h"
#endif
Expand Down
8 changes: 6 additions & 2 deletions music_cmd.c
Expand Up @@ -23,7 +23,7 @@

/* This file supports an external command for playing music */

#if defined(unix) || defined(__MACOSX__) /* This is a UNIX-specific hack */
#ifdef CMD_MUSIC

#include <sys/types.h>
#include <sys/wait.h>
Expand Down Expand Up @@ -143,7 +143,11 @@ static char **parse_args(char *command, char *last_arg)
/* Start playback of a given music stream */
void MusicCMD_Start(MusicCMD *music)
{
#ifdef HAVE_FORK
music->pid = fork();
#else
music->pid = vfork();
#endif
switch(music->pid) {
/* Failed fork() system call */
case -1:
Expand Down Expand Up @@ -235,4 +239,4 @@ int MusicCMD_Active(MusicCMD *music)
return(active);
}

#endif /* unix */
#endif /* CMD_MUSIC */
4 changes: 2 additions & 2 deletions music_cmd.h
Expand Up @@ -22,7 +22,7 @@

/* This file supports an external command for playing music */

#if defined(unix) || defined(__MACOSX__) /* This is a UNIX-specific hack */
#ifdef CMD_MUSIC

#include <sys/types.h>
#include <limits.h>
Expand Down Expand Up @@ -60,4 +60,4 @@ extern void MusicCMD_FreeSong(MusicCMD *music);
/* Return non-zero if a stream is currently playing */
extern int MusicCMD_Active(MusicCMD *music);

#endif /* unix */
#endif /* CMD_MUSIC */

0 comments on commit fe18ede

Please sign in to comment.