SpatializerWrapper


@RequiresApi(value = 32)
@UnstableApi
class SpatializerWrapper


SpatializerWrapper Wraps the Spatializer in order to encapsulate its APIs within an inner class, to avoid runtime linking on devices with API < 32.

Also centralizes logic such as for special cases of TVs and audio formats without fixed output channel counts and for default channel masks.

Summary

Public constructors

SpatializerWrapper(
    context: Context?,
    spatializerChangedCallback: Runnable?,
    deviceIsTv: Boolean?
)

Creates an instance of the Spatializer Wrapper and registers it to listen for changes.

Public functions

Boolean
canBeSpatialized(audioAttributes: AudioAttributes!, format: Format!)

Returns true if the given AudioAttributes and Format can be spatialized.

(Mutable)List<Int!>!

Returns the list of channel masks that are natively supported by the Spatializer.

Boolean

Returns true if the Spatializer is available.

Boolean

Returns true if the Spatializer is enabled.

Boolean

Returns true if the immersive level is not SPATIALIZER_IMMERSIVE_LEVEL_NONE.

Boolean

A convenience method for the combined checks to see if spatialization is actually available.

Unit

Public constructors

SpatializerWrapper

SpatializerWrapper(
    context: Context?,
    spatializerChangedCallback: Runnable?,
    deviceIsTv: Boolean?
)

Creates an instance of the Spatializer Wrapper and registers it to listen for changes.

Parameters
context: Context?

A context for obtaining the Spatializer.

spatializerChangedCallback: Runnable?

A callback to run when the Spatializer state changes.

deviceIsTv: Boolean?

Optional. Whether the device is a TV. If true, the Spatializer is not used.

Public functions

canBeSpatialized

fun canBeSpatialized(audioAttributes: AudioAttributes!, format: Format!): Boolean

Returns true if the given AudioAttributes and Format can be spatialized.

Includes special logic for immersive audio formats.

getSpatializedChannelMasks

fun getSpatializedChannelMasks(): (Mutable)List<Int!>!

Returns the list of channel masks that are natively supported by the Spatializer.

On API 36+, this is delegated to the getSpatializedChannelMasks. On API 32-35, the default channel mask is 5.1.

isAvailable

fun isAvailable(): Boolean

Returns true if the Spatializer is available.

This is delegated to isAvailable.

isEnabled

fun isEnabled(): Boolean

Returns true if the Spatializer is enabled.

This is delegated to isEnabled.

isSpatializationSupported

fun isSpatializationSupported(): Boolean

Returns true if the immersive level is not SPATIALIZER_IMMERSIVE_LEVEL_NONE.

isSupportedAvailableAndEnabled

fun isSupportedAvailableAndEnabled(): Boolean

A convenience method for the combined checks to see if spatialization is actually available.

release

fun release(): Unit