]> cvs.zerfleddert.de Git - micropolis/blobdiff - src/sim/w_sound.c
explicitly start sdl_helper with /bin/sh
[micropolis] / src / sim / w_sound.c
index 260218341d12ccc1a58ca8c5ba1ea1f0a62e0515..a7dae7836d2d85030efd8d56d0cfd9ea5ee0df7b 100644 (file)
  * CONSUMER, SO SOME OR ALL OF THE ABOVE EXCLUSIONS AND LIMITATIONS MAY
  * NOT APPLY TO YOU.
  */
-#include <SDL/SDL.h>
-#include <SDL/SDL_mixer.h>
+#ifdef WITH_SDL_MIXER
+#include "SDL.h"
+#include "SDL_mixer.h"
+#endif
+
 #include "sim.h"
 
 
 struct sound {
   char *id;
   char *file;
+#ifdef WITH_SDL_MIXER
   Mix_Chunk *wave;
+#else
+  void *wave;
+#endif
 };
 
 struct sound sounds[SIM_NSOUNDS] = {
@@ -129,10 +136,12 @@ struct sound sounds[SIM_NSOUNDS] = {
   { "Zone",            "zone.wav",             NULL }
 };
 
+static int SoundInitialized = 0;
+
+#ifdef WITH_SDL_MIXER
 /* Sound routines */
 
 
-int SoundInitialized = 0;
 Mix_Chunk *rumble;
 
 
@@ -228,36 +237,87 @@ MakeSound(char *channel, char *id)
     fprintf(stderr, "Mix_PlayChannel: %s\n", Mix_GetError());
 }
 
-MakeSoundOn(SimView *view, char *channel, char *id)
+StartBulldozer(void)
 {
   if (!UserSoundOn) return;
   if (!SoundInitialized) return;
 
-  MakeSound(channel, id);
+  if (Mix_PlayChannel(DOZER_CHANNEL, rumble, 4) == -1) {
+    printf("Mix_PlayChannel: %s\n", Mix_GetError());
+    return;
+  }
 }
 
 
-StartBulldozer(void)
+StopBulldozer(void)
 {
-  size_t size;
-  char buf[256];
+  if (!UserSoundOn) return;
+  if (!SoundInitialized) return;
+
+  Mix_HaltChannel(DOZER_CHANNEL);
+}
+
+#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;
 
   if (!UserSoundOn) return;
   if (!SoundInitialized) return;
 
-  if (Mix_PlayChannel(DOZER_CHANNEL, rumble, 4) == -1) {
-    printf("Mix_PlayChannel: %s\n", Mix_GetError());
-    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)
+{
+}
+#endif
+
+
+MakeSoundOn(SimView *view, char *channel, char *id)
 {
   if (!UserSoundOn) return;
   if (!SoundInitialized) return;
 
-  Mix_HaltChannel(DOZER_CHANNEL);
+  MakeSound(channel, id);
 }
 
 
Impressum, Datenschutz