rnd-20020407-5-src
authorHolger Schemel <info@artsoft.org>
Sun, 7 Apr 2002 19:04:13 +0000 (21:04 +0200)
committerHolger Schemel <info@artsoft.org>
Sat, 30 Aug 2014 08:36:55 +0000 (10:36 +0200)
src/init.c
src/libgame/sound.c
src/libgame/sound.h
src/timestamp.h

index e5a1738b4840f59a4b2cc3c31fac267cd4f40d71..733df29cb65ef6fee578938201e4cf80a7c99ff3 100644 (file)
@@ -424,14 +424,14 @@ void ReloadCustomArtwork()
 
   if (artwork.sounds_set_current != artwork.snd_current->name)
   {
-    printf("reload sounds ...\n");
+    InitReloadSounds(artwork.snd_current->name);
 
     artwork.sounds_set_current = artwork.snd_current->name;
   }
 
   if (artwork.music_set_current != artwork.mus_current->name)
   {
-    printf("reload music ...\n");
+    InitReloadMusic(artwork.mus_current->name);
 
     artwork.music_set_current = artwork.mus_current->name;
   }
index 92c2253c81acad8581b67d82c9dec25e0f16bca5..29d5a981f3d2836356d397f7160a2e49da7bb482 100644 (file)
@@ -38,7 +38,7 @@ static int playing_sounds = 0;
 static struct SoundControl playlist[MAX_SOUNDS_PLAYING];
 static struct SoundControl emptySoundControl =
 {
-  -1,0,0, FALSE,FALSE,FALSE,FALSE,FALSE, 0,0L,0L,NULL
+  -1,0,0, FALSE,FALSE,FALSE,FALSE,FALSE,FALSE,FALSE, 0,0L,0L,NULL
 };
 
 #if defined(PLATFORM_UNIX)
@@ -227,6 +227,22 @@ void SoundServer(void)
        != sizeof(snd_ctrl))
       Error(ERR_EXIT_SOUND_SERVER, "broken pipe -- no sounds");
 
+    if (snd_ctrl.reload_sounds || snd_ctrl.reload_music)
+    {
+      for(i=0;i<MAX_SOUNDS_PLAYING;i++)
+       playlist[i] = emptySoundControl;
+      playing_sounds = 0;
+
+      close(audio.device_fd);
+
+      if (snd_ctrl.reload_sounds)
+       ReloadSounds();
+      else
+       ReloadMusic();
+
+      continue;
+    }
+
 #if defined(AUDIO_STREAMING_DSP)
 
     if (snd_ctrl.fade_sound)
@@ -244,8 +260,8 @@ void SoundServer(void)
        continue;
 
       for(i=0;i<MAX_SOUNDS_PLAYING;i++)
-       playlist[i]=emptySoundControl;
-      playing_sounds=0;
+       playlist[i] = emptySoundControl;
+      playing_sounds = 0;
 
       close(audio.device_fd);
     }
@@ -257,7 +273,7 @@ void SoundServer(void)
       for(i=0;i<MAX_SOUNDS_PLAYING;i++)
        if (playlist[i].nr == snd_ctrl.nr)
        {
-         playlist[i]=emptySoundControl;
+         playlist[i] = emptySoundControl;
          playing_sounds--;
        }
 
@@ -910,6 +926,15 @@ static int ulaw_to_linear(unsigned char ulawbyte)
 /* ========================================================================= */
 /* THE STUFF BELOW IS ONLY USED BY THE MAIN PROCESS                          */
 
+void ReloadSounds()
+{
+  printf("reloading sounds ...\n");
+}
+
+void ReloadMusic()
+{
+  printf("reloading music ...\n");
+}
 
 #define CHUNK_ID_LEN            4       /* IFF style chunk id length */
 #define WAV_HEADER_SIZE                20      /* size of WAV file header */
@@ -1292,6 +1317,58 @@ void StopSoundExt(int nr, int method)
 #endif
 }
 
+void InitReloadSounds(char *set_name)
+{
+  struct SoundControl snd_ctrl = emptySoundControl;
+
+  if (!audio.sound_available)
+    return;
+
+  snd_ctrl.reload_sounds = TRUE;
+
+#if defined(TARGET_SDL)
+  ReloadSounds();
+#elif defined(PLATFORM_UNIX)
+  if (audio.soundserver_pid == 0)      /* we are child process */
+    return;
+
+  if (write(audio.soundserver_pipe[1], &snd_ctrl, sizeof(snd_ctrl)) < 0)
+  {
+    Error(ERR_WARN, "cannot pipe to child process -- no sounds");
+    audio.sound_available = audio.sound_enabled = FALSE;
+    return;
+  }
+#elif defined(PLATFORM_MSDOS)
+  sound_handler(snd_ctrl);
+#endif
+}
+
+void InitReloadMusic(char *set_name)
+{
+  struct SoundControl snd_ctrl = emptySoundControl;
+
+  if (!audio.sound_available)
+    return;
+
+  snd_ctrl.reload_music = TRUE;
+
+#if defined(TARGET_SDL)
+  ReloadMusic();
+#elif defined(PLATFORM_UNIX)
+  if (audio.soundserver_pid == 0)      /* we are child process */
+    return;
+
+  if (write(audio.soundserver_pipe[1], &snd_ctrl, sizeof(snd_ctrl)) < 0)
+  {
+    Error(ERR_WARN, "cannot pipe to child process -- no sounds");
+    audio.sound_available = audio.sound_enabled = FALSE;
+    return;
+  }
+#elif defined(PLATFORM_MSDOS)
+  sound_handler(snd_ctrl);
+#endif
+}
+
 void FreeSounds(int num_sounds)
 {
   int i;
index 07e73550085431f76d563cc7913d33840fe1d980..c45736d35010496cbb97e0e4d89d3ddb20405bd3 100644 (file)
@@ -184,6 +184,8 @@ struct SoundControl
   boolean fade_sound;
   boolean stop_sound;
   boolean stop_all_sounds;
+  boolean reload_sounds;
+  boolean reload_music;
   int playingtime;
   long playingpos;
   long data_len;
@@ -204,6 +206,8 @@ void StartSoundserver(void);
 void SoundServer(void);
 
 /* sound client functions */
+void ReloadSounds(void);
+void ReloadMusic(void);
 boolean LoadSound(char *);
 boolean LoadMod(char *);
 int LoadMusic(void);
@@ -219,6 +223,8 @@ void StopMusic(void);
 void StopSound(int);
 void StopSounds(void);
 void StopSoundExt(int, int);
+void InitReloadSounds(char *);
+void InitReloadMusic(char *);
 void FreeSounds(int);
 
 #endif
index af1b9a59efd83dd1408b9cbe3fd71128b6b671ca..f99d17f4347bdcca3554c2b28fe1873dbe0753cc 100644 (file)
@@ -1 +1 @@
-#define COMPILE_DATE_STRING "[2002-04-07 20:31]"
+#define COMPILE_DATE_STRING "[2002-04-07 21:03]"