From ce4483cb83afb3a42a32ef2cb00cf04d6f9018fd Mon Sep 17 00:00:00 2001 From: Benson Huang Date: Wed, 17 Sep 2014 17:21:02 +0800 Subject: [PATCH] [FM] Add FM_TUNER audio source to support L version FM radio app 1.MediaRecorder.java: Add FM_TUNER audio source type for FM record. 2.AudioRecord.java: For FM output to the other device, (except the headset case), record the FM tuner signal to a track and playback the recorded signal by a track. 3.AudioAttributes.java: Thus we use AudioRecord, need to modify setCapturePreset to support MediaRecorder.AudioSource.FM_TUNER. Review: https://partner-android-review.git.corp.google.com/#/c/182071 Signed-off-by: Benson Huang Change-Id: If068d0bbbffb4848887004396a8a8d9bcba1334e --- media/java/android/media/AudioAttributes.java | 7 ++++--- media/java/android/media/AudioRecord.java | 1 + media/java/android/media/MediaRecorder.java | 8 ++++++++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/media/java/android/media/AudioAttributes.java b/media/java/android/media/AudioAttributes.java index 25dfee6340656..17d3251b3a6f9 100644 --- a/media/java/android/media/AudioAttributes.java +++ b/media/java/android/media/AudioAttributes.java @@ -518,14 +518,15 @@ public final class AudioAttributes implements Parcelable { /** * @hide - * Same as {@link #setCapturePreset(int)} but authorizes the use of HOTWORD and - * REMOTE_SUBMIX. + * Same as {@link #setCapturePreset(int)} but authorizes the use of HOTWORD, + * REMOTE_SUBMIX and FM_TUNER. * @param preset * @return the same Builder instance. */ public Builder setInternalCapturePreset(int preset) { if ((preset == MediaRecorder.AudioSource.HOTWORD) - || (preset == MediaRecorder.AudioSource.REMOTE_SUBMIX)) { + || (preset == MediaRecorder.AudioSource.REMOTE_SUBMIX) + || (preset == MediaRecorder.AudioSource.FM_TUNER)) { mSource = preset; } else { setCapturePreset(preset); diff --git a/media/java/android/media/AudioRecord.java b/media/java/android/media/AudioRecord.java index 5be6371ee9988..ef1c0b0d2356f 100644 --- a/media/java/android/media/AudioRecord.java +++ b/media/java/android/media/AudioRecord.java @@ -351,6 +351,7 @@ public class AudioRecord // audio source if ( (audioSource < MediaRecorder.AudioSource.DEFAULT) || ((audioSource > MediaRecorder.getAudioSourceMax()) && + (audioSource != MediaRecorder.AudioSource.FM_TUNER) && (audioSource != MediaRecorder.AudioSource.HOTWORD)) ) { throw new IllegalArgumentException("Invalid audio source."); } diff --git a/media/java/android/media/MediaRecorder.java b/media/java/android/media/MediaRecorder.java index a77bb96266b3c..81d5afee5d119 100644 --- a/media/java/android/media/MediaRecorder.java +++ b/media/java/android/media/MediaRecorder.java @@ -221,6 +221,14 @@ public class MediaRecorder */ public static final int REMOTE_SUBMIX = 8; + /** + * Audio source for FM, which is used to capture current FM tuner output by FMRadio app. + * There are two use cases, one is for record FM stream for later listening, another is + * for FM indirect mode(the routing except FM to headset(headphone) device routing). + * @hide + */ + public static final int FM_TUNER = 1998; + /** * Audio source for preemptible, low-priority software hotword detection * It presents the same gain and pre processing tuning as {@link #VOICE_RECOGNITION}.