Skip to content

getAudioInterruption ​

Get Audio Interruption State ​

getAudioInterruption is a synchronous query method in the SUDRTGameAudioSession interface. It is used to check whether the current game audio is in a "passively interrupted" state (e.g., suspended due to an incoming call, the App moving to the background, or a third-party voice app seizing the audio focus).


Method Declaration ​

java
/**
 * Get the audio interruption state of the current game instance.
 * @return boolean Returns true if the audio is currently suspended (interrupted); returns false if the audio is actively running.
 */
boolean getAudioInterruption();

Runtime Behavior ​

  1. State Mapping: This method returns the logical state most recently set via setAudioInterruption(boolean).
  2. Audio Stream Monitoring: When it returns true, it means the SDK's internal audio renderer has stopped working and no longer occupies the system's AudioTrack resources.
  3. Recovery Basis: The App typically calls this method in onResume or after a call ends to decide whether audio output needs to be resumed.

Code Example ​

Validate the state in the App's global audio management logic:

java
// Get the audio session control object
SUDRTGameAudioSession audioSession = mGameHandle.getAudioSession();

// Simulate the check when returning from background to foreground
@Override
protected void onResume() {
    super.onResume();
    
    // If the audio is still interrupted and playback conditions are now met, resume it
    if (audioSession.getAudioInterruption()) {
        Log.d("SudAudio", "Detected audio in interrupted state, attempting to resume...");
        audioSession.setAudioInterruption(false);
    }
}

Notes ​

  • Difference from isMute:

  • isMute() returns the "mute" switch set explicitly by the user.

  • getAudioInterruption() returns the "suspended" state caused by external interference or system policies.

  • Resource Release Flag: On the Android platform, when this state is true, it usually means the App has released part of its audio hardware occupation, which is important for passing system checks (such as OOM or battery optimization).

  • Default Value: After game initialization completes, this state defaults to false.