Skip to content

Write callback not called after seeking to frame within last block #906

Description

@sbooth

Thank you for FLAC!

I've noticed that after a seek to a sample number that is within the last block the stream decoder no longer calls the write callback. This seems contrary to the documentation for FLAC__stream_decoder_seek_absolute which states

/** Flush the input and seek to an absolute sample.
 *  Decoding will resume at the given sample.  Note that because of
 *  this, the next write callback may contain a partial block.

As an example, I've been using the following file for testing:

METADATA block #0
  type: 0 (STREAMINFO)
  is last: false
  length: 34
  minimum blocksize: 4096 samples
  maximum blocksize: 4096 samples
  minimum framesize: 23 bytes
  maximum framesize: 5975 bytes
  sample_rate: 44100 Hz
  channels: 5
  bits-per-sample: 16
  total samples: 258048
  MD5 signature: e0aec84b52ef7ad5f9619e24fb357684

If I call FLAC__stream_decoder_seek_absolute with a sample >= (258048-4096) the function returns 1, however further calls to FLAC__stream_decoder_process_single no longer call the write callback/produce audio. I expected that the remaining samples in the file would be sent to the write callback.

I believe this may be because the stream decoder's state is FLAC__STREAM_DECODER_END_OF_STREAM following the seek but I am not familiar enough with libFLAC to understand the root cause and if this is the expected behavior.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions