Hey :) More FREE STUFF !!!  8)

The attachments implement code to play wav and mp3 files via OpenAL, and without using GLUT or similar support libs.
That's cool - I don't think you'll find any examples on the internet which play MP3 without help (I looked).
So basically, I just lifted the MP3 player code straight out of my old DirectSound engine.

These files compliment the OpenAL headers (AL.inc, ALC.inc) and OpenAL support lib (GLADD) which I have posted recently.
The implementation is not sophisticated (I wrote it as five classes, before boiling back down into two) - this makes it perfect to use as the basis for a more serious project, or just use it how it is.

Enjoy :)
Posted on 2010-07-05 06:30:14 by Homer
I've made some improvements to the audio engine.

The worker thread responsible for refilling streaming buffers will now Wait on a manual-reset event, whose purpose is to indicate that at least one SoundSource is currently playing Streamed audio. This flag is set and reset automatically from the Play and Stop methods.

When there is no sounds playing, the worker will wait up to 2 seconds for a sound to start playing, before checking whether the application is closing (and thus the thread should terminate), and otherwise sleeping for 250 ms.

The critical section around the refill call was left in place.
This means that while sounds are playing, the worker thread will consume as much processor time as it requires to keep the streaming buffers refilled, at all costs (!) ... but will effectively use zero cpu time when no sounds are playing.

There needs to be a way to somehow scale this, I'm not sure how yet, because it's not good to run out of streaming buffers, but we have other code that will require cpu time and there will at some point be a fight over it.

If you would like me to continue posting updates for this module, just say so and it will be done :)

Also - I am HAPPY to discuss this code, even if you think your questions are dumb, feel free to ask them, that's why this place exists :)
Posted on 2010-07-15 08:05:47 by Homer