Skip to content

Commit

Permalink
Implemented exchange of baseline array information via rdsampjni.c
Browse files Browse the repository at this point in the history
  • Loading branch information
ikarosilva committed Apr 1, 2015
1 parent 25836d6 commit ff6a648
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 24 deletions.
25 changes: 5 additions & 20 deletions dependencies/jni/rdsampjni.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 0 additions & 4 deletions src/org/physionet/wfdb/jni/Rdsamp.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ public class Rdsamp {
int[] baseline;
double gain;
double fs;
int[] foo={1,3};

static {
System.loadLibrary("rdsampjni");
Expand All @@ -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();
Expand Down

0 comments on commit ff6a648

Please sign in to comment.