[Openal] resuming audio files in OpenAL1.0 and 1.1

Garin Hiebert garinh at cheesetoast.net
Thu Aug 4 08:29:55 PDT 2005


> This allows me to resume in the most simple way, but how can I resume
> playback from an arbitrary point in the wav data stream?

If you have a buffer attached to a source and playing, call  
alSourcePause, and then at a later time want to resume playback, you  
can call alSourcePlay on that source and it will resume playing.   
This will work on AL 1.0 or 1.1.

If you have a buffer attached to a source and playing, stop it,  
attach another buffer to the source, stop it, attach the first buffer  
back to the source and want to "resume" from where it was stopped  
before, then the solution may be different for 1.0 and 1.1:
     1.0 -- a) Instead of attaching the full buffer of data, you  
could attach a new buffer containing part of the first buffer's data
               b) Any source which needs to be flexible in this way  
could be set up as a streaming source -- use a series of small queued  
buffers to attach data to the source from whatever buffer you want.
     1.1 -- a) Use Get/Set offset for exact control over playback.
               b) Streaming, as with 1.0.

Which way you want to go depends on your application.  If you are  
using a lot of sources and all the sources you will be controlling  
need the ability to switch buffers and jump to arbitrary positions in  
the new buffer, then you should just use AL 1.1 -- that's certainly  
easiest.  If you only need this flexibility for a few sources and the  
rest of your app would be perfectly good on 1.0, then you might want  
to consider streaming for the "resumable" sources.

Additional notes:

ALUT --  ALUT will still be there for 1.1 (for compatibility with  
1.0).  Also, the ALUT code in the Windows branch is BSD-licensed --  
so feel free to grab the WAV-file loading code out of there and use  
it in your app directly (if you're just dealing with WAV files, then  
this is certainly the way to go).  alutInit and alutExit  
functionality is very simple and best done in your app anyways for  
better error handling.

Garin




More information about the Openal mailing list