am b7e8fdce: am ee99d080: Merge "AudioRecord: add HW hotword capture flag" into lmp-dev

* commit 'b7e8fdcedb9e9f62cd91ec53384f9ab1571e3835':
  AudioRecord: add HW hotword capture flag
This commit is contained in:
Eric Laurent
2014-09-24 03:53:05 +00:00
committed by Android Git Automerger
2 changed files with 22 additions and 4 deletions

View File

@@ -45,6 +45,7 @@ struct audio_record_fields_t {
};
struct audio_attributes_fields_t {
jfieldID fieldRecSource; // AudioAttributes.mSource
jfieldID fieldFlags; // AudioAttributes.mFlags
jfieldID fieldFormattedTags;// AudioAttributes.mFormattedTags
};
static audio_attributes_fields_t javaAudioAttrFields;
@@ -212,9 +213,13 @@ android_media_AudioRecord_setup(JNIEnv *env, jobject thiz, jobject weak_this,
strncpy(paa->tags, tags, AUDIO_ATTRIBUTES_TAGS_MAX_SIZE - 1);
env->ReleaseStringUTFChars(jtags, tags);
paa->source = (audio_source_t) env->GetIntField(jaa, javaAudioAttrFields.fieldRecSource);
paa->flags = (audio_flags_mask_t)env->GetIntField(jaa, javaAudioAttrFields.fieldFlags);
ALOGV("AudioRecord_setup for source=%d tags=%s flags=%08x", paa->source, paa->tags, paa->flags);
ALOGV("AudioRecord_setup for source=%d tags=%s", paa->source, paa->tags);
audio_input_flags_t flags = AUDIO_INPUT_FLAG_NONE;
if (paa->flags & AUDIO_FLAG_HW_HOTWORD) {
flags = AUDIO_INPUT_FLAG_HW_HOTWORD;
}
// create the callback information:
// this data will be passed with every AudioRecord callback
audiorecord_callback_cookie *lpCallbackData = new audiorecord_callback_cookie;
@@ -232,7 +237,9 @@ android_media_AudioRecord_setup(JNIEnv *env, jobject thiz, jobject weak_this,
lpCallbackData,// void* user
0, // notificationFrames,
true, // threadCanCallJava
sessionId);
sessionId,
AudioRecord::TRANSFER_DEFAULT,
flags);
if (status != NO_ERROR) {
ALOGE("Error creating AudioRecord instance: initialization check failed with status %d.",
@@ -638,10 +645,12 @@ int register_android_media_AudioRecord(JNIEnv *env)
}
jclass audioAttributesClassRef = (jclass)env->NewGlobalRef(audioAttrClass);
javaAudioAttrFields.fieldRecSource = env->GetFieldID(audioAttributesClassRef, "mSource", "I");
javaAudioAttrFields.fieldFlags = env->GetFieldID(audioAttributesClassRef, "mFlags", "I");
javaAudioAttrFields.fieldFormattedTags =
env->GetFieldID(audioAttributesClassRef, "mFormattedTags", "Ljava/lang/String;");
env->DeleteGlobalRef(audioAttributesClassRef);
if (javaAudioAttrFields.fieldRecSource == NULL
|| javaAudioAttrFields.fieldFlags == NULL
|| javaAudioAttrFields.fieldFormattedTags == NULL) {
ALOGE("Can't initialize AudioAttributes fields");
return -1;

View File

@@ -194,8 +194,17 @@ public final class AudioAttributes implements Parcelable {
*/
public final static int FLAG_HW_AV_SYNC = 0x1 << 4;
/**
* @hide
* Flag requesting capture from the source used for hardware hotword detection.
* To be used with capture preset MediaRecorder.AudioSource.HOTWORD or
* MediaRecorder.AudioSource.VOICE_RECOGNITION.
*/
@SystemApi
public final static int FLAG_HW_HOTWORD = 0x1 << 5;
private final static int FLAG_ALL = FLAG_AUDIBILITY_ENFORCED | FLAG_SECURE | FLAG_SCO |
FLAG_BEACON | FLAG_HW_AV_SYNC;
FLAG_BEACON | FLAG_HW_AV_SYNC | FLAG_HW_HOTWORD;
private final static int FLAG_ALL_PUBLIC = FLAG_AUDIBILITY_ENFORCED | FLAG_HW_AV_SYNC;
private int mUsage = USAGE_UNKNOWN;