O'Reilly logo

Android NDK Beginner's Guide by Sylvain Ratabouil

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

Time for action – creating OpenSL ES engine and output

First, let’s create this new class to manage sounds:

  1. Open project DroidBlaster and create a new file jni/SoundService.hpp. First, include OpenSL ES headers: the standard header OpenSLES.h, OpenSLES_Android.h, and OpenSLES_AndroidConfiguration.h. The two latter define objects and methods , and are specifically created for Android. Then create SoundService class to do the following:
    • Initialize OpenSL ES with the method start()
    • Stop the sound and release OpenSL ES with the method stop()

    There are two main kinds of pseudo-object structures (that is, containing function pointers applied on the structure itself like a C++ object with this) in OpenSL ES:

    • Objects: These are represented by a SLObjectItf ...

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