• Quick Start
  • Booting
  • Platform
  • Portals
  • References
    • API Reference TOI3
    • IIP Reference
  • Resources
ARRIS Enterprises, Inc. Confidential Information

ToiAudioOutputService

Class Summary

Extends:
  • ToiEventTarget

ToiAudioOutputService is used for controlling audio outputs. It allows the client to control how to decode and mix audio content and route the modified/unmodified content to the outputs.

Service:

This is a service and can be accessed through toi.audioOutputService
  • Methods
  • Members
  • Types
  • Events

Method Summary

createConfigurationSession ( )  → ToiAudioOutputConfigurationSession Creates a session for changing the audio output configuration.
getConfiguration ( )  → ToiAudioOutputConfiguration

Returns the audio output configuration.

getConnections ( )  → Array.<ToiAudioOutputService.ToiAudioConnectionDescriptor>

Returns available audio connections.

getLatency ( connectionId )  → latency

Returns the audio latency of a connection.

getMasterVolume ( )  → level Returns the master volume of the system, in the range 0-100.
getMuteState ( connectionId )  → state

Returns the mutes state of a connection.

getVolume ( connectionId )  → level Returns the volume level of a connection, in the range 0-100.
setLatency ( connectionId , latency ) Sets the latency for an audio connection in milliseconds.
setMasterVolume ( level ) Sets the master audio volume. Range 0-100.
setMuteState ( connectionId , state )

Sets the mute state of a connection.

setVolume ( connectionId , level ) Sets the volume for a connection. Range 0-100.

Inherited Methods

addEventListener ( type , listener )

This method registers an event listener for a specific event. Multiple listeners can be added for the same event. Events are broadcast to all registered listeners.

removeEventListener ( type , listener )

This method removes an event listener for a specific event.

Type Definitions

ToiAudioConnectionDirection (Type: enum)

Input or output connection direction.

  • AUDIO_CONNECTION_DIRECTION_INPUT
  • AUDIO_CONNECTION_DIRECTION_OUTPUT
ToiAudioConnectionId (Type: number)

Audio connection identifier type.

ToiAudioConnectionType (Type: enum)

Audio connection types.

  • AUDIO_CONNECTION_TYPE_ANALOG
  • AUDIO_CONNECTION_TYPE_BUFFER
  • AUDIO_CONNECTION_TYPE_DECODER
  • AUDIO_CONNECTION_TYPE_HDMI
  • AUDIO_CONNECTION_TYPE_I2S
  • AUDIO_CONNECTION_TYPE_SPDIF

Events

  • ON_CONFIGURATION_CHANGED
  • ON_LATENCY_CHANGED
  • ON_MASTER_VOLUME_CHANGED
  • ON_MUTE_STATE_CHANGED
  • ON_VOLUME_CHANGED

Methods

addEventListener ( type , listener )

This method registers an event listener for a specific event. Multiple listeners can be added for the same event. Events are broadcast to all registered listeners.

Inherited From:

  • ToiEventTarget#addEventListener

Parameters:

Name Type Description
type number

The event type of the event to subscribe to.

listener ToiEventListener

The JavaScript function that will receive events.

Throws:

ToiInvalidArgumentException Raised if the event type is not supported by this object or if the listener is not a valid JavaScript function. This exception is also raised if the application calls addEventListener with the same combination of type and listener twice.

createConfigurationSession ( )  → ToiAudioOutputConfigurationSession

Creates and returns a session to change the audio output configuration. The session is active between this call and either ToiAudioOutputConfigurationSession#apply or ToiAudioOutputConfigurationSession#revert.

Throws:

ToiInvalidArgumentException

Raised if the application identifier is invalid.

ToiInvalidPreconditionException

Raised if another session is active.

Returns:

The ToiAudioOutputConfigurationSession address.

Type: ToiAudioOutputConfigurationSession
getConfiguration ( )  → ToiAudioOutputConfiguration

Returns the audio output configuration.

Returns:

The ToiAudioOutputConfiguration address.

Type: ToiAudioOutputConfiguration
getConnections ( )  → Array.<ToiAudioOutputService.ToiAudioConnectionDescriptor>

