O'Reilly logo

Mastering Android NDK by Viktor Latypov, Sergey Kosarevsky

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Streaming sounds

Now that we can play short audio samples, it is time to organize our audio system into classes and take a closer look at the 2_Streaming example. Long audio samples, such as background music, require a lot of memory in a decompressed form. Streaming is a technique to decompress them in small chunks, piece by piece. The clAudioThread class manages the initialization and does everything from the previous sample except playing the sound:

 class clAudioThread: public iThread { public: clAudioThread() : FDevice( nullptr ) , FContext( nullptr ) , FInitialized( false ) {} virtual void Run() { if ( !LoadAL() ) { return; } FDevice = alcOpenDevice( nullptr ); FContext = alcCreateContext( FDevice, nullptr ); alcMakeContextCurrent( FContext ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required