static void ReloadCustomSounds();
static void ReloadCustomMusic();
-static void FreeSound(SoundInfo *);
+static void FreeSound(void *);
#if defined(PLATFORM_UNIX)
static int OpenAudioDevice(char *audio_device_name)
static void LoadCustomSound(SoundInfo **snd_info, char *basename)
{
char *filename = getCustomSoundFilename(basename);
+ ListNode *node;
if (filename == NULL) /* (should never happen) */
{
and a fallback to the existing sound is done. */
#if 1
- printf("[sound '%s' already exists]\n", filename);
+ printf("[sound '%s' already exists (same list entry)]\n", filename);
#endif
return;
}
+#if 1
+ printf("[decrementing reference counter of sound '%s']\n", filename_old);
+#endif
+
if (--(*snd_info)->num_references <= 0)
{
#if 1
}
}
+ /* check if this sound already exists in the list of sounds */
+ node = getNodeFromKey(SoundFileList, filename);
+ if (node)
+ {
+#if 1
+ printf("[sound '%s' already exists (other list entry)]\n", filename);
+#endif
+
+ *snd_info = (SoundInfo *)node->content;
+ (*snd_info)->num_references++;
+
+ return;
+ }
+
*snd_info = Load_WAV(filename);
(*snd_info)->num_references = 1;
while (node)
{
- printf("['%s']\n", node->key);
+ printf("['%s' (%d)]\n", node->key,
+ ((SoundInfo *)node->content)->num_references);
node = node->next;
}
#if 1
for (i=0; i<num_sounds; i++)
- printf("'%s' -> '%s'\n", sound_effect[i].text, sound_effect[i].filename);
+ {
+ printf("'%s' ", sound_effect[i].text);
+ if (sound_effect[i].filename)
+ printf("-> '%s'\n", sound_effect[i].filename);
+ else
+ printf("-> UNDEFINED [-> '%s']\n", sound_effect[i].default_filename);
+ }
#endif
}
}
InitReloadSoundsOrMusic(set_name, SND_RELOAD_MUSIC);
}
-void FreeSound(SoundInfo *sound)
+void FreeSound(void *ptr)
{
+ SoundInfo *sound = (SoundInfo *)ptr;
+
if (sound == NULL)
return;