Package 

Object AudioEngine


  • 
    public class AudioEngine
    
                        

    Provides control over the Rive audio engine (powered by https://miniaud.io/).

    The audio engine uses reference counting to manage its start/stop state. Multiple "stakeholders" (e.g., CommandQueue instances and the legacy WorkerImpl) can acquire/release references independently. The engine is started when the ref count becomes 0 and stopped when it reaches 0.

    This ultimately allows pausing audio (stopping the engine's playback) and resuming it (starting it again) when the app is backgrounded. We ref count so that a stakeholder, e.g. a command queue, can be destroyed without stopping the audio engine for other instances that may be playing.

    Audio playback and miniaudio may be excluded from the build via a Gradle property, in which case these methods will no-op.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      public final static AudioEngine INSTANCE
    • Method Summary

      Modifier and Type Method Description
      final Unit acquire() Acquire a reference to the audio engine, incrementing the ref count.
      final Unit release() Release a reference to the audio engine, decrementing the ref count.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • acquire

         final Unit acquire()

        Acquire a reference to the audio engine, incrementing the ref count. If the ref count goes from 0 to 1, the audio engine is started.

      • release

         final Unit release()

        Release a reference to the audio engine, decrementing the ref count. If the ref count goes from 1 to 0, the audio engine is stopped.