[flac-dev] FLAC__stream_decoder_seek_absolute calling write callback

Tamás Zahola tzahola at gmail.com
Tue Jan 19 13:15:08 PST 2016


> Hi,
> Sorry for the tardy response to this. I've now read your email a number of
> times and I'm still not sure what needs to be done.
> Maybe it would help if you could explain the following:
> * What is actually happening.
> * What you expect to happen and how that differs from what is happening.
> * Propose a fix.
> Once thing that may actually help is a small chunk of code demonstrating
> the problem.

Thanks for your response!
Here's an example:

    #include <iostream>
    #include <FLAC++/all.h>

    int main(int argc, const char * argv[]) {
        class Decoder : public FLAC::Decoder::File {
        protected:
            virtual ::FLAC__StreamDecoderWriteStatus
write_callback(const ::FLAC__Frame *frame, const FLAC__int32 * const
buffer[]) override {
                std::cout << "write_callback called!" << std::endl;
                abort();
                return
FLAC__StreamDecoderWriteStatus::FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE;
            }

            virtual void
error_callback(::FLAC__StreamDecoderErrorStatus status) override {}
        } decoder;

        decoder.init("sample.flac");
        decoder.process_until_end_of_metadata();
        decoder.seek_absolute(1);

        return 0;
    }

Despite not calling `process_single`, this snippet crashes with
"write_callback called!" because internally `seek_absolute(sample)`
processes the frame which contains `sample`. My question was whether
this behaviour was intentional/documented (I haven't found it being
mentioned in the docs) and whether if it happens always (or e.g. only
if I specify a sample that's not on a frame boundary, etc.)?

Best regards,
Tamas Zahola


More information about the flac-dev mailing list