Skip to content

Commit 7f630e1

Browse files
committed
80 fps max refresh rate
1 parent ba63f74 commit 7f630e1

8 files changed

Lines changed: 619 additions & 14 deletions

File tree

JavaGUI/hs_err_pid2052.log

Lines changed: 288 additions & 0 deletions
Large diffs are not rendered by default.

JavaGUI/hs_err_pid3056.log

Lines changed: 288 additions & 0 deletions
Large diffs are not rendered by default.

JavaGUI/jni/TSDRLibraryNDK.c

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ tsdr_lib_t tsdr_instance;
1313

1414
struct java_context {
1515
jobject obj;
16+
jclass cls;
17+
jfieldID fid_pixels;
18+
jfieldID fid_width;
19+
jfieldID fid_height;
20+
jmethodID fixSize;
21+
jmethodID notifyCallbacks;
1622
} typedef java_context_t;
1723

1824
static JavaVM *jvm;
@@ -95,13 +101,15 @@ void read_async(float *buf, int width, int height, void *ctx) {
95101
if ((*jvm)->GetEnv(jvm, (void **)&env, javaversion) == JNI_EDETACHED)
96102
(*jvm)->AttachCurrentThread(jvm, (void **) &env, 0);
97103

98-
jclass cls = (*env)->GetObjectClass(env, context->obj);
104+
jint i_width = (*env)->GetIntField(env, context->obj, context->fid_width);
105+
jint i_height = (*env)->GetIntField(env, context->obj, context->fid_height);
99106

100-
// fixSize(200, 200);
101-
jmethodID fixSize = (*env)->GetMethodID(env, cls, "fixSize", "(II)V");
102-
(*env)->CallVoidMethod(env, context->obj, fixSize, width, height);
107+
if (i_width != width || i_height != height) {
108+
// fixSize(200, 200);
109+
(*env)->CallVoidMethod(env, context->obj, context->fixSize, width, height);
110+
}
103111

104-
jintArray pixels_obj = (*env)->GetObjectField(env, context->obj, (*env)->GetFieldID(env, cls, "pixels", "[I"));
112+
jintArray pixels_obj = (*env)->GetObjectField(env, context->obj, context->fid_pixels);
105113
jint * pixels = (*env)->GetIntArrayElements(env,pixels_obj,0);
106114
jint * data = pixels;
107115

@@ -116,19 +124,26 @@ void read_async(float *buf, int width, int height, void *ctx) {
116124
(*env)->ReleaseIntArrayElements(env,pixels_obj,pixels,0);
117125

118126
// notifyCallbacks();
119-
jmethodID notifyCallbacks = (*env)->GetMethodID(env, cls, "notifyCallbacks", "()V");
120-
(*env)->CallVoidMethod(env, context->obj, notifyCallbacks);
127+
(*env)->CallVoidMethod(env, context->obj, context->notifyCallbacks);
121128
}
122129

123130
JNIEXPORT void JNICALL Java_martin_tempest_core_TSDRLibrary_nativeStart (JNIEnv * env, jobject obj) {
124131

125132
java_context_t * context = (java_context_t *) malloc(sizeof(java_context_t));
133+
126134
context->obj = (*env)->NewGlobalRef(env, obj);
127135
(*env)->DeleteLocalRef(env, obj);
136+
context->cls = (jclass) (*env)->NewGlobalRef(env, (*env)->GetObjectClass(env, context->obj));
137+
context->fid_pixels = (*env)->GetFieldID(env, context->cls, "pixels", "[I");
138+
context->fid_width = (*env)->GetFieldID(env, context->cls, "width", "I");
139+
context->fid_height = (*env)->GetFieldID(env, context->cls, "height", "I");
140+
context->fixSize = (*env)->GetMethodID(env, context->cls, "fixSize", "(II)V");
141+
context->notifyCallbacks = (*env)->GetMethodID(env, context->cls, "notifyCallbacks", "()V");
128142

129143
THROW(tsdr_readasync(&tsdr_instance, read_async, (void *) context));
130144

131145
(*env)->DeleteGlobalRef(env, context->obj);
146+
(*env)->DeleteGlobalRef(env, context->cls);
132147
free(context);
133148
}
134149

JavaGUI/jni/makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ ifndef JAVA_HOME
33
$(warning JAVA_HOME should be set so it points to your jdk installation dir)
44
endif
55

6+
# Flags
7+
CPPFLAGS=-O3
8+
69
# Headers
710
INC = "$(JAVA_HOME)/include" "$(JAVA_HOME)/include/win32"
811

@@ -60,7 +63,7 @@ rebuildtempestsdr : $(OUTPUTFOLDER)
6063

6164
# Compile the sources to obj files
6265
TSDRLibraryNDK.o : TSDRLibraryNDK.c TSDRLibraryNDK.h include/TSDRLibrary.h include/TSDRCodes.h
63-
gcc $(foreach d, $(INC), -I$d) -c $< -o $@
66+
gcc $(foreach d, $(INC), -I$d) $(CFLAGS) -c $< -o $@
6467

6568
# Copy over a fresh set of library headers
6669
include/%.h : ../../TempestSDR/src/include/%.h

JavaGUI/src/martin/tempest/ImageVisualizer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
public class ImageVisualizer extends JPanel {
1414

1515
private static final long serialVersionUID = -6754436015453195809L;
16-
private static final int COUNT_TO_AVG = 5;
16+
private static final int COUNT_TO_AVG = 50;
1717

1818
private BufferedImage todraw = null;
1919

JavaGUI/src/martin/tempest/core/TSDRLibrary.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
import java.io.FileOutputStream;
99
import java.io.IOException;
1010
import java.io.InputStream;
11-
import java.util.LinkedList;
11+
import java.util.ArrayList;
12+
import java.util.List;
1213

1314
import martin.tempest.core.exceptions.TSDRException;
1415
import martin.tempest.core.exceptions.TSDRLibraryNotCompatible;
@@ -23,13 +24,15 @@ public class TSDRLibrary {
2324

2425
private static TSDRSource[] PLUGINS = new TSDRSource[] {new TSDRSource("TSDRPlugin_RawFile")};
2526

26-
// TODO! STATIC?!?!?!?!?!?!??!
2727
private BufferedImage bimage;
2828
private int[] pixels;
2929

30+
private int width;
31+
private int height;
32+
3033
// If the binaries weren't loaded, this will go off
3134
private static TSDRLibraryNotCompatible m_e = null;
32-
private final LinkedList<FrameReadyCallback> callbacks = new LinkedList<FrameReadyCallback>();
35+
private final List<FrameReadyCallback> callbacks = new ArrayList<FrameReadyCallback>();
3336

3437
/**
3538
* Extracts a library to a temporary path and prays for the OS to delete it after the app closes.
@@ -193,6 +196,8 @@ private void fixSize(final int x, final int y) {
193196
if (bimage == null || bimage.getWidth() != x || bimage.getHeight() != y) {
194197
bimage = new BufferedImage(x, y, BufferedImage.TYPE_INT_RGB);
195198
pixels = ((DataBufferInt) bimage.getRaster().getDataBuffer()).getData();
199+
width = x;
200+
height = y;
196201
}
197202
}
198203

TSDRPlugin_RawFile/makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ SOURCEFOLDER=src
4848
OUTPUTFOLDER=bin/$(OSNAME)/$(ARCHNAME)
4949
OBJFOLDER=obj
5050

51+
# Flags
52+
CPPFLAGS=-O3
53+
5154
# Calculate the path to dependencies
5255
_OBJS = $(patsubst %,$(OBJFOLDER)/%,$(OBJS))
5356
_DEPS = $(patsubst %,$(SOURCEFOLDER)/%,$(DEPS))
@@ -68,7 +71,7 @@ $(OUTPUTFOLDER)/$(PLUGNAME)$(EXT): copyoverheaderfile $(_OBJS)
6871
$(OBJFOLDER)/%.o : $(SOURCEFOLDER)/%.c $(_DEPS)
6972
mkdir -p $(OUTPUTFOLDER)
7073
mkdir -p $(OBJFOLDER)
71-
gcc $(foreach d, $(INC), -I$d) -c $< -o $@
74+
gcc $(foreach d, $(INC), -I$d) $(CFLAGS) -c $< -o $@
7275

7376
.PHONY: clean
7477

TempestSDR/makefile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ SOURCEFOLDER=src
4343
OUTPUTFOLDER=bin/$(OSNAME)/$(ARCHNAME)
4444
OBJFOLDER=obj
4545

46+
# Flags
47+
CPPFLAGS=-O3
48+
4649
# The obj files reside in the bin/obj directory
4750
_OBJS = $(patsubst %,$(OBJFOLDER)/%,$(OBJS))
4851

@@ -60,7 +63,7 @@ $(OUTPUTFOLDER)/TSDRLibrary$(EXT) : $(_OBJS)
6063
$(OBJFOLDER)/%.o : src/%.c $(_DEPS)
6164
mkdir -p $(OUTPUTFOLDER)
6265
mkdir -p $(OBJFOLDER)
63-
gcc $(foreach d, $(INC), -I$d) -c $< -o $@
66+
gcc $(foreach d, $(INC), -I$d) $(CFLAGS) -c $< -o $@
6467

6568
.PHONY: clean
6669

0 commit comments

Comments
 (0)