AudioTrack.SetBufferSizeInFrames(Int32) Method

Definition

Limits the effective size of the AudioTrack buffer that the application writes to.

[Android.Runtime.Register("setBufferSizeInFrames", "(I)I", "GetSetBufferSizeInFrames_IHandler", ApiSince=24)]
public virtual int SetBufferSizeInFrames (int bufferSizeInFrames);
[<Android.Runtime.Register("setBufferSizeInFrames", "(I)I", "GetSetBufferSizeInFrames_IHandler", ApiSince=24)>]
abstract member SetBufferSizeInFrames : int -> int
override this.SetBufferSizeInFrames : int -> int

Parameters

bufferSizeInFrames
Int32

requested buffer size in frames

Returns

the actual buffer size in frames or an error code, #ERROR_BAD_VALUE, #ERROR_INVALID_OPERATION

Attributes

Remarks

Limits the effective size of the AudioTrack buffer that the application writes to.

A write to this AudioTrack will not fill the buffer beyond this limit. If a blocking write is used then the write will block until the data can fit within this limit.

Changing this limit modifies the latency associated with the buffer for this track. A smaller size will give lower latency but there may be more glitches due to buffer underruns.

The actual size used may not be equal to this requested size. It will be limited to a valid range with a maximum of #getBufferCapacityInFrames(). It may also be adjusted slightly for internal reasons. If bufferSizeInFrames is less than zero then #ERROR_BAD_VALUE will be returned.

This method is supported for PCM audio at all API levels. Compressed audio is supported in API levels 33 and above. For compressed streams the size of a frame is considered to be exactly one byte.

Java documentation for android.media.AudioTrack.setBufferSizeInFrames(int).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to