as

Settings
Sign out
Notifications
Alexa
Amazon Appstore
AWS
Documentation
Support
Contact Us
My Cases
Get Started
Design and Develop
Publish
Reference
Support

AudioRecordStreamTurboModule

Extends

  • KeplerTurboModule

Properties

buildAudioRecordStreamAsync()

buildAudioRecordStreamAsync: (args) => Promise<number>

Creates a new audio record stream with the specified configuration. Requires microphone privilege com.amazon.audio.privilege.microphone.access.

Parameters

args

Object

Configuration object containing:

  • audio_config: AudioConfig object
  • audio_source: AudioSource type
  • audio_flags: Optional AudioFlags

Returns

Promise<number>

A promise that resolves to:

  • Positive number: New stream ID on success
  • STATUS_NO_MEMORY (-1): Memory allocation failed
  • STATUS_BAD_VALUE (-2): Invalid configuration
  • STATUS_PERMISSION_DENIED (-9): Missing microphone privilege

destroyAudioRecordStreamAsync()

destroyAudioRecordStreamAsync: (streamId) => Promise<number>

Destroys an existing audio record stream.

Parameters

streamId

number

ID of the stream to destroy

Returns

Promise<number>

A promise that resolves to:

  • STATUS_NO_ERROR (0): Success
  • STATUS_BAD_VALUE (-2): Invalid stream ID
  • STATUS_NO_INIT (-3): Stream not initialized
  • STATUS_INVALID_OPERATION (-8): Stream in invalid state

flushAsync()

flushAsync: (streamId) => Promise<number>

Flushes any pending audio data fa from the record stream.

Parameters

streamId

number

ID of the stream

Returns

Promise<number>

A promise that resolves to:

  • STATUS_NO_ERROR (0): Success
  • STATUS_BAD_VALUE (-2): Invalid stream ID
  • STATUS_NO_INIT (-3): Stream not initialized
  • STATUS_INVALID_OPERATION (-8): Invalid state for flush
  • STATUS_DEAD_OBJECT (-5): Server connection lost

getAudioConfigAsync()

getAudioConfigAsync: (streamId) => Promise<Object>

Gets the audio configuration of the record stream.

Parameters

streamId

number

ID of the stream

Returns

Promise<Object>

A promise that resolves to an object containing:

  • sample_rate: Sample rate in Hz
  • channel_mask: Channel configuration
  • format: Audio format type

Rejects with:

  • STATUS_BAD_VALUE (-2): Invalid stream ID
  • STATUS_NO_INIT (-3): Stream not initialized
  • STATUS_DEAD_OBJECT (-5): Server connection lost

getAudioEffectSessionIdAsync()

getAudioEffectSessionIdAsync: (streamId) => Promise<number>

Gets the audio effect session ID associated with this stream.

Parameters

streamId

number

ID of the stream

Returns

Promise<number>

A promise that resolves to:

  • Positive number: Audio effect session ID
  • STATUS_BAD_VALUE (-2): Invalid stream ID
  • STATUS_NO_INIT (-3): Stream not initialized
  • STATUS_DEAD_OBJECT (-5): Server connection lost

getAudioFlagsAsync()

getAudioFlagsAsync: (streamId) => Promise<number>

Gets the audio flags configured for this stream.

Parameters

streamId

number

ID of the stream

Returns

Promise<number>

A promise that resolves to:

AudioFlags value (bitwise combination):

  • FLAG_NONE (0x0)
  • FLAG_AUDIBILITY_ENFORCED (1 << 0)
  • FLAG_HW_AV_SYNC (1 << 1)
  • FLAG_LOW_LATENCY (1 << 2)
  • FLAG_LOW_POWER (1 << 3)
  • FLAG_TIMED_AUDIO (1 << 4)
  • FLAG_OFFLOAD (1 << 5)
  • FLAG_PASSTHROUGH (1 << 6)
  • STATUS_BAD_VALUE (-2): Invalid stream ID
  • STATUS_NO_INIT (-3): Stream not initialized
  • STATUS_DEAD_OBJECT (-5): Server connection lost

