Share via


AudioTrack.GetMinBufferSize(Int32, ChannelOut, Encoding) Method

Definition

Returns the estimated minimum buffer size required for an AudioTrack object to be created in the #MODE_STREAM mode.

[Android.Runtime.Register("getMinBufferSize", "(III)I", "")]
public static int GetMinBufferSize (int sampleRateInHz, Android.Media.ChannelOut channelConfig, Android.Media.Encoding audioFormat);
[<Android.Runtime.Register("getMinBufferSize", "(III)I", "")>]
static member GetMinBufferSize : int * Android.Media.ChannelOut * Android.Media.Encoding -> int

Parameters

sampleRateInHz
Int32

the source sample rate expressed in Hz. AudioFormat#SAMPLE_RATE_UNSPECIFIED is not permitted.

channelConfig
ChannelOut

describes the configuration of the audio channels. See AudioFormat#CHANNEL_OUT_MONO and AudioFormat#CHANNEL_OUT_STEREO

audioFormat
Encoding

the format in which the audio data is represented. See AudioFormat#ENCODING_PCM_16BIT and AudioFormat#ENCODING_PCM_8BIT, and AudioFormat#ENCODING_PCM_FLOAT.

Returns

#ERROR_BAD_VALUE if an invalid parameter was passed, or #ERROR if unable to query for output properties, or the minimum buffer size expressed in bytes.

Attributes

Remarks

Returns the estimated minimum buffer size required for an AudioTrack object to be created in the #MODE_STREAM mode. The size is an estimate because it does not consider either the route or the sink, since neither is known yet. Note that this size doesn't guarantee a smooth playback under load, and higher values should be chosen according to the expected frequency at which the buffer will be refilled with additional data to play. For example, if you intend to dynamically set the source sample rate of an AudioTrack to a higher value than the initial source sample rate, be sure to configure the buffer size based on the highest planned sample rate.

Java documentation for android.media.AudioTrack.getMinBufferSize(int, int, 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