SpatializerWrapper


@RequiresApi(value = 32)
@UnstableApi
public 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(
    @Nullable Context context,
    @Nullable Runnable spatializerChangedCallback,
    @Nullable Boolean deviceIsTv
)

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

Public methods

boolean
canBeSpatialized(AudioAttributes audioAttributes, Format format)

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

List<Integer>

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.

void

Public constructors

SpatializerWrapper

public SpatializerWrapper(
    @Nullable Context context,
    @Nullable Runnable spatializerChangedCallback,
    @Nullable Boolean deviceIsTv
)

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

Parameters
@Nullable Context context

A context for obtaining the Spatializer.

@Nullable Runnable spatializerChangedCallback

A callback to run when the Spatializer state changes.

@Nullable Boolean deviceIsTv

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

Public methods

canBeSpatialized

public boolean canBeSpatialized(AudioAttributes audioAttributes, Format format)

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

Includes special logic for immersive audio formats.

getSpatializedChannelMasks

public List<IntegergetSpatializedChannelMasks()

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

public boolean isAvailable()

Returns true if the Spatializer is available.

This is delegated to isAvailable.

isEnabled

public boolean isEnabled()

Returns true if the Spatializer is enabled.

This is delegated to isEnabled.

isSpatializationSupported

public boolean isSpatializationSupported()

Returns true if the immersive level is not SPATIALIZER_IMMERSIVE_LEVEL_NONE.

isSupportedAvailableAndEnabled

public boolean isSupportedAvailableAndEnabled()

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

release

public void release()