X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Flibgame%2Fsound.c;h=ae4028d74589bd98e6d41f6eb32155f9d8263f71;hb=b81f28710057e7d84528b65b92e9b4d1aaadab6c;hp=b29d5dd62616a3dc9b1f245b2cb83707b9cf6397;hpb=cb5fe20318d9b2c18cb82bc1f7197150cfba7bc0;p=rocksndiamonds.git diff --git a/src/libgame/sound.c b/src/libgame/sound.c index b29d5dd6..ae4028d7 100644 --- a/src/libgame/sound.c +++ b/src/libgame/sound.c @@ -71,6 +71,8 @@ #define SOUND_VOLUME_LEFT(x) (stereo_volume[x]) #define SOUND_VOLUME_RIGHT(x) (stereo_volume[SOUND_MAX_LEFT2RIGHT-x]) +#define SAME_SOUND_NR(x,y) ((x).nr == (y).nr) +#define SAME_SOUND_DATA(x,y) ((x).data_ptr == (y).data_ptr) #if 0 struct SoundHeader_SUN @@ -495,6 +497,9 @@ static void WriteReloadInfoToPipe(char *set_name, int type) 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; + boolean override_level_artwork = (type == SND_CTRL_RELOAD_SOUNDS ? + setup.override_level_sounds : + setup.override_level_music); if (IS_CHILD_PROCESS(audio.mixer_pid)) return; @@ -510,6 +515,8 @@ static void WriteReloadInfoToPipe(char *set_name, int type) sizeof(snd_ctrl)) < 0 || write(audio.mixer_pipe[1], set_name, snd_ctrl.data_len) < 0 || + write(audio.mixer_pipe[1], &override_level_artwork, + sizeof(boolean)) < 0 || write(audio.mixer_pipe[1], leveldir_current, sizeof(TreeInfo)) < 0 || write(audio.mixer_pipe[1], ti, @@ -540,6 +547,9 @@ static void ReadReloadInfoFromPipe(SoundControl *snd_ctrl) TreeInfo *ti = *ti_ptr; unsigned long str_size1, str_size2, str_size3; static char *set_name = NULL; + boolean *override_level_artwork = (snd_ctrl->state & SND_CTRL_RELOAD_SOUNDS ? + &setup.override_level_sounds : + &setup.override_level_music); if (set_name) free(set_name); @@ -559,6 +569,8 @@ static void ReadReloadInfoFromPipe(SoundControl *snd_ctrl) if (read(audio.mixer_pipe[0], set_name, snd_ctrl->data_len) != snd_ctrl->data_len || + read(audio.mixer_pipe[0], override_level_artwork, + sizeof(boolean)) != sizeof(boolean) || read(audio.mixer_pipe[0], leveldir_current, sizeof(TreeInfo)) != sizeof(TreeInfo) || read(audio.mixer_pipe[0], ti, @@ -584,9 +596,9 @@ static void ReadReloadInfoFromPipe(SoundControl *snd_ctrl) Error(ERR_EXIT_SOUND_SERVER, "broken pipe -- no sounds"); if (snd_ctrl->state & SND_CTRL_RELOAD_SOUNDS) - artwork.sounds_set_current = set_name; + artwork.sounds_set_current_name = set_name; else - artwork.music_set_current = set_name; + artwork.music_set_current_name = set_name; } #endif /* AUDIO_UNIX_NATIVE */ @@ -826,9 +838,9 @@ static void Mixer_InsertSound(SoundControl snd_ctrl) return; } - /* check if sound is already being played (and how often) */ + /* check if (and how often) this sound sample is already playing */ for (k=0, i=audio.first_sound_channel; i= 2) { @@ -878,7 +894,7 @@ static void Mixer_InsertSound(SoundControl snd_ctrl) int playing_time = playing_current - mixer[i].playing_starttime; int actual; - if (!mixer[i].active || mixer[i].nr != snd_ctrl.nr) + if (!mixer[i].active || !SAME_SOUND_NR(mixer[i], snd_ctrl)) continue; actual = 1000 * playing_time / mixer[i].data_len; @@ -1008,7 +1024,7 @@ static void HandleSoundRequest(SoundControl snd_ctrl) } for(i=audio.first_sound_channel; i