From 2e2003643afcb2128f6d233252a8053ba0c0b2e4 Mon Sep 17 00:00:00 2001 From: Neil C Smith Date: Tue, 18 Nov 2014 10:06:27 +0000 Subject: [PATCH] Fix segfault when JackClient garbage collected. --- pom.xml | 2 +- src/main/java/org/jaudiolibs/jnajack/JackClient.java | 12 ++++-------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/pom.xml b/pom.xml index 1922814..142fa4c 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ org.jaudiolibs jnajack - 1.1.0 + 1.1.1 jar jnajack diff --git a/src/main/java/org/jaudiolibs/jnajack/JackClient.java b/src/main/java/org/jaudiolibs/jnajack/JackClient.java index b1fd4cd..6e90d0d 100644 --- a/src/main/java/org/jaudiolibs/jnajack/JackClient.java +++ b/src/main/java/org/jaudiolibs/jnajack/JackClient.java @@ -55,7 +55,8 @@ public class JackClient { final Jack jack; final JackLibrary jackLib; final String name; - final JackLibrary._jack_client clientPtr; // package private + + JackLibrary._jack_client clientPtr; // package private private ProcessCallbackWrapper processCallback; // reference kept - is in use! private BufferSizeCallbackWrapper buffersizeCallback; @@ -395,7 +396,7 @@ public void deactivate() { /** * Disconnects this client from the JACK server. */ - public void close() { + public synchronized void close() { try { if (clientPtr != null) { jackLib.jack_client_close(clientPtr); @@ -404,7 +405,7 @@ public void close() { } catch (Throwable e) { LOG.log(Level.SEVERE, CALL_ERROR_MSG, e); } finally { -// clientPtr = null; + clientPtr = null; } } @@ -453,11 +454,6 @@ private void processShutdown() { } } - @Override - protected void finalize() throws Throwable { - super.finalize(); - close(); - } private class ProcessCallbackWrapper implements JackLibrary.JackProcessCallback {