[LAD] A question about audio file interfaces
paul at linuxaudiosystems.com
Sun Dec 1 14:08:37 UTC 2013
On Sun, Dec 1, 2013 at 6:48 AM, Fons Adriaensen <fons at linuxaudio.org> wrote:
> No, it's just about the code to read/write the files - what
> it should do or not do in order to make it perform well with
> 'smart' disk access threads which will have there own ways to
> organise buffering. If two (or more) such schemes are used on
> top of each other the result could be worse than with just
> one of them.
linus has always insisted (rightly or wrongly) that user-space code should
assume omnipotence and beneficence on the part of the kernel with respect
to I/O. there are plenty of people who don't agree with him, hence things
like the madvise() call. but i think that it is a pretty good bet for most
cases. in ardour, the purpose of the disk i/o thread (the "butler") is
primarily to organize buffering within user space based on observed (but
very occasional) delays in I/O. it is not attempting to do better than the
kernel in handling read-ahead and in fact for quite a lot of situations,
ardour really does rely on the kernel's own buffering to do a good job. we
only buffer "more" because of the delays that have been seen over the
years, which suggest that is expedient to not rely on data being available
from read() within any reliable time frame less than a few seconds.
> * use mmap, read/write or stdio ?
several years ago, linus told me in no uncertain terms not to use mmap for
disk i/o. his perspective is that even though it works, the kernel is not
developed or optimized with this in mind, and that normal streaming i/o
interfaces like read/write will always be the right path.
if you use stdio, you add an additional, hidden layer of buffering that
really provides very few benefits given that you will likely be
reading/writing fairly large chunks already.
read and write are certainly my preference, although to handle the
possibility of multithreaded access to the same file descriptor, pread and
pwrite are attractive.
> * any point in implementing things like gather/scatter, or
> async access ?
the kernel provides internal implementations of this, as does the firmware
on almost any storage device. probably not worth reimplementing (especially
given that you don't have any special knowledge about the device)
> * for multichannel: offer de-interleaved access, sparse
> channel sets, etc. ?
seems application-centric. some cases would need this some would not.
i would still try to add support for this format to libsndfile, so as to
gain all the benefits it offers from an application perspective.
> I have various use cases for such a library, one of them being
> to replace the private .ald format used by Aliki and some other
> apps. But the code should also work efficiently with e.g. a DAW
> having maybe a hundred files open at any time, and multiple
> streams from the same file.
> A world of exhaustive, reliable metadata would be an utopia.
> It's also a pipe-dream, founded on self-delusion, nerd hubris
> and hysterically inflated market opportunities. (Cory Doctorow)
> Linux-audio-dev mailing list
> Linux-audio-dev at lists.linuxaudio.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Linux-audio-dev