Returns available audio connections.

Returns:

The list available audio connections.

Type: Array.<ToiAudioOutputService.ToiAudioConnectionDescriptor>
getLatency ( connectionId )  → latency

Returns the audio latency of a connection.

Parameters:

Name Type Description
connectionId ToiAudioOutputService.ToiAudioConnectionId

The identifier of the connection to query.

Throws:

ToiInvalidArgumentException

Raised if there is no such connection.

ToiOperationNotSupportedException

Raised if the latency for the connection is not adjustable.

Returns:

The audio latency in milliseconds.

Type: number
getMasterVolume ( )  → level

Returns the master audio volume level of the system. Possible level range from 0 and 100 where 0 is the lowest volume and 100 the highest volume.

See ToiAudioOutputService#setMasterVolume for a description of what connection(s) are used for the master volume. If multiple connections are used the value of one will be returned. The one used will be the HDMI connection if available, otherwise the analog connection, otherwise the first one found.

If ToiAudioOutputService#setVolume has been used to modify the individual levels of connections since the last call to ToiAudioOutputService#setMasterVolume the value might not be the actual level used on all output connections.

If the master volume could be set on the decoder input the value returned will be calculated by scaling the decoder volume level using the output volume of the output most likely to be connected, that is the same as the one that had been used if decoder was not adjustable, HDMI if available, otherwise analog, otherwise the first one found.

Throws:

ToiInvalidArgumentException

Raised if the application identifier is invalid.

ToiOperationNotSupportedException

Raised if it was not possible to find any adjustable connections.

Returns:

The volume level.

Type: number
getMuteState ( connectionId )  → state

Returns the mutes state of a connection.

Parameters:

Name Type Description
connectionId ToiAudioOutputService.ToiAudioConnectionId

The identifier of the connection to query.

Throws:

ToiInvalidArgumentException

Raised if there is no such connection.

ToiOperationNotSupportedException

Raised if the connection is not mutable.

Returns:

The mute state.

Type: boolean
getVolume ( connectionId )  → level

Returns the audio volume level of a connection. Possible level range from 0 and 100 where 0 is the lowest volume and 100 the highest volume.

Parameters:

Name Type Description
connectionId ToiAudioOutputService.ToiAudioConnectionId

The identifier of the connection to query.

Throws:

ToiInvalidArgumentException

Raised if there is no such connection.

ToiOperationNotSupportedException

Raised if the volume for the connection is not adjustable.

Returns:

The volume level.

Type: number
removeEventListener ( type , listener )

This method removes an event listener for a specific event.

Inherited From:

  • ToiEventTarget#removeEventListener

Parameters:

Name Type Description
type number

The event type of the event to remove the listener from.

listener ToiEventListener

The JavaScript function that was previously added as an event listener.

Throws:

ToiInvalidArgumentException Raised if the event type is not supported by this object or if the listener is not a valid JavaScript function. This exception is also raised if the listener has not previously been added.

setLatency ( connectionId , latency )

Set an audio connection audio latency. latency is in milliseconds. This should affect all audio formats. If the latency parameter is out of range, the closest supported value is set. Setting the latency for one connection may impact the latency for other connections. In this case, the ToiAudioOutputLatencyChangedEvent will be notified on the impacted connections.

Parameters:

Name Type Description
connectionId ToiAudioOutputService.ToiAudioConnectionId

The identifier of the connection for which the audio latency will be changed.

latency number

The desired audio latency in milliseconds.

Throws:

ToiInvalidArgumentException

Raised if there is no such connection.

ToiOperationNotSupportedException

Raised if the latency for the connection is not adjustable.

setMasterVolume ( level )

Set the master audio output volume. The level can be adjusted between 0 and 100 where 0 is the lowest volume and 100 the highest volume.

This will affect the volume on one or more audio connections depending on platform and hardware capabilities. If possible the volume will be adjusted on the decoder connection, because a change there will automatically affect all audio outputs. This will also set all adjustable output connections to 100 (maximum volume). If the decoder volume connection is not adjustable the volume will instead be applied to all outputs that are adjustable.

