Methods Summary |
---|
public void | close()
waitForRequest(REQ_CLOSE);
|
public void | flush()
waitForRequest(REQ_FLUSH);
|
public void | open()
if (requestThread == null) {
requestThread = new Thread(this);
requestThread.start();
}
waitForRequest(REQ_OPEN);
if (failure)
throw new Error("Error opening DSound for capture");
|
public int | read(byte[] data, int offset, int len)
this.data = data;
this.offset = offset;
this.len = len;
waitForRequest(REQ_READ);
return result;
|
public void | run()
boolean done = false;
while (!done) {
synchronized (requestLock) {
while (request == 0) {
try {
requestLock.wait();
} catch (InterruptedException ie) {
}
}
}
if (request > 0) {
switch (request) {
case REQ_OPEN:
try {
super.open();
} catch (Error e) {
failure = true;
}
break;
case REQ_START:
super.start();
break;
case REQ_STOP:
super.stop();
break;
case REQ_READ:
result = super.read(data, offset, len);
break;
case REQ_FLUSH:
super.flush();
break;
case REQ_CLOSE:
super.close();
done = true;
}
}
synchronized (requestLock) {
request = 0;
requestLock.notifyAll();
}
}
|
public void | start()
waitForRequest(REQ_START);
|
public void | stop()
waitForRequest(REQ_STOP);
|
private void | waitForRequest(int req)
synchronized (requestLock) {
request = req;
requestLock.notifyAll();
while (request > 0) {
try {
requestLock.wait(100);
} catch (InterruptedException ie) {
}
}
}
|