Merge "fix problem in AudioEffect JNI setup." into gingerbread
This commit is contained in:
@@ -252,21 +252,23 @@ android_media_AudioTrack_native_setup(JNIEnv *env, jobject thiz, jobject weak_th
|
|||||||
lpJniStorage->mCallbackData.audioTrack_ref = env->NewGlobalRef(weak_this);
|
lpJniStorage->mCallbackData.audioTrack_ref = env->NewGlobalRef(weak_this);
|
||||||
|
|
||||||
lpJniStorage->mStreamType = atStreamType;
|
lpJniStorage->mStreamType = atStreamType;
|
||||||
|
|
||||||
jint* nSession = NULL;
|
if (jSession == NULL) {
|
||||||
if (jSession) {
|
|
||||||
nSession = (jint *) env->GetPrimitiveArrayCritical(jSession, NULL);
|
|
||||||
if (nSession == NULL) {
|
|
||||||
LOGE("Error creating AudioTrack: Error retrieving session id pointer");
|
|
||||||
delete lpJniStorage;
|
|
||||||
return AUDIOTRACK_ERROR;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
LOGE("Error creating AudioTrack: invalid session ID pointer");
|
LOGE("Error creating AudioTrack: invalid session ID pointer");
|
||||||
delete lpJniStorage;
|
delete lpJniStorage;
|
||||||
return AUDIOTRACK_ERROR;
|
return AUDIOTRACK_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
jint* nSession = (jint *) env->GetPrimitiveArrayCritical(jSession, NULL);
|
||||||
|
if (nSession == NULL) {
|
||||||
|
LOGE("Error creating AudioTrack: Error retrieving session id pointer");
|
||||||
|
delete lpJniStorage;
|
||||||
|
return AUDIOTRACK_ERROR;
|
||||||
|
}
|
||||||
|
int sessionId = nSession[0];
|
||||||
|
env->ReleasePrimitiveArrayCritical(jSession, nSession, 0);
|
||||||
|
nSession = NULL;
|
||||||
|
|
||||||
// create the native AudioTrack object
|
// create the native AudioTrack object
|
||||||
AudioTrack* lpTrack = new AudioTrack();
|
AudioTrack* lpTrack = new AudioTrack();
|
||||||
if (lpTrack == NULL) {
|
if (lpTrack == NULL) {
|
||||||
@@ -288,7 +290,7 @@ android_media_AudioTrack_native_setup(JNIEnv *env, jobject thiz, jobject weak_th
|
|||||||
0,// notificationFrames == 0 since not using EVENT_MORE_DATA to feed the AudioTrack
|
0,// notificationFrames == 0 since not using EVENT_MORE_DATA to feed the AudioTrack
|
||||||
0,// shared mem
|
0,// shared mem
|
||||||
true,// thread can call Java
|
true,// thread can call Java
|
||||||
nSession[0]);// audio session ID
|
sessionId);// audio session ID
|
||||||
|
|
||||||
} else if (memoryMode == javaAudioTrackFields.MODE_STATIC) {
|
} else if (memoryMode == javaAudioTrackFields.MODE_STATIC) {
|
||||||
// AudioTrack is using shared memory
|
// AudioTrack is using shared memory
|
||||||
@@ -309,7 +311,7 @@ android_media_AudioTrack_native_setup(JNIEnv *env, jobject thiz, jobject weak_th
|
|||||||
0,// notificationFrames == 0 since not using EVENT_MORE_DATA to feed the AudioTrack
|
0,// notificationFrames == 0 since not using EVENT_MORE_DATA to feed the AudioTrack
|
||||||
lpJniStorage->mMemBase,// shared mem
|
lpJniStorage->mMemBase,// shared mem
|
||||||
true,// thread can call Java
|
true,// thread can call Java
|
||||||
nSession[0]);// audio session ID
|
sessionId);// audio session ID
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lpTrack->initCheck() != NO_ERROR) {
|
if (lpTrack->initCheck() != NO_ERROR) {
|
||||||
@@ -317,9 +319,13 @@ android_media_AudioTrack_native_setup(JNIEnv *env, jobject thiz, jobject weak_th
|
|||||||
goto native_init_failure;
|
goto native_init_failure;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nSession = (jint *) env->GetPrimitiveArrayCritical(jSession, NULL);
|
||||||
|
if (nSession == NULL) {
|
||||||
|
LOGE("Error creating AudioTrack: Error retrieving session id pointer");
|
||||||
|
goto native_init_failure;
|
||||||
|
}
|
||||||
// read the audio session ID back from AudioTrack in case we create a new session
|
// read the audio session ID back from AudioTrack in case we create a new session
|
||||||
nSession[0] = lpTrack->getSessionId();
|
nSession[0] = lpTrack->getSessionId();
|
||||||
|
|
||||||
env->ReleasePrimitiveArrayCritical(jSession, nSession, 0);
|
env->ReleasePrimitiveArrayCritical(jSession, nSession, 0);
|
||||||
nSession = NULL;
|
nSession = NULL;
|
||||||
|
|
||||||
|
|||||||
@@ -304,14 +304,7 @@ android_media_AudioEffect_native_setup(JNIEnv *env, jobject thiz, jobject weak_t
|
|||||||
lpJniStorage->mCallbackData.audioEffect_class,
|
lpJniStorage->mCallbackData.audioEffect_class,
|
||||||
&lpJniStorage->mCallbackData);
|
&lpJniStorage->mCallbackData);
|
||||||
|
|
||||||
if (jId) {
|
if (jId == NULL) {
|
||||||
nId = (jint *) env->GetPrimitiveArrayCritical(jId, NULL);
|
|
||||||
if (nId == NULL) {
|
|
||||||
LOGE("setup: Error retrieving id pointer");
|
|
||||||
lStatus = AUDIOEFFECT_ERROR_BAD_VALUE;
|
|
||||||
goto setup_failure;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
LOGE("setup: NULL java array for id pointer");
|
LOGE("setup: NULL java array for id pointer");
|
||||||
lStatus = AUDIOEFFECT_ERROR_BAD_VALUE;
|
lStatus = AUDIOEFFECT_ERROR_BAD_VALUE;
|
||||||
goto setup_failure;
|
goto setup_failure;
|
||||||
@@ -336,8 +329,13 @@ android_media_AudioEffect_native_setup(JNIEnv *env, jobject thiz, jobject weak_t
|
|||||||
goto setup_failure;
|
goto setup_failure;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nId = (jint *) env->GetPrimitiveArrayCritical(jId, NULL);
|
||||||
|
if (nId == NULL) {
|
||||||
|
LOGE("setup: Error retrieving id pointer");
|
||||||
|
lStatus = AUDIOEFFECT_ERROR_BAD_VALUE;
|
||||||
|
goto setup_failure;
|
||||||
|
}
|
||||||
nId[0] = lpAudioEffect->id();
|
nId[0] = lpAudioEffect->id();
|
||||||
|
|
||||||
env->ReleasePrimitiveArrayCritical(jId, nId, 0);
|
env->ReleasePrimitiveArrayCritical(jId, nId, 0);
|
||||||
nId = NULL;
|
nId = NULL;
|
||||||
|
|
||||||
|
|||||||
@@ -246,14 +246,7 @@ android_media_visualizer_native_setup(JNIEnv *env, jobject thiz, jobject weak_th
|
|||||||
lpJniStorage->mCallbackData.visualizer_class,
|
lpJniStorage->mCallbackData.visualizer_class,
|
||||||
&lpJniStorage->mCallbackData);
|
&lpJniStorage->mCallbackData);
|
||||||
|
|
||||||
if (jId) {
|
if (jId == NULL) {
|
||||||
nId = (jint *) env->GetPrimitiveArrayCritical(jId, NULL);
|
|
||||||
if (nId == NULL) {
|
|
||||||
LOGE("setup: Error retrieving id pointer");
|
|
||||||
lStatus = VISUALIZER_ERROR_BAD_VALUE;
|
|
||||||
goto setup_failure;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
LOGE("setup: NULL java array for id pointer");
|
LOGE("setup: NULL java array for id pointer");
|
||||||
lStatus = VISUALIZER_ERROR_BAD_VALUE;
|
lStatus = VISUALIZER_ERROR_BAD_VALUE;
|
||||||
goto setup_failure;
|
goto setup_failure;
|
||||||
@@ -275,8 +268,13 @@ android_media_visualizer_native_setup(JNIEnv *env, jobject thiz, jobject weak_th
|
|||||||
goto setup_failure;
|
goto setup_failure;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nId = (jint *) env->GetPrimitiveArrayCritical(jId, NULL);
|
||||||
|
if (nId == NULL) {
|
||||||
|
LOGE("setup: Error retrieving id pointer");
|
||||||
|
lStatus = VISUALIZER_ERROR_BAD_VALUE;
|
||||||
|
goto setup_failure;
|
||||||
|
}
|
||||||
nId[0] = lpVisualizer->id();
|
nId[0] = lpVisualizer->id();
|
||||||
|
|
||||||
env->ReleasePrimitiveArrayCritical(jId, nId, 0);
|
env->ReleasePrimitiveArrayCritical(jId, nId, 0);
|
||||||
nId = NULL;
|
nId = NULL;
|
||||||
|
|
||||||
@@ -424,7 +422,6 @@ android_media_visualizer_native_getWaveForm(JNIEnv *env, jobject thiz, jbyteArra
|
|||||||
jint status = translateError(lpVisualizer->getWaveForm((uint8_t *)nWaveform));
|
jint status = translateError(lpVisualizer->getWaveForm((uint8_t *)nWaveform));
|
||||||
|
|
||||||
env->ReleasePrimitiveArrayCritical(jWaveform, nWaveform, 0);
|
env->ReleasePrimitiveArrayCritical(jWaveform, nWaveform, 0);
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user