< prev index next >
src/java.desktop/share/classes/com/sun/media/sound/DirectAudioDevice.java
Print this page
*** 1003,1013 ****
* This clip is realized in software only
*/
private static final class DirectClip extends DirectDL
implements Clip, Runnable, AutoClosingClip {
! private Thread thread;
private byte[] audioData = null;
private int frameSize; // size of one frame in bytes
private int m_lengthInFrames;
private int loopCount;
private int clipBytePosition; // index in the audioData array at current playback
--- 1003,1013 ----
* This clip is realized in software only
*/
private static final class DirectClip extends DirectDL
implements Clip, Runnable, AutoClosingClip {
! private volatile Thread thread;
private byte[] audioData = null;
private int frameSize; // size of one frame in bytes
private int m_lengthInFrames;
private int loopCount;
private int clipBytePosition; // index in the audioData array at current playback
*** 1343,1361 ****
// main playback loop
@Override
public void run() {
if (Printer.trace) Printer.trace(">>> DirectClip: run() threadID="+Thread.currentThread().getId());
! while (thread != null) {
// doIO is volatile, but we could check it, then get
// pre-empted while another thread changes doIO and notifies,
// before we wait (so we sleep in wait forever).
synchronized(lock) {
if (!doIO) {
try {
lock.wait();
! } catch(InterruptedException ie) {}
}
}
while (doIO) {
if (newFramePosition >= 0) {
clipBytePosition = newFramePosition * frameSize;
--- 1343,1367 ----
// main playback loop
@Override
public void run() {
if (Printer.trace) Printer.trace(">>> DirectClip: run() threadID="+Thread.currentThread().getId());
! Thread curThread = Thread.currentThread();
! while (thread == curThread) {
// doIO is volatile, but we could check it, then get
// pre-empted while another thread changes doIO and notifies,
// before we wait (so we sleep in wait forever).
synchronized(lock) {
if (!doIO) {
try {
lock.wait();
! } catch(InterruptedException ie) {
! } finally {
! if (thread != curThread) {
! break;
! }
! }
}
}
while (doIO) {
if (newFramePosition >= 0) {
clipBytePosition = newFramePosition * frameSize;
< prev index next >