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

Erik de Castro Lopo mle+la at mega-nerd.com
Tue Jun 14 08:44:13 UTC 2011

Dan Muresan wrote:

> >> be nice to add a sf_reset() function or a SF_RESET sf_command()
> >> parameter.
> >
> > What problem does that fix? Do you even know if there is a problem?
> The problem of a SNDFILE becoming invalid after a cancelled I/O. Yes,
> there is a problem -- valgrind reports nasty memory errors (and
> eventually I get a segfault) if I don't re-open the SNDFILE.

I can't say I'm all that surpised, this is not something that was
designed to work.

That leaves you two options:

  a) Debug the problem, come up with a fix and send a patch.

  b) Work around it.
> [ If you meant I should test the sf_seek() trick first -- I doubt that
> testing a few sf_seek()s on a few FLAC files will reliably establish
> whether sf_seek() really does reset all encoder and decoder structure
> under all circumstances. Especially since you said you weren't sure
> yourself. ]

The problem you face is difficult enough with file formats that are
supported natively by libsndfile. It will be much more difficult for
the formats that require external libraries because the fix may
require fixes in libFLAC, libogg or libvorbis.

Erik de Castro Lopo

More information about the Linux-audio-dev mailing list