- snd_ctrl.nr = nr;
- snd_ctrl.state = state;
-
-#if defined(TARGET_SDL)
-
- if (state & SND_CTRL_FADE)
- {
- int i;
-
- for (i=0; i<audio.channels; i++)
- if (i != audio.music_channel || snd_ctrl.music)
- Mix_FadeOutChannel(i, SOUND_FADING_INTERVAL);
- if (state & SND_CTRL_MUSIC)
- Mix_FadeOutMusic(SOUND_FADING_INTERVAL);
- }
- else
- {
- int i;
-
- for (i=0; i<audio.channels; i++)
- if (i != audio.music_channel || snd_ctrl.music)
- Mix_HaltChannel(i);
- if (state & SND_CTRL_MUSIC)
- Mix_HaltMusic();
- }
-
-#elif !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");
- audio.sound_available = audio.sound_enabled = FALSE;
- return;
- }
-#else /* PLATFORM_MSDOS */
- sound_handler(snd_ctrl);
-#endif
-}
-
-ListNode *newListNode()
-{
- return checked_calloc(sizeof(ListNode));
-}
-
-void addNodeToList(ListNode **node_first, char *key, void *content)
-{
- ListNode *node_new = newListNode();
-
-#if 0
- printf("LIST: adding node with key '%s'\n", key);
-#endif
-
- node_new->key = getStringCopy(key);
- node_new->content = content;
- node_new->next = *node_first;
- *node_first = node_new;
-}
-
-void deleteNodeFromList(ListNode **node_first, char *key,
- void (*destructor_function)(void *))
-{
- if (node_first == NULL || *node_first == NULL)
- return;
-
-#if 0
- printf("[CHECKING LIST KEY '%s' == '%s']\n",
- (*node_first)->key, key);
-#endif
-
- if (strcmp((*node_first)->key, key) == 0)
- {
-#if 0
- printf("[DELETING LIST ENTRY]\n");
-#endif
-
- free((*node_first)->key);
- if (destructor_function)
- destructor_function((*node_first)->content);
- *node_first = (*node_first)->next;
- }
- else
- deleteNodeFromList(&(*node_first)->next, key, destructor_function);
-}
-
-ListNode *getNodeFromKey(ListNode *node_first, char *key)
-{
- if (node_first == NULL)
- return NULL;
-
- if (strcmp(node_first->key, key) == 0)
- return node_first;
- else
- return getNodeFromKey(node_first->next, key);
-}
-
-int getNumNodes(ListNode *node_first)
-{
- return (node_first ? 1 + getNumNodes(node_first->next) : 0);
-}
-
-void dumpList(ListNode *node_first)
-{
- ListNode *node = node_first;
-
- while (node)
- {
- printf("['%s' (%d)]\n", node->key,
- ((SoundInfo *)node->content)->num_references);
- node = node->next;
- }
-
- printf("[%d nodes]\n", getNumNodes(node_first));
-}
-
-static void LoadSoundsInfo()
-{
- char *filename = getCustomSoundConfigFilename();
- struct SetupFileList *setup_file_list;
- int i;
-
- /* always start with reliable default values */
- for (i=0; i<num_sounds; i++)
- sound_effect[i].filename = NULL;
-
- if (filename == NULL)
- return;
-
- if ((setup_file_list = loadSetupFileList(filename)))
- {
- for (i=0; i<num_sounds; i++)
- sound_effect[i].filename =
- getStringCopy(getTokenValue(setup_file_list, sound_effect[i].text));