static int _seek_to_beginning_of_data(FILE *fp) { DataChunk temp; if (read_data_chunk(fp, &temp)) { return EXIT_FAILURE; } return EXIT_SUCCESS; }
static int _process_chunk(QSP_ARG_DECL Image_File *ifp, Wav_Chunk_Hdr *wch_p) { // See what kind of chunk it is... if( !strncmp(wch_p->wch_label,"fmt ",4) ){ fprintf(stderr,"format chunk seen!\n"); return read_format_chunk(ifp,wch_p); } else if( !strncmp(wch_p->wch_label,"data",4) ){ fprintf(stderr,"data chunk seen!\n"); if( read_data_chunk(ifp,wch_p) != 0 ) return -1; return 1; // special return val for data chunk } else if( !strncmp(wch_p->wch_label,"LIST",4) ){ fprintf(stderr,"list chunk seen!\n"); return ignore_chunk(ifp,wch_p); } else { char s[5]; strncpy(s,wch_p->wch_label,4); s[4]=0; if( is_printable(s) ){ sprintf(ERROR_STRING, "read_next_chunk_header (%s): unrecognized chunk label \"%s\"!?\n", ifp->if_name,s); warn(ERROR_STRING); } else { wav_error("unprintable chunk label",ifp); } // should read the chunk data!? return 0; } }
int read_wav_file_header(FILE *fp, WavFileHeader *header) { RiffChunk riff_chunk; FmtChunk fmt_chunk; DataChunk data_chunk; if (read_riff_chunk(fp, &riff_chunk)) { return EXIT_FAILURE; } if (read_fmt_chunk(fp, &fmt_chunk)) { return EXIT_FAILURE; } if (read_data_chunk(fp, &data_chunk)) { return EXIT_FAILURE; } header->r = riff_chunk; header->f = fmt_chunk; header->d = data_chunk; return EXIT_SUCCESS; }