summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorJean-Michel Trivi <jmtrivi@google.com>2015-05-08 15:10:09 -0700
committerJean-Michel Trivi <jmtrivi@google.com>2015-05-11 10:58:16 -0700
commit46011f88710e8b874e1e55d2430c727bfd9d79a9 (patch)
treebd6e069af4915373e5bb8ee2651ca0ba78c99e3a /media
parent3ce72722ca14ad9e84ca54920bb2829696f68d53 (diff)
downloadframeworks_base-46011f88710e8b874e1e55d2430c727bfd9d79a9.zip
frameworks_base-46011f88710e8b874e1e55d2430c727bfd9d79a9.tar.gz
frameworks_base-46011f88710e8b874e1e55d2430c727bfd9d79a9.tar.bz2
AudioRecord.Builder works with no or partial parameters
Complete missing build-time parameters for encoding and channel mask, according to documentation. Bug 20894895 Change-Id: I61f9bfab374effeeded5ae782c4e8513b7310c06
Diffstat (limited to 'media')
-rw-r--r--media/java/android/media/AudioRecord.java20
1 files changed, 18 insertions, 2 deletions
diff --git a/media/java/android/media/AudioRecord.java b/media/java/android/media/AudioRecord.java
index 216d9b9..c0bc6d6 100644
--- a/media/java/android/media/AudioRecord.java
+++ b/media/java/android/media/AudioRecord.java
@@ -416,7 +416,8 @@ public class AudioRecord
* <br>If the audio format is not specified or is incomplete, its sample rate will be the
* default output sample rate of the device (see
* {@link AudioManager#PROPERTY_OUTPUT_SAMPLE_RATE}), its channel configuration will be
- * {@link AudioFormat#CHANNEL_IN_DEFAULT}.
+ * {@link AudioFormat#CHANNEL_IN_MONO}, and the encoding will be
+ * {@link AudioFormat#ENCODING_PCM_16BIT}.
* <br>If the buffer size is not specified with {@link #setBufferSizeInBytes(int)},
* the minimum buffer size for the source is used.
*/
@@ -533,7 +534,22 @@ public class AudioRecord
*/
public AudioRecord build() throws UnsupportedOperationException {
if (mFormat == null) {
- mFormat = new AudioFormat.Builder().build();
+ mFormat = new AudioFormat.Builder()
+ .setEncoding(AudioFormat.ENCODING_PCM_16BIT)
+ .setChannelMask(AudioFormat.CHANNEL_IN_MONO)
+ .build();
+ } else {
+ if (mFormat.getEncoding() == AudioFormat.ENCODING_INVALID) {
+ mFormat = new AudioFormat.Builder(mFormat)
+ .setEncoding(AudioFormat.ENCODING_PCM_16BIT)
+ .build();
+ }
+ if (mFormat.getChannelMask() == AudioFormat.CHANNEL_INVALID
+ && mFormat.getChannelIndexMask() == AudioFormat.CHANNEL_INVALID) {
+ mFormat = new AudioFormat.Builder(mFormat)
+ .setChannelMask(AudioFormat.CHANNEL_IN_MONO)
+ .build();
+ }
}
if (mAttributes == null) {
mAttributes = new AudioAttributes.Builder()