Skip to content

Commit 4a4175c

Browse files
committed
Stop button working
1 parent 5cdaa85 commit 4a4175c

2 files changed

Lines changed: 13 additions & 3 deletions

File tree

JavaGUI/src/martin/tempest/Main.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,8 +250,12 @@ private void onVideoModeSelected(final VideoMode m) {
250250
private void performStartStop() {
251251

252252
if (mSdrlib.isRunning()) {
253-
254-
btnStartStop.setText("Start");
253+
try {
254+
mSdrlib.stop();
255+
} catch (TSDRException e) {
256+
displayException(frmTempestSdr, e);
257+
}
258+
255259
} else {
256260
final TSDRSource src = (TSDRSource) cbDevice.getSelectedItem();
257261

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import java.util.ArrayList;
1212
import java.util.List;
1313

14+
import martin.tempest.core.exceptions.TSDRAlreadyRunningException;
1415
import martin.tempest.core.exceptions.TSDRException;
1516
import martin.tempest.core.exceptions.TSDRLibraryNotCompatible;
1617
import martin.tempest.sources.TSDRSource;
@@ -29,6 +30,8 @@ public class TSDRLibrary {
2930
private int width;
3031
private int height;
3132

33+
volatile private boolean nativerunning = false;
34+
3235
// If the binaries weren't loaded, this will go off
3336
private static TSDRLibraryNotCompatible m_e = null;
3437
private final List<FrameReadyCallback> callbacks = new ArrayList<FrameReadyCallback>();
@@ -143,13 +146,15 @@ public TSDRLibrary() throws TSDRException {
143146
public native void setResolution(int width, int height, double refreshrate) throws TSDRException;
144147

145148
public void startAsync(final TSDRSource plugin, int width, int height, double refreshrate) throws TSDRException {
149+
if (nativerunning) throw new TSDRAlreadyRunningException("");
150+
146151
final String absolute_path = plugin.absolute ? plugin.libname : (extractLibrary(plugin.libname).getAbsolutePath());
147152

148153
setResolution(width, height, refreshrate);
149154

150155
new Thread() {
151156
public void run() {
152-
157+
nativerunning = true;
153158
Runtime.getRuntime().addShutdownHook(unloaderhook);
154159
try {
155160
nativeStart(absolute_path, plugin.getParams());
@@ -161,6 +166,7 @@ public void run() {
161166
} catch (Throwable e) {};
162167
}
163168
for (final FrameReadyCallback callback : callbacks) callback.onClosed(TSDRLibrary.this);
169+
nativerunning = false;
164170
};
165171
}.start();
166172

0 commit comments

Comments
 (0)