I added LibFlac to the xcode project. Then I added decode / main.c from Libflac to my project. I passed infile.flac and executed the project executable, but it gave the following error.
decoding: FAILED state: FLAC__STREAM_DECODER_END_OF_STREAM logou
t
Here is main.c
int main(int argc, char *argv[]) { FLAC__bool ok = true; FLAC__StreamDecoder *decoder = 0; FLAC__StreamDecoderInitStatus init_status; FILE *fout; const char *infile = "infile.flac"; const char *outfile = "outfile.wav"; if((fout = fopen("infile.flac", "wb")) == NULL) { fprintf(stderr, "ERROR: opening %s for output\n", argv[2]); return 1; } if((decoder = FLAC__stream_decoder_new()) == NULL) { fprintf(stderr, "ERROR: allocating decoder\n"); fclose(fout); return 1; } (void)FLAC__stream_decoder_set_md5_checking(decoder, true); init_status = FLAC__stream_decoder_init_file(decoder, infile, write_callback, metadata_callback, error_callback, fout); if(init_status != FLAC__STREAM_DECODER_INIT_STATUS_OK) { fprintf(stderr, "ERROR: initializing decoder: %s\n", FLAC__StreamDecoderInitStatusString[init_status]); ok = false; } if(ok) { ok = FLAC__stream_decoder_process_until_end_of_stream(decoder); fprintf(stderr, "decoding: %s\n", ok? "succeeded" : "FAILED"); fprintf(stderr, " state: %s\n", FLAC__StreamDecoderStateString[FLAC__stream_decoder_get_state(decoder)]); } FLAC__stream_decoder_delete(decoder); fclose(fout); return 0; }
Please help me. why am i getting this error?
source share