Not all audio might be affected by changing the master volume. Any passthrough audio will not be affected by volume adjustments.

ToiAudioOutputVolumeChangedEvent will be notified on the impacted connections, followed one call to ToiAudioOutputMasterVolumeChangedEvent.

This method will override previous calls to ToiAudioOutputService#setVolume on individual channels.

Parameters:

Name Type Description
level number

The desired volume level.

Throws:

ToiInvalidArgumentException

Raised if the application identifier is invalid or the level is outside the allowed interval.

ToiOperationNotSupportedException

Raised if it was not possible to find any adjustable connections.

setMuteState ( connectionId , state )

Sets the mute state of a connection.

Parameters:

Name Type Description
connectionId ToiAudioOutputService.ToiAudioConnectionId

The identifier of the connection to query.

state boolean

The desired mute state.

Throws:

ToiInvalidArgumentException

Raised if there is no such connection.

ToiOperationNotSupportedException

Raised if the connection is not mutable or it is currently enforced to mute due to DRM restriction.

setVolume ( connectionId , level )

Set an audio connection volume level. The level can be adjusted between 0 and 100 where 0 is the lowest volume and 100 the highest volume. The volume is only affected if the content is decoded or non compressed.

ToiAudioOutputVolumeChangedEvent will be notified.

If the connection is one that will be used in calculating the returned level for ToiAudioOutputService#getMasterVolume ToiAudioOutputMasterVolumeChangedEvent will be notified. It is possible that the experienced end-user volume will be modified even if changing the volume on other connections.

Parameters:

Name Type Description
connectionId ToiAudioOutputService.ToiAudioConnectionId

The identifier of the connection for which the volume will be changed.

level number

The desired volume level.

Throws:

ToiInvalidArgumentException

Raised if there is no such connection or if the level is outside the allowed interval.

ToiOperationNotSupportedException

Raised if the volume for the connection is not adjustable.

Members

ON_CONFIGURATION_CHANGED (Type: ToiAudioOutputConfigurationChangedEvent) (value = 3100) (static, constant)

This is an Event identifier for ToiAudioOutputConfigurationChangedEvent.

Called when the audio output configuration has changed.

This constant can also be accessed from toi.consts.ToiAudioOutputService.ON_CONFIGURATION_CHANGED.
ON_LATENCY_CHANGED (Type: ToiAudioOutputLatencyChangedEvent) (value = 3103) (static, constant)

This is an Event identifier for ToiAudioOutputLatencyChangedEvent.

Called when the audio latency of the specified connection has changed.

This constant can also be accessed from toi.consts.ToiAudioOutputService.ON_LATENCY_CHANGED.
ON_MASTER_VOLUME_CHANGED (Type: ToiAudioOutputMasterVolumeChangedEvent) (value = 3104) (static, constant)

This is an Event identifier for ToiAudioOutputMasterVolumeChangedEvent.

Called when the master volume has changed.

This constant can also be accessed from toi.consts.ToiAudioOutputService.ON_MASTER_VOLUME_CHANGED.
ON_MUTE_STATE_CHANGED (Type: ToiAudioOutputMuteStateChangedEvent) (value = 3102) (static, constant)

This is an Event identifier for ToiAudioOutputMuteStateChangedEvent.

Called when the mute state of the specified connection has changed.

This constant can also be accessed from toi.consts.ToiAudioOutputService.ON_MUTE_STATE_CHANGED.
ON_VOLUME_CHANGED (Type: ToiAudioOutputVolumeChangedEvent) (value = 3101) (static, constant)

This is an Event identifier for ToiAudioOutputVolumeChangedEvent.

Called when the volume level of the specified connection has changed.

This constant can also be accessed from toi.consts.ToiAudioOutputService.ON_VOLUME_CHANGED.
AUDIO_CONNECTION_DIRECTION_INPUT (Type: ToiAudioOutputService.ToiAudioConnectionDirection) (value = 0) (static, constant)

The connection is an input.

