Chapter 5. Cross-platform Audio Streaming
In this chapter, we consider the last non-visual component needed to build interactive mobile applications. We are looking for a truly portable implementation of audio playback for Android and desktop PCs. We propose using the OpenAL library, since it is a well-established library on desktop platforms. Audio playback is inherently an asynchronous process, so the decoding and submitting of data to the sound API should be done on a separate thread. We will create an audio streaming library based on the multi-threading code from Chapter 3, Networking.
Raw uncompressed audio can take up a lot of memory, so compressed formats of different flavors are used quite often. We consider some of them in this chapter and will show you how to play them in Android using native C++ code and popular third-party libraries.