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(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 |
(Mutable)List<Int!>! |
Returns the list of channel masks that are natively supported by the |
Boolean |
Returns true if the |
Boolean |
Returns true if the |
Boolean |
Returns true if the immersive level is not |
Boolean |
A convenience method for the combined checks to see if spatialization is actually available. |
Unit |
release() |
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 |
spatializerChangedCallback: Runnable? |
A callback to run when the |
deviceIsTv: Boolean? |
Optional. Whether the device is a TV. If true, the |
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.