From 9cc489a2196e449dbe090ad9bdbc5cedd0b8334f Mon Sep 17 00:00:00 2001 From: Eric Laurent Date: Sat, 5 Dec 2009 05:20:01 -0800 Subject: Fix issue 2304669: VoiceIME: starting and canceling voice IME yields persistent "error 8" state on future attempts and breaks voice search. Fixed AudioFlinger::openInput() broken in change ddb78e7753be03937ad57ce7c3c842c52bdad65e so that an invalid IO handle (0) is returned in case of failure. Applied the same correction to openOutput(). Modified RecordThread start procedure so that a failure occuring during the first read from audio input stream is detected and causes the record start to fail. Modified RecordThread stop procedure to make sure that audio input stream fd is closed before we exit the stop function. Fixed AudioRecord JAVA and JNI implementation to take status of native AudioRecord::start() into account and not change mRecordingState to RECORDSTATE_RECORDING if start fails. --- core/jni/android_media_AudioRecord.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'core') diff --git a/core/jni/android_media_AudioRecord.cpp b/core/jni/android_media_AudioRecord.cpp index 0be996d..d7485ae 100644 --- a/core/jni/android_media_AudioRecord.cpp +++ b/core/jni/android_media_AudioRecord.cpp @@ -224,17 +224,17 @@ native_track_failure: // ---------------------------------------------------------------------------- -static void +static int android_media_AudioRecord_start(JNIEnv *env, jobject thiz) { AudioRecord *lpRecorder = (AudioRecord *)env->GetIntField(thiz, javaAudioRecordFields.nativeRecorderInJavaObj); if (lpRecorder == NULL ) { jniThrowException(env, "java/lang/IllegalStateException", NULL); - return; + return AUDIORECORD_ERROR; } - lpRecorder->start(); + return android_media_translateRecorderErrorCode(lpRecorder->start()); } @@ -482,7 +482,7 @@ static jint android_media_AudioRecord_get_min_buff_size(JNIEnv *env, jobject th // ---------------------------------------------------------------------------- static JNINativeMethod gMethods[] = { // name, signature, funcPtr - {"native_start", "()V", (void *)android_media_AudioRecord_start}, + {"native_start", "()I", (void *)android_media_AudioRecord_start}, {"native_stop", "()V", (void *)android_media_AudioRecord_stop}, {"native_setup", "(Ljava/lang/Object;IIIII)I", (void *)android_media_AudioRecord_setup}, -- cgit v1.1