This constant can also be accessed from toi.consts.ToiAudioOutputService.AUDIO_CONNECTION_DIRECTION_INPUT.
AUDIO_CONNECTION_DIRECTION_OUTPUT (Type: ToiAudioOutputService.ToiAudioConnectionDirection) (value = 1) (static, constant)

The connection is an output.

This constant can also be accessed from toi.consts.ToiAudioOutputService.AUDIO_CONNECTION_DIRECTION_OUTPUT.
AUDIO_CONNECTION_TYPE_ANALOG (Type: ToiAudioOutputService.ToiAudioConnectionType) (value = 0) (static, constant)

Analog connection.

This constant can also be accessed from toi.consts.ToiAudioOutputService.AUDIO_CONNECTION_TYPE_ANALOG.
AUDIO_CONNECTION_TYPE_BUFFER (Type: ToiAudioOutputService.ToiAudioConnectionType) (value = 4) (static, constant)

Memory buffer connection, one of the inputs to the audio mixer. If audio overlay is supported, it is stored in this memory buffer.

This constant can also be accessed from toi.consts.ToiAudioOutputService.AUDIO_CONNECTION_TYPE_BUFFER.
AUDIO_CONNECTION_TYPE_DECODER (Type: ToiAudioOutputService.ToiAudioConnectionType) (value = 3) (static, constant)

Decoder connection, one of the inputs to the audio mixer. If digital audio is decoded to PCM it is done by the decoder.

This constant can also be accessed from toi.consts.ToiAudioOutputService.AUDIO_CONNECTION_TYPE_DECODER.
AUDIO_CONNECTION_TYPE_HDMI (Type: ToiAudioOutputService.ToiAudioConnectionType) (value = 2) (static, constant)

HDMI connection.

This constant can also be accessed from toi.consts.ToiAudioOutputService.AUDIO_CONNECTION_TYPE_HDMI.
AUDIO_CONNECTION_TYPE_I2S (Type: ToiAudioOutputService.ToiAudioConnectionType) (value = 5) (static, constant)

I2S connection.

This constant can also be accessed from toi.consts.ToiAudioOutputService.AUDIO_CONNECTION_TYPE_I2S.
AUDIO_CONNECTION_TYPE_SPDIF (Type: ToiAudioOutputService.ToiAudioConnectionType) (value = 1) (static, constant)

S/PDIF connection.

This constant can also be accessed from toi.consts.ToiAudioOutputService.AUDIO_CONNECTION_TYPE_SPDIF.
ToiAudioConnectionDescriptor (Type: struct) (static)

Audio connection descriptor.

Struct fields

Name Description
direction

The connection direction.

Type: ToiAudioOutputService.ToiAudioConnectionDirection
id

A unique identifier among all connections.

Type: ToiAudioOutputService.ToiAudioConnectionId
index

An incrementing index, starting with 0, which is unique for each type and direction combination

Type: number
isAdjustable

If true, the volume can be adjusted.

Type: boolean
isLatencyAdjustable

If true, the audio latency can be adjusted.

Type: boolean
isMutable

If true, the mute state can be altered.

Type: boolean
type

The connection type.

Type: ToiAudioOutputService.ToiAudioConnectionType

Events

ON_CONFIGURATION_CHANGED ( )

This is an Event identifier for ToiAudioOutputConfigurationChangedEvent.

Value: 3100

ON_LATENCY_CHANGED ( )

This is an Event identifier for ToiAudioOutputLatencyChangedEvent.

Value: 3103

ON_MASTER_VOLUME_CHANGED ( )

This is an Event identifier for ToiAudioOutputMasterVolumeChangedEvent.

Value: 3104

ON_MUTE_STATE_CHANGED ( )

This is an Event identifier for ToiAudioOutputMuteStateChangedEvent.

Value: 3102

ON_VOLUME_CHANGED ( )

This is an Event identifier for ToiAudioOutputVolumeChangedEvent.

Value: 3101

5.1.1.p8

Copyright (c) 2018 ARRIS Enterprises, LLC. All Rights Reserved. ARRIS Enterprises, LLC. Confidential Information.