diff options
author | Android (Google) Code Review <android-gerrit@google.com> | 2009-05-26 10:04:50 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2009-05-26 10:04:50 -0700 |
commit | de8268d6d1cd168510c490b17e93154d2eab767c (patch) | |
tree | 1e4b879d15302cdea436cb33c505bda945dec5b5 /core | |
parent | 30d79f64ecdd15d279cae6421f39a0c8fa2fab7d (diff) | |
parent | 4bc035a65cac177be9294e69f110497e3b6e34e6 (diff) | |
download | frameworks_base-de8268d6d1cd168510c490b17e93154d2eab767c.zip frameworks_base-de8268d6d1cd168510c490b17e93154d2eab767c.tar.gz frameworks_base-de8268d6d1cd168510c490b17e93154d2eab767c.tar.bz2 |
Merge change 2331 into donut
* changes:
Fix issue 1846343 - part 1
Diffstat (limited to 'core')
-rw-r--r-- | core/jni/android_media_AudioRecord.cpp | 34 |
1 files changed, 9 insertions, 25 deletions
diff --git a/core/jni/android_media_AudioRecord.cpp b/core/jni/android_media_AudioRecord.cpp index 288433a..e71e348 100644 --- a/core/jni/android_media_AudioRecord.cpp +++ b/core/jni/android_media_AudioRecord.cpp @@ -45,8 +45,6 @@ struct fields_t { jmethodID postNativeEventInJava; //... event post callback method int PCM16; //... format constants int PCM8; //... format constants - int SOURCE_DEFAULT; //... record source constants - int SOURCE_MIC; //... record source constants jfieldID nativeRecorderInJavaObj; // provides access to the C++ AudioRecord object jfieldID nativeCallbackCookie; // provides access to the AudioRecord callback data }; @@ -66,7 +64,7 @@ struct audiorecord_callback_cookie { #define AUDIORECORD_ERROR_SETUP_ZEROFRAMECOUNT -16 #define AUDIORECORD_ERROR_SETUP_INVALIDCHANNELCOUNT -17 #define AUDIORECORD_ERROR_SETUP_INVALIDFORMAT -18 -#define AUDIORECORD_ERROR_SETUP_INVALIDSTREAMTYPE -19 +#define AUDIORECORD_ERROR_SETUP_INVALIDSOURCE -19 #define AUDIORECORD_ERROR_SETUP_NATIVEINITFAILED -20 jint android_media_translateRecorderErrorCode(int code) { @@ -154,17 +152,16 @@ android_media_AudioRecord_setup(JNIEnv *env, jobject thiz, jobject weak_this, int frameSize = nbChannels * bytesPerSample; size_t frameCount = buffSizeInBytes / frameSize; - // compare the source against the Java constants - AudioRecord::stream_type arSource; - if (source == javaAudioRecordFields.SOURCE_DEFAULT) { - arSource = AudioRecord::DEFAULT_INPUT; - } else if (source == javaAudioRecordFields.SOURCE_MIC) { - arSource = AudioRecord::MIC_INPUT; - } else { + // convert and check input source value + // input_source values defined in AudioRecord.h are equal to + // JAVA MediaRecord.AudioSource values minus 1. + AudioRecord::input_source arSource = (AudioRecord::input_source)(source - 1); + if (arSource < AudioRecord::DEFAULT_INPUT || + arSource >= AudioRecord::NUM_INPUT_SOURCES) { LOGE("Error creating AudioRecord: unknown source."); - return AUDIORECORD_ERROR_SETUP_INVALIDSTREAMTYPE; + return AUDIORECORD_ERROR_SETUP_INVALIDSOURCE; } - + audiorecord_callback_cookie *lpCallbackData = NULL; AudioRecord* lpRecorder = NULL; @@ -511,8 +508,6 @@ static JNINativeMethod gMethods[] = { #define JAVA_POSTEVENT_CALLBACK_NAME "postEventFromNative" #define JAVA_CONST_PCM16_NAME "ENCODING_PCM_16BIT" #define JAVA_CONST_PCM8_NAME "ENCODING_PCM_8BIT" -#define JAVA_CONST_SOURCEDEFAULT_NAME "SOURCE_DEFAULT" -#define JAVA_CONST_SOURCEMIC_NAME "SOURCE_MIC" #define JAVA_NATIVERECORDERINJAVAOBJ_FIELD_NAME "mNativeRecorderInJavaObj" #define JAVA_NATIVECALLBACKINFO_FIELD_NAME "mNativeCallbackCookie" @@ -583,17 +578,6 @@ int register_android_media_AudioRecord(JNIEnv *env) return -1; } - // Get the recording source constants from the AudioRecord class - if ( !android_media_getIntConstantFromClass(env, javaAudioRecordFields.audioRecordClass, - kClassPathName, - JAVA_CONST_SOURCEDEFAULT_NAME, &(javaAudioRecordFields.SOURCE_DEFAULT)) - || !android_media_getIntConstantFromClass(env, javaAudioRecordFields.audioRecordClass, - kClassPathName, - JAVA_CONST_SOURCEMIC_NAME, &(javaAudioRecordFields.SOURCE_MIC)) ) { - // error log performed in getIntConstantFromClass() - return -1; - } - return AndroidRuntime::registerNativeMethods(env, kClassPathName, gMethods, NELEM(gMethods)); } |