Re: [linux-audio-dev] memory-mapped wav files

From: <james@email-addr-hidden-dot-dat.net>
Date: Fri Jul 14 2006 - 02:06:23 EEST

On Thu, 13 Jul, 2006 at 04:45PM -0400, Stephen Sinclair spake thus:
> A thought occured to me recently...
>
> If I am writing an application which needs to stream a large wav file,
> I am having to write something which reserves some memory, and loads
> pieces of the wav file from disk on request. Say I need to be able to
> jump around the file a bit, I would have to detect when the piece is
> not available and load it in as appropriate.
>
> ... which I realized is exactly what the OS VM paging system does.
> So, has anyone tried using memory-mapped files for streaming audio
> data? (obviously, I mean, in a non-realtime thread, using a buffer).
> Or would this be totally inefficient?
>
> I was thinking it could really simplify programming, just directly
> accessing parts of the wav file as needed, and letting the OS load it
> up into physical memory when it wants to.

It's perfectly sensible. I do it a lot, because it's easy. The
problem is having to load the whole thing into memory before you
start, which makes things alow to start. If you're playing linearly,
to solve this, you need can load it in chunks and start playing the
first chunk straight away.

> Just curious.
>
>
> Steve
>
Received on Fri Jul 14 04:15:11 2006

This archive was generated by hypermail 2.1.8 : Fri Jul 14 2006 - 04:15:11 EEST