< prev index next >
src/java.desktop/share/classes/com/sun/media/sound/DirectAudioDevice.java
Print this page
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2002, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
@@ -545,19 +545,20 @@
monitoring = requiresServicing();
if (monitoring) {
getEventDispatcher().addLineMonitor(this);
}
+ synchronized(lock) {
doIO = true;
-
// need to set Active and Started
// note: the current API always requires that
// Started and Active are set at the same time...
if (isSource && stoppedWritten) {
setStarted(true);
setActive(true);
}
+ }
if (Printer.trace) Printer.trace("<< DirectDL: implStart() succeeded");
}
@Override
@@ -580,14 +581,14 @@
synchronized(lock) {
// need to set doIO to false before notifying the
// read/write thread, that's why isStartedRunning()
// cannot be used
doIO = false;
- lock.notifyAll();
- }
setActive(false);
setStarted(false);
+ lock.notifyAll();
+ }
stoppedWritten = false;
if (Printer.trace) Printer.trace(" << DirectDL: implStop() succeeded");
}
@@ -729,17 +730,19 @@
throw new ArrayIndexOutOfBoundsException(off);
}
if ((long)off + (long)len > (long)b.length) {
throw new ArrayIndexOutOfBoundsException(b.length);
}
-
+ synchronized(lock) {
if (!isActive() && doIO) {
// this is not exactly correct... would be nicer
- // if the native sub system sent a callback when IO really starts
+ // if the native sub system sent a callback when IO really
+ // starts
setActive(true);
setStarted(true);
}
+ }
int written = 0;
while (!flushing) {
int thisWritten;
synchronized (lockNative) {
thisWritten = nWrite(id, b, off, len,
@@ -955,16 +958,19 @@
throw new ArrayIndexOutOfBoundsException(off);
}
if ((long)off + (long)len > (long)b.length) {
throw new ArrayIndexOutOfBoundsException(b.length);
}
+ synchronized(lock) {
if (!isActive() && doIO) {
// this is not exactly correct... would be nicer
- // if the native sub system sent a callback when IO really starts
+ // if the native sub system sent a callback when IO really
+ // starts
setActive(true);
setStarted(true);
}
+ }
int read = 0;
while (doIO && !flushing) {
int thisRead;
synchronized (lockNative) {
thisRead = nRead(id, b, off, len, softwareConversionSize);
< prev index next >