Amazon Developer

as

Settings
Sign out
Notifications
Alexa
Amazon Appstore
Ring
AWS
Documentation
Support
Contact Us
My Cases
Get Started
Design and Develop
Publish
Reference
Support
Native
Skip to main content

Interface IAudioStreamPlayback

interface IAudioStreamPlayback
Extends com.amazon.apmf.IStandard Interface for encapsulating Audio Playback functionality

Methods

initCheck()

bool initCheck()
Initialization state checking for playback client object.

Returns

bool true if the object was created and initialized successfully.

getAudioConfig()

AudioConfig getAudioConfig()
Get audio config

Returns

AudioConfig audio configuration of audio data feb by the client

getAudioAttributes()

AudioAttributes getAudioAttributes()
Get audio attributes

Returns

AudioAttributes audio playback attributes

getNumBytesInPipeline()

i32 getNumBytesInPipeline()
Audio data in bytes pending to be copied by the client from server memory.

Returns

i32 pending number of data bytes in shared memory between client and server.

getNumBytesOfNativeBuffer()

i32 getNumBytesOfNativeBuffer()
Total Shared memory size in bytes between client and audio server. Total memory size would be equal to framesPerBuffer * bufferCount * bytesPerFrame.

Returns

i32 size of total shared memory size in bytes. 0 otherwise.

getFramesPerBuffer()

i32 getFramesPerBuffer()
Get pre configured shared buffer size supplied to the stream builder.

Returns

i32 number of frames per buffer in the buffer queue. 0 on error.

getBufferCount()

i32 getBufferCount()
Get pre configured shared buffer queue count from the builder.

Returns

i32 number of buffers inside buffer queue. 0 on error.

getUnderrunSize()

i32 getUnderrunSize()
Get underrun size. If a client has set a buffer underrun threshold and playback buffer is in underrun state, this API will return the difference between the buffer size and the threshold value. Otherwise, this API will return 0.

Returns

i32 difference in frames between buffer size and underrun threshold. Frame value is rounded up.

getUnderrunCount()

i32 getUnderrunCount()
Get number of underruns occurred during the stream lifetime.

Returns

i32 number of underrun occurrences that occurred during stream lifetime.

getAudioFocusSessionId()

i32 getAudioFocusSessionId()
Get audio focus session ID associated with the stream.

Returns

i32 audio focus session ID.

getLatencyInMs()

i32 getLatencyInMs()
Latency in milliseconds from audio pipeline.

Returns

i32 latency in milliseconds on initialized object. 0 otherwise.

getPresentedFrameCount()

i64 getPresentedFrameCount()
Get number of audio frames already presented and accepted by the audio pipeline. API support high frequency call with interpolated frame count. if calling frequency is higher than kernel or server side frame count update rate, client API will calculate elapsed time since last kernel/server frame update and synthesize an interpolated frame count as intermediate query result. if stream is paused or stream is experiencing underrun, the frame count will stay unchanged during the period. frame count will be reset to 0 if stream is stopped

Returns

i64 number of audio frames presented to audio pipeline on success.

getDuckingPolicy()

StreamDuckingPolicy getDuckingPolicy()
Get current stream volume ducking policy

Returns

StreamDuckingPolicy current audio ducking policy

duckVolume()

void duckVolume(DuckingMode* mode, i32 value, i32 rampDurationMs)
Duck/unduck the stream by specified db/percentage Duck/Unduck volume based on against the applicable system volume for the stream

Parameters

mode
DuckingMode* — Required ducking mode to be applied.
value
i32 — Required If the mode is DuckingMode::DB, then value indicates dB to reduce from current stream volume (range: 0 to 144). If the mode is DuckingMode::PERCENTAGE, value indicates volume percentage to be reduced from current stream volume (range: 0 to 100). If the value is 0, the stream will be unducked to original stream volume
rampDurationMs
i32 — Required duration in milliseconds to go from current volume to target volume.

setVolume()

void setVolume(i32 gain)
Set individual stream volume by absolute gain in percentage. Set gain for this stream; It will be applied on top of the current system volume applicable for this stream. For e.g. if this is a media stream. then this stream will have volume = gain * current media volume.

Parameters

gain
i32 — Required applied on volume of current stream type (range: 0 to 100).

getVolume()

i32 getVolume()
Get individual stream volume. Query current individual stream volume in percentage.

Returns

i32 volume current volume of the stream in percentage.

pause()

void pause()
Pause the audio playback stream. Stream will enter pause state if pause() request is correctly dispatched.
  • if start() is called after pause(), pending data will be played continuously.
  • if flush() is called after pause(), pending data will be discarded and stream will enter stopped state.
Data that has not been presented to hardware will not be discarded.

start()

void start()
Start the audio playback stream. Start stream from stopped or paused state. Stream will enter active state if start() request is correctly dispatched.

stop()

void stop()
Stop the audio playback stream. Stop stream and drain remaining data from audio pipeline if stream is under active state. Stop stream and flush discarding remaining audio samples from audio pipeline if stream is under paused state. Stream will enter stopped state if stop() request is correctly dispatched.

flush()

void flush()
Flush the audio playback stream. Flush data within audio pipeline, any pending audio samples that are not yet presented to audio hardware will be discarded. no-op if playback is active.

write()

i32 write(u8[] data)
Write audio buffer to the stream for rendering Write call will be blocking until all the data has been enqueued for playback and returns the full transaction byte count. If any internal error happens which results in partial data enqueue, actual enqueued number of byte will be returned. If any internal error happens before any data enqueue, an exception will be thrown

Parameters

data
u8[] — Required buffer to audio sample data.

Returns

i32 number of bytes consumed from the data buffer

addAudioStreamEventListener()

com.amazon.apmf.ISubscription* addAudioStreamEventListener(IAudioStreamEventListener* callback)
Register listener for audio record events

Parameters

callback
IAudioStreamEventListener* — Required pointer to listener object

Returns

com.amazon.apmf.ISubscription* ISubscription pointer to be used to unsubscribe to the listener
Last modified on October 29, 2026