Merge "Default compressed audio bytes per sample to 1" am: aa2884ac69 am: ce94c11c87

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1444316

Change-Id: I8d777a76eeacbf351837a70653fdef0f0b91316e
This commit is contained in:
Treehugger Robot
2020-10-15 18:08:03 +00:00
committed by Automerger Merge Worker

View File

@@ -1261,14 +1261,20 @@ public class AudioTrack extends PlayerBase
// TODO: Check mEncapsulationMode compatibility with MODE_STATIC, etc?
try {
// If the buffer size is not specified in streaming mode,
// use a single frame for the buffer size and let the
// native code figure out the minimum buffer size.
if (mMode == MODE_STREAM && mBufferSizeInBytes == 0) {
mBufferSizeInBytes = mFormat.getChannelCount()
* mFormat.getBytesPerSample(mFormat.getEncoding());
// If the buffer size is not specified in streaming mode,
// use a single frame for the buffer size and let the
// native code figure out the minimum buffer size.
if (mMode == MODE_STREAM && mBufferSizeInBytes == 0) {
int bytesPerSample = 1;
try {
bytesPerSample = mFormat.getBytesPerSample(mFormat.getEncoding());
} catch (IllegalArgumentException e) {
// do nothing
}
mBufferSizeInBytes = mFormat.getChannelCount() * bytesPerSample;
}
try {
final AudioTrack track = new AudioTrack(
mAttributes, mFormat, mBufferSizeInBytes, mMode, mSessionId, mOffload,
mEncapsulationMode, mTunerConfiguration);