[Openal] Playing finite looping sounds
Chris Robinson
chris.kcat at gmail.com
Tue Jun 19 09:19:55 PDT 2007
On Tuesday 19 June 2007 05:13:37 am Agustin Rubio Mingorance wrote:
> Hi,
>
> I have writen the next function to play finite looping sounds:
>
> When I use if with buffers created with alutCreateBufferFromFile
> (file_str), it works fine.
> When I use an OGG file (loaded with VORBIS extension), the sound is
> played in an infinite
> loop whenever loop!=1;
>
> Am I doing something wrongly?
Buffers created from the Vorbis extension are implemented using buffer
callbacks, and buffer callbacks do not play well with looping. Use of the
Vorbis extension is generally discouraged, in favor of using libvorbisfile to
decode/stream the file yourself and buffering it to AL buffers like normal. I
think the current plan is to remove the Vorbis extension from the SI since it
uses the broken buffer callback method, as well as removing the buffer
callback extension, though Vorbis may or may not come back when a more
suitable method is found.
Also, you may not want to use buffer queues to emulate looping sounds. On
certain systems, buffer queues can be a bit more resource intensive than a
normal buffer (drivers may, for instance, stream sources that use buffer
queues to the card instead of storing the buffers on the card; and this could
quickly saturate the PCI BUS if you use too many). I have patches waiting for
the SI that implement reading the byte/sample/seconds offset from a source,
and it would be trivial to detect loops with that to subsequently remove the
looping flag from the source when the loop limit is detected.
More information about the Openal
mailing list