+#if 0
+ printf("DEBUG: file '%s', chunk id '%s', chunk size '%d' [%d]\n",
+ filename, chunk_name, chunk_size, feof(file));
+#endif
+
+ if (strcmp(chunk_name, "fmt ") == 0)
+ {
+ /* read header information */
+ for (i=0; i < MIN(chunk_size, WAV_HEADER_SIZE); i++)
+ sound_header_buffer[i] = fgetc(file);
+
+ if (chunk_size > WAV_HEADER_SIZE)
+ ReadUnusedBytesFromFile(file, chunk_size - WAV_HEADER_SIZE);
+ }
+ else if (strcmp(chunk_name, "data") == 0)
+ {
+ snd_info->data_len = chunk_size;
+ snd_info->data_ptr = checked_malloc(snd_info->data_len);
+
+ /* read sound data */
+ if (fread(snd_info->data_ptr, 1, snd_info->data_len, file) !=
+ snd_info->data_len)
+ {
+ Error(ERR_WARN,"cannot read 'data' chunk of sound file '%s'",filename);
+ fclose(file);
+ free(filename);
+ return FALSE;
+ }
+
+ /* check for odd number of sample bytes (data chunk is word aligned) */
+ if ((chunk_size % 2) == 1)
+ ReadUnusedBytesFromFile(file, 1);
+ }
+ else /* unknown chunk -- ignore */
+ ReadUnusedBytesFromFile(file, chunk_size);