summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Treehugger Robot <treehugger-gerrit@google.com> 2020-10-15 18:08:03 +0000
committer Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> 2020-10-15 18:08:03 +0000
commit313ffe6d313b3853000e5ed06f4e024fcdfee737 (patch)
tree624b696b8777ba754f912f90a1d078cc078ad103
parent732c8b8f4ae53aa733361e03322c37b5a1a72137 (diff)
parentce94c11c87a0100edc96c10ceee6d5fb2b908e6b (diff)
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
-rw-r--r--media/java/android/media/AudioTrack.java20
1 files changed, 13 insertions, 7 deletions
diff --git a/media/java/android/media/AudioTrack.java b/media/java/android/media/AudioTrack.java
index 1c0a526f536c..eff56f3d8c19 100644
--- a/media/java/android/media/AudioTrack.java
+++ b/media/java/android/media/AudioTrack.java
@@ -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);