projects
/
rocksndiamonds.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
rnd-20020803-1-src
[rocksndiamonds.git]
/
src
/
libgame
/
sound.c
diff --git
a/src/libgame/sound.c
b/src/libgame/sound.c
index 414ab122befa69174fd501a16ec44763f0a41797..cd34b284473e3126a0191fc3074f7005793fd0e0 100644
(file)
--- a/
src/libgame/sound.c
+++ b/
src/libgame/sound.c
@@
-1,7
+1,7
@@
/***********************************************************
* Artsoft Retro-Game Library *
*----------------------------------------------------------*
/***********************************************************
* Artsoft Retro-Game Library *
*----------------------------------------------------------*
-* (c) 1994-200
1
Artsoft Entertainment *
+* (c) 1994-200
2
Artsoft Entertainment *
* Holger Schemel *
* Detmolder Strasse 189 *
* 33604 Bielefeld *
* Holger Schemel *
* Detmolder Strasse 189 *
* 33604 Bielefeld *
@@
-11,8
+11,9
@@
* sound.c *
***********************************************************/
* sound.c *
***********************************************************/
-#include <s
tring
.h>
+#include <s
ys/types
.h>
#include <sys/time.h>
#include <sys/time.h>
+#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <dirent.h>
#include <unistd.h>
#include <fcntl.h>
#include <dirent.h>
@@
-497,6
+498,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;
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;
if (IS_CHILD_PROCESS(audio.mixer_pid))
return;
@@
-512,6
+516,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 ||
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,
write(audio.mixer_pipe[1], leveldir_current,
sizeof(TreeInfo)) < 0 ||
write(audio.mixer_pipe[1], ti,
@@
-542,6
+548,9
@@
static void ReadReloadInfoFromPipe(SoundControl *snd_ctrl)
TreeInfo *ti = *ti_ptr;
unsigned long str_size1, str_size2, str_size3;
static char *set_name = NULL;
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);
if (set_name)
free(set_name);
@@
-561,6
+570,8
@@
static void ReadReloadInfoFromPipe(SoundControl *snd_ctrl)
if (read(audio.mixer_pipe[0], set_name,
snd_ctrl->data_len) != snd_ctrl->data_len ||
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,
read(audio.mixer_pipe[0], leveldir_current,
sizeof(TreeInfo)) != sizeof(TreeInfo) ||
read(audio.mixer_pipe[0], ti,
@@
-586,9
+597,9
@@
static void ReadReloadInfoFromPipe(SoundControl *snd_ctrl)
Error(ERR_EXIT_SOUND_SERVER, "broken pipe -- no sounds");
if (snd_ctrl->state & SND_CTRL_RELOAD_SOUNDS)
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
else
- artwork.music_set_current = set_name;
+ artwork.music_set_current
_name
= set_name;
}
#endif /* AUDIO_UNIX_NATIVE */
}
#endif /* AUDIO_UNIX_NATIVE */
@@
-800,7
+811,12
@@
static void Mixer_InsertSound(SoundControl snd_ctrl)
#endif
if (IS_MUSIC(snd_ctrl))
#endif
if (IS_MUSIC(snd_ctrl))
+ {
+ if (num_music == 0)
+ return;
+
snd_ctrl.nr = snd_ctrl.nr % num_music;
snd_ctrl.nr = snd_ctrl.nr % num_music;
+ }
else if (snd_ctrl.nr >= num_sounds)
return;
else if (snd_ctrl.nr >= num_sounds)
return;
@@
-1289,7
+1305,7
@@
static int Mixer_Main_SimpleAudio(SoundControl snd_ctrl)
mixer[i].volume * (long)premix_first_buffer[j] / SOUND_MAX_VOLUME;
/* might be needed for u-law /dev/audio */
mixer[i].volume * (long)premix_first_buffer[j] / SOUND_MAX_VOLUME;
/* might be needed for u-law /dev/audio */
-#if
0
+#if
1
for(j=0; j<sample_size; j++)
playing_buffer[j] =
linear_to_ulaw(premix_first_buffer[j]);
for(j=0; j<sample_size; j++)
playing_buffer[j] =
linear_to_ulaw(premix_first_buffer[j]);
@@
-1831,6
+1847,7
@@
static MusicInfo *Load_MOD(char *filename)
void LoadCustomMusic(void)
{
static boolean draw_init_text = TRUE; /* only draw at startup */
void LoadCustomMusic(void)
{
static boolean draw_init_text = TRUE; /* only draw at startup */
+ static char *last_music_directory = NULL;
char *music_directory = getCustomMusicDirectory();
DIR *dir;
struct dirent *dir_entry;
char *music_directory = getCustomMusicDirectory();
DIR *dir;
struct dirent *dir_entry;
@@
-1838,6
+1855,14
@@
void LoadCustomMusic(void)
if (!audio.sound_available)
return;
if (!audio.sound_available)
return;
+ if (last_music_directory != NULL &&
+ strcmp(last_music_directory, music_directory) == 0)
+ return; /* old and new music directory are the same */
+
+ last_music_directory = music_directory;
+
+ FreeAllMusic();
+
if ((dir = opendir(music_directory)) == NULL)
{
Error(ERR_WARN, "cannot read music directory '%s'", music_directory);
if ((dir = opendir(music_directory)) == NULL)
{
Error(ERR_WARN, "cannot read music directory '%s'", music_directory);
@@
-2108,7
+2133,7
@@
static void ReloadCustomSounds()
int i;
#if 0
int i;
#if 0
- printf("DEBUG: reloading sounds '%s' ...\n",
artwork.sounds_set_current
);
+ printf("DEBUG: reloading sounds '%s' ...\n",
artwork.sounds_set_current_name
);
#endif
LoadSoundsInfo();
#endif
LoadSoundsInfo();
@@
-2145,10
+2170,13
@@
static void ReloadCustomSounds()
static void ReloadCustomMusic()
{
#if 0
static void ReloadCustomMusic()
{
#if 0
- printf("DEBUG: reloading music '%s' ...\n", artwork.music_set_current);
+ printf("DEBUG: reloading music '%s' ...\n", artwork.music_set_current
_name
);
#endif
#endif
+#if 0
+ /* this is done directly in LoadCustomMusic() now */
FreeAllMusic();
FreeAllMusic();
+#endif
LoadCustomMusic();
}
LoadCustomMusic();
}