+ {
+ if (sound_effect[i].filename)
+ LoadSoundToList(sound_effect[i].filename, i);
+ else
+ LoadSoundToList(sound_effect[i].default_filename, i);
+ }
+
+ /*
+ printf("list size == %d\n", getNumNodes(SoundFileList));
+ */
+
+#if 0
+ dumpList(SoundFileList);
+#endif
+}
+
+static void ReloadCustomMusic()
+{
+#if 0
+ printf("DEBUG: reloading music '%s' ...\n", artwork.music_set_current);
+#endif
+
+ FreeAllMusic();
+
+ LoadCustomMusic();
+}
+
+static void InitReloadSoundsOrMusic(char *set_name, int type)
+{
+#if defined(PLATFORM_UNIX) && !defined(TARGET_SDL)
+ struct SoundControl snd_ctrl = emptySoundControl;
+ TreeInfo *ti =
+ (type == SND_RELOAD_SOUNDS ? artwork.snd_current : artwork.mus_current);
+ unsigned long str_size1 = strlen(leveldir_current->fullpath) + 1;
+ unsigned long str_size2 = strlen(ti->basepath) + 1;
+ unsigned long str_size3 = strlen(ti->fullpath) + 1;
+#endif
+
+ if (!audio.sound_available)
+ return;
+
+#if defined(TARGET_SDL) || defined(TARGET_ALLEGRO)
+ if (type == SND_RELOAD_SOUNDS)
+ audio.func_reload_sounds();
+ else
+ audio.func_reload_music();
+#elif defined(PLATFORM_UNIX)
+ if (audio.soundserver_pid == 0) /* we are child process */
+ return;
+
+ if (leveldir_current == NULL) /* should never happen */
+ Error(ERR_EXIT, "leveldir_current == NULL");
+
+ snd_ctrl.reload_sounds = (type == SND_RELOAD_SOUNDS);
+ snd_ctrl.reload_music = (type == SND_RELOAD_MUSIC);
+ snd_ctrl.data_len = strlen(set_name) + 1;
+
+ if (write(audio.soundserver_pipe[1], &snd_ctrl,
+ sizeof(snd_ctrl)) < 0 ||
+ write(audio.soundserver_pipe[1], set_name,
+ snd_ctrl.data_len) < 0 ||
+ write(audio.soundserver_pipe[1], leveldir_current,
+ sizeof(TreeInfo)) < 0 ||
+ write(audio.soundserver_pipe[1], ti,
+ sizeof(TreeInfo)) < 0 ||
+ write(audio.soundserver_pipe[1], &str_size1,
+ sizeof(unsigned long)) < 0 ||
+ write(audio.soundserver_pipe[1], &str_size2,
+ sizeof(unsigned long)) < 0 ||
+ write(audio.soundserver_pipe[1], &str_size3,
+ sizeof(unsigned long)) < 0 ||
+ write(audio.soundserver_pipe[1], leveldir_current->fullpath,
+ str_size1) < 0 ||
+ write(audio.soundserver_pipe[1], ti->basepath,
+ str_size2) < 0 ||
+ write(audio.soundserver_pipe[1], ti->fullpath,
+ str_size3) < 0)
+ {
+ Error(ERR_WARN, "cannot pipe to child process -- no sounds");
+ audio.sound_available = audio.sound_enabled = FALSE;
+ return;
+ }
+#endif
+}
+
+void InitReloadSounds(char *set_name)
+{
+ InitReloadSoundsOrMusic(set_name, SND_RELOAD_SOUNDS);
+}
+
+void InitReloadMusic(char *set_name)
+{
+ InitReloadSoundsOrMusic(set_name, SND_RELOAD_MUSIC);
+}
+
+void FreeSound(void *ptr)
+{
+ SoundInfo *sound = (SoundInfo *)ptr;
+
+ if (sound == NULL)
+ return;
+
+ if (sound->data_ptr)
+ {