Merge "AudioDeviceInfo: fix back microphone type conversion"
This commit is contained in:
@@ -110,7 +110,7 @@ public final class AudioDeviceAttributes implements Parcelable {
|
||||
mNativeType = AudioDeviceInfo.convertDeviceTypeToInternalDevice(type);
|
||||
} else if (role == ROLE_INPUT) {
|
||||
AudioDeviceInfo.enforceValidAudioDeviceTypeIn(type);
|
||||
mNativeType = AudioDeviceInfo.convertDeviceTypeToInternalInputDevice(type);
|
||||
mNativeType = AudioDeviceInfo.convertDeviceTypeToInternalInputDevice(type, address);
|
||||
} else {
|
||||
mNativeType = AudioSystem.DEVICE_NONE;
|
||||
}
|
||||
|
||||
@@ -581,7 +581,16 @@ public final class AudioDeviceInfo {
|
||||
|
||||
/** @hide */
|
||||
public static int convertDeviceTypeToInternalInputDevice(int deviceType) {
|
||||
return EXT_TO_INT_INPUT_DEVICE_MAPPING.get(deviceType, AudioSystem.DEVICE_NONE);
|
||||
return convertDeviceTypeToInternalInputDevice(deviceType, "");
|
||||
}
|
||||
/** @hide */
|
||||
public static int convertDeviceTypeToInternalInputDevice(int deviceType, String address) {
|
||||
int internalType = EXT_TO_INT_INPUT_DEVICE_MAPPING.get(deviceType, AudioSystem.DEVICE_NONE);
|
||||
if (internalType == AudioSystem.DEVICE_IN_BUILTIN_MIC
|
||||
&& "back".equals(address)) {
|
||||
internalType = AudioSystem.DEVICE_IN_BACK_MIC;
|
||||
}
|
||||
return internalType;
|
||||
}
|
||||
|
||||
private static final SparseIntArray INT_TO_EXT_DEVICE_MAPPING;
|
||||
@@ -671,9 +680,6 @@ public final class AudioDeviceInfo {
|
||||
EXT_TO_INT_DEVICE_MAPPING.put(TYPE_USB_ACCESSORY, AudioSystem.DEVICE_OUT_USB_ACCESSORY);
|
||||
EXT_TO_INT_DEVICE_MAPPING.put(TYPE_DOCK, AudioSystem.DEVICE_OUT_ANLG_DOCK_HEADSET);
|
||||
EXT_TO_INT_DEVICE_MAPPING.put(TYPE_FM, AudioSystem.DEVICE_OUT_FM);
|
||||
EXT_TO_INT_DEVICE_MAPPING.put(TYPE_BUILTIN_MIC, AudioSystem.DEVICE_IN_BUILTIN_MIC);
|
||||
EXT_TO_INT_DEVICE_MAPPING.put(TYPE_FM_TUNER, AudioSystem.DEVICE_IN_FM_TUNER);
|
||||
EXT_TO_INT_DEVICE_MAPPING.put(TYPE_TV_TUNER, AudioSystem.DEVICE_IN_TV_TUNER);
|
||||
EXT_TO_INT_DEVICE_MAPPING.put(TYPE_TELEPHONY, AudioSystem.DEVICE_OUT_TELEPHONY_TX);
|
||||
EXT_TO_INT_DEVICE_MAPPING.put(TYPE_AUX_LINE, AudioSystem.DEVICE_OUT_AUX_LINE);
|
||||
EXT_TO_INT_DEVICE_MAPPING.put(TYPE_IP, AudioSystem.DEVICE_OUT_IP);
|
||||
|
||||
@@ -1915,7 +1915,7 @@ public class AudioSystem
|
||||
types[i] = devices.get(i).getInternalType();
|
||||
if (types[i] == AudioSystem.DEVICE_NONE) {
|
||||
types[i] = AudioDeviceInfo.convertDeviceTypeToInternalInputDevice(
|
||||
devices.get(i).getType());
|
||||
devices.get(i).getType(), devices.get(i).getAddress());
|
||||
}
|
||||
addresses[i] = devices.get(i).getAddress();
|
||||
}
|
||||
|
||||
@@ -511,7 +511,12 @@ public class AudioEffect {
|
||||
int deviceType = AudioSystem.DEVICE_NONE;
|
||||
String deviceAddress = "";
|
||||
if (device != null) {
|
||||
deviceType = AudioDeviceInfo.convertDeviceTypeToInternalDevice(device.getType());
|
||||
if (device.getRole() == AudioDeviceAttributes.ROLE_OUTPUT) {
|
||||
deviceType = AudioDeviceInfo.convertDeviceTypeToInternalDevice(device.getType());
|
||||
} else {
|
||||
deviceType = AudioDeviceInfo.convertDeviceTypeToInternalInputDevice(
|
||||
device.getType(), device.getAddress());
|
||||
}
|
||||
deviceAddress = device.getAddress();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user