Introduction
We are looking for a truly portable implementation of the sound playback for desktop PCs and mobile devices. We propose using the OpenAL library, since it is a well-established library on a desktop, and using it will make easier porting of existing games to Android. In this chapter we organize a small multithreaded sound streaming library.
Audio playback is inherently an asynchronous process, so the decoding and control of sound hardware should be done on a separate thread and controlled from other dedicated threads. For example, when a player presses a fire button, or a character in an arcade game hits the ground, we might just ask the system to start playback of an audio file. The latency of this operation in games usually does not matter so much.
From the digital perspective, a monaural or monophonic sound (mono for short), is nothing more than a long one-dimensional array of values representing a continuous signal. Stereophonic or multichannel sounds are represented by a few...