Merge "Default compressed audio bytes per sample to 1"

This commit is contained in:
Treehugger Robot
2020-10-15 17:48:07 +00:00
committed by Gerrit Code Review

View File

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