]> cvs.zerfleddert.de Git - micropolis/commitdiff
use old forking player when SDL_mixer is not available
authorMichael Gernoth <michael@gernoth.net>
Mon, 11 Feb 2008 21:23:19 +0000 (22:23 +0100)
committerMichael Gernoth <michael@gernoth.net>
Mon, 11 Feb 2008 21:23:19 +0000 (22:23 +0100)
res/micropolis.tcl
src/sim/w_sound.c

index 1d56b751b26f64802e613150b2a295f4375dfc1d..5704330d82f25288932aad3c8d640c3ff0559ad5 100644 (file)
@@ -416,6 +416,10 @@ set FontPath "[pwd]/res/dejavu-lgc"
 system "xset -fp \"$FontPath\" >/dev/null 2>&1"
 system "xset +fp \"$FontPath\" >/dev/null 2>&1"
 
+# Ignore SIGCHLD for spawned sound-player childs, this should lead to them
+# being reaped by init
+signal ignore SIGCHLD
+
 
 ########################################################################
 # Messages
index 1c112023a6f4fa8275cf40c89d989248f33eab18..a7dae7836d2d85030efd8d56d0cfd9ea5ee0df7b 100644 (file)
@@ -237,15 +237,6 @@ MakeSound(char *channel, char *id)
     fprintf(stderr, "Mix_PlayChannel: %s\n", Mix_GetError());
 }
 
-MakeSoundOn(SimView *view, char *channel, char *id)
-{
-  if (!UserSoundOn) return;
-  if (!SoundInitialized) return;
-
-  MakeSound(channel, id);
-}
-
-
 StartBulldozer(void)
 {
   if (!UserSoundOn) return;
@@ -269,22 +260,50 @@ StopBulldozer(void)
 #else /* WITH_SDL_MIXER */
 InitializeSound()
 {
+  SoundInitialized = 1;
 }
 
 ShutDownSound()
 {
+  SoundInitialized = 0;
 }
 
 MakeSound(char *channel, char *id)
 {
-}
+  char filename[256], player[256];
+  int i;
+  pid_t pid;
 
-MakeSoundOn(SimView *view, char *channel, char *id)
-{
+  if (!UserSoundOn) return;
+  if (!SoundInitialized) return;
+
+  for (i = 0; i < SIM_NSOUNDS; i++) {
+    if (!strcmp(sounds[i].id, id))
+      break;
+  }
+  snprintf(filename, sizeof(filename), "%s/sounds/%s", ResourceDir,
+          sounds[i].file);
+
+  snprintf(player, sizeof(player), "%s/sounds/player", ResourceDir);
+
+  pid = fork();
+
+  switch(pid) {
+    case 0:
+      execl(player, player, filename, NULL);
+      break;
+    case -1:
+      perror("fork failed");
+      break;
+    default:
+      break;
+  }
 }
 
 StartBulldozer(void)
 {
+  MakeSound(0, "Rumble");
 }
 
 StopBulldozer(void)
@@ -293,6 +312,15 @@ StopBulldozer(void)
 #endif
 
 
+MakeSoundOn(SimView *view, char *channel, char *id)
+{
+  if (!UserSoundOn) return;
+  if (!SoundInitialized) return;
+
+  MakeSound(channel, id);
+}
+
+
 /* XXX comefrom: doKeyEvent */
 SoundOff(void)
 {
Impressum, Datenschutz