Package: android.hardware.audio@4.0

IStream

interface IStream

Methods

getFrameSize

getFrameSize ()
generates (uint64_t frameSize)

Return the frame size(number of bytes per sample).

Details
Generates
frameSize
frame size in bytes.

getFrameCount

getFrameCount ()
generates (uint64_t count)

Return the frame count of the buffer.Calling this method is equivalent to getting AUDIO_PARAMETER_STREAM_FRAME_COUNT on the legacy HAL.

Details
Generates
count
frame count.

getBufferSize

getBufferSize ()
generates (uint64_t bufferSize)

Return the size of input/output buffer in bytes for this stream.It must be a multiple of the frame size.

Details
Generates
bufferSize

getSampleRate

getSampleRate ()
generates (uint32_t sampleRateHz)

Return the sampling rate in Hz.

Details
Generates
sampleRateHz
sample rate in Hz.

getSupportedSampleRates

getSupportedSampleRates (AudioFormat format)
generates (Result retval, vec<uint32_t> sampleRates)

Return supported native sampling rates of the stream for a given format.A supported native sample rate is a sample rate that can be efficiently played by the hardware(typically without sample-rate conversions).

This function is only called for dynamic profile.If called for non-dynamic profile is should return NOT_SUPPORTED or the same list as in audio_policy_configuration.xml.

Calling this method is equivalent to getting AUDIO_PARAMETER_STREAM_SUP_SAMPLING_RATES on the legacy HAL.

Details
Parameters
format
audio format for which the sample rates are supported.
Generates
retval
operation completion status.Must be OK if the format is supported.
sampleRates

setSampleRate

setSampleRate (uint32_t sampleRateHz)
generates (Result retval)

Sets the sampling rate of the stream.Calling this method is equivalent to setting AUDIO_PARAMETER_STREAM_SAMPLING_RATE on the legacy HAL.Optional method.If implemented, only called on a stopped stream.

Details
Parameters
sampleRateHz
sample rate in Hz.
Generates
retval
operation completion status.

getChannelMask

getChannelMask ()
generates (bitfield<AudioChannelMask> mask)

Return the channel mask of the stream.

Details
Generates
mask
channel mask.

getSupportedChannelMasks

getSupportedChannelMasks (AudioFormat format)
generates (Result retval, vec<bitfield<AudioChannelMask>> masks)

Return supported channel masks of the stream.Calling this method is equivalent to getting AUDIO_PARAMETER_STREAM_SUP_CHANNELS on the legacy HAL.

Details
Parameters
format
audio format for which the channel masks are supported.
Generates
retval
operation completion status.Must be OK if the format is supported.
masks
supported audio masks.

setChannelMask

setChannelMask (bitfield<AudioChannelMask> mask)
generates (Result retval)

Sets the channel mask of the stream.Calling this method is equivalent to setting AUDIO_PARAMETER_STREAM_CHANNELS on the legacy HAL.Optional method

Details
Parameters
mask
Generates
retval
operation completion status.

getFormat

getFormat ()
generates (AudioFormat format)

Return the audio format of the stream.

Details
Generates
format
audio format.

getSupportedFormats

getSupportedFormats ()
generates (vec<AudioFormat> formats)

Return supported audio formats of the stream.Calling this method is equivalent to getting AUDIO_PARAMETER_STREAM_SUP_FORMATS on the legacy HAL.

Details
Generates
formats
supported audio formats.

setFormat

setFormat (AudioFormat format)
generates (Result retval)

Sets the audio format of the stream.Calling this method is equivalent to setting AUDIO_PARAMETER_STREAM_FORMAT on the legacy HAL.Optional method

Details
Parameters
format
audio format.
Generates
retval
operation completion status.

getAudioProperties

getAudioProperties ()
generates (uint32_t sampleRateHz, bitfield<AudioChannelMask> mask, AudioFormat format)

Convenience method for retrieving several stream parameters in one transaction.

Details
Generates
sampleRateHz
sample rate in Hz.
mask
channel mask.
format
audio format.

addEffect

addEffect (uint64_t effectId)
generates (Result retval)

Applies audio effect to the stream.

Details
Parameters
effectId
effect ID(obtained from IEffectsFactory.createEffect)of the effect to apply.
Generates
retval
operation completion status.

removeEffect

removeEffect (uint64_t effectId)
generates (Result retval)

Stops application of the effect to the stream.

Details
Parameters
effectId
effect ID(obtained from IEffectsFactory.createEffect)of the effect to remove.
Generates
retval
operation completion status.

