Merge "AudioRecord: Add setLogSessionId" into sc-dev
This commit is contained in:
@@ -861,6 +861,23 @@ static int android_media_AudioRecord_set_preferred_microphone_field_dimension(
|
||||
return jStatus;
|
||||
}
|
||||
|
||||
static void android_media_AudioRecord_setLogSessionId(JNIEnv *env, jobject thiz,
|
||||
jstring jlogSessionId) {
|
||||
sp<AudioRecord> record = getAudioRecord(env, thiz);
|
||||
if (record == nullptr) {
|
||||
jniThrowException(env, "java/lang/IllegalStateException",
|
||||
"Unable to retrieve AudioRecord pointer for setLogSessionId()");
|
||||
}
|
||||
if (jlogSessionId == nullptr) {
|
||||
ALOGV("%s: logSessionId nullptr", __func__);
|
||||
record->setLogSessionId(nullptr);
|
||||
return;
|
||||
}
|
||||
ScopedUtfChars logSessionId(env, jlogSessionId);
|
||||
ALOGV("%s: logSessionId '%s'", __func__, logSessionId.c_str());
|
||||
record->setLogSessionId(logSessionId.c_str());
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
static jint android_media_AudioRecord_get_port_id(JNIEnv *env, jobject thiz) {
|
||||
sp<AudioRecord> lpRecorder = getAudioRecord(env, thiz);
|
||||
@@ -876,50 +893,48 @@ static jint android_media_AudioRecord_get_port_id(JNIEnv *env, jobject thiz) {
|
||||
// ----------------------------------------------------------------------------
|
||||
// ----------------------------------------------------------------------------
|
||||
static const JNINativeMethod gMethods[] = {
|
||||
// name, signature, funcPtr
|
||||
{"native_start", "(II)I", (void *)android_media_AudioRecord_start},
|
||||
{"native_stop", "()V", (void *)android_media_AudioRecord_stop},
|
||||
{"native_setup", "(Ljava/lang/Object;Ljava/lang/Object;[IIIII[ILjava/lang/String;J)I",
|
||||
(void *)android_media_AudioRecord_setup},
|
||||
{"native_finalize", "()V", (void *)android_media_AudioRecord_finalize},
|
||||
{"native_release", "()V", (void *)android_media_AudioRecord_release},
|
||||
{"native_read_in_byte_array",
|
||||
"([BIIZ)I",
|
||||
(void *)android_media_AudioRecord_readInArray<jbyteArray>},
|
||||
{"native_read_in_short_array",
|
||||
"([SIIZ)I",
|
||||
(void *)android_media_AudioRecord_readInArray<jshortArray>},
|
||||
{"native_read_in_float_array",
|
||||
"([FIIZ)I",
|
||||
(void *)android_media_AudioRecord_readInArray<jfloatArray>},
|
||||
{"native_read_in_direct_buffer","(Ljava/lang/Object;IZ)I",
|
||||
(void *)android_media_AudioRecord_readInDirectBuffer},
|
||||
{"native_get_buffer_size_in_frames",
|
||||
"()I", (void *)android_media_AudioRecord_get_buffer_size_in_frames},
|
||||
{"native_set_marker_pos","(I)I", (void *)android_media_AudioRecord_set_marker_pos},
|
||||
{"native_get_marker_pos","()I", (void *)android_media_AudioRecord_get_marker_pos},
|
||||
{"native_set_pos_update_period",
|
||||
"(I)I", (void *)android_media_AudioRecord_set_pos_update_period},
|
||||
{"native_get_pos_update_period",
|
||||
"()I", (void *)android_media_AudioRecord_get_pos_update_period},
|
||||
{"native_get_min_buff_size",
|
||||
"(III)I", (void *)android_media_AudioRecord_get_min_buff_size},
|
||||
{"native_getMetrics", "()Landroid/os/PersistableBundle;",
|
||||
(void *)android_media_AudioRecord_native_getMetrics},
|
||||
{"native_setInputDevice", "(I)Z", (void *)android_media_AudioRecord_setInputDevice},
|
||||
{"native_getRoutedDeviceId", "()I", (void *)android_media_AudioRecord_getRoutedDeviceId},
|
||||
{"native_enableDeviceCallback", "()V", (void *)android_media_AudioRecord_enableDeviceCallback},
|
||||
{"native_disableDeviceCallback", "()V",
|
||||
(void *)android_media_AudioRecord_disableDeviceCallback},
|
||||
{"native_get_timestamp", "(Landroid/media/AudioTimestamp;I)I",
|
||||
(void *)android_media_AudioRecord_get_timestamp},
|
||||
{"native_get_active_microphones", "(Ljava/util/ArrayList;)I",
|
||||
(void *)android_media_AudioRecord_get_active_microphones},
|
||||
{"native_getPortId", "()I", (void *)android_media_AudioRecord_get_port_id},
|
||||
{"native_set_preferred_microphone_direction", "(I)I",
|
||||
(void *)android_media_AudioRecord_set_preferred_microphone_direction},
|
||||
{"native_set_preferred_microphone_field_dimension", "(F)I",
|
||||
(void *)android_media_AudioRecord_set_preferred_microphone_field_dimension},
|
||||
{"native_start", "(II)I", (void *)android_media_AudioRecord_start},
|
||||
{"native_stop", "()V", (void *)android_media_AudioRecord_stop},
|
||||
{"native_setup", "(Ljava/lang/Object;Ljava/lang/Object;[IIIII[ILjava/lang/String;J)I",
|
||||
(void *)android_media_AudioRecord_setup},
|
||||
{"native_finalize", "()V", (void *)android_media_AudioRecord_finalize},
|
||||
{"native_release", "()V", (void *)android_media_AudioRecord_release},
|
||||
{"native_read_in_byte_array", "([BIIZ)I",
|
||||
(void *)android_media_AudioRecord_readInArray<jbyteArray>},
|
||||
{"native_read_in_short_array", "([SIIZ)I",
|
||||
(void *)android_media_AudioRecord_readInArray<jshortArray>},
|
||||
{"native_read_in_float_array", "([FIIZ)I",
|
||||
(void *)android_media_AudioRecord_readInArray<jfloatArray>},
|
||||
{"native_read_in_direct_buffer", "(Ljava/lang/Object;IZ)I",
|
||||
(void *)android_media_AudioRecord_readInDirectBuffer},
|
||||
{"native_get_buffer_size_in_frames", "()I",
|
||||
(void *)android_media_AudioRecord_get_buffer_size_in_frames},
|
||||
{"native_set_marker_pos", "(I)I", (void *)android_media_AudioRecord_set_marker_pos},
|
||||
{"native_get_marker_pos", "()I", (void *)android_media_AudioRecord_get_marker_pos},
|
||||
{"native_set_pos_update_period", "(I)I",
|
||||
(void *)android_media_AudioRecord_set_pos_update_period},
|
||||
{"native_get_pos_update_period", "()I",
|
||||
(void *)android_media_AudioRecord_get_pos_update_period},
|
||||
{"native_get_min_buff_size", "(III)I", (void *)android_media_AudioRecord_get_min_buff_size},
|
||||
{"native_getMetrics", "()Landroid/os/PersistableBundle;",
|
||||
(void *)android_media_AudioRecord_native_getMetrics},
|
||||
{"native_setInputDevice", "(I)Z", (void *)android_media_AudioRecord_setInputDevice},
|
||||
{"native_getRoutedDeviceId", "()I", (void *)android_media_AudioRecord_getRoutedDeviceId},
|
||||
{"native_enableDeviceCallback", "()V",
|
||||
(void *)android_media_AudioRecord_enableDeviceCallback},
|
||||
{"native_disableDeviceCallback", "()V",
|
||||
(void *)android_media_AudioRecord_disableDeviceCallback},
|
||||
{"native_get_timestamp", "(Landroid/media/AudioTimestamp;I)I",
|
||||
(void *)android_media_AudioRecord_get_timestamp},
|
||||
{"native_get_active_microphones", "(Ljava/util/ArrayList;)I",
|
||||
(void *)android_media_AudioRecord_get_active_microphones},
|
||||
{"native_getPortId", "()I", (void *)android_media_AudioRecord_get_port_id},
|
||||
{"native_set_preferred_microphone_direction", "(I)I",
|
||||
(void *)android_media_AudioRecord_set_preferred_microphone_direction},
|
||||
{"native_set_preferred_microphone_field_dimension", "(F)I",
|
||||
(void *)android_media_AudioRecord_set_preferred_microphone_field_dimension},
|
||||
{"native_setLogSessionId", "(Ljava/lang/String;)V",
|
||||
(void *)android_media_AudioRecord_setLogSessionId},
|
||||
};
|
||||
|
||||
// field names found in android/media/AudioRecord.java
|
||||
|
||||
@@ -1426,8 +1426,13 @@ static void android_media_AudioTrack_setLogSessionId(JNIEnv *env, jobject thiz,
|
||||
jniThrowException(env, "java/lang/IllegalStateException",
|
||||
"Unable to retrieve AudioTrack pointer for setLogSessionId()");
|
||||
}
|
||||
if (jlogSessionId == nullptr) {
|
||||
ALOGV("%s: logSessionId nullptr", __func__);
|
||||
track->setLogSessionId(nullptr);
|
||||
return;
|
||||
}
|
||||
ScopedUtfChars logSessionId(env, jlogSessionId);
|
||||
ALOGV("%s: logSessionId %s", __func__, logSessionId.c_str());
|
||||
ALOGV("%s: logSessionId '%s'", __func__, logSessionId.c_str());
|
||||
track->setLogSessionId(logSessionId.c_str());
|
||||
}
|
||||
|
||||
|
||||
@@ -275,6 +275,12 @@ public class AudioRecord implements AudioRouting, MicrophoneDirection,
|
||||
private AudioAttributes mAudioAttributes;
|
||||
private boolean mIsSubmixFullVolume = false;
|
||||
|
||||
/**
|
||||
* The log session id used for metrics.
|
||||
* A null or empty string here means it is not set.
|
||||
*/
|
||||
private String mLogSessionId;
|
||||
|
||||
//---------------------------------------------------------
|
||||
// Constructor, Finalize
|
||||
//--------------------
|
||||
@@ -1913,6 +1919,25 @@ public class AudioRecord implements AudioRouting, MicrophoneDirection,
|
||||
return native_set_preferred_microphone_field_dimension(zoom) == AudioSystem.SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a string handle to this AudioRecord for metrics collection.
|
||||
*
|
||||
* @param logSessionId a string which is used to identify this object
|
||||
* to the metrics service. Proper generated Ids must be obtained
|
||||
* from the Java metrics service and should be considered opaque.
|
||||
* Use null to remove the logSessionId association.
|
||||
* @throws IllegalStateException if AudioRecord not initialized.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public void setLogSessionId(@Nullable String logSessionId) {
|
||||
if (mState == STATE_UNINITIALIZED) {
|
||||
throw new IllegalStateException("AudioRecord not initialized");
|
||||
}
|
||||
native_setLogSessionId(logSessionId);
|
||||
mLogSessionId = logSessionId;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------
|
||||
// Interface definitions
|
||||
//--------------------
|
||||
@@ -2072,6 +2097,8 @@ public class AudioRecord implements AudioRouting, MicrophoneDirection,
|
||||
private native int native_set_preferred_microphone_direction(int direction);
|
||||
private native int native_set_preferred_microphone_field_dimension(float zoom);
|
||||
|
||||
private native void native_setLogSessionId(@Nullable String logSessionId);
|
||||
|
||||
//---------------------------------------------------------
|
||||
// Utility methods
|
||||
//------------------
|
||||
|
||||
@@ -567,6 +567,7 @@ public class AudioTrack extends PlayerBase
|
||||
|
||||
/**
|
||||
* The log session id used for metrics.
|
||||
* A null or empty string here means it is not set.
|
||||
*/
|
||||
private String mLogSessionId;
|
||||
|
||||
@@ -3978,12 +3979,14 @@ public class AudioTrack extends PlayerBase
|
||||
* Sets a string handle to this AudioTrack for metrics collection.
|
||||
*
|
||||
* @param logSessionId a string which is used to identify this object
|
||||
* to the metrics service.
|
||||
* to the metrics service. Proper generated Ids must be obtained
|
||||
* from the Java metrics service and should be considered opaque.
|
||||
* Use null to remove the logSessionId association.
|
||||
* @throws IllegalStateException if AudioTrack not initialized.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public void setLogSessionId(@NonNull String logSessionId) {
|
||||
public void setLogSessionId(@Nullable String logSessionId) {
|
||||
if (mState == STATE_UNINITIALIZED) {
|
||||
throw new IllegalStateException("track not initialized");
|
||||
}
|
||||
@@ -4226,7 +4229,7 @@ public class AudioTrack extends PlayerBase
|
||||
private native int native_get_audio_description_mix_level_db(float[] level);
|
||||
private native int native_set_dual_mono_mode(int dualMonoMode);
|
||||
private native int native_get_dual_mono_mode(int[] dualMonoMode);
|
||||
private native void native_setLogSessionId(@NonNull String logSessionId);
|
||||
private native void native_setLogSessionId(@Nullable String logSessionId);
|
||||
|
||||
/**
|
||||
* Sets the audio service Player Interface Id.
|
||||
|
||||
Reference in New Issue
Block a user