diff options
| author | 2020-10-15 18:19:27 +0000 | |
|---|---|---|
| committer | 2020-10-15 18:19:27 +0000 | |
| commit | 32039640dfcfede08f5b64a75348337fbcdfe97b (patch) | |
| tree | 4e0fad1936f99990a5bd98a16eb8e23bafbc4aa6 | |
| parent | 9a46d248ed827670e871d9001aa539390957b4ba (diff) | |
| parent | 313ffe6d313b3853000e5ed06f4e024fcdfee737 (diff) | |
Merge "Default compressed audio bytes per sample to 1" am: aa2884ac69 am: ce94c11c87 am: 313ffe6d31
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1444316
Change-Id: I944e555922d1c1acdd2f196cb4e11b532fe8a507
| -rw-r--r-- | media/java/android/media/AudioTrack.java | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/media/java/android/media/AudioTrack.java b/media/java/android/media/AudioTrack.java index de2a7b2c15e3..fa6a4ff5af67 100644 --- a/media/java/android/media/AudioTrack.java +++ b/media/java/android/media/AudioTrack.java @@ -1263,14 +1263,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); |