typedef struct SoundControl SoundControl;
static struct ArtworkListInfo *sound_info = NULL;
+#if 0
static SoundInfo **Sound = NULL;
+#endif
static MusicInfo **Music = NULL;
-static int num_sounds = 0, num_music = 0;
+#if 0
+static int num_sounds = 0;
+#endif
+static int num_music = 0;
static int stereo_volume[SOUND_MAX_LEFT2RIGHT + 1];
static void ReloadCustomMusic();
static void FreeSound(void *);
+static SoundInfo *getSoundInfoEntryFromSoundID(int);
+
/* ------------------------------------------------------------------------- */
/* functions for native (non-SDL) Unix audio/mixer support */
return FALSE;
}
+ if (audio.mixer_pid == 0) /* we are the child process */
+ audio.mixer_pid = getpid();
+
#if 0
- printf("PID: %d [%s]\n", getpid(),
- (IS_CHILD_PROCESS(audio.mixer_pid) ? "child" : "parent"));
+ printf("PID: %d [%s]\n", getpid(),(IS_CHILD_PROCESS() ? "child" : "parent"));
Delay(10000 * 0);
#endif
- if (IS_CHILD_PROCESS(audio.mixer_pid))
+ if (IS_CHILD_PROCESS())
Mixer_Main(); /* this function never returns */
else
close(audio.mixer_pipe[0]); /* no reading from pipe needed */
if (audio.device_fd)
close(audio.device_fd);
- if (IS_PARENT_PROCESS(audio.mixer_pid))
+ if (IS_PARENT_PROCESS() && HAS_CHILD_PROCESS())
kill(audio.mixer_pid, SIGTERM);
}
/* "ioctl()" expects pointer to 'int' value for stereo flag
(boolean is defined as 'char', which will not work here) */
unsigned int fragment_spec = 0;
- int fragment_size_query;
+ int fragment_size_query = -1;
int stereo = TRUE;
struct
{
static void SendSoundControlToMixerProcess(SoundControl *snd_ctrl)
{
- if (IS_CHILD_PROCESS(audio.mixer_pid))
+ if (IS_CHILD_PROCESS())
return;
if (write(audio.mixer_pipe[1], snd_ctrl, sizeof(SoundControl)) < 0)
static void ReadSoundControlFromMainProcess(SoundControl *snd_ctrl)
{
- if (IS_PARENT_PROCESS(audio.mixer_pid))
+ if (IS_PARENT_PROCESS())
return;
if (read(audio.mixer_pipe[0], snd_ctrl, sizeof(SoundControl))
setup.override_level_sounds :
setup.override_level_music);
- if (IS_CHILD_PROCESS(audio.mixer_pid))
+ if (IS_CHILD_PROCESS())
return;
if (leveldir_current == NULL) /* should never happen */
Error(ERR_EXIT, "leveldir_current == NULL");
+ memset(&snd_ctrl, 0, sizeof(SoundControl)); /* to make valgrind happy */
+
snd_ctrl.active = FALSE;
snd_ctrl.state = type;
snd_ctrl.data_len = strlen(set_identifier) + 1;
{
SoundInfo *snd_info;
int i, k;
+ int num_sounds = getSoundListSize();
#if 0
printf("NEW SOUND %d ARRIVED [%d] [%d ACTIVE CHANNELS]\n",
else if (snd_ctrl.nr >= num_sounds)
return;
+#if 0
snd_info = (IS_MUSIC(snd_ctrl) ? Music[snd_ctrl.nr] : Sound[snd_ctrl.nr]);
+#else
+ snd_info = (IS_MUSIC(snd_ctrl) ? Music[snd_ctrl.nr] :
+ getSoundInfoEntryFromSoundID(snd_ctrl.nr));
+#endif
+
if (snd_info == NULL)
return;
int i;
#if defined(AUDIO_UNIX_NATIVE)
- if (IS_PARENT_PROCESS(audio.mixer_pid))
+ if (IS_PARENT_PROCESS())
{
SendSoundControlToMixerProcess(&snd_ctrl);
return;
return snd_info;
}
-struct FileInfo *getCurrentSoundList()
+int getSoundListSize()
{
- return sound_info->file_list;
+ return (sound_info->num_file_list_entries +
+ sound_info->num_dynamic_file_list_entries);
+}
+
+struct FileInfo *getSoundListEntry(int pos)
+{
+ int num_list_entries = sound_info->num_file_list_entries;
+ int list_pos = (pos < num_list_entries ? pos : pos - num_list_entries);
+
+ return (pos < num_list_entries ? &sound_info->file_list[list_pos] :
+ &sound_info->dynamic_file_list[list_pos]);
+}
+
+static SoundInfo *getSoundInfoEntryFromSoundID(int pos)
+{
+ int num_list_entries = sound_info->num_file_list_entries;
+ int list_pos = (pos < num_list_entries ? pos : pos - num_list_entries);
+ SoundInfo **snd_info =
+ (SoundInfo **)(pos < num_list_entries ? sound_info->artwork_list :
+ sound_info->dynamic_artwork_list);
+
+ return snd_info[list_pos];
+}
+
+int getSoundListPropertyMappingSize()
+{
+ return sound_info->num_property_mapping_entries;
+}
+
+struct PropertyMapping *getSoundListPropertyMapping()
+{
+ return sound_info->property_mapping;
}
void InitSoundList(struct ConfigInfo *config_list, int num_file_list_entries,
struct ConfigInfo *config_suffix_list,
- char **base_prefixes,
- char **ext1_suffixes,
- char **ext2_suffixes)
+ char **base_prefixes, char **ext1_suffixes,
+ char **ext2_suffixes, char **ext3_suffixes,
+ char **ignore_tokens)
{
int i;
sound_info->num_file_list_entries = num_file_list_entries;
sound_info->num_dynamic_file_list_entries = 0;
- sound_info->num_suffix_list_entries = 0;
- for (i=0; config_suffix_list[i].token != NULL; i++)
- sound_info->num_suffix_list_entries++;
-
sound_info->file_list =
- getFileListFromConfigList(config_list, config_suffix_list,
+ getFileListFromConfigList(config_list, config_suffix_list, ignore_tokens,
num_file_list_entries);
sound_info->dynamic_file_list = NULL;
+ sound_info->num_suffix_list_entries = 0;
+ for (i=0; config_suffix_list[i].token != NULL; i++)
+ sound_info->num_suffix_list_entries++;
+
sound_info->suffix_list = config_suffix_list;
/* ---------- initialize base prefix and suffixes lists ---------- */
for (i=0; ext2_suffixes[i] != NULL; i++)
sound_info->num_ext2_suffixes++;
+ sound_info->num_ext3_suffixes = 0;
+ for (i=0; ext3_suffixes[i] != NULL; i++)
+ sound_info->num_ext3_suffixes++;
+
+ sound_info->num_ignore_tokens = 0;
+ for (i=0; ignore_tokens[i] != NULL; i++)
+ sound_info->num_ignore_tokens++;
+
sound_info->base_prefixes = base_prefixes;
sound_info->ext1_suffixes = ext1_suffixes;
sound_info->ext2_suffixes = ext2_suffixes;
+ sound_info->ext3_suffixes = ext3_suffixes;
+ sound_info->ignore_tokens = ignore_tokens;
+
+ sound_info->num_property_mapping_entries = 0;
+
+ sound_info->property_mapping = NULL;
/* ---------- initialize artwork reference and content lists ---------- */
+ sound_info->sizeof_artwork_list_entry = sizeof(SoundInfo *);
+
sound_info->artwork_list =
checked_calloc(num_file_list_entries * sizeof(SoundInfo *));
+ sound_info->dynamic_artwork_list = NULL;
sound_info->content_list = NULL;
sound_info->load_artwork = Load_WAV;
sound_info->free_artwork = FreeSound;
+#if 0
num_sounds = sound_info->num_file_list_entries;
Sound = (SoundInfo **)sound_info->artwork_list;
+#endif
}
static MusicInfo *Load_MOD(char *filename)
else if (stereo_position > SOUND_MAX_RIGHT)
stereo_position = SOUND_MAX_RIGHT;
+ memset(&snd_ctrl, 0, sizeof(SoundControl)); /* to make valgrind happy */
+
snd_ctrl.active = TRUE;
snd_ctrl.nr = nr;
snd_ctrl.volume = volume;
if (!audio.sound_available)
return;
+ memset(&snd_ctrl, 0, sizeof(SoundControl)); /* to make valgrind happy */
+
snd_ctrl.active = FALSE;
snd_ctrl.nr = nr;
snd_ctrl.state = state;
LoadArtworkConfig(sound_info);
ReloadCustomArtworkList(sound_info);
+
+#if 0
+ num_sounds = getSoundListSize();
+#endif
}
static void ReloadCustomMusic()
void FreeAllSounds()
{
- FreeCustomArtworkList(sound_info);
+ FreeCustomArtworkLists(sound_info);
}
void FreeAllMusic()