X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Flibgame%2Fsound.c;h=92c2253c81acad8581b67d82c9dec25e0f16bca5;hb=e849e67ceff4a2f5d457dedee8f18de1646b9dc3;hp=220dfde6ded3f5265e5492d1de81ed2e6a50f8dd;hpb=d6877ad6d36ea50b9ae41afe3586c5b539aa60e4;p=rocksndiamonds.git diff --git a/src/libgame/sound.c b/src/libgame/sound.c index 220dfde6..92c2253c 100644 --- a/src/libgame/sound.c +++ b/src/libgame/sound.c @@ -135,7 +135,7 @@ static boolean ForkAudioProcess(void) return FALSE; } - if (audio.soundserver_pid == 0) /* we are child */ + if (audio.soundserver_pid == 0) /* we are child process */ { SoundServer(); @@ -168,7 +168,7 @@ void UnixCloseAudio(void) if (audio.device_fd) close(audio.device_fd); - if (audio.soundserver_pid) + if (audio.soundserver_pid > 0) /* we are parent process */ kill(audio.soundserver_pid, SIGTERM); } #endif /* PLATFORM_UNIX */ @@ -1080,21 +1080,10 @@ int LoadMusic(void) { char *filename = dir_entry->d_name; - if (strlen(filename) > 4 && - strcmp(&filename[strlen(filename) - 4], ".wav") == 0) - { - if (LoadSoundExt(filename, TRUE)) - num_wav_music++; - } - else if (strlen(filename) > 4 && - (strcmp(&filename[strlen(filename) - 4], ".mod") == 0 || - strcmp(&filename[strlen(filename) - 4], ".MOD") == 0 || - strncmp(filename, "mod.", 4) == 0 || - strncmp(filename, "MOD.", 4) == 0)) - { - if (LoadMod(filename)) - num_mod_music++; - } + if (FileIsSound(filename) && LoadSoundExt(filename, TRUE)) + num_wav_music++; + else if (FileIsMusic(filename) && LoadMod(filename)) + num_mod_music++; } closedir(dir); @@ -1180,6 +1169,9 @@ void PlaySoundExt(int nr, int volume, int stereo, boolean loop) Mix_Volume(-1, SOUND_MAX_VOLUME); Mix_PlayChannel(-1, Sound[nr].mix_chunk, (loop ? -1 : 0)); #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"); @@ -1285,6 +1277,9 @@ void StopSoundExt(int nr, int method) #else #if !defined(PLATFORM_MSDOS) + 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");