am 09ff9125
: Merge "Convert record channel mask for dynamic mix" into lmp-mr1-dev
* commit '09ff91255e945f2588c377614bf7b7c0d512118e': Convert record channel mask for dynamic mix
This commit is contained in:
@ -126,6 +126,29 @@ public class AudioFormat {
|
|||||||
CHANNEL_OUT_LOW_FREQUENCY);
|
CHANNEL_OUT_LOW_FREQUENCY);
|
||||||
// CHANNEL_OUT_ALL is not yet defined; if added then it should match AUDIO_CHANNEL_OUT_ALL
|
// CHANNEL_OUT_ALL is not yet defined; if added then it should match AUDIO_CHANNEL_OUT_ALL
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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
|
* @hide
|
||||||
* Return the number of channels from an input channel mask
|
* Return the number of channels from an input channel mask
|
||||||
|
@ -155,6 +155,7 @@ public class AudioPolicy {
|
|||||||
{
|
{
|
||||||
throw new IllegalArgumentException("Invalid AudioMix: not defined for loop back");
|
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;
|
return null;
|
||||||
}
|
}
|
||||||
checkMixReadyToUse(mix, false/*not for an AudioTrack*/);
|
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
|
// create the AudioRecord, configured for loop back, using the same format as the mix
|
||||||
AudioRecord ar = new AudioRecord(
|
AudioRecord ar = new AudioRecord(
|
||||||
new AudioAttributes.Builder()
|
new AudioAttributes.Builder()
|
||||||
.setInternalCapturePreset(MediaRecorder.AudioSource.REMOTE_SUBMIX)
|
.setInternalCapturePreset(MediaRecorder.AudioSource.REMOTE_SUBMIX)
|
||||||
.addTag(mix.getRegistration())
|
.addTag(mix.getRegistration())
|
||||||
.build(),
|
.build(),
|
||||||
mix.getFormat(),
|
mixFormat,
|
||||||
AudioRecord.getMinBufferSize(mix.getFormat().getSampleRate(),
|
AudioRecord.getMinBufferSize(mix.getFormat().getSampleRate(),
|
||||||
// using stereo for buffer size to avoid the current poor support for masks
|
// using stereo for buffer size to avoid the current poor support for masks
|
||||||
AudioFormat.CHANNEL_IN_STEREO, mix.getFormat().getEncoding()),
|
AudioFormat.CHANNEL_IN_STEREO, mix.getFormat().getEncoding()),
|
||||||
|
Reference in New Issue
Block a user