Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6bb5cb24 authored by Narayan Kamath's avatar Narayan Kamath
Browse files

Resolved conflicts for merge of 28c6ec02 to master

Change-Id: Idf1cabf2694dfa13d928df944d346f5e051b6948
parents f12fa012 28c6ec02
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -34,7 +34,7 @@ public final class MicrophoneInputStream extends InputStream {
    }
    
    private final static String TAG = "MicrophoneInputStream";
    private int mAudioRecord = 0;
    private long mAudioRecord = 0;
    private byte[] mOneByte = new byte[1];
    
    /**
@@ -102,9 +102,9 @@ public final class MicrophoneInputStream extends InputStream {
    //
    // AudioRecord JNI interface
    //
    private static native int AudioRecordNew(int sampleRate, int fifoDepth);
    private static native int AudioRecordStart(int audioRecord);
    private static native int AudioRecordRead(int audioRecord, byte[] b, int offset, int length) throws IOException;
    private static native void AudioRecordStop(int audioRecord) throws IOException;
    private static native void AudioRecordDelete(int audioRecord) throws IOException;
    private static native long AudioRecordNew(int sampleRate, int fifoDepth);
    private static native int AudioRecordStart(long audioRecord);
    private static native int AudioRecordRead(long audioRecord, byte[] b, int offset, int length) throws IOException;
    private static native void AudioRecordStop(long audioRecord) throws IOException;
    private static native void AudioRecordDelete(long audioRecord) throws IOException;
}
+68 −68
Original line number Diff line number Diff line
@@ -123,10 +123,10 @@ public final class Recognizer {
    public static final String KEY_MEANING = "meaning";

    // handle to SR_Vocabulary object
    private int mVocabulary = 0;
    private long mVocabulary = 0;
    
    // handle to SR_Recognizer object
    private int mRecognizer = 0;
    private long mRecognizer = 0;
    
    // Grammar currently associated with Recognizer via SR_GrammarSetupRecognizer
    private Grammar mActiveGrammar = null;
@@ -172,7 +172,7 @@ public final class Recognizer {
     * Represents a grammar loaded into the Recognizer.
     */
    public class Grammar {
        private int mGrammar = 0;
        private long mGrammar = 0;

        /**
         * Create a <code>Grammar</code> instance.
@@ -601,116 +601,116 @@ public final class Recognizer {
    //
    // SR_Recognizer methods
    //
    private static native void SR_RecognizerStart(int recognizer);
    private static native void SR_RecognizerStop(int recognizer);
    private static native int SR_RecognizerCreate();
    private static native void SR_RecognizerDestroy(int recognizer);
    private static native void SR_RecognizerSetup(int recognizer);
    private static native void SR_RecognizerUnsetup(int recognizer);
    private static native boolean SR_RecognizerIsSetup(int recognizer);
    private static native String SR_RecognizerGetParameter(int recognizer, String key);
    private static native int SR_RecognizerGetSize_tParameter(int recognizer, String key);
    private static native boolean SR_RecognizerGetBoolParameter(int recognizer, String key);
    private static native void SR_RecognizerSetParameter(int recognizer, String key, String value);
    private static native void SR_RecognizerSetSize_tParameter(int recognizer,
    private static native void SR_RecognizerStart(long recognizer);
    private static native void SR_RecognizerStop(long recognizer);
    private static native long SR_RecognizerCreate();
    private static native void SR_RecognizerDestroy(long recognizer);
    private static native void SR_RecognizerSetup(long recognizer);
    private static native void SR_RecognizerUnsetup(long recognizer);
    private static native boolean SR_RecognizerIsSetup(long recognizer);
    private static native String SR_RecognizerGetParameter(long recognizer, String key);
    private static native int SR_RecognizerGetSize_tParameter(long recognizer, String key);
    private static native boolean SR_RecognizerGetBoolParameter(long recognizer, String key);
    private static native void SR_RecognizerSetParameter(long recognizer, String key, String value);
    private static native void SR_RecognizerSetSize_tParameter(long recognizer,
            String key, int value);
    private static native void SR_RecognizerSetBoolParameter(int recognizer, String key,
    private static native void SR_RecognizerSetBoolParameter(long recognizer, String key,
            boolean value);
    private static native void SR_RecognizerSetupRule(int recognizer, int grammar,
    private static native void SR_RecognizerSetupRule(long recognizer, long grammar,
            String ruleName);
    private static native boolean SR_RecognizerHasSetupRules(int recognizer);
    private static native void SR_RecognizerActivateRule(int recognizer, int grammar,
    private static native boolean SR_RecognizerHasSetupRules(long recognizer);
    private static native void SR_RecognizerActivateRule(long recognizer, long grammar,
            String ruleName, int weight);
    private static native void SR_RecognizerDeactivateRule(int recognizer, int grammar,
    private static native void SR_RecognizerDeactivateRule(long recognizer, long grammar,
            String ruleName);
    private static native void SR_RecognizerDeactivateAllRules(int recognizer);
    private static native boolean SR_RecognizerIsActiveRule(int recognizer, int grammar,
    private static native void SR_RecognizerDeactivateAllRules(long recognizer);
    private static native boolean SR_RecognizerIsActiveRule(long recognizer, long grammar,
            String ruleName);
    private static native boolean SR_RecognizerCheckGrammarConsistency(int recognizer,
            int grammar);
    private static native int SR_RecognizerPutAudio(int recognizer, byte[] buffer, int offset,
    private static native boolean SR_RecognizerCheckGrammarConsistency(long recognizer,
            long grammar);
    private static native int SR_RecognizerPutAudio(long recognizer, byte[] buffer, int offset,
            int length, boolean isLast);
    private static native int SR_RecognizerAdvance(int recognizer);
    // private static native void SR_RecognizerLoadUtterance(int recognizer,
    private static native int SR_RecognizerAdvance(long recognizer);
    // private static native void SR_RecognizerLoadUtterance(long recognizer,
    //         const LCHAR* filename);
    // private static native void SR_RecognizerLoadWaveFile(int recognizer,
    // private static native void SR_RecognizerLoadWaveFile(long recognizer,
    //         const LCHAR* filename);
    // private static native void SR_RecognizerSetLockFunction(int recognizer,
    // private static native void SR_RecognizerSetLockFunction(long recognizer,
    //         SR_RecognizerLockFunction function, void* data);
    private static native boolean SR_RecognizerIsSignalClipping(int recognizer);
    private static native boolean SR_RecognizerIsSignalDCOffset(int recognizer);
    private static native boolean SR_RecognizerIsSignalNoisy(int recognizer);
    private static native boolean SR_RecognizerIsSignalTooQuiet(int recognizer);
    private static native boolean SR_RecognizerIsSignalTooFewSamples(int recognizer);
    private static native boolean SR_RecognizerIsSignalTooManySamples(int recognizer);
    private static native boolean SR_RecognizerIsSignalClipping(long recognizer);
    private static native boolean SR_RecognizerIsSignalDCOffset(long recognizer);
    private static native boolean SR_RecognizerIsSignalNoisy(long recognizer);
    private static native boolean SR_RecognizerIsSignalTooQuiet(long recognizer);
    private static native boolean SR_RecognizerIsSignalTooFewSamples(long recognizer);
    private static native boolean SR_RecognizerIsSignalTooManySamples(long recognizer);
    // private static native void SR_Recognizer_Change_Sample_Rate (size_t new_sample_rate);
    
    
    //
    // SR_AcousticState native methods
    //
    private static native void SR_AcousticStateReset(int recognizer);
    private static native void SR_AcousticStateSet(int recognizer, String state);
    private static native String SR_AcousticStateGet(int recognizer);
    private static native void SR_AcousticStateReset(long recognizer);
    private static native void SR_AcousticStateSet(long recognizer, String state);
    private static native String SR_AcousticStateGet(long recognizer);


    //
    // SR_Grammar native methods
    //
    private static native void SR_GrammarCompile(int grammar);
    private static native void SR_GrammarAddWordToSlot(int grammar, String slot,
    private static native void SR_GrammarCompile(long grammar);
    private static native void SR_GrammarAddWordToSlot(long grammar, String slot,
            String word, String pronunciation, int weight, String tag);
    private static native void SR_GrammarResetAllSlots(int grammar);
    // private static native void SR_GrammarAddNametagToSlot(int grammar, String slot,
    private static native void SR_GrammarResetAllSlots(long grammar);
    // private static native void SR_GrammarAddNametagToSlot(long grammar, String slot,
    // const struct SR_Nametag_t* nametag, int weight, String tag);
    private static native void SR_GrammarSetupVocabulary(int grammar, int vocabulary);
    // private static native void SR_GrammarSetupModels(int grammar, SR_AcousticModels* models);
    private static native void SR_GrammarSetupRecognizer(int grammar, int recognizer);
    private static native void SR_GrammarUnsetupRecognizer(int grammar);
    // private static native void SR_GrammarGetModels(int grammar,SR_AcousticModels** models);
    private static native int SR_GrammarCreate();
    private static native void SR_GrammarDestroy(int grammar);
    private static native int SR_GrammarLoad(String filename);
    private static native void SR_GrammarSave(int grammar, String filename);
    // private static native void SR_GrammarSetDispatchFunction(int grammar,
    private static native void SR_GrammarSetupVocabulary(long grammar, long vocabulary);
    // private static native void SR_GrammarSetupModels(long grammar, SR_AcousticModels* models);
    private static native void SR_GrammarSetupRecognizer(long grammar, long recognizer);
    private static native void SR_GrammarUnsetupRecognizer(long grammar);
    // private static native void SR_GrammarGetModels(long grammar,SR_AcousticModels** models);
    private static native long SR_GrammarCreate();
    private static native void SR_GrammarDestroy(long grammar);
    private static native long SR_GrammarLoad(String filename);
    private static native void SR_GrammarSave(long grammar, String filename);
    // private static native void SR_GrammarSetDispatchFunction(long grammar,
    //         const LCHAR* name, void* userData, SR_GrammarDispatchFunction function);
    // private static native void SR_GrammarSetParameter(int grammar, const
    // private static native void SR_GrammarSetParameter(long grammar, const
    //         LCHAR* key, void* value);
    // private static native void SR_GrammarSetSize_tParameter(int grammar,
    // private static native void SR_GrammarSetSize_tParameter(long grammar,
    //         const LCHAR* key, size_t value);
    // private static native void SR_GrammarGetParameter(int grammar, const
    // private static native void SR_GrammarGetParameter(long grammar, const
    //         LCHAR* key, void** value);
    // private static native void SR_GrammarGetSize_tParameter(int grammar,
    // private static native void SR_GrammarGetSize_tParameter(long grammar,
    //         const LCHAR* key, size_t* value);
    // private static native void SR_GrammarCheckParse(int grammar, const LCHAR*
    // private static native void SR_GrammarCheckParse(long grammar, const LCHAR*
    //         transcription, SR_SemanticResult** result, size_t* resultCount);
    private static native void SR_GrammarAllowOnly(int grammar, String transcription);
    private static native void SR_GrammarAllowAll(int grammar);
    private static native void SR_GrammarAllowOnly(long grammar, String transcription);
    private static native void SR_GrammarAllowAll(long grammar);


    //
    // SR_Vocabulary native methods
    //
    // private static native int SR_VocabularyCreate();
    private static native int SR_VocabularyLoad();
    private static native long SR_VocabularyLoad();
    // private static native void SR_VocabularySave(SR_Vocabulary* self,
    //         const LCHAR* filename);
    // private static native void SR_VocabularyAddWord(SR_Vocabulary* self,
    //         const LCHAR* word);
    // private static native void SR_VocabularyGetLanguage(SR_Vocabulary* self,
    //         ESR_Locale* locale);
    private static native void SR_VocabularyDestroy(int vocabulary);
    private static native String SR_VocabularyGetPronunciation(int vocabulary, String word);
    private static native void SR_VocabularyDestroy(long vocabulary);
    private static native String SR_VocabularyGetPronunciation(long vocabulary, String word);


    //
    // SR_RecognizerResult native methods
    //
    private static native byte[] SR_RecognizerResultGetWaveform(int recognizer);
    private static native int SR_RecognizerResultGetSize(int recognizer);
    private static native int SR_RecognizerResultGetKeyCount(int recognizer, int nbest);
    private static native String[] SR_RecognizerResultGetKeyList(int recognizer, int nbest);
    private static native String SR_RecognizerResultGetValue(int recognizer,
    private static native byte[] SR_RecognizerResultGetWaveform(long recognizer);
    private static native int SR_RecognizerResultGetSize(long recognizer);
    private static native int SR_RecognizerResultGetKeyCount(long recognizer, int nbest);
    private static native String[] SR_RecognizerResultGetKeyList(long recognizer, int nbest);
    private static native String SR_RecognizerResultGetValue(long recognizer,
            int nbest, String key);
    // private static native void SR_RecognizerResultGetLocale(int recognizer, ESR_Locale* locale);
    // private static native void SR_RecognizerResultGetLocale(long recognizer, ESR_Locale* locale);
}
+22 −22
Original line number Diff line number Diff line
@@ -131,7 +131,7 @@ static sp<AudioRecord> getAudioRecord(JNIEnv* env, jobject thiz)
{
    Mutex::Autolock l(sLock);
    AudioRecord* const ar =
            (AudioRecord*)env->GetIntField(thiz, javaAudioRecordFields.nativeRecorderInJavaObj);
            (AudioRecord*)env->GetLongField(thiz, javaAudioRecordFields.nativeRecorderInJavaObj);
    return sp<AudioRecord>(ar);
}

@@ -139,19 +139,19 @@ static sp<AudioRecord> setAudioRecord(JNIEnv* env, jobject thiz, const sp<AudioR
{
    Mutex::Autolock l(sLock);
    sp<AudioRecord> old =
            (AudioRecord*)env->GetIntField(thiz, javaAudioRecordFields.nativeRecorderInJavaObj);
            (AudioRecord*)env->GetLongField(thiz, javaAudioRecordFields.nativeRecorderInJavaObj);
    if (ar.get()) {
        ar->incStrong((void*)setAudioRecord);
    }
    if (old != 0) {
        old->decStrong((void*)setAudioRecord);
    }
    env->SetIntField(thiz, javaAudioRecordFields.nativeRecorderInJavaObj, (int)ar.get());
    env->SetLongField(thiz, javaAudioRecordFields.nativeRecorderInJavaObj, (jlong)ar.get());
    return old;
}

// ----------------------------------------------------------------------------
static int
static jint
android_media_AudioRecord_setup(JNIEnv *env, jobject thiz, jobject weak_this,
        jint source, jint sampleRateInHertz, jint channelMask,
                // Java channel masks map directly to the native definition
@@ -163,7 +163,7 @@ android_media_AudioRecord_setup(JNIEnv *env, jobject thiz, jobject weak_this,

    if (!audio_is_input_channel(channelMask)) {
        ALOGE("Error creating AudioRecord: channel mask %#x is not valid.", channelMask);
        return AUDIORECORD_ERROR_SETUP_INVALIDCHANNELMASK;
        return (jint) AUDIORECORD_ERROR_SETUP_INVALIDCHANNELMASK;
    }
    uint32_t nbChannels = popcount(channelMask);

@@ -171,38 +171,38 @@ android_media_AudioRecord_setup(JNIEnv *env, jobject thiz, jobject weak_this,
    audio_format_t format = audioFormatToNative(audioFormat);
    if (format == AUDIO_FORMAT_INVALID) {
        ALOGE("Error creating AudioRecord: unsupported audio format %d.", audioFormat);
        return AUDIORECORD_ERROR_SETUP_INVALIDFORMAT;
        return (jint) AUDIORECORD_ERROR_SETUP_INVALIDFORMAT;
    }

    size_t bytesPerSample = audio_bytes_per_sample(format);

    if (buffSizeInBytes == 0) {
         ALOGE("Error creating AudioRecord: frameCount is 0.");
        return AUDIORECORD_ERROR_SETUP_ZEROFRAMECOUNT;
        return (jint) AUDIORECORD_ERROR_SETUP_ZEROFRAMECOUNT;
    }
    size_t frameSize = nbChannels * bytesPerSample;
    size_t frameCount = buffSizeInBytes / frameSize;

    if ((uint32_t(source) >= AUDIO_SOURCE_CNT) && (uint32_t(source) != AUDIO_SOURCE_HOTWORD)) {
        ALOGE("Error creating AudioRecord: unknown source %d.", source);
        return AUDIORECORD_ERROR_SETUP_INVALIDSOURCE;
        return (jint) AUDIORECORD_ERROR_SETUP_INVALIDSOURCE;
    }

    jclass clazz = env->GetObjectClass(thiz);
    if (clazz == NULL) {
        ALOGE("Can't find %s when setting up callback.", kClassPathName);
        return AUDIORECORD_ERROR_SETUP_NATIVEINITFAILED;
        return (jint) AUDIORECORD_ERROR_SETUP_NATIVEINITFAILED;
    }

    if (jSession == NULL) {
        ALOGE("Error creating AudioRecord: invalid session ID pointer");
        return AUDIORECORD_ERROR;
        return (jint) AUDIORECORD_ERROR;
    }

    jint* nSession = (jint *) env->GetPrimitiveArrayCritical(jSession, NULL);
    if (nSession == NULL) {
        ALOGE("Error creating AudioRecord: Error retrieving session id pointer");
        return AUDIORECORD_ERROR;
        return (jint) AUDIORECORD_ERROR;
    }
    int sessionId = nSession[0];
    env->ReleasePrimitiveArrayCritical(jSession, nSession, 0);
@@ -257,33 +257,33 @@ android_media_AudioRecord_setup(JNIEnv *env, jobject thiz, jobject weak_this,

    // save our newly created callback information in the "nativeCallbackCookie" field
    // of the Java object (in mNativeCallbackCookie) so we can free the memory in finalize()
    env->SetIntField(thiz, javaAudioRecordFields.nativeCallbackCookie, (int)lpCallbackData);
    env->SetLongField(thiz, javaAudioRecordFields.nativeCallbackCookie, (jlong)lpCallbackData);

    return AUDIORECORD_SUCCESS;
    return (jint) AUDIORECORD_SUCCESS;

    // failure:
native_init_failure:
    env->DeleteGlobalRef(lpCallbackData->audioRecord_class);
    env->DeleteGlobalRef(lpCallbackData->audioRecord_ref);
    delete lpCallbackData;
    env->SetIntField(thiz, javaAudioRecordFields.nativeCallbackCookie, 0);
    env->SetLongField(thiz, javaAudioRecordFields.nativeCallbackCookie, 0);

    return AUDIORECORD_ERROR_SETUP_NATIVEINITFAILED;
    return (jint) AUDIORECORD_ERROR_SETUP_NATIVEINITFAILED;
}



// ----------------------------------------------------------------------------
static int
static jint
android_media_AudioRecord_start(JNIEnv *env, jobject thiz, jint event, jint triggerSession)
{
    sp<AudioRecord> lpRecorder = getAudioRecord(env, thiz);
    if (lpRecorder == NULL ) {
        jniThrowException(env, "java/lang/IllegalStateException", NULL);
        return AUDIORECORD_ERROR;
        return (jint) AUDIORECORD_ERROR;
    }

    return android_media_translateRecorderErrorCode(
    return (jint) android_media_translateRecorderErrorCode(
            lpRecorder->start((AudioSystem::sync_event_t)event, triggerSession));
}

@@ -314,12 +314,12 @@ static void android_media_AudioRecord_release(JNIEnv *env, jobject thiz) {
    ALOGV("About to delete lpRecorder: %x\n", (int)lpRecorder.get());
    lpRecorder->stop();

    audiorecord_callback_cookie *lpCookie = (audiorecord_callback_cookie *)env->GetIntField(
    audiorecord_callback_cookie *lpCookie = (audiorecord_callback_cookie *)env->GetLongField(
        thiz, javaAudioRecordFields.nativeCallbackCookie);

    // reset the native resources in the Java object so any attempt to access
    // them after a call to release fails.
    env->SetIntField(thiz, javaAudioRecordFields.nativeCallbackCookie, 0);
    env->SetLongField(thiz, javaAudioRecordFields.nativeCallbackCookie, 0);

    // delete the callback information
    if (lpCookie) {
@@ -580,7 +580,7 @@ int register_android_media_AudioRecord(JNIEnv *env)
    //    mNativeRecorderInJavaObj
    javaAudioRecordFields.nativeRecorderInJavaObj =
        env->GetFieldID(audioRecordClass,
                        JAVA_NATIVERECORDERINJAVAOBJ_FIELD_NAME, "I");
                        JAVA_NATIVERECORDERINJAVAOBJ_FIELD_NAME, "J");
    if (javaAudioRecordFields.nativeRecorderInJavaObj == NULL) {
        ALOGE("Can't find AudioRecord.%s", JAVA_NATIVERECORDERINJAVAOBJ_FIELD_NAME);
        return -1;
@@ -588,7 +588,7 @@ int register_android_media_AudioRecord(JNIEnv *env)
    //     mNativeCallbackCookie
    javaAudioRecordFields.nativeCallbackCookie = env->GetFieldID(
            audioRecordClass,
            JAVA_NATIVECALLBACKINFO_FIELD_NAME, "I");
            JAVA_NATIVECALLBACKINFO_FIELD_NAME, "J");
    if (javaAudioRecordFields.nativeCallbackCookie == NULL) {
        ALOGE("Can't find AudioRecord.%s", JAVA_NATIVECALLBACKINFO_FIELD_NAME);
        return -1;
+26 −26

File changed.

Preview size limit exceeded, changes collapsed.

+21 −21
Original line number Diff line number Diff line
@@ -171,7 +171,7 @@ static sp<AudioTrack> getAudioTrack(JNIEnv* env, jobject thiz)
{
    Mutex::Autolock l(sLock);
    AudioTrack* const at =
            (AudioTrack*)env->GetIntField(thiz, javaAudioTrackFields.nativeTrackInJavaObj);
            (AudioTrack*)env->GetLongField(thiz, javaAudioTrackFields.nativeTrackInJavaObj);
    return sp<AudioTrack>(at);
}

@@ -179,19 +179,19 @@ static sp<AudioTrack> setAudioTrack(JNIEnv* env, jobject thiz, const sp<AudioTra
{
    Mutex::Autolock l(sLock);
    sp<AudioTrack> old =
            (AudioTrack*)env->GetIntField(thiz, javaAudioTrackFields.nativeTrackInJavaObj);
            (AudioTrack*)env->GetLongField(thiz, javaAudioTrackFields.nativeTrackInJavaObj);
    if (at.get()) {
        at->incStrong((void*)setAudioTrack);
    }
    if (old != 0) {
        old->decStrong((void*)setAudioTrack);
    }
    env->SetIntField(thiz, javaAudioTrackFields.nativeTrackInJavaObj, (int)at.get());
    env->SetLongField(thiz, javaAudioTrackFields.nativeTrackInJavaObj, (jlong)at.get());
    return old;
}

// ----------------------------------------------------------------------------
static int
static jint
android_media_AudioTrack_native_setup(JNIEnv *env, jobject thiz, jobject weak_this,
        jint streamType, jint sampleRateInHertz, jint javaChannelMask,
        jint audioFormat, jint buffSizeInBytes, jint memoryMode, jintArray jSession)
@@ -203,11 +203,11 @@ android_media_AudioTrack_native_setup(JNIEnv *env, jobject thiz, jobject weak_th

    if (AudioSystem::getOutputFrameCount(&afFrameCount, (audio_stream_type_t) streamType) != NO_ERROR) {
        ALOGE("Error creating AudioTrack: Could not get AudioSystem frame count.");
        return AUDIOTRACK_ERROR_SETUP_AUDIOSYSTEM;
        return (jint) AUDIOTRACK_ERROR_SETUP_AUDIOSYSTEM;
    }
    if (AudioSystem::getOutputSamplingRate(&afSampleRate, (audio_stream_type_t) streamType) != NO_ERROR) {
        ALOGE("Error creating AudioTrack: Could not get AudioSystem sampling rate.");
        return AUDIOTRACK_ERROR_SETUP_AUDIOSYSTEM;
        return (jint) AUDIOTRACK_ERROR_SETUP_AUDIOSYSTEM;
    }

    // Java channel masks don't map directly to the native definition, but it's a simple shift
@@ -216,7 +216,7 @@ android_media_AudioTrack_native_setup(JNIEnv *env, jobject thiz, jobject weak_th

    if (!audio_is_output_channel(nativeChannelMask)) {
        ALOGE("Error creating AudioTrack: invalid channel mask %#x.", javaChannelMask);
        return AUDIOTRACK_ERROR_SETUP_INVALIDCHANNELMASK;
        return (jint) AUDIOTRACK_ERROR_SETUP_INVALIDCHANNELMASK;
    }

    int nbChannels = popcount(nativeChannelMask);
@@ -236,7 +236,7 @@ android_media_AudioTrack_native_setup(JNIEnv *env, jobject thiz, jobject weak_th
        break;
    default:
        ALOGE("Error creating AudioTrack: unknown stream type.");
        return AUDIOTRACK_ERROR_SETUP_INVALIDSTREAMTYPE;
        return (jint) AUDIOTRACK_ERROR_SETUP_INVALIDSTREAMTYPE;
    }

    // check the format.
@@ -245,7 +245,7 @@ android_media_AudioTrack_native_setup(JNIEnv *env, jobject thiz, jobject weak_th
    if (format == AUDIO_FORMAT_INVALID) {

        ALOGE("Error creating AudioTrack: unsupported audio format.");
        return AUDIOTRACK_ERROR_SETUP_INVALIDFORMAT;
        return (jint) AUDIOTRACK_ERROR_SETUP_INVALIDFORMAT;
    }

    // for the moment 8bitPCM in MODE_STATIC is not supported natively in the AudioTrack C++ class
@@ -268,18 +268,18 @@ android_media_AudioTrack_native_setup(JNIEnv *env, jobject thiz, jobject weak_th
    jclass clazz = env->GetObjectClass(thiz);
    if (clazz == NULL) {
        ALOGE("Can't find %s when setting up callback.", kClassPathName);
        return AUDIOTRACK_ERROR_SETUP_NATIVEINITFAILED;
        return (jint) AUDIOTRACK_ERROR_SETUP_NATIVEINITFAILED;
    }

    if (jSession == NULL) {
        ALOGE("Error creating AudioTrack: invalid session ID pointer");
        return AUDIOTRACK_ERROR;
        return (jint) AUDIOTRACK_ERROR;
    }

    jint* nSession = (jint *) env->GetPrimitiveArrayCritical(jSession, NULL);
    if (nSession == NULL) {
        ALOGE("Error creating AudioTrack: Error retrieving session id pointer");
        return AUDIOTRACK_ERROR;
        return (jint) AUDIOTRACK_ERROR;
    }
    int sessionId = nSession[0];
    env->ReleasePrimitiveArrayCritical(jSession, nSession, 0);
@@ -366,10 +366,10 @@ android_media_AudioTrack_native_setup(JNIEnv *env, jobject thiz, jobject weak_th
    setAudioTrack(env, thiz, lpTrack);

    // save the JNI resources so we can free them later
    //ALOGV("storing lpJniStorage: %x\n", (int)lpJniStorage);
    env->SetIntField(thiz, javaAudioTrackFields.jniData, (int)lpJniStorage);
    //ALOGV("storing lpJniStorage: %x\n", (long)lpJniStorage);
    env->SetLongField(thiz, javaAudioTrackFields.jniData, (jlong)lpJniStorage);

    return AUDIOTRACK_SUCCESS;
    return (jint) AUDIOTRACK_SUCCESS;

    // failures:
native_init_failure:
@@ -379,9 +379,9 @@ native_init_failure:
    env->DeleteGlobalRef(lpJniStorage->mCallbackData.audioTrack_class);
    env->DeleteGlobalRef(lpJniStorage->mCallbackData.audioTrack_ref);
    delete lpJniStorage;
    env->SetIntField(thiz, javaAudioTrackFields.jniData, 0);
    env->SetLongField(thiz, javaAudioTrackFields.jniData, 0);

    return AUDIOTRACK_ERROR_SETUP_NATIVEINITFAILED;
    return (jint) AUDIOTRACK_ERROR_SETUP_NATIVEINITFAILED;
}


@@ -470,11 +470,11 @@ static void android_media_AudioTrack_native_release(JNIEnv *env, jobject thiz)
    lpTrack->stop();

    // delete the JNI data
    AudioTrackJniStorage* pJniStorage = (AudioTrackJniStorage *)env->GetIntField(
    AudioTrackJniStorage* pJniStorage = (AudioTrackJniStorage *)env->GetLongField(
        thiz, javaAudioTrackFields.jniData);
    // reset the native resources in the Java object so any attempt to access
    // them after a call to release fails.
    env->SetIntField(thiz, javaAudioTrackFields.jniData, 0);
    env->SetLongField(thiz, javaAudioTrackFields.jniData, 0);

    if (pJniStorage) {
        Mutex::Autolock l(sLock);
@@ -970,7 +970,7 @@ int register_android_media_AudioTrack(JNIEnv *env)
    //      nativeTrackInJavaObj
    javaAudioTrackFields.nativeTrackInJavaObj = env->GetFieldID(
            audioTrackClass,
            JAVA_NATIVETRACKINJAVAOBJ_FIELD_NAME, "I");
            JAVA_NATIVETRACKINJAVAOBJ_FIELD_NAME, "J");
    if (javaAudioTrackFields.nativeTrackInJavaObj == NULL) {
        ALOGE("Can't find AudioTrack.%s", JAVA_NATIVETRACKINJAVAOBJ_FIELD_NAME);
        return -1;
@@ -978,7 +978,7 @@ int register_android_media_AudioTrack(JNIEnv *env)
    //      jniData;
    javaAudioTrackFields.jniData = env->GetFieldID(
            audioTrackClass,
            JAVA_JNIDATA_FIELD_NAME, "I");
            JAVA_JNIDATA_FIELD_NAME, "J");
    if (javaAudioTrackFields.jniData == NULL) {
        ALOGE("Can't find AudioTrack.%s", JAVA_JNIDATA_FIELD_NAME);
        return -1;
Loading