Skip to content

Commit

Permalink
Fix segfault when JackClient garbage collected.
Browse files Browse the repository at this point in the history
  • Loading branch information
neilcsmith-net committed Nov 18, 2014
1 parent 1d7861a commit 2e20036
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<groupId>org.jaudiolibs</groupId>
<artifactId>jnajack</artifactId>
<version>1.1.0</version>
<version>1.1.1</version>
<packaging>jar</packaging>

<name>jnajack</name>
Expand Down
12 changes: 4 additions & 8 deletions src/main/java/org/jaudiolibs/jnajack/JackClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -404,7 +405,7 @@ public void close() {
} catch (Throwable e) {
LOG.log(Level.SEVERE, CALL_ERROR_MSG, e);
} finally {
// clientPtr = null;
clientPtr = null;
}
}

Expand Down Expand Up @@ -453,11 +454,6 @@ private void processShutdown() {
}
}

@Override
protected void finalize() throws Throwable {
super.finalize();
close();
}

private class ProcessCallbackWrapper implements JackLibrary.JackProcessCallback {

Expand Down

0 comments on commit 2e20036

Please sign in to comment.