Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7040381
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:54:42+00:00 2026-05-28T01:54:42+00:00

I have added LibFlac in xcode project . Then I added decode/main.c from Libflac

  • 0

I have added LibFlac in xcode project . Then I added decode/main.c from Libflac in my project.
I passed infile.flac and run executable of project but it is giving 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(argc != 3) {
        fprintf(stderr, "usage: %s infile.flac outfile.wav\n", argv[0]);
        return 1;
    }
    */

    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, /*client_data=*/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 I am getting this error ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T01:54:42+00:00Added an answer on May 28, 2026 at 1:54 am

    fopening your input file with “wb” will truncate your infile on opening it. That can’t be what you want, right?
    I think you really mean;

    if((fout = fopen(outfile, "wb")) == NULL) {
    

    There seems to be some confusion how the FLAC sample works.

    FLAC__stream_decoder_init_file
    

    opens the file you give it the filename to for decoding and sets up callbacks for the decoding.

    FLAC__stream_decoder_process_until_end_of_stream
    

    decodes the file and for every decoded frame it calls the write_callback function provided in the call to FLAC__stream_decoder_init_file with the parameter given as last parameter to it.

    In other words, all the work of writing the file is done in write_callback. That’s where you are provided with the decoded data and you should generate and write the output file, frame by frame. If you look at the sample at http://flac.cvs.sourceforge.net/viewvc/flac/flac/examples/c/decode/file/main.c?view=markup which seems to be what you’ve copied to start with, that’s exactly what it does.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have added a controller to my project named UserManager (automatically generated from the
I have added the required assemblies and registered the NVelocityViewFactory in global.asax.cs page but
I have added an EventHandler for the Click-event to a picturebox but on runtime
I have added a new job in my hudson server which builds the project
I have added a simple .gif file into Resources folder in my project. Now
I have added the back ground color as an image to uiwebview but it
I have added multiple app.config (each with a differet name) files to a project,
I have added above code in my WPF from which include animated GIF image,
I have added meta tag description in my page, but it is not displaying
I have added a resource in my project. Its size is 4.096 byte. i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.