getAudioSourceAsync()

getAudioSourceAsync: (streamId) => Promise<number>

Gets the audio source type configured for this stream.

Parameters

streamId

number

ID of the stream

Returns

Promise<number>

A promise that resolves to:

  • NONE (0)
  • RAW (1)
  • VOICE_COMMUNICATION (2)
  • WAKEWORD (3)
  • CAMCORDER (4)
  • VOICE_RECOGNITION (5)
  • ULTRASOUND (6)
  • TAP_DETECTION (7)
  • BLUETOOTH_A2DP (8)
  • BLUETOOTH_SCO (9)
  • STATUS_BAD_VALUE (-2): Invalid stream ID
  • STATUS_NO_INIT (-3): Stream not initialized
  • STATUS_DEAD_OBJECT (-5): Server connection lost

getChannelCountAsync()

getChannelCountAsync: (streamId) => Promise<number>

Gets the channel count nt of the record stream.

Parameters

streamId

number

ID of the stream

Returns

Promise<number>

A promise that resolves to:

  • Positive number: Number of channels
  • STATUS_BAD_VALUE (-2): Invalid stream ID
  • STATUS_NO_INIT (-3): Stream not initialized
  • STATUS_DEAD_OBJECT (-5): Server connection lost

getLatencyInMsAsync()

getLatencyInMsAsync: (streamId) => Promise<number>

Gets the latency of the audio record stream in milliseconds.

Parameters

streamId

number

ID of the stream

Returns

Promise<number>

A promise that resolves to:

  • Positive number: Latency in milliseconds
  • STATUS_BAD_VALUE (-2): Invalid stream ID
  • STATUS_NO_INIT (-3): Stream not initialized
  • STATUS_DEAD_OBJECT (-5): Server connection lost

getMajorVersion()

readonly getMajorVersion: () => number

Gets the major version number of the AudioRecordStreamTurboModule. Can be used to make version checks.

Returns

number

The major version number

Overrides

KeplerTurboModule.getMajorVersion


getMinBufferSizeInBytesAsync()

getMinBufferSizeInBytesAsync: (streamId) => Promise<number>

Gets the minimum buffer size required for reading from the stream. Read operations must use a buffer size at least this large.

Parameters

streamId

number

ID of the stream

Returns

Promise<number>

A promise that resolves to:

  • Positive number: Minimum buffer size in bytes
  • STATUS_BAD_VALUE (-2): Invalid stream ID
  • STATUS_NO_INIT (-3): Stream not initialized
  • STATUS_DEAD_OBJECT (-5): Server connection lost

getMinorVersion()

readonly getMinorVersion: () => number

Gets the minor version number of the AudioRecordStreamTurboModule. Can be used to make version checks.

Returns

number

The minor version number

Overrides

KeplerTurboModule.getMinorVersion


getNumBytesInPipelineAsync()

getNumBytesInPipelineAsync: (streamId) => Promise<number>

Gets the number of bytes currently in the audio pipeline.

Parameters

streamId

number

ID of the stream

Returns

Promise<number>

A promise that resolves to:

  • Positive number: Number of bytes es in pipeline
  • STATUS_BAD_VALUE (-2): Invalid stream ID
  • STATUS_NO_INIT (-3): Stream not initialized
  • STATUS_DEAD_OBJECT (-5): Server connection lost

getNumBytesOfNativeBufferAsync()

getNumBytesOfNativeBufferAsync: (streamId) => Promise<number>

Gets the size of the native buffer in bytes.

Parameters

streamId

number

ID of the st stream

Returns

Promise<number>

A promise that resolves to:

  • Positive number: Buffer size in bytes
  • STATUS_BAD_VALUE (-2): Invalid stream ID
  • STATUS_NO_INIT (-3): Stream not initialized
  • STATUS_DEAD_OBJECT (-5): Server connection lost

getPatchVersion()

readonly getPatchVersion: () => number

Gets the patch version number of the AudioRecordStreamTurboModule. Can be used to make version checks.

Returns

number

The patch version number

Overrides

KeplerTurboModule.getPatchVersion


getSampleRateAsync()

getSampleRateAsync: (streamId) => Promise<number>

Gets the sample rate of the record stream.

Parameters

streamId

number

ID of the stream

Returns

Promise<number>

A promise that resolves to:

  • Positive number: Sample rate in Hz
  • STATUS_BAD_VALUE (-2): Invalid stream ID
  • STATUS_NO_INIT (-3): Stream not initialized
  • STATUS_DEAD_OBJECT (-5): Server connection lost

getSampleSizeAsync()

getSampleSizeAsync: (streamId) => Promise<number>

Gets the sample size in bits.

Parameters

streamId

number

ID of the stream

Returns

Promise<number>

A promise that resolves to:

  • Positive number: Sample size in bits
  • STATUS_BAD_VALUE (-2): Invalid stream ID
  • STATUS_NO_INIT (-3): Stream not initialized
  • STATUS_DEAD_OBJECT (-5): Server connection lost

initCheckAsync()

initCheckAsync: (streamId) => Promise<number>

Checks if the stream is properly initialized.

Parameters

streamId

number

ID of the stream to check

Returns

Promise<number>

A promise that resolves to:

  • STATUS_NO_ERROR (0): Stream initialized
  • STATUS_NO_INIT (-3): Stream not initialized
  • STATUS_BAD_VALUE (-2): Invalid stream ID
  • STATUS_DEAD_OBJECT (-5): Server connection lost

readAsync()

readAsync: (streamId, bytes) => Promise<ArrayBuffer>

Reads audio data from the record stream. Requires microphone privilege com.amazon.audio.privilege.microphone.access.

Parameters

streamId

number

ID of the stream

bytes

number

Number of bytes to read (must be >= minimum buffer size)

Returns

Promise<ArrayBuffer>

A promise that resolves to:

  • ArrayBuffer containing the recorded audio data

Rejects with:

  • STATUS_BAD_VALUE (-2): Invalid stream ID or size
  • STATUS_NO_INIT (-3): Stream not initialized
  • STATUS_PERMISSION_DENIED (-9): Missing microphone privilege
  • STATUS_DEAD_OBJECT (-5): Server connection lost

registerEventObserverAsync()

registerEventObserverAsync: (streamId, callback) => Promise<number>

Registers a callback function for record stream events.

Parameters

streamId

number

ID of the stream

callback

(value) => void

Callback function to handle events:

  • DIED (0): Stream became unavailable
  • RECOVERED (1): Stream recovered
  • MUTE_STATE_CHANGED (2): Mute state changed

Returns

Promise<number>

A promise that resolves to:

  • STATUS_NO_ERROR (0): Success
  • STATUS_BAD_VALUE (-2): Invalid stream ID or callback
  • STATUS_NO_INIT (-3): Stream not initialized
  • STATUS_ALREADY_EXISTS (-4): Callback already registered
  • STATUS_DEAD_OBJECT (-5): Server connection lost

unregisterEventObserverAsync()

unregisterEventObserverAsync: (streamId) => Promise<number>

Unregister the event callback for the record stream.

Parameters

streamId

number

ID of the stream

Returns

Promise<number>

A promise that resolves to:

  • STATUS_NO_ERROR (0): Success
  • STATUS_BAD_VALUE (-2): Invalid stream ID
  • STATUS_NO_INIT (-3): Stream not initialized
  • STATUS_INVALID_OPERATION (-8): No callback registered
  • STATUS_DEAD_OBJECT (-5): Server connection lost

Methods

getConstants()?

optional getConstants(): object

Returns

object

Inherited from

KeplerTurboModule.getConstants


Last updated: Sep 30, 2025