From ff6a648630deeff4bc773157518c0a4f136edcaa Mon Sep 17 00:00:00 2001 From: ikarosilva Date: Wed, 1 Apr 2015 14:26:33 -0400 Subject: [PATCH] Implemented exchange of baseline array information via rdsampjni.c --- dependencies/jni/rdsampjni.c | 25 +++++-------------------- src/org/physionet/wfdb/jni/Rdsamp.java | 4 ---- 2 files changed, 5 insertions(+), 24 deletions(-) diff --git a/dependencies/jni/rdsampjni.c b/dependencies/jni/rdsampjni.c index 038a74f..888ec77 100644 --- a/dependencies/jni/rdsampjni.c +++ b/dependencies/jni/rdsampjni.c @@ -67,36 +67,21 @@ JNIEXPORT void JNICALL Java_org_physionet_wfdb_jni_Rdsamp_getData(JNIEnv *env, j exit(2); } - fprintf(stderr,"creating new array \n"); - jintArray fill; - jfieldID arrg=(*env)->GetFieldID(env,myRdsamp,"foo","[I"); - if(arrg ==NULL ){ - fprintf(stderr,"Could not allocate arrg! \n"); - exit(2); - } - fill=(*env)->GetObjectField(env,this,arrg); - //fill = (*env)->NewIntArray(env,size); + jintArray fill = (*env)->NewIntArray(env,size); if(fill ==NULL ){ fprintf(stderr,"Could not allocate space for fill array! \n"); exit(2); } - /* - fprintf(stderr,"getting new array pointer \n"); + + //Copy array contents jint *narr = (*env)->GetIntArrayElements(env,fill,NULL); - fprintf(stderr,"filling array \n"); for (n = 0; n < size; n++) { - fprintf(stderr,"Writing: narr[%u]=%u\n",n,baseline[n]); - //narr[n] = baseline[n]; + narr[n] = baseline[n]; } + //Release array and call method to (*env)->ReleaseIntArrayElements(env,fill,narr,0); - */ - - fprintf(stderr,"done filling array \n"); (*env)->CallVoidMethod(env,this,setBaseline,fill); - fprintf(stderr,"Cleaning up...\n"); - - //Clean up free(baseline); baseline=NULL; diff --git a/src/org/physionet/wfdb/jni/Rdsamp.java b/src/org/physionet/wfdb/jni/Rdsamp.java index 213c835..fd2caaa 100644 --- a/src/org/physionet/wfdb/jni/Rdsamp.java +++ b/src/org/physionet/wfdb/jni/Rdsamp.java @@ -5,7 +5,6 @@ public class Rdsamp { int[] baseline; double gain; double fs; - int[] foo={1,3}; static { System.loadLibrary("rdsampjni"); @@ -23,10 +22,7 @@ public static void main(String[] args) { } public void setBaseline(int[] newBaseline){ - System.out.println("In Java:setBaseline"); - System.out.println("new baseline length=" + newBaseline.length); baseline=newBaseline; - System.out.println("New baseline is: " + baseline.length); } public native void getData();