Menu

#57 Load file into memory if stream length can't be determined

open
nobody
None
3
2003-11-09
2003-11-09
Chad Austin
No

Per e-mail with Jason Winnebeck:

Hi Jason,

Jason Winnebeck wrote:
> Hello, I am new to this list and the Audiere library.
I'm going to start
> by asking a question I'm sure is FAQ fodder for this
list, but the FAQ
> didn't answer it and the archives were down at the time.

I'll go ahead and add it to the FAQ.

> It seems that Audiere does not actually load any
sounds until you play them
> for the first time. This causes sporadic pauses in
my game when sounds are
> played. How can I pre-cache the sounds during
loadtime so that they do not
> stop the game for the first play?

The OpenSound function has two modes of operation:
streaming and nonstreaming. If you pass streaming =
false as the last argument to OpenSound, Audiere tries
to load the sound into memory before playing it. (That
is, if it can. Some sound types, such as MP3, can't be
loaded into memory -- at least not yet. I recommend
WAV or Ogg Vorbis.) Pass true as the third argument if
you want to stream the audio (background music), and
false if you don't (sound effects). If you omit the
argument entirely, it defaults to false.

I'm considering adding a feature where it will still
load the *file* into memory if the stream's length
can't be determined. So it's still streaming, just not
off of a slow disk...

Hope that helps,
Chad

Discussion


Log in to post a comment.