rnd-20040103-1-src
[rocksndiamonds.git] / src / libgame / sound.c
index c8d61a828abbd877fee2c5d641132d970089a470..b9fd88c66a460dd72e58300cba60644236440794 100644 (file)
@@ -569,8 +569,7 @@ static void ReadReloadInfoFromPipe(SoundControl *snd_ctrl)
                                     &setup.override_level_sounds :
                                     &setup.override_level_music);
 
-  if (set_identifier)
-    free(set_identifier);
+  checked_free(set_identifier);
 
   set_identifier = checked_malloc(snd_ctrl->data_len);
 
@@ -579,16 +578,12 @@ static void ReadReloadInfoFromPipe(SoundControl *snd_ctrl)
 
   if (ti == NULL)
     ti = *ti_ptr = checked_calloc(sizeof(TreeInfo));
-  if (leveldir_current->fullpath != NULL)
-    free(leveldir_current->fullpath);
-  if (leveldir_current->sounds_path != NULL)
-    free(leveldir_current->sounds_path);
-  if (leveldir_current->music_path != NULL)
-    free(leveldir_current->music_path);
-  if (ti->basepath != NULL)
-    free(ti->basepath);
-  if (ti->fullpath != NULL)
-    free(ti->fullpath);
+
+  checked_free(leveldir_current->fullpath);
+  checked_free(leveldir_current->sounds_path);
+  checked_free(leveldir_current->music_path);
+  checked_free(ti->basepath);
+  checked_free(ti->fullpath);
 
   if (read(audio.mixer_pipe[0], set_identifier,
           snd_ctrl->data_len) != snd_ctrl->data_len ||
@@ -1885,15 +1880,6 @@ void LoadCustomMusic_NoConf(void)
   struct dirent *dir_entry;
   int num_music = getMusicListSize();
 
-#if 0
-  int ii;
-  for (ii = 0; ii < num_music; ii++)
-  {
-    struct FileInfo *music = getMusicListEntry(ii);
-    printf("sound process: music %d: '%s'\n", ii, music->filename);
-  }
-#endif
-
   if (!audio.sound_available)
     return;
 
@@ -1925,14 +1911,11 @@ void LoadCustomMusic_NoConf(void)
     boolean music_already_used = FALSE;
     int i;
 
+    /* skip all music files that are configured in music config file */
     for (i = 0; i < num_music; i++)
     {
       struct FileInfo *music = getMusicListEntry(i);
 
-#if 0
-      printf("sound process: '%s'\n", music->filename);
-#endif
-
       if (strcmp(basename, music->filename) == 0)
       {
        music_already_used = TRUE;
@@ -1977,10 +1960,6 @@ void LoadCustomMusic_NoConf(void)
   closedir(dir);
 
   draw_init_text = FALSE;
-
-  if (num_music_noconf == 0)
-    Error(ERR_WARN, "cannot find any valid music files in directory '%s'",
-         music_directory);
 }
 
 int getSoundListSize()
@@ -2400,8 +2379,7 @@ void FreeSound(void *ptr)
 #endif
   }
 
-  if (sound->source_filename)
-    free(sound->source_filename);
+  checked_free(sound->source_filename);
 
   free(sound);
 }