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

Erik de Castro Lopo mle+la at mega-nerd.com
Tue Jun 21 07:57:55 UTC 2011

Dan Muresan wrote:

> > I never much liked the VIO layer. It was only ever added because
> > a large number of people requested it. I think its fragile and
> > it exposes too much of libsndfile internals to the user.
> Well, it doesn't seem to expose anything other than the set of chosen
> functions (read / write / seek etc) -- no data structure, no special
> #include's...

Yes, but it means that I can't decide to replace all uses
of write() with pwrite() for instance. At one stage I
though this was a good idea.

> My problem is that the VIO API isn't (yet) clearly specified /
> documented (e.g. what the virtual read / write should return for
> errors, for EOF, whether it's acceptable to return short counts). You
> may also be missing an errno-like VIO function, but I can't comment
> much as I don't quite understand the existing sf_error() stuff.

This lack of clarity is one of the things I don't like.
> By "fragile" you probably mean that the set of VIO functions, or their
> API, might change in the future?

More that bugs or inconsistency in the user provided VIO functions 
look like libsndfile bugs.

> > I would be surprised if reset-by-seek didn't work on standard
> > WAV/AIFF etc files with PCM data accessed via the standard
> > sf_read/write* functions.
> Probably, but since I'm using sndfile, I don't want to special-case
> formats in my app...

You shouldn't have too.

Anything that you can do with 16 bit PCM WAV files that you can't
do with FLAC (and libsndfile doesn't say there is an error) is
probably a bug.

> At the very least, does a successful sf_seek()
> guarantee that all errors have been cleared and that future I/O will
> occur undisturbed (in the places where the file contains no errors,
> obviously)?

It should for all the standard file formats. If it doesn't for
FLAC then thats a bug that I would try to fix or make sure that
libsndfile notifies the client program that something has gone

Erik de Castro Lopo

More information about the Linux-audio-dev mailing list