summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Michel Trivi <jmtrivi@google.com>2014-11-20 22:02:13 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-11-20 22:02:15 +0000
commit09ff91255e945f2588c377614bf7b7c0d512118e (patch)
tree10ac23cf2bd2417c754d1c877c19fd27e0356e93
parent93ef96395a95317bec4f27423ade1ce0d6aa07d8 (diff)
parent8dc1031453377d2f9d9c7847027f276e6726a4c8 (diff)
downloadframeworks_base-09ff91255e945f2588c377614bf7b7c0d512118e.zip
frameworks_base-09ff91255e945f2588c377614bf7b7c0d512118e.tar.gz
frameworks_base-09ff91255e945f2588c377614bf7b7c0d512118e.tar.bz2
Merge "Convert record channel mask for dynamic mix" into lmp-mr1-dev
-rw-r--r--media/java/android/media/AudioFormat.java23
-rw-r--r--media/java/android/media/audiopolicy/AudioPolicy.java9
2 files changed, 31 insertions, 1 deletions
diff --git a/media/java/android/media/AudioFormat.java b/media/java/android/media/AudioFormat.java
index 58ed4f8..9a0266d 100644
--- a/media/java/android/media/AudioFormat.java
+++ b/media/java/android/media/AudioFormat.java
@@ -128,6 +128,29 @@ public class AudioFormat {
/**
* @hide
+ * Return the input channel mask corresponding to an output channel mask.
+ * This can be used for submix rerouting for the mask of the recorder to map to that of the mix.
+ * @param outMask a combination of the CHANNEL_OUT_* definitions, but not CHANNEL_OUT_DEFAULT
+ * @return a combination of CHANNEL_IN_* definitions matching an output channel mask
+ * @throws IllegalArgumentException
+ */
+ public static int inChannelMaskFromOutChannelMask(int outMask) throws IllegalArgumentException {
+ if (outMask == CHANNEL_OUT_DEFAULT) {
+ throw new IllegalArgumentException(
+ "Illegal CHANNEL_OUT_DEFAULT channel mask for input.");
+ }
+ switch (channelCountFromOutChannelMask(outMask)) {
+ case 1:
+ return CHANNEL_IN_MONO;
+ case 2:
+ return CHANNEL_IN_STEREO;
+ default:
+ throw new IllegalArgumentException("Unsupported channel configuration for input.");
+ }
+ }
+
+ /**
+ * @hide
* Return the number of channels from an input channel mask
* @param mask a combination of the CHANNEL_IN_* definitions, even CHANNEL_IN_DEFAULT
* @return number of channels for the mask
diff --git a/media/java/android/media/audiopolicy/AudioPolicy.java b/media/java/android/media/audiopolicy/AudioPolicy.java
index 255d828..e9dc3af 100644
--- a/media/java/android/media/audiopolicy/AudioPolicy.java
+++ b/media/java/android/media/audiopolicy/AudioPolicy.java
@@ -155,6 +155,7 @@ public class AudioPolicy {
{
throw new IllegalArgumentException("Invalid AudioMix: not defined for loop back");
}
+ // TODO also check mix is defined for playback or recording, and matches forTrack argument
}
/**
@@ -175,13 +176,19 @@ public class AudioPolicy {
return null;
}
checkMixReadyToUse(mix, false/*not for an AudioTrack*/);
+ // create an AudioFormat from the mix format compatible with recording, as the mix
+ // was defined for playback
+ AudioFormat mixFormat = new AudioFormat.Builder(mix.getFormat())
+ .setChannelMask(AudioFormat.inChannelMaskFromOutChannelMask(
+ mix.getFormat().getChannelMask()))
+ .build();
// create the AudioRecord, configured for loop back, using the same format as the mix
AudioRecord ar = new AudioRecord(
new AudioAttributes.Builder()
.setInternalCapturePreset(MediaRecorder.AudioSource.REMOTE_SUBMIX)
.addTag(mix.getRegistration())
.build(),
- mix.getFormat(),
+ mixFormat,
AudioRecord.getMinBufferSize(mix.getFormat().getSampleRate(),
// using stereo for buffer size to avoid the current poor support for masks
AudioFormat.CHANNEL_IN_STEREO, mix.getFormat().getEncoding()),