[LAD] [LAU] cancelling I/O with libsndfile

Dan Muresan danmbox at gmail.com
Tue Jun 21 06:24:17 UTC 2011


>> does libsndfile ever clear the error flag on a file? E.g. if there is
>> a decoding error in a FLAC, and I sf_seek() back to the beginning,
>> will sf_read_() work "normally" again?
>
> Maybe not on FLAC. I would suggest  that you write a small
> standalone test program to  test this and if you don't

With a small standalone broken FLAC file :) FLAC was just an example.

What seems to happen is that after a decoder error, a subsequent
sf_seek() fails. I guess the only reliable thing to do is to close &
reopen the file on error -- which is inefficient because a bunch of
data structure get re-allocated, and a bunch of meta-data gets
re-read.

That's why I thought a sf_reset() would be useful. For example FLAC
has FLAC__stream_decoder_reset(). Granted, on some formats (PCM)
sf_reset() might work efficiently, on others inefficiently, and on
others yet it might do a close & re-open (or return FALSE).

Even better would be some way to save & restore the entire decoder (or
encoder) state. That would allow a player to go back to a known point
instantly, without any gaps in playback. But, of course, most external
file format libraries don't have the means to cooperate with that.

-- Dan



More information about the Linux-audio-dev mailing list