O'Reilly logo

Android NDK Game Development Cookbook 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

We have learned how to play short audio samples, and now we are ready to organize sound streaming. This recipe explains how to organize a buffer queue to allow on-the-fly sound generation and streaming.

Getting ready

We suppose that the reader is already familiar with our AudioSource and iWaveDataProvider classes described in the previous recipe.

How to do it…

  1. First, we enrich iWaveDataProvider with the additional methods IsStreaming(), which indicates that the data from this provider should be read in small chunks, and StreamWaveData(), which actually reads a single chunk:
    class iWaveDataProvider: public iObject
      …
      virtual bool IsStreaming() const { return false; }
      virtual int  StreamWaveData( int Size ) { return 0; }
      …
    };
  2. Next we write ...

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