standby

standby ()
generates (Result retval)

Put the audio hardware input/output into standby mode.Driver must exit from standby mode at the next I/O operation.

Details
Generates
retval
operation completion status.

getDevices

getDevices ()
generates (Result retval, vec<DeviceAddress> devices)

Return the set of devices which this stream is connected to.Optional method

Details
Generates
retval
operation completion status:OK or NOT_SUPPORTED.
devices

setDevices

setDevices (vec<DeviceAddress> devices)
generates (Result retval)

Connects the stream to one or multiple devices.

This method must only be used for HALs that do not support 'IDevice.createAudioPatch' method.Calling this method is equivalent to setting AUDIO_PARAMETER_STREAM_ROUTING preceeded with a device address in the legacy HAL interface.

Details
Parameters
devices
Generates
retval
operation completion status.

setHwAvSync

setHwAvSync (AudioHwSync hwAvSync)
generates (Result retval)

Sets the HW synchronization source.Calling this method is equivalent to setting AUDIO_PARAMETER_STREAM_HW_AV_SYNC on the legacy HAL.Optional method

Details
Parameters
hwAvSync
HW synchronization source
Generates
retval
operation completion status.

getParameters

getParameters (vec<ParameterValue> context, vec<string> keys)
generates (Result retval, vec<ParameterValue> parameters)

Generic method for retrieving vendor-specific parameter values.The framework does not interpret the parameters, they are passed in an opaque manner between a vendor application and HAL.

Multiple parameters can be retrieved at the same time.The implementation should return as many requested parameters as possible, even if one or more is not supported

Details
Parameters
context
provides more information about the request
keys
keys of the requested parameters
Generates
retval
operation completion status.OK must be returned if keys is empty.NOT_SUPPORTED must be returned if at least one key is unknown.
parameters
parameter key value pairs.Must contain the value of all requested keys if retval == OK

setParameters

setParameters (vec<ParameterValue> context, vec<ParameterValue> parameters)
generates (Result retval)

Generic method for setting vendor-specific parameter values.The framework does not interpret the parameters, they are passed in an opaque manner between a vendor application and HAL.

Multiple parameters can be set at the same time though this is discouraged as it make failure analysis harder.

If possible, a failed setParameters should not impact the platform state.

Details
Parameters
context
provides more information about the request
parameters
parameter key value pairs.
Generates
retval
operation completion status.All parameters must be successfully set for OK to be returned

start

start ()
generates (Result retval)

Called by the framework to start a stream operating in mmap mode.createMmapBuffer() must be called before calling start().Function only implemented by streams operating in mmap mode.

Details
Generates
retval
OK in case the success.NOT_SUPPORTED on non mmap mode streams INVALID_STATE if called out of sequence

stop

stop ()
generates (Result retval)

Called by the framework to stop a stream operating in mmap mode.Function only implemented by streams operating in mmap mode.

Details
Generates
retval
OK in case the succes.NOT_SUPPORTED on non mmap mode streams INVALID_STATE if called out of sequence

createMmapBuffer

createMmapBuffer (int32_t minSizeFrames)
generates (Result retval, MmapBufferInfo info)

Called by the framework to retrieve information on the mmap buffer used for audio samples transfer.Function only implemented by streams operating in mmap mode.

Details
Parameters
minSizeFrames
minimum buffer size requested.The actual buffer size returned in struct MmapBufferInfo can be larger.
Generates
retval
OK in case the success.NOT_SUPPORTED on non mmap mode streams NOT_INITIALIZED in case of memory allocation error INVALID_ARGUMENTS if the requested buffer size is too large INVALID_STATE if called out of sequence
info
a MmapBufferInfo struct containing information on the MMMAP buffer created.

getMmapPosition

getMmapPosition ()
generates (Result retval, MmapPosition position)

Called by the framework to read current read/write position in the mmap buffer with associated time stamp.Function only implemented by streams operating in mmap mode.

Details
Generates
retval
OK in case the success.NOT_SUPPORTED on non mmap mode streams INVALID_STATE if called out of sequence
position
a MmapPosition struct containing current HW read/write position in frames with associated time stamp.

close

close ()
generates (Result retval)

Called by the framework to deinitialize the stream and free up all the currently allocated resources.It is recommended to close the stream on the client side as soon as it is becomes unused.

Details
Generates
retval
OK in case the success.NOT_SUPPORTED if called on IStream instead of input or output stream interface.INVALID_STATE if the stream was already closed.