Mercurial > hg > pulseaudio
changeset 62:686f9e8f1803
2008-08-11 Omair Majid <omajid@redhat.com>
* src/java/org/classpath/icedtea/pulseaudio/Operation.java: synchronized the native calls; start on a function to wait for operation to complete
author | Omair Majid <omajid@redhat.com> |
---|---|
date | Mon, 11 Aug 2008 17:38:17 -0400 |
parents | ffc11c4c5c53 |
children | 3887b2fc72a5 |
files | src/java/org/classpath/icedtea/pulseaudio/Operation.java |
diffstat | 1 files changed, 37 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/src/java/org/classpath/icedtea/pulseaudio/Operation.java Mon Aug 11 17:30:11 2008 -0400 +++ b/src/java/org/classpath/icedtea/pulseaudio/Operation.java Mon Aug 11 17:38:17 2008 -0400 @@ -1,5 +1,7 @@ package org.classpath.icedtea.pulseaudio; +import java.io.IOException; + /* * Encapsulates a pa_operation object * @@ -12,11 +14,24 @@ public class Operation { long operationPointer; + EventLoop eventLoop; public enum State { Running, Done, Cancelled, } + static { + try { + String library = new java.io.File(".").getCanonicalPath() + + java.io.File.separatorChar + + System.mapLibraryName("pulse-java"); + System.out.println(library); + System.load(library); + } catch (IOException e) { + assert ("Loading failed".endsWith("library")); + } + } + private native void native_ref(); private native void native_unref(); @@ -25,21 +40,29 @@ public Operation(long operationPointer) { this.operationPointer = operationPointer; + this.eventLoop = EventLoop.getEventLoop(); } public void addReference() { - assert(operationPointer != 0); - native_ref(); + assert (operationPointer != 0); + synchronized (eventLoop.threadLock) { + native_ref(); + } } public void releaseReference() { - assert(operationPointer!= 0); - native_unref(); + assert (operationPointer != 0); + synchronized (eventLoop.threadLock) { + native_unref(); + } } public State getState() { - assert(operationPointer!= 0); - int state = native_get_state(); + assert (operationPointer != 0); + int state; + synchronized (eventLoop.threadLock) { + state = native_get_state(); + } switch (state) { case 0: return State.Running; @@ -53,4 +76,12 @@ } + public void waitForCompletion() { + throw new RuntimeException("not implemented"); + + synchronized (eventLoop.threadLock) { + eventLoop.threadLock.wait(); + } + + } }