summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Eric Laurent <elaurent@google.com> 2019-01-15 18:38:32 -0800
committer Eric Laurent <elaurent@google.com> 2019-01-16 09:53:51 -0800
commit0016c5b73913b0deca25b92f887200625d371be3 (patch)
tree6872ac15f0b6f75a7d287c2d9e65dfa835345735
parenta32c79d362e851816b3e4b892f65fa9a274c0c68 (diff)
add new audio sources for audio capture
This commit adds the following audio capture sources: - AudioSource.VOICE_PERFORMANCE: for real time live performances like Karaoke. - AudioSource.ECHO_REFERENCE: for capturing the reference signal to suppress by an echo canceller. Protected by privileged permission CAPTURE_AUDIO_OUTPUT. Also added device AUDIO_DEVICE_IN_ECHO_REFERENCE selected when the requested capture source is AudioSource.ECHO_REFERENCE. Bug: 118203066 Test: CTS tests for audio capture Change-Id: I8258296736848986562f7fc89c9260aad562d3d1
-rw-r--r--api/current.txt1
-rw-r--r--api/system-current.txt1
-rw-r--r--media/java/android/media/AudioAttributes.java11
-rw-r--r--media/java/android/media/AudioRecordingConfiguration.java3
-rw-r--r--media/java/android/media/AudioSystem.java10
-rw-r--r--media/java/android/media/MediaRecorder.java35
6 files changed, 55 insertions, 6 deletions
diff --git a/api/current.txt b/api/current.txt
index 18f150fc57d8..b452a28f5844 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -25653,6 +25653,7 @@ package android.media {
field public static final int VOICE_CALL = 4; // 0x4
field public static final int VOICE_COMMUNICATION = 7; // 0x7
field public static final int VOICE_DOWNLINK = 3; // 0x3
+ field public static final int VOICE_PERFORMANCE = 10; // 0xa
field public static final int VOICE_RECOGNITION = 6; // 0x6
field public static final int VOICE_UPLINK = 2; // 0x2
}
diff --git a/api/system-current.txt b/api/system-current.txt
index 78f3471c3e86..3901ed517b29 100644
--- a/api/system-current.txt
+++ b/api/system-current.txt
@@ -3301,6 +3301,7 @@ package android.media {
}
public final class MediaRecorder.AudioSource {
+ field public static final int ECHO_REFERENCE = 1997; // 0x7cd
field public static final int HOTWORD = 1999; // 0x7cf
field public static final int RADIO_TUNER = 1998; // 0x7ce
}
diff --git a/media/java/android/media/AudioAttributes.java b/media/java/android/media/AudioAttributes.java
index 4f23cca1171f..f5a6f8667fa6 100644
--- a/media/java/android/media/AudioAttributes.java
+++ b/media/java/android/media/AudioAttributes.java
@@ -736,8 +736,9 @@ public final class AudioAttributes implements Parcelable {
* @param preset one of {@link MediaRecorder.AudioSource#DEFAULT},
* {@link MediaRecorder.AudioSource#MIC}, {@link MediaRecorder.AudioSource#CAMCORDER},
* {@link MediaRecorder.AudioSource#VOICE_RECOGNITION},
- * {@link MediaRecorder.AudioSource#VOICE_COMMUNICATION} or
- * {@link MediaRecorder.AudioSource#UNPROCESSED}
+ * {@link MediaRecorder.AudioSource#VOICE_COMMUNICATION},
+ * {@link MediaRecorder.AudioSource#UNPROCESSED} or
+ * {@link MediaRecorder.AudioSource#VOICE_PERFORMANCE}
* @return the same Builder instance.
*/
@SystemApi
@@ -749,6 +750,7 @@ public final class AudioAttributes implements Parcelable {
case MediaRecorder.AudioSource.VOICE_RECOGNITION:
case MediaRecorder.AudioSource.VOICE_COMMUNICATION:
case MediaRecorder.AudioSource.UNPROCESSED:
+ case MediaRecorder.AudioSource.VOICE_PERFORMANCE:
mSource = preset;
break;
default:
@@ -760,7 +762,7 @@ public final class AudioAttributes implements Parcelable {
/**
* @hide
* Same as {@link #setCapturePreset(int)} but authorizes the use of HOTWORD,
- * REMOTE_SUBMIX, RADIO_TUNER, VOICE_DOWNLINK, VOICE_UPLINK and VOICE_CALL.
+ * REMOTE_SUBMIX, RADIO_TUNER, VOICE_DOWNLINK, VOICE_UPLINK, VOICE_CALL and ECHO_REFERENCE.
* @param preset
* @return the same Builder instance.
*/
@@ -771,7 +773,8 @@ public final class AudioAttributes implements Parcelable {
|| (preset == MediaRecorder.AudioSource.RADIO_TUNER)
|| (preset == MediaRecorder.AudioSource.VOICE_DOWNLINK)
|| (preset == MediaRecorder.AudioSource.VOICE_UPLINK)
- || (preset == MediaRecorder.AudioSource.VOICE_CALL)) {
+ || (preset == MediaRecorder.AudioSource.VOICE_CALL)
+ || (preset == MediaRecorder.AudioSource.ECHO_REFERENCE)) {
mSource = preset;
} else {
setCapturePreset(preset);
diff --git a/media/java/android/media/AudioRecordingConfiguration.java b/media/java/android/media/AudioRecordingConfiguration.java
index de76aeff82c4..52771e4199d8 100644
--- a/media/java/android/media/AudioRecordingConfiguration.java
+++ b/media/java/android/media/AudioRecordingConfiguration.java
@@ -172,7 +172,8 @@ public final class AudioRecordingConfiguration implements Parcelable {
MediaRecorder.AudioSource.CAMCORDER,
MediaRecorder.AudioSource.VOICE_RECOGNITION,
MediaRecorder.AudioSource.VOICE_COMMUNICATION,
- MediaRecorder.AudioSource.UNPROCESSED
+ MediaRecorder.AudioSource.UNPROCESSED,
+ MediaRecorder.AudioSource.VOICE_PERFORMANCE
})
@Retention(RetentionPolicy.SOURCE)
public @interface AudioSource {}
diff --git a/media/java/android/media/AudioSystem.java b/media/java/android/media/AudioSystem.java
index 45cde0ffecc4..de73649d59dc 100644
--- a/media/java/android/media/AudioSystem.java
+++ b/media/java/android/media/AudioSystem.java
@@ -541,6 +541,8 @@ public class AudioSystem
public static final int DEVICE_IN_BUS = DEVICE_BIT_IN | 0x100000;
public static final int DEVICE_IN_PROXY = DEVICE_BIT_IN | 0x1000000;
public static final int DEVICE_IN_USB_HEADSET = DEVICE_BIT_IN | 0x2000000;
+ public static final int DEVICE_IN_BLUETOOTH_BLE = DEVICE_BIT_IN | 0x4000000;
+ public static final int DEVICE_IN_ECHO_REFERENCE = DEVICE_BIT_IN | 0x10000000;
@UnsupportedAppUsage
public static final int DEVICE_IN_DEFAULT = DEVICE_BIT_IN | DEVICE_BIT_DEFAULT;
@@ -567,6 +569,8 @@ public class AudioSystem
DEVICE_IN_BUS |
DEVICE_IN_PROXY |
DEVICE_IN_USB_HEADSET |
+ DEVICE_IN_BLUETOOTH_BLE |
+ DEVICE_IN_ECHO_REFERENCE |
DEVICE_IN_DEFAULT);
public static final int DEVICE_IN_ALL_SCO = DEVICE_IN_BLUETOOTH_SCO_HEADSET;
public static final int DEVICE_IN_ALL_USB = (DEVICE_IN_USB_ACCESSORY |
@@ -641,6 +645,8 @@ public class AudioSystem
public static final String DEVICE_IN_BUS_NAME = "bus";
public static final String DEVICE_IN_PROXY_NAME = "proxy";
public static final String DEVICE_IN_USB_HEADSET_NAME = "usb_headset";
+ public static final String DEVICE_IN_BLUETOOTH_BLE_NAME = "bt_ble";
+ public static final String DEVICE_IN_ECHO_REFERENCE_NAME = "echo_reference";
@UnsupportedAppUsage
public static String getOutputDeviceName(int device)
@@ -757,6 +763,10 @@ public class AudioSystem
return DEVICE_IN_PROXY_NAME;
case DEVICE_IN_USB_HEADSET:
return DEVICE_IN_USB_HEADSET_NAME;
+ case DEVICE_IN_BLUETOOTH_BLE:
+ return DEVICE_IN_BLUETOOTH_BLE_NAME;
+ case DEVICE_IN_ECHO_REFERENCE:
+ return DEVICE_IN_ECHO_REFERENCE_NAME;
case DEVICE_IN_DEFAULT:
default:
return Integer.toString(device);
diff --git a/media/java/android/media/MediaRecorder.java b/media/java/android/media/MediaRecorder.java
index 25b1df26fd40..1304afe3654e 100644
--- a/media/java/android/media/MediaRecorder.java
+++ b/media/java/android/media/MediaRecorder.java
@@ -302,6 +302,34 @@ public class MediaRecorder implements AudioRouting,
* {@link #DEFAULT} otherwise. */
public static final int UNPROCESSED = 9;
+
+ /**
+ * Source for capturing audio meant to be processed in real time and played back for live
+ * performance (e.g karaoke).
+ * <p>
+ * The capture path will minimize latency and coupling with
+ * playback path.
+ * </p>
+ */
+ public static final int VOICE_PERFORMANCE = 10;
+
+ /**
+ * Source for an echo canceller to capture the reference signal to be cancelled.
+ * <p>
+ * The echo reference signal will be captured as close as possible to the DAC in order
+ * to include all post processing applied to the playback path.
+ * </p><p>
+ * Capturing the echo reference requires the
+ * {@link android.Manifest.permission#CAPTURE_AUDIO_OUTPUT} permission.
+ * This permission is reserved for use by system components and is not available to
+ * third-party applications.
+ * </p>
+ * @hide
+ */
+ @SystemApi
+ @RequiresPermission(android.Manifest.permission.CAPTURE_AUDIO_OUTPUT)
+ public static final int ECHO_REFERENCE = 1997;
+
/**
* Audio source for capturing broadcast radio tuner output.
* @hide
@@ -343,6 +371,7 @@ public class MediaRecorder implements AudioRouting,
case AudioSource.VOICE_COMMUNICATION:
//case REMOTE_SUBMIX: considered "system" as it requires system permissions
case AudioSource.UNPROCESSED:
+ case AudioSource.VOICE_PERFORMANCE:
return false;
default:
return true;
@@ -372,6 +401,10 @@ public class MediaRecorder implements AudioRouting,
return "REMOTE_SUBMIX";
case AudioSource.UNPROCESSED:
return "UNPROCESSED";
+ case AudioSource.ECHO_REFERENCE:
+ return "ECHO_REFERENCE";
+ case AudioSource.VOICE_PERFORMANCE:
+ return "VOICE_PERFORMANCE";
case AudioSource.RADIO_TUNER:
return "RADIO_TUNER";
case AudioSource.HOTWORD:
@@ -524,7 +557,7 @@ public class MediaRecorder implements AudioRouting,
* @see android.media.MediaRecorder.AudioSource
*/
public static final int getAudioSourceMax() {
- return AudioSource.UNPROCESSED;
+ return AudioSource.VOICE_PERFORMANCE;
}
/**