8222438: Drop of outdated logging in the com.sun.media.sound package
Reviewed-by: amenkov
--- a/src/java.desktop/share/classes/com/sun/media/sound/AbstractDataLine.java Thu Apr 25 15:19:09 2019 +0530
+++ b/src/java.desktop/share/classes/com/sun/media/sound/AbstractDataLine.java Thu Apr 25 15:13:36 2019 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2019, 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
@@ -101,15 +101,11 @@
public final void open(AudioFormat format, int bufferSize) throws LineUnavailableException {
//$$fb 2001-10-09: Bug #4517739: avoiding deadlock by synchronizing to mixer !
synchronized (mixer) {
- if (Printer.trace) Printer.trace("> AbstractDataLine.open(format, bufferSize) (class: "+getClass().getName());
-
// if the line is not currently open, try to open it with this format and buffer size
if (!isOpen()) {
// make sure that the format is specified correctly
// $$fb part of fix for 4679187: Clip.open() throws unexpected Exceptions
Toolkit.isFullySpecifiedAudioFormat(format);
-
- if (Printer.debug) Printer.debug(" need to open the mixer...");
// reserve mixer resources for this line
//mixer.open(this, format, bufferSize);
mixer.open(this);
@@ -127,8 +123,6 @@
throw e;
}
} else {
- if (Printer.debug) Printer.debug(" dataline already open");
-
// if the line is already open and the requested format differs from the
// current settings, throw an IllegalStateException
//$$fb 2002-04-02: fix for 4661602: Buffersize is checked when re-opening line
@@ -141,8 +135,6 @@
setBufferSize(bufferSize);
}
}
-
- if (Printer.trace) Printer.trace("< AbstractDataLine.open(format, bufferSize) completed");
}
}
@@ -163,7 +155,6 @@
*/
@Override
public void drain() {
- if (Printer.trace) Printer.trace("AbstractDataLine: drain");
}
/**
@@ -171,14 +162,12 @@
*/
@Override
public void flush() {
- if (Printer.trace) Printer.trace("AbstractDataLine: flush");
}
@Override
public final void start() {
//$$fb 2001-10-09: Bug #4517739: avoiding deadlock by synchronizing to mixer !
synchronized(mixer) {
- if (Printer.trace) Printer.trace("> "+getClass().getName()+".start() - AbstractDataLine");
// $$kk: 06.06.99: if not open, this doesn't work....???
if (isOpen()) {
@@ -194,8 +183,6 @@
synchronized(lock) {
lock.notifyAll();
}
-
- if (Printer.trace) Printer.trace("< "+getClass().getName()+".start() - AbstractDataLine");
}
@Override
@@ -203,8 +190,6 @@
//$$fb 2001-10-09: Bug #4517739: avoiding deadlock by synchronizing to mixer !
synchronized(mixer) {
- if (Printer.trace) Printer.trace("> "+getClass().getName()+".stop() - AbstractDataLine");
-
// $$kk: 06.06.99: if not open, this doesn't work.
if (isOpen()) {
@@ -226,8 +211,6 @@
synchronized(lock) {
lock.notifyAll();
}
-
- if (Printer.trace) Printer.trace("< "+getClass().getName()+".stop() - AbstractDataLine");
}
// $$jb: 12.10.99: The official API for this is isRunning().
@@ -309,9 +292,6 @@
* events if it changes.
*/
final void setActive(boolean active) {
-
- if (Printer.trace) Printer.trace("> AbstractDataLine: setActive(" + active + ")");
-
//boolean sendEvents = false;
//long position = getLongFramePosition();
@@ -341,9 +321,6 @@
* events if it changes.
*/
final void setStarted(boolean started) {
-
- if (Printer.trace) Printer.trace("> AbstractDataLine: setStarted(" + started + ")");
-
boolean sendEvents = false;
long position = getLongFramePosition();
@@ -363,7 +340,6 @@
sendEvents(new LineEvent(this, LineEvent.Type.STOP, position));
}
}
- if (Printer.trace) Printer.trace("< AbstractDataLine: setStarted completed");
}
/**
@@ -371,12 +347,9 @@
* It is here for historic reasons when an EOM event existed.
*/
final void setEOM() {
-
- if (Printer.trace) Printer.trace("> AbstractDataLine: setEOM()");
//$$fb 2002-04-21: sometimes, 2 STOP events are generated.
// better use setStarted() to send STOP event.
setStarted(false);
- if (Printer.trace) Printer.trace("< AbstractDataLine: setEOM() completed");
}
// OVERRIDES OF ABSTRACT LINE METHODS
@@ -389,12 +362,8 @@
*/
@Override
public final void open() throws LineUnavailableException {
-
- if (Printer.trace) Printer.trace("> "+getClass().getName()+".open() - AbstractDataLine");
-
// this may throw a LineUnavailableException.
open(format, bufferSize);
- if (Printer.trace) Printer.trace("< "+getClass().getName()+".open() - AbstractDataLine");
}
/**
@@ -405,8 +374,6 @@
public final void close() {
//$$fb 2001-10-09: Bug #4517739: avoiding deadlock by synchronizing to mixer !
synchronized (mixer) {
- if (Printer.trace) Printer.trace("> "+getClass().getName()+".close() - in AbstractDataLine.");
-
if (isOpen()) {
// stop
@@ -426,7 +393,6 @@
bufferSize = defaultBufferSize;
}
}
- if (Printer.trace) Printer.trace("< "+getClass().getName()+".close() - in AbstractDataLine");
}
abstract void implOpen(AudioFormat format, int bufferSize) throws LineUnavailableException;
--- a/src/java.desktop/share/classes/com/sun/media/sound/AbstractLine.java Thu Apr 25 15:19:09 2019 +0530
+++ b/src/java.desktop/share/classes/com/sun/media/sound/AbstractLine.java Thu Apr 25 15:13:36 2019 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2019, 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
@@ -156,9 +156,6 @@
* events if it changes.
*/
final void setOpen(boolean open) {
-
- if (Printer.trace) Printer.trace("> "+getClass().getName()+" (AbstractLine): setOpen(" + open + ") this.open: " + this.open);
-
boolean sendEvents = false;
long position = getLongFramePosition();
@@ -176,7 +173,6 @@
sendEvents(new LineEvent(this, LineEvent.Type.CLOSE, position));
}
}
- if (Printer.trace) Printer.trace("< "+getClass().getName()+" (AbstractLine): setOpen(" + open + ") this.open: " + this.open);
}
/**
--- a/src/java.desktop/share/classes/com/sun/media/sound/AbstractMidiDevice.java Thu Apr 25 15:19:09 2019 +0530
+++ b/src/java.desktop/share/classes/com/sun/media/sound/AbstractMidiDevice.java Thu Apr 25 15:13:36 2019 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2019, 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
@@ -50,8 +50,6 @@
*/
abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice {
- private static final boolean TRACE_TRANSMITTER = false;
-
private ArrayList<Receiver> receiverList;
private TransmitterList transmitterList;
@@ -88,13 +86,8 @@
* The initial mode and only supported mode default to OMNI_ON_POLY.
*/
protected AbstractMidiDevice(MidiDevice.Info info) {
-
- if(Printer.trace) Printer.trace(">> AbstractMidiDevice CONSTRUCTOR");
-
this.info = info;
openRefCount = 0;
-
- if(Printer.trace) Printer.trace("<< AbstractMidiDevice CONSTRUCTOR completed");
}
// MIDI DEVICE METHODS
@@ -111,12 +104,10 @@
*/
@Override
public final void open() throws MidiUnavailableException {
- if (Printer.trace) Printer.trace("> AbstractMidiDevice: open()");
synchronized(this) {
openRefCount = -1;
doOpen();
}
- if (Printer.trace) Printer.trace("< AbstractMidiDevice: open() completed");
}
/** Open the device implicitly.
@@ -131,7 +122,6 @@
* @object The Receiver or Transmitter instance that triggered this implicit open.
*/
private void openInternal(Object object) throws MidiUnavailableException {
- if (Printer.trace) Printer.trace("> AbstractMidiDevice: openInternal()");
synchronized(this) {
if (openRefCount != -1) {
openRefCount++;
@@ -140,28 +130,23 @@
// double calls to doOpens() will be catched by the open flag.
doOpen();
}
- if (Printer.trace) Printer.trace("< AbstractMidiDevice: openInternal() completed");
}
private void doOpen() throws MidiUnavailableException {
- if (Printer.trace) Printer.trace("> AbstractMidiDevice: doOpen()");
synchronized(this) {
if (! isOpen()) {
implOpen();
open = true;
}
}
- if (Printer.trace) Printer.trace("< AbstractMidiDevice: doOpen() completed");
}
@Override
public final void close() {
- if (Printer.trace) Printer.trace("> AbstractMidiDevice: close()");
synchronized (this) {
doClose();
openRefCount = 0;
}
- if (Printer.trace) Printer.trace("< AbstractMidiDevice: close() completed");
}
/** Close the device for an object that implicitely opened it.
@@ -177,7 +162,6 @@
* this may be a Transmitter or receiver).
*/
public final void closeInternal(Object object) {
- if (Printer.trace) Printer.trace("> AbstractMidiDevice: closeInternal()");
synchronized(this) {
if (getOpenKeepingObjects().remove(object)) {
if (openRefCount > 0) {
@@ -188,18 +172,15 @@
}
}
}
- if (Printer.trace) Printer.trace("< AbstractMidiDevice: closeInternal() completed");
}
public final void doClose() {
- if (Printer.trace) Printer.trace("> AbstractMidiDevice: doClose()");
synchronized(this) {
if (isOpen()) {
implClose();
open = false;
}
}
- if (Printer.trace) Printer.trace("< AbstractMidiDevice: doClose() completed");
}
@Override
@@ -530,7 +511,6 @@
@Override
public final void setReceiver(Receiver receiver) {
if (tlist != null && this.receiver != receiver) {
- if (Printer.debug) Printer.debug("Transmitter "+toString()+": set receiver "+receiver);
tlist.receiverChanged(this, this.receiver, receiver);
this.receiver = receiver;
}
@@ -583,7 +563,6 @@
if (t instanceof BasicTransmitter) {
((BasicTransmitter) t).setTransmitterList(this);
}
- if (Printer.debug) Printer.debug("--added transmitter "+t);
}
private void remove(Transmitter t) {
@@ -591,7 +570,6 @@
int index = transmitters.indexOf(t);
if (index >= 0) {
transmitters.remove(index);
- if (Printer.debug) Printer.debug("--removed transmitter "+t);
}
}
}
@@ -625,7 +603,6 @@
}
transmitters.clear();
}
- if (Printer.trace) Printer.trace("TransmitterList.close() succeeded");
}
@@ -642,11 +619,9 @@
int size = transmitters.size();
if (optimizedReceiverCount == size) {
if (midiOutReceiver != null) {
- if (TRACE_TRANSMITTER) Printer.println("Sending packed message to MidiOutReceiver");
midiOutReceiver.sendPackedMidiMessage(packedMessage, timeStamp);
}
} else {
- if (TRACE_TRANSMITTER) Printer.println("Sending packed message to "+size+" transmitter's receivers");
for (int i = 0; i < size; i++) {
Receiver receiver = transmitters.get(i).getReceiver();
if (receiver != null) {
@@ -672,7 +647,6 @@
try {
synchronized(transmitters) {
int size = transmitters.size();
- if (TRACE_TRANSMITTER) Printer.println("Sending long message to "+size+" transmitter's receivers");
for (int i = 0; i < size; i++) {
Receiver receiver = transmitters.get(i).getReceiver();
if (receiver != null) {
@@ -703,11 +677,9 @@
int size = transmitters.size();
if (optimizedReceiverCount == size) {
if (midiOutReceiver != null) {
- if (TRACE_TRANSMITTER) Printer.println("Sending MIDI message to MidiOutReceiver");
midiOutReceiver.send(message, timeStamp);
}
} else {
- if (TRACE_TRANSMITTER) Printer.println("Sending MIDI message to "+size+" transmitter's receivers");
for (int i = 0; i < size; i++) {
Receiver receiver = transmitters.get(i).getReceiver();
if (receiver != null) {
--- a/src/java.desktop/share/classes/com/sun/media/sound/AbstractMidiDeviceProvider.java Thu Apr 25 15:19:09 2019 +0530
+++ b/src/java.desktop/share/classes/com/sun/media/sound/AbstractMidiDeviceProvider.java Thu Apr 25 15:13:36 2019 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2019, 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
@@ -43,11 +43,8 @@
* Create objects representing all MIDI output devices on the system.
*/
static {
- if (Printer.trace) Printer.trace("AbstractMidiDeviceProvider: static");
Platform.initialize();
enabled = Platform.isMidiIOEnabled();
- if (Printer.trace) Printer.trace("AbstractMidiDeviceProvider: enabled: " + enabled);
-
// $$fb number of MIDI devices may change with time
// also for memory's sake, do not initialize the arrays here
}
@@ -68,10 +65,6 @@
int oldNumDevices = (infos==null)?-1:infos.length;
int newNumDevices = getNumDevices();
if (oldNumDevices != newNumDevices) {
- if (Printer.trace) Printer.trace(getClass().toString()
- +": readDeviceInfos: old numDevices: "+oldNumDevices
- +" newNumDevices: "+ newNumDevices);
-
// initialize the arrays
Info[] newInfos = new Info[newNumDevices];
MidiDevice[] newDevices = new MidiDevice[newNumDevices];
--- a/src/java.desktop/share/classes/com/sun/media/sound/AbstractMixer.java Thu Apr 25 15:19:09 2019 +0530
+++ b/src/java.desktop/share/classes/com/sun/media/sound/AbstractMixer.java Thu Apr 25 15:13:36 2019 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2019, 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
@@ -282,7 +282,6 @@
* This implementation tries to open the mixer with its current format and buffer size settings.
*/
final synchronized void open(boolean manual) throws LineUnavailableException {
- if (Printer.trace) Printer.trace(">> AbstractMixer: open()");
if (!isOpen()) {
implOpen();
// if the mixer is not currently open, set open to true and send event
@@ -291,8 +290,6 @@
manuallyOpened = true;
}
}
-
- if (Printer.trace) Printer.trace("<< AbstractMixer: open() succeeded");
}
// METHOD FOR INTERNAL IMPLEMENTATION USE
@@ -305,12 +302,8 @@
* format if it is a DataLine.
*/
final synchronized void open(Line line) throws LineUnavailableException {
-
- if (Printer.trace) Printer.trace(">> AbstractMixer: open(line = " + line + ")");
-
// $$kk: 06.11.99: ignore ourselves for now
if (this.equals(line)) {
- if (Printer.trace) Printer.trace("<< AbstractMixer: open(" + line + ") nothing done");
return;
}
@@ -339,8 +332,6 @@
if (Printer.err) Printer.err("Unknown line received for AbstractMixer.open(Line): " + line);
}
}
-
- if (Printer.trace) Printer.trace("<< AbstractMixer: open(" + line + ") completed");
}
/**
@@ -349,28 +340,17 @@
* If the list is now empty, closes the mixer.
*/
final synchronized void close(Line line) {
-
- if (Printer.trace) Printer.trace(">> AbstractMixer: close(" + line + ")");
-
// $$kk: 06.11.99: ignore ourselves for now
if (this.equals(line)) {
- if (Printer.trace) Printer.trace("<< AbstractMixer: close(" + line + ") nothing done");
return;
}
sourceLines.removeElement(line);
targetLines.removeElement(line);
- if (Printer.debug) Printer.debug("AbstractMixer: close(line): sourceLines.size() now: " + sourceLines.size());
- if (Printer.debug) Printer.debug("AbstractMixer: close(line): targetLines.size() now: " + targetLines.size());
-
-
if (sourceLines.isEmpty() && targetLines.isEmpty() && !manuallyOpened) {
- if (Printer.trace) Printer.trace("AbstractMixer: close(" + line + "): need to close the mixer");
close();
}
-
- if (Printer.trace) Printer.trace("<< AbstractMixer: close(" + line + ") succeeded");
}
/**
@@ -378,7 +358,6 @@
*/
@Override
public final synchronized void close() {
- if (Printer.trace) Printer.trace(">> AbstractMixer: close()");
if (isOpen()) {
// close all source lines
Line[] localLines = getSourceLines();
@@ -398,42 +377,30 @@
setOpen(false);
}
manuallyOpened = false;
- if (Printer.trace) Printer.trace("<< AbstractMixer: close() succeeded");
}
/**
* Starts the mixer.
*/
final synchronized void start(Line line) {
-
- if (Printer.trace) Printer.trace(">> AbstractMixer: start(" + line + ")");
-
// $$kk: 06.11.99: ignore ourselves for now
if (this.equals(line)) {
- if (Printer.trace) Printer.trace("<< AbstractMixer: start(" + line + ") nothing done");
return;
}
// we just start the mixer regardless of anything else here.
if (!started) {
- if (Printer.debug) Printer.debug("AbstractMixer: start(line): starting the mixer");
implStart();
started = true;
}
-
- if (Printer.trace) Printer.trace("<< AbstractMixer: start(" + line + ") succeeded");
}
/**
* Stops the mixer if this was the last running line.
*/
final synchronized void stop(Line line) {
-
- if (Printer.trace) Printer.trace(">> AbstractMixer: stop(" + line + ")");
-
// $$kk: 06.11.99: ignore ourselves for now
if (this.equals(line)) {
- if (Printer.trace) Printer.trace("<< AbstractMixer: stop(" + line + ") nothing done");
return;
}
@@ -447,7 +414,6 @@
if (localSourceLines.elementAt(i) instanceof AbstractDataLine) {
AbstractDataLine sourceLine = (AbstractDataLine)localSourceLines.elementAt(i);
if ( sourceLine.isStartedRunning() && (!sourceLine.equals(line)) ) {
- if (Printer.trace) Printer.trace("<< AbstractMixer: stop(" + line + ") found running sourceLine: " + sourceLine);
return;
}
}
@@ -462,18 +428,14 @@
if (localTargetLines.elementAt(i) instanceof AbstractDataLine) {
AbstractDataLine targetLine = (AbstractDataLine)localTargetLines.elementAt(i);
if ( targetLine.isStartedRunning() && (!targetLine.equals(line)) ) {
- if (Printer.trace) Printer.trace("<< AbstractMixer: stop(" + line + ") found running targetLine: " + targetLine);
return;
}
}
}
// otherwise, stop
- if (Printer.debug) Printer.debug("AbstractMixer: stop(line): stopping the mixer");
started = false;
implStop();
-
- if (Printer.trace) Printer.trace("<< AbstractMixer: stop(" + line + ") succeeded");
}
/**
--- a/src/java.desktop/share/classes/com/sun/media/sound/DataPusher.java Thu Apr 25 15:19:09 2019 +0530
+++ b/src/java.desktop/share/classes/com/sun/media/sound/DataPusher.java Thu Apr 25 15:13:36 2019 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2019, 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
@@ -44,7 +44,6 @@
public final class DataPusher implements Runnable {
private static final int AUTO_CLOSE_TIME = 5000;
- private static final boolean DEBUG = false;
private final SourceDataLine source;
private final AudioFormat format;
@@ -94,26 +93,20 @@
}
public synchronized void start(boolean loop) {
- if (DEBUG || Printer.debug) Printer.debug("> DataPusher.start(loop="+loop+")");
try {
if (threadState == STATE_STOPPING) {
// wait that the thread has finished stopping
- if (DEBUG || Printer.trace)Printer.trace("DataPusher.start(): calling stop()");
stop();
}
looping = loop;
newPos = 0;
wantedState = STATE_PLAYING;
if (!source.isOpen()) {
- if (DEBUG || Printer.trace)Printer.trace("DataPusher: source.open()");
source.open(format);
}
- if (DEBUG || Printer.trace)Printer.trace("DataPusher: source.flush()");
source.flush();
- if (DEBUG || Printer.trace)Printer.trace("DataPusher: source.start()");
source.start();
if (pushThread == null) {
- if (DEBUG || Printer.debug) Printer.debug("DataPusher.start(): Starting push");
pushThread = JSSecurityManager.createThread(this,
null, // name
false, // daemon
@@ -122,24 +115,18 @@
}
notifyAll();
} catch (Exception e) {
- if (DEBUG || Printer.err) e.printStackTrace();
+ if (Printer.err) e.printStackTrace();
}
- if (DEBUG || Printer.debug) Printer.debug("< DataPusher.start(loop="+loop+")");
}
public synchronized void stop() {
- if (DEBUG || Printer.debug) Printer.debug("> DataPusher.stop()");
if (threadState == STATE_STOPPING
|| threadState == STATE_STOPPED
|| pushThread == null) {
- if (DEBUG || Printer.debug) Printer.debug("DataPusher.stop(): nothing to do");
return;
}
- if (DEBUG || Printer.debug) Printer.debug("DataPusher.stop(): Stopping push");
-
wantedState = STATE_WAITING;
if (source != null) {
- if (DEBUG || Printer.trace)Printer.trace("DataPusher: source.flush()");
source.flush();
}
notifyAll();
@@ -149,12 +136,10 @@
wait(100);
} catch (InterruptedException e) { }
}
- if (DEBUG || Printer.debug) Printer.debug("< DataPusher.stop()");
}
synchronized void close() {
if (source != null) {
- if (DEBUG || Printer.trace)Printer.trace("DataPusher.close(): source.close()");
source.close();
}
}
@@ -175,7 +160,6 @@
//try {
if (wantedState == STATE_WAITING) {
// wait for 5 seconds - maybe the clip is to be played again
- if (DEBUG || Printer.debug)Printer.debug("DataPusher.run(): waiting 5 seconds");
try {
synchronized(this) {
threadState = STATE_WAITING;
@@ -183,7 +167,6 @@
wait(AUTO_CLOSE_TIME);
}
} catch (InterruptedException ie) {}
- if (DEBUG || Printer.debug)Printer.debug("DataPusher.run(): waiting finished");
continue;
}
if (newPos >= 0) {
@@ -211,37 +194,26 @@
}
}
if (toWrite < 0) {
- if (DEBUG || Printer.debug) Printer.debug("DataPusher.run(): Found end of stream");
if (!useStream && looping) {
- if (DEBUG || Printer.debug)Printer.debug("DataPusher.run(): setting pos back to 0");
pos = 0;
continue;
}
- if (DEBUG || Printer.debug)Printer.debug("DataPusher.run(): calling drain()");
wantedState = STATE_WAITING;
source.drain();
continue;
}
- if (DEBUG || Printer.debug) Printer.debug("> DataPusher.run(): Writing " + toWrite + " bytes");
- int bytesWritten = source.write(buffer, pos, toWrite);
- pos += bytesWritten;
- if (DEBUG || Printer.debug) Printer.debug("< DataPusher.run(): Wrote " + bytesWritten + " bytes");
+ int bytesWritten = source.write(buffer, pos, toWrite);
+ pos += bytesWritten;
}
threadState = STATE_STOPPING;
- if (DEBUG || Printer.debug)Printer.debug("DataPusher: closing device");
- if (Printer.trace)Printer.trace("DataPusher: source.flush()");
source.flush();
- if (DEBUG || Printer.trace)Printer.trace("DataPusher: source.stop()");
source.stop();
- if (DEBUG || Printer.trace)Printer.trace("DataPusher: source.flush()");
source.flush();
- if (DEBUG || Printer.trace)Printer.trace("DataPusher: source.close()");
source.close();
threadState = STATE_STOPPED;
synchronized (this) {
pushThread = null;
notifyAll();
}
- if (DEBUG || Printer.debug)Printer.debug("DataPusher:end of thread");
}
} // class DataPusher
--- a/src/java.desktop/share/classes/com/sun/media/sound/DirectAudioDevice.java Thu Apr 25 15:19:09 2019 +0530
+++ b/src/java.desktop/share/classes/com/sun/media/sound/DirectAudioDevice.java Thu Apr 25 15:13:36 2019 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2019, 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
@@ -64,9 +64,6 @@
null, // Control[]
null, // Line.Info[] sourceLineInfo
null); // Line.Info[] targetLineInfo
-
- if (Printer.trace) Printer.trace(">> DirectAudioDevice: constructor");
-
// source lines
DirectDLI srcLineInfo = createDataLineInfo(true);
if (srcLineInfo != null) {
@@ -90,7 +87,6 @@
} else {
targetLineInfo = new Line.Info[0];
}
- if (Printer.trace) Printer.trace("<< DirectAudioDevice: constructor completed");
}
private DirectDLI createDataLineInfo(boolean isSource) {
@@ -236,22 +232,18 @@
@Override
protected void implOpen() throws LineUnavailableException {
- if (Printer.trace) Printer.trace("DirectAudioDevice: implOpen - void method");
}
@Override
protected void implClose() {
- if (Printer.trace) Printer.trace("DirectAudioDevice: implClose - void method");
}
@Override
protected void implStart() {
- if (Printer.trace) Printer.trace("DirectAudioDevice: implStart - void method");
}
@Override
protected void implStop() {
- if (Printer.trace) Printer.trace("DirectAudioDevice: implStop - void method");
}
int getMixerIndex() {
@@ -400,7 +392,6 @@
int deviceID,
boolean isSource) {
super(info, mixer, null, format, bufferSize);
- if (Printer.trace) Printer.trace("DirectDL CONSTRUCTOR: info: " + info);
this.mixerIndex = mixerIndex;
this.deviceID = deviceID;
this.waitTime = 10; // 10 milliseconds default wait time
@@ -410,8 +401,6 @@
@Override
void implOpen(AudioFormat format, int bufferSize) throws LineUnavailableException {
- if (Printer.trace) Printer.trace(">> DirectDL: implOpen("+format+", "+bufferSize+" bytes)");
-
// $$fb part of fix for 4679187: Clip.open() throws unexpected Exceptions
Toolkit.isFullySpecifiedAudioFormat(format);
@@ -462,8 +451,6 @@
controls[1] = muteControl;
}
}
- if (Printer.debug) Printer.debug("DirectAudioDevice: got "+controls.length+" controls.");
-
hardwareFormat = format;
/* some magic to account for not-supported endianness or signed-ness */
@@ -475,12 +462,6 @@
hardwareFormat = newFormat;
// So do endian/sign conversion in software
softwareConversionSize = format.getFrameSize() / format.getChannels();
- if (Printer.debug) {
- Printer.debug("DirectAudioDevice: softwareConversionSize "
- +softwareConversionSize+":");
- Printer.debug(" from "+format);
- Printer.debug(" to "+newFormat);
- }
}
}
@@ -524,14 +505,10 @@
stoppedWritten = false;
doIO = false;
calcVolume();
-
- if (Printer.trace) Printer.trace("<< DirectDL: implOpen() succeeded");
}
@Override
void implStart() {
- if (Printer.trace) Printer.trace(" >> DirectDL: implStart()");
-
// check for record permission
if (!isSource) {
JSSecurityManager.checkRecordPermission();
@@ -557,14 +534,10 @@
setActive(true);
}
}
-
- if (Printer.trace) Printer.trace("<< DirectDL: implStart() succeeded");
}
@Override
void implStop() {
- if (Printer.trace) Printer.trace(">> DirectDL: implStop()");
-
// check for record permission
if (!isSource) {
JSSecurityManager.checkRecordPermission();
@@ -588,14 +561,10 @@
lock.notifyAll();
}
stoppedWritten = false;
-
- if (Printer.trace) Printer.trace(" << DirectDL: implStop() succeeded");
}
@Override
void implClose() {
- if (Printer.trace) Printer.trace(">> DirectDL: implClose()");
-
// check for record permission
if (!isSource) {
JSSecurityManager.checkRecordPermission();
@@ -615,7 +584,6 @@
}
bytePosition = 0;
softwareConversionSize = 0;
- if (Printer.trace) Printer.trace("<< DirectDL: implClose() succeeded");
}
@Override
@@ -700,8 +668,6 @@
}
// hack because ALSA sometimes reports wrong framepos
if (pos < 0) {
- if (Printer.debug) Printer.debug("DirectLine.getLongFramePosition: Native reported pos="
- +pos+"! is changed to 0. byteposition="+bytePosition);
pos = 0;
}
return (pos / getFormat().getFrameSize());
@@ -920,9 +886,7 @@
int bufferSize,
DirectAudioDevice mixer) {
super(info, mixer, format, bufferSize, mixer.getMixerIndex(), mixer.getDeviceID(), true);
- if (Printer.trace) Printer.trace("DirectSDL CONSTRUCTOR: completed");
}
-
}
/**
@@ -936,7 +900,6 @@
int bufferSize,
DirectAudioDevice mixer) {
super(info, mixer, format, bufferSize, mixer.getMixerIndex(), mixer.getDeviceID(), false);
- if (Printer.trace) Printer.trace("DirectTDL CONSTRUCTOR: completed");
}
@Override
@@ -1029,7 +992,6 @@
int bufferSize,
DirectAudioDevice mixer) {
super(info, mixer, format, bufferSize, mixer.getMixerIndex(), mixer.getDeviceID(), true);
- if (Printer.trace) Printer.trace("DirectClip CONSTRUCTOR: completed");
}
// CLIP METHODS
@@ -1055,10 +1017,6 @@
Toolkit.isFullySpecifiedAudioFormat(format);
synchronized (mixer) {
- if (Printer.trace) Printer.trace("> DirectClip.open(format, data, frameLength)");
- if (Printer.debug) Printer.debug(" data="+((data==null)?"null":""+data.length+" bytes"));
- if (Printer.debug) Printer.debug(" frameLength="+frameLength);
-
if (isOpen()) {
throw new IllegalStateException("Clip is already open with format " + getFormat() +
" and frame lengh of " + getFrameLength());
@@ -1103,7 +1061,6 @@
if (isAutoClosing()) {
getEventDispatcher().autoClosingClipOpened(this);
}
- if (Printer.trace) Printer.trace("< DirectClip.open completed");
}
@Override
@@ -1113,7 +1070,6 @@
Toolkit.isFullySpecifiedAudioFormat(format);
synchronized (mixer) {
- if (Printer.trace) Printer.trace("> DirectClip.open(stream)");
byte[] streamData = null;
if (isOpen()) {
@@ -1121,8 +1077,6 @@
" and frame lengh of " + getFrameLength());
}
int lengthInFrames = (int)stream.getFrameLength();
- if (Printer.debug) Printer.debug("DirectClip: open(AIS): lengthInFrames: " + lengthInFrames);
-
int bytesRead = 0;
if (lengthInFrames != AudioSystem.NOT_SPECIFIED) {
// read the data from the stream into an array in one fell swoop.
@@ -1164,12 +1118,8 @@
}
lengthInFrames = bytesRead / stream.getFormat().getFrameSize();
- if (Printer.debug) Printer.debug("Read to end of stream. lengthInFrames: " + lengthInFrames);
-
// now try to open the device
open(stream.getFormat(), streamData, lengthInFrames);
-
- if (Printer.trace) Printer.trace("< DirectClip.open(stream) succeeded");
} // synchronized
}
@@ -1185,8 +1135,6 @@
@Override
public void setFramePosition(int frames) {
- if (Printer.trace) Printer.trace("> DirectClip: setFramePosition: " + frames);
-
if (frames < 0) {
frames = 0;
}
@@ -1213,14 +1161,6 @@
synchronized (lockNative) {
nSetBytePosition(id, isSource, frames * frameSize);
}
-
- if (Printer.debug) Printer.debug(" DirectClip.setFramePosition: "
- +" doIO="+doIO
- +" newFramePosition="+newFramePosition
- +" clipBytePosition="+clipBytePosition
- +" bytePosition="+bytePosition
- +" getLongFramePosition()="+getLongFramePosition());
- if (Printer.trace) Printer.trace("< DirectClip: setFramePosition");
}
// replacement for getFramePosition (see AbstractDataLine)
@@ -1241,18 +1181,12 @@
@Override
public synchronized void setMicrosecondPosition(long microseconds) {
- if (Printer.trace) Printer.trace("> DirectClip: setMicrosecondPosition: " + microseconds);
-
long frames = Toolkit.micros2frames(getFormat(), microseconds);
setFramePosition((int) frames);
-
- if (Printer.trace) Printer.trace("< DirectClip: setMicrosecondPosition succeeded");
}
@Override
public void setLoopPoints(int start, int end) {
- if (Printer.trace) Printer.trace("> DirectClip: setLoopPoints: start: " + start + " end: " + end);
-
if (start < 0 || start >= getFrameLength()) {
throw new IllegalArgumentException("illegal value for start: "+start);
}
@@ -1275,9 +1209,6 @@
// slight race condition with the run() method, but not a big problem
loopStartFrame = start;
loopEndFrame = end;
-
- if (Printer.trace) Printer.trace(" loopStart: " + loopStartFrame + " loopEnd: " + loopEndFrame);
- if (Printer.trace) Printer.trace("< DirectClip: setLoopPoints completed");
}
@Override
@@ -1300,8 +1231,6 @@
@Override
void implClose() {
- if (Printer.trace) Printer.trace(">> DirectClip: implClose()");
-
// dispose of thread
Thread oldThread = thread;
thread = null;
@@ -1324,33 +1253,24 @@
// remove this instance from the list of auto closing clips
getEventDispatcher().autoClosingClipClosed(this);
-
- if (Printer.trace) Printer.trace("<< DirectClip: implClose() succeeded");
}
@Override
void implStart() {
- if (Printer.trace) Printer.trace("> DirectClip: implStart()");
super.implStart();
- if (Printer.trace) Printer.trace("< DirectClip: implStart() succeeded");
}
@Override
void implStop() {
- if (Printer.trace) Printer.trace(">> DirectClip: implStop()");
-
super.implStop();
// reset loopCount field so that playback will be normal with
// next call to start()
loopCount = 0;
-
- if (Printer.trace) Printer.trace("<< DirectClip: implStop() succeeded");
}
// 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
@@ -1396,9 +1316,6 @@
newFramePosition = loopStartFrame;
} else {
// no looping, stop playback
- if (Printer.debug) Printer.debug("stop clip in run() loop:");
- if (Printer.debug) Printer.debug(" doIO="+doIO+" written="+written+" clipBytePosition="+clipBytePosition);
- if (Printer.debug) Printer.debug(" framePos="+framePos+" endFrame="+endFrame);
drain();
stop();
}
@@ -1406,7 +1323,6 @@
}
}
}
- if (Printer.trace) Printer.trace("<<< DirectClip: run() threadID="+Thread.currentThread().getId());
}
// AUTO CLOSING CLIP SUPPORT
--- a/src/java.desktop/share/classes/com/sun/media/sound/DirectAudioDeviceProvider.java Thu Apr 25 15:19:09 2019 +0530
+++ b/src/java.desktop/share/classes/com/sun/media/sound/DirectAudioDeviceProvider.java Thu Apr 25 15:13:36 2019 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2019, 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
@@ -69,7 +69,6 @@
int numDevices = nGetNumDevices();
if (infos == null || infos.length != numDevices) {
- if (Printer.trace) Printer.trace("DirectAudioDeviceProvider: init()");
// initialize the arrays
infos = new DirectAudioDeviceInfo[numDevices];
devices = new DirectAudioDevice[numDevices];
@@ -78,7 +77,6 @@
for (int i = 0; i < infos.length; i++) {
infos[i] = nNewDirectAudioDeviceInfo(i);
}
- if (Printer.trace) Printer.trace("DirectAudioDeviceProvider: init(): found numDevices: " + numDevices);
}
}
--- a/src/java.desktop/share/classes/com/sun/media/sound/EventDispatcher.java Thu Apr 25 15:19:09 2019 +0530
+++ b/src/java.desktop/share/classes/com/sun/media/sound/EventDispatcher.java Thu Apr 25 15:13:36 2019 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2019, 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
@@ -100,7 +100,6 @@
// process an LineEvent
if (eventInfo.getEvent() instanceof LineEvent) {
LineEvent event = (LineEvent) eventInfo.getEvent();
- if (Printer.debug) Printer.debug("Sending "+event+" to "+count+" listeners");
for (int i = 0; i < count; i++) {
try {
((LineListener) eventInfo.getListener(i)).update(event);
@@ -241,7 +240,6 @@
*/
private void closeAutoClosingClips() {
synchronized(autoClosingClips) {
- if (Printer.debug)Printer.debug("> EventDispatcher.closeAutoClosingClips ("+autoClosingClips.size()+" clips)");
long currTime = System.currentTimeMillis();
for (int i = autoClosingClips.size()-1; i >= 0 ; i--) {
ClipInfo info = autoClosingClips.get(i);
@@ -249,23 +247,15 @@
AutoClosingClip clip = info.getClip();
// sanity check
if (!clip.isOpen() || !clip.isAutoClosing()) {
- if (Printer.debug)Printer.debug("EventDispatcher: removing clip "+clip+" isOpen:"+clip.isOpen());
autoClosingClips.remove(i);
}
else if (!clip.isRunning() && !clip.isActive() && clip.isAutoClosing()) {
- if (Printer.debug)Printer.debug("EventDispatcher: closing clip "+clip);
clip.close();
} else {
- if (Printer.debug)Printer.debug("Doing nothing with clip "+clip+":");
- if (Printer.debug)Printer.debug(" open="+clip.isOpen()+", autoclosing="+clip.isAutoClosing());
- if (Printer.debug)Printer.debug(" isRunning="+clip.isRunning()+", isActive="+clip.isActive());
}
- } else {
- if (Printer.debug)Printer.debug("EventDispatcher: clip "+info.getClip()+" not yet expired");
}
}
}
- if (Printer.debug)Printer.debug("< EventDispatcher.closeAutoClosingClips ("+autoClosingClips.size()+" clips)");
}
private int getAutoClosingClipIndex(AutoClosingClip clip) {
@@ -283,12 +273,10 @@
* called from auto-closing clips when one of their open() method is called.
*/
void autoClosingClipOpened(AutoClosingClip clip) {
- if (Printer.debug)Printer.debug("> EventDispatcher.autoClosingClipOpened ");
int index = 0;
synchronized(autoClosingClips) {
index = getAutoClosingClipIndex(clip);
if (index == -1) {
- if (Printer.debug)Printer.debug("EventDispatcher: adding auto-closing clip "+clip);
autoClosingClips.add(new ClipInfo(clip));
}
}
@@ -301,7 +289,6 @@
notifyAll();
}
}
- if (Printer.debug)Printer.debug("< EventDispatcher.autoClosingClipOpened finished("+autoClosingClips.size()+" clips)");
}
/**
@@ -326,48 +313,38 @@
*/
private void monitorLines() {
synchronized(lineMonitors) {
- if (Printer.debug)Printer.debug("> EventDispatcher.monitorLines ("+lineMonitors.size()+" monitors)");
for (int i = 0; i < lineMonitors.size(); i++) {
lineMonitors.get(i).checkLine();
}
}
- if (Printer.debug)Printer.debug("< EventDispatcher.monitorLines("+lineMonitors.size()+" monitors)");
}
/**
* Add this LineMonitor instance to the list of monitors.
*/
void addLineMonitor(LineMonitor lm) {
- if (Printer.trace)Printer.trace("> EventDispatcher.addLineMonitor("+lm+")");
synchronized(lineMonitors) {
if (lineMonitors.indexOf(lm) >= 0) {
- if (Printer.trace)Printer.trace("< EventDispatcher.addLineMonitor finished -- this monitor already exists!");
return;
}
- if (Printer.debug)Printer.debug("EventDispatcher: adding line monitor "+lm);
lineMonitors.add(lm);
}
synchronized (this) {
// need to interrupt the infinite wait()
notifyAll();
}
- if (Printer.debug)Printer.debug("< EventDispatcher.addLineMonitor finished -- now ("+lineMonitors.size()+" monitors)");
}
/**
* Remove this LineMonitor instance from the list of monitors.
*/
void removeLineMonitor(LineMonitor lm) {
- if (Printer.trace)Printer.trace("> EventDispatcher.removeLineMonitor("+lm+")");
synchronized(lineMonitors) {
if (lineMonitors.indexOf(lm) < 0) {
- if (Printer.trace)Printer.trace("< EventDispatcher.removeLineMonitor finished -- this monitor does not exist!");
return;
}
- if (Printer.debug)Printer.debug("EventDispatcher: removing line monitor "+lm);
lineMonitors.remove(lm);
}
- if (Printer.debug)Printer.debug("< EventDispatcher.removeLineMonitor finished -- now ("+lineMonitors.size()+" monitors)");
}
/**
--- a/src/java.desktop/share/classes/com/sun/media/sound/JSSecurityManager.java Thu Apr 25 15:19:09 2019 +0530
+++ b/src/java.desktop/share/classes/com/sun/media/sound/JSSecurityManager.java Thu Apr 25 15:13:36 2019 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2019, 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
@@ -53,7 +53,6 @@
}
static void checkRecordPermission() throws SecurityException {
- if(Printer.trace) Printer.trace("JSSecurityManager.checkRecordPermission()");
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
sm.checkPermission(new AudioPermission("record"));
--- a/src/java.desktop/share/classes/com/sun/media/sound/JavaSoundAudioClip.java Thu Apr 25 15:19:09 2019 +0530
+++ b/src/java.desktop/share/classes/com/sun/media/sound/JavaSoundAudioClip.java Thu Apr 25 15:13:36 2019 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2019, 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
@@ -60,7 +60,6 @@
@SuppressWarnings("deprecation")
public final class JavaSoundAudioClip implements AudioClip, MetaEventListener, LineListener {
- private static final boolean DEBUG = false;
private static final int BUFFER_SIZE = 16384; // number of bytes written each time to the source data line
private long lastPlayCall = 0;
@@ -115,8 +114,6 @@
}
private void init(InputStream in) throws IOException {
- if (DEBUG || Printer.debug)Printer.debug("JavaSoundAudioClip.<init>");
-
BufferedInputStream bis = new BufferedInputStream(in, STREAM_BUFFER_SIZE);
bis.mark(STREAM_BUFFER_SIZE);
try {
@@ -165,12 +162,9 @@
long currentTime = System.currentTimeMillis();
long diff = currentTime - lastPlayCall;
if (diff < MINIMUM_PLAY_DELAY) {
- if (DEBUG || Printer.debug) Printer.debug("JavaSoundAudioClip.startImpl(loop="+loop+"): abort - too rapdly");
return;
}
lastPlayCall = currentTime;
-
- if (DEBUG || Printer.debug) Printer.debug("JavaSoundAudioClip.startImpl(loop="+loop+")");
try {
if (clip != null) {
// We need to disable autoclosing mechanism otherwise the clip
@@ -200,7 +194,6 @@
}
} else if (datapusher != null ) {
datapusher.start(loop);
- if (DEBUG || Printer.debug)Printer.debug("Stream should be playing/looping");
} else if (sequencer != null) {
sequencerloop = loop;
@@ -213,21 +206,20 @@
sequencer.setSequence(sequence);
} catch (InvalidMidiDataException e1) {
- if (DEBUG || Printer.err)e1.printStackTrace();
+ if (Printer.err) e1.printStackTrace();
} catch (MidiUnavailableException e2) {
- if (DEBUG || Printer.err)e2.printStackTrace();
+ if (Printer.err) e2.printStackTrace();
}
}
sequencer.addMetaEventListener(this);
try {
sequencer.start();
} catch (Exception e) {
- if (DEBUG || Printer.err) e.printStackTrace();
+ if (Printer.err) e.printStackTrace();
}
- if (DEBUG || Printer.debug)Printer.debug("Sequencer should be playing/looping");
}
} catch (Exception e) {
- if (DEBUG || Printer.err)e.printStackTrace();
+ if (Printer.err) e.printStackTrace();
}
}
@@ -236,29 +228,21 @@
if (!success) {
return;
}
-
- if (DEBUG || Printer.debug)Printer.debug("JavaSoundAudioClip->stop()");
lastPlayCall = 0;
if (clip != null) {
try {
- if (DEBUG || Printer.trace)Printer.trace("JavaSoundAudioClip: clip.flush()");
clip.flush();
} catch (Exception e1) {
if (Printer.err) e1.printStackTrace();
}
try {
- if (DEBUG || Printer.trace)Printer.trace("JavaSoundAudioClip: clip.stop()");
clip.stop();
} catch (Exception e2) {
if (Printer.err) e2.printStackTrace();
}
- if (DEBUG || Printer.debug)Printer.debug("Clip should be stopped");
-
} else if (datapusher != null) {
datapusher.stop();
- if (DEBUG || Printer.debug)Printer.debug("Stream should be stopped");
-
} else if (sequencer != null) {
try {
sequencerloop = false;
@@ -272,7 +256,6 @@
} catch (Exception e4) {
if (Printer.err) e4.printStackTrace();
}
- if (DEBUG || Printer.debug)Printer.debug("Sequencer should be stopped");
}
}
@@ -280,16 +263,12 @@
@Override
public synchronized void update(LineEvent event) {
- if (DEBUG || Printer.debug) Printer.debug("line event received: "+event);
}
// handle MIDI track end meta events for looping
@Override
public synchronized void meta(MetaMessage message) {
-
- if (DEBUG || Printer.debug)Printer.debug("META EVENT RECEIVED!!!!! ");
-
if( message.getType() == 47 ) {
if (sequencerloop){
//notifyAll();
@@ -310,7 +289,6 @@
protected void finalize() {
if (clip != null) {
- if (DEBUG || Printer.trace)Printer.trace("JavaSoundAudioClip.finalize: clip.close()");
clip.close();
}
@@ -327,8 +305,6 @@
// FILE LOADING METHODS
private boolean loadAudioData(AudioInputStream as) throws IOException, UnsupportedAudioFileException {
- if (DEBUG || Printer.debug)Printer.debug("JavaSoundAudioClip->openAsClip()");
-
// first possibly convert this stream to PCM
as = Toolkit.getPCMConvertedAudioInputStream(as);
if (as == null) {
@@ -404,27 +380,23 @@
// METHODS FOR CREATING THE DEVICE
private boolean createClip() {
-
- if (DEBUG || Printer.debug)Printer.debug("JavaSoundAudioClip.createClip()");
-
try {
DataLine.Info info = new DataLine.Info(Clip.class, loadedAudioFormat);
if (!(AudioSystem.isLineSupported(info)) ) {
- if (DEBUG || Printer.err)Printer.err("Clip not supported: "+loadedAudioFormat);
+ if (Printer.err) Printer.err("Clip not supported: "+loadedAudioFormat);
// fail silently
return false;
}
Object line = AudioSystem.getLine(info);
if (!(line instanceof AutoClosingClip)) {
- if (DEBUG || Printer.err)Printer.err("Clip is not auto closing!"+clip);
+ if (Printer.err) Printer.err("Clip is not auto closing!"+clip);
// fail -> will try with SourceDataLine
return false;
}
clip = (AutoClosingClip) line;
clip.setAutoClosing(true);
- if (DEBUG || Printer.debug) clip.addLineListener(this);
} catch (Exception e) {
- if (DEBUG || Printer.err)e.printStackTrace();
+ if (Printer.err) e.printStackTrace();
// fail silently
return false;
}
@@ -433,24 +405,21 @@
// fail silently
return false;
}
-
- if (DEBUG || Printer.debug)Printer.debug("Loaded clip.");
return true;
}
private boolean createSourceDataLine() {
- if (DEBUG || Printer.debug)Printer.debug("JavaSoundAudioClip.createSourceDataLine()");
try {
DataLine.Info info = new DataLine.Info(SourceDataLine.class, loadedAudioFormat);
if (!(AudioSystem.isLineSupported(info)) ) {
- if (DEBUG || Printer.err)Printer.err("Line not supported: "+loadedAudioFormat);
+ if (Printer.err) Printer.err("Line not supported: "+loadedAudioFormat);
// fail silently
return false;
}
SourceDataLine source = (SourceDataLine) AudioSystem.getLine(info);
datapusher = new DataPusher(source, loadedAudioFormat, loadedAudio, loadedAudioByteLength);
} catch (Exception e) {
- if (DEBUG || Printer.err)e.printStackTrace();
+ if (Printer.err) e.printStackTrace();
// fail silently
return false;
}
@@ -459,20 +428,15 @@
// fail silently
return false;
}
-
- if (DEBUG || Printer.debug)Printer.debug("Created SourceDataLine.");
return true;
}
private boolean createSequencer(BufferedInputStream in) throws IOException {
-
- if (DEBUG || Printer.debug)Printer.debug("JavaSoundAudioClip.createSequencer()");
-
// get the sequencer
try {
sequencer = MidiSystem.getSequencer( );
} catch(MidiUnavailableException me) {
- if (DEBUG || Printer.err)me.printStackTrace();
+ if (Printer.err) me.printStackTrace();
return false;
}
if (sequencer==null) {
@@ -485,11 +449,9 @@
return false;
}
} catch (InvalidMidiDataException e) {
- if (DEBUG || Printer.err)e.printStackTrace();
+ if (Printer.err) e.printStackTrace();
return false;
}
-
- if (DEBUG || Printer.debug)Printer.debug("Created Sequencer.");
return true;
}
--- a/src/java.desktop/share/classes/com/sun/media/sound/MidiInDevice.java Thu Apr 25 15:19:09 2019 +0530
+++ b/src/java.desktop/share/classes/com/sun/media/sound/MidiInDevice.java Thu Apr 25 15:13:36 2019 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2019, 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
@@ -41,15 +41,12 @@
MidiInDevice(AbstractMidiDeviceProvider.Info info) {
super(info);
- if(Printer.trace) Printer.trace("MidiInDevice CONSTRUCTOR");
}
// $$kk: 06.24.99: i have this both opening and starting the midi in device.
// may want to separate these??
@Override
protected synchronized void implOpen() throws MidiUnavailableException {
- if (Printer.trace) Printer.trace("> MidiInDevice: implOpen()");
-
int index = ((MidiInDeviceProvider.MidiInDeviceInfo)getDeviceInfo()).getIndex();
id = nOpen(index); // can throw MidiUnavailableException
@@ -67,14 +64,12 @@
}
nStart(id); // can throw MidiUnavailableException
- if (Printer.trace) Printer.trace("< MidiInDevice: implOpen() completed");
}
// $$kk: 06.24.99: i have this both stopping and closing the midi in device.
// may want to separate these??
@Override
protected synchronized void implClose() {
- if (Printer.trace) Printer.trace("> MidiInDevice: implClose()");
long oldId = id;
id = 0;
@@ -90,7 +85,6 @@
}
}
nClose(oldId);
- if (Printer.trace) Printer.trace("< MidiInDevice: implClose() completed");
}
@Override
@@ -137,7 +131,6 @@
} catch (InterruptedException e) {}
}
}
- if(Printer.verbose) Printer.verbose("MidiInDevice Thread exit");
// let the thread exit
midiInThread = null;
}
--- a/src/java.desktop/share/classes/com/sun/media/sound/MidiInDeviceProvider.java Thu Apr 25 15:19:09 2019 +0530
+++ b/src/java.desktop/share/classes/com/sun/media/sound/MidiInDeviceProvider.java Thu Apr 25 15:13:36 2019 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2019, 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
@@ -53,7 +53,6 @@
* Required public no-arg constructor.
*/
public MidiInDeviceProvider() {
- if (Printer.trace) Printer.trace("MidiInDeviceProvider: constructor");
}
// implementation of abstract methods in AbstractMidiDeviceProvider
@@ -77,11 +76,9 @@
@Override
int getNumDevices() {
if (!enabled) {
- if (Printer.debug)Printer.debug("MidiInDevice not enabled, returning 0 devices");
return 0;
}
int numDevices = nGetNumDevices();
- if (Printer.debug)Printer.debug("MidiInDeviceProvider.getNumDevices(): devices: " + numDevices);
return numDevices;
}
--- a/src/java.desktop/share/classes/com/sun/media/sound/MidiOutDevice.java Thu Apr 25 15:19:09 2019 +0530
+++ b/src/java.desktop/share/classes/com/sun/media/sound/MidiOutDevice.java Thu Apr 25 15:13:36 2019 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2019, 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
@@ -40,24 +40,20 @@
final class MidiOutDevice extends AbstractMidiDevice {
MidiOutDevice(AbstractMidiDeviceProvider.Info info) {
- super(info);
- if(Printer.trace) Printer.trace("MidiOutDevice CONSTRUCTOR");
+ super(info);
}
@Override
protected synchronized void implOpen() throws MidiUnavailableException {
- if (Printer.trace) Printer.trace("> MidiOutDevice: implOpen()");
int index = ((AbstractMidiDeviceProvider.Info)getDeviceInfo()).getIndex();
id = nOpen(index); // can throw MidiUnavailableException
if (id == 0) {
throw new MidiUnavailableException("Unable to open native device");
}
- if (Printer.trace) Printer.trace("< MidiOutDevice: implOpen(): completed.");
}
@Override
protected synchronized void implClose() {
- if (Printer.trace) Printer.trace("> MidiOutDevice: implClose()");
// prevent further action
long oldId = id;
id = 0;
@@ -66,7 +62,6 @@
// close the device
nClose(oldId);
- if (Printer.trace) Printer.trace("< MidiOutDevice: implClose(): completed");
}
@Override
--- a/src/java.desktop/share/classes/com/sun/media/sound/MidiOutDeviceProvider.java Thu Apr 25 15:19:09 2019 +0530
+++ b/src/java.desktop/share/classes/com/sun/media/sound/MidiOutDeviceProvider.java Thu Apr 25 15:13:36 2019 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2019, 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
@@ -53,7 +53,6 @@
* Required public no-arg constructor.
*/
public MidiOutDeviceProvider() {
- if (Printer.trace) Printer.trace("MidiOutDeviceProvider: constructor");
}
@Override
@@ -75,7 +74,6 @@
@Override
int getNumDevices() {
if (!enabled) {
- if (Printer.debug)Printer.debug("MidiOutDevice not enabled, returning 0 devices");
return 0;
}
return nGetNumDevices();
--- a/src/java.desktop/share/classes/com/sun/media/sound/MidiUtils.java Thu Apr 25 15:19:09 2019 +0530
+++ b/src/java.desktop/share/classes/com/sun/media/sound/MidiUtils.java Thu Apr 25 15:13:36 2019 -0700
@@ -269,8 +269,6 @@
i++;
}
tick = ticks[i - 1] + microsec2ticks(micros - us, tempos[i - 1], resolution);
- if (Printer.debug) Printer.debug("microsecond2tick(" + (micros / 1000)+") = "+tick+" ticks.");
- //if (Printer.debug) Printer.debug(" -> convert back = " + (tick2microsecond(seq, tick, null) / 1000)+" microseconds");
}
cache.currTempo = tempos[i - 1];
return tick;
--- a/src/java.desktop/share/classes/com/sun/media/sound/PCMtoPCMCodec.java Thu Apr 25 15:19:09 2019 +0530
+++ b/src/java.desktop/share/classes/com/sun/media/sound/PCMtoPCMCodec.java Thu Apr 25 15:13:36 2019 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2019, 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
@@ -374,45 +374,31 @@
if( AudioFormat.Encoding.PCM_UNSIGNED.equals(inputEncoding) &&
AudioFormat.Encoding.PCM_SIGNED.equals(outputEncoding) ) {
conversionType = PCM_SWITCH_SIGNED_8BIT;
- if(Printer.debug) Printer.debug("PCMtoPCMCodecStream: conversionType = PCM_SWITCH_SIGNED_8BIT");
-
} else if( AudioFormat.Encoding.PCM_SIGNED.equals(inputEncoding) &&
AudioFormat.Encoding.PCM_UNSIGNED.equals(outputEncoding) ) {
conversionType = PCM_SWITCH_SIGNED_8BIT;
- if(Printer.debug) Printer.debug("PCMtoPCMCodecStream: conversionType = PCM_SWITCH_SIGNED_8BIT");
}
} else {
if( inputEncoding.equals(outputEncoding) && (inputIsBigEndian != outputIsBigEndian) ) {
conversionType = PCM_SWITCH_ENDIAN;
- if(Printer.debug) Printer.debug("PCMtoPCMCodecStream: conversionType = PCM_SWITCH_ENDIAN");
-
-
} else if (AudioFormat.Encoding.PCM_UNSIGNED.equals(inputEncoding) && !inputIsBigEndian &&
AudioFormat.Encoding.PCM_SIGNED.equals(outputEncoding) && outputIsBigEndian) {
conversionType = PCM_UNSIGNED_LE2SIGNED_BE;
- if(Printer.debug) Printer.debug("PCMtoPCMCodecStream: conversionType = PCM_UNSIGNED_LE2SIGNED_BE");
-
} else if (AudioFormat.Encoding.PCM_SIGNED.equals(inputEncoding) && !inputIsBigEndian &&
AudioFormat.Encoding.PCM_UNSIGNED.equals(outputEncoding) && outputIsBigEndian) {
conversionType = PCM_SIGNED_LE2UNSIGNED_BE;
- if(Printer.debug) Printer.debug("PCMtoPCMCodecStream: conversionType = PCM_SIGNED_LE2UNSIGNED_BE");
-
} else if (AudioFormat.Encoding.PCM_UNSIGNED.equals(inputEncoding) && inputIsBigEndian &&
AudioFormat.Encoding.PCM_SIGNED.equals(outputEncoding) && !outputIsBigEndian) {
conversionType = PCM_UNSIGNED_BE2SIGNED_LE;
- if(Printer.debug) Printer.debug("PCMtoPCMCodecStream: conversionType = PCM_UNSIGNED_BE2SIGNED_LE");
-
} else if (AudioFormat.Encoding.PCM_SIGNED.equals(inputEncoding) && inputIsBigEndian &&
AudioFormat.Encoding.PCM_UNSIGNED.equals(outputEncoding) && !outputIsBigEndian) {
conversionType = PCM_SIGNED_BE2UNSIGNED_LE;
- if(Printer.debug) Printer.debug("PCMtoPCMCodecStream: conversionType = PCM_SIGNED_BE2UNSIGNED_LE");
-
}
}
--- a/src/java.desktop/share/classes/com/sun/media/sound/Platform.java Thu Apr 25 15:19:09 2019 +0530
+++ b/src/java.desktop/share/classes/com/sun/media/sound/Platform.java Thu Apr 25 15:13:36 2019 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2019, 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
@@ -49,8 +49,6 @@
private static boolean bigEndian;
static {
- if(Printer.trace)Printer.trace(">> Platform.java: static");
-
loadLibraries();
}
@@ -64,7 +62,6 @@
* Dummy method for forcing initialization.
*/
static void initialize() {
- if(Printer.trace)Printer.trace("Platform: initialize()");
}
/**
@@ -78,8 +75,6 @@
* Load the native library or libraries.
*/
private static void loadLibraries() {
- if(Printer.trace)Printer.trace(">>Platform.loadLibraries");
-
// load the native library
isNativeLibLoaded = true;
try {
@@ -97,17 +92,14 @@
}
static boolean isMidiIOEnabled() {
- if (Printer.debug) Printer.debug("Platform: Checking for MidiIO; library is loaded=" + isNativeLibLoaded);
return isNativeLibLoaded;
}
static boolean isPortsEnabled() {
- if (Printer.debug) Printer.debug("Platform: Checking for Ports; library is loaded=" + isNativeLibLoaded);
return isNativeLibLoaded;
}
static boolean isDirectAudioEnabled() {
- if (Printer.debug) Printer.debug("Platform: Checking for DirectAudio; library is loaded=" + isNativeLibLoaded);
return isNativeLibLoaded;
}
--- a/src/java.desktop/share/classes/com/sun/media/sound/PortMixer.java Thu Apr 25 15:19:09 2019 +0530
+++ b/src/java.desktop/share/classes/com/sun/media/sound/PortMixer.java Thu Apr 25 15:13:36 2019 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2019, 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
@@ -67,9 +67,6 @@
null, // Control[]
null, // Line.Info[] sourceLineInfo
null); // Line.Info[] targetLineInfo
-
- if (Printer.trace) Printer.trace(">> PortMixer: constructor");
-
int count = 0;
int srcLineCount = 0;
int dstLineCount = 0;
@@ -80,7 +77,6 @@
if (id != 0) {
count = nGetPortCount(id);
if (count < 0) {
- if (Printer.trace) Printer.trace("nGetPortCount() returned error code: " + count);
count = 0;
}
}
@@ -113,8 +109,6 @@
targetLineInfo[dstLineCount++] = portInfos[i];
}
}
-
- if (Printer.trace) Printer.trace("<< PortMixer: constructor completed");
}
@Override
@@ -149,18 +143,12 @@
@Override
protected void implOpen() throws LineUnavailableException {
- if (Printer.trace) Printer.trace(">> PortMixer: implOpen (id="+id+")");
-
// open the mixer device
id = nOpen(getMixerIndex());
-
- if (Printer.trace) Printer.trace("<< PortMixer: implOpen succeeded.");
}
@Override
protected void implClose() {
- if (Printer.trace) Printer.trace(">> PortMixer: implClose");
-
// close the mixer device
long thisID = id;
id = 0;
@@ -172,8 +160,6 @@
}
}
}
-
- if (Printer.trace) Printer.trace("<< PortMixer: implClose succeeded");
}
@Override
@@ -194,7 +180,7 @@
case DST_LINE_OUT: return Port.Info.LINE_OUT;
}
// should never happen...
- if (Printer.debug) Printer.debug("unknown port type: "+type);
+ if (Printer.err) Printer.err("unknown port type: "+type);
return null;
}
@@ -231,12 +217,10 @@
PortMixer mixer,
int portIndex) {
super(info, mixer, null);
- if (Printer.trace) Printer.trace("PortMixerPort CONSTRUCTOR: info: " + info);
this.portIndex = portIndex;
}
void implOpen() throws LineUnavailableException {
- if (Printer.trace) Printer.trace(">> PortMixerPort: implOpen().");
long newID = ((PortMixer) mixer).getID();
if ((id == 0) || (newID != id) || (controls.length == 0)) {
id = newID;
@@ -251,7 +235,6 @@
} else {
enableControls(controls, true);
}
- if (Printer.trace) Printer.trace("<< PortMixerPort: implOpen() succeeded");
}
private void enableControls(Control[] controls, boolean enable) {
@@ -274,10 +257,8 @@
}
void implClose() {
- if (Printer.trace) Printer.trace(">> PortMixerPort: implClose()");
// get rid of controls
enableControls(controls, false);
- if (Printer.trace) Printer.trace("<< PortMixerPort: implClose() succeeded");
}
// this is very similar to open(AudioFormat, int) in AbstractDataLine...
@@ -286,7 +267,6 @@
synchronized (mixer) {
// if the line is not currently open, try to open it with this format and buffer size
if (!isOpen()) {
- if (Printer.trace) Printer.trace("> PortMixerPort: open");
// reserve mixer resources for this line
mixer.open(this);
try {
@@ -300,7 +280,6 @@
mixer.close(this);
throw e;
}
- if (Printer.trace) Printer.trace("< PortMixerPort: open succeeded");
}
}
}
@@ -310,8 +289,6 @@
public void close() {
synchronized (mixer) {
if (isOpen()) {
- if (Printer.trace) Printer.trace("> PortMixerPort.close()");
-
// set the open state to false and send events
setOpen(false);
@@ -320,7 +297,6 @@
// release mixer resources for this line
mixer.close(this);
- if (Printer.trace) Printer.trace("< PortMixerPort.close() succeeded");
}
}
}
--- a/src/java.desktop/share/classes/com/sun/media/sound/PortMixerProvider.java Thu Apr 25 15:19:09 2019 +0530
+++ b/src/java.desktop/share/classes/com/sun/media/sound/PortMixerProvider.java Thu Apr 25 15:13:36 2019 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2002, 2019, 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
@@ -69,7 +69,6 @@
int numDevices = nGetNumDevices();
if (infos == null || infos.length != numDevices) {
- if (Printer.trace) Printer.trace("PortMixerProvider: init()");
// initialize the arrays
infos = new PortMixerInfo[numDevices];
devices = new PortMixer[numDevices];
@@ -79,7 +78,6 @@
for (int i = 0; i < infos.length; i++) {
infos[i] = nNewPortMixerInfo(i);
}
- if (Printer.trace) Printer.trace("PortMixerProvider: init(): found numDevices: " + numDevices);
}
}
--- a/src/java.desktop/share/classes/com/sun/media/sound/Printer.java Thu Apr 25 15:19:09 2019 +0530
+++ b/src/java.desktop/share/classes/com/sun/media/sound/Printer.java Thu Apr 25 15:13:36 2019 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2019, 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
@@ -25,6 +25,10 @@
package com.sun.media.sound;
+import java.security.AccessController;
+
+import sun.security.action.GetPropertyAction;
+
/**
* Printer allows you to set up global debugging status and print
* messages accordingly.
@@ -34,39 +38,10 @@
*/
final class Printer {
- static final boolean err = false;
- static final boolean debug = false;
- static final boolean trace = false;
- static final boolean verbose = false;
- static final boolean release = false;
-
- static final boolean SHOW_THREADID = false;
- static final boolean SHOW_TIMESTAMP = false;
-
- /*static void setErrorPrint(boolean on) {
-
- err = on;
- }
-
- static void setDebugPrint(boolean on) {
+ static final boolean err = isBuildInternal();
- debug = on;
- }
-
- static void setTracePrint(boolean on) {
-
- trace = on;
- }
-
- static void setVerbosePrint(boolean on) {
-
- verbose = on;
- }
-
- static void setReleasePrint(boolean on) {
-
- release = on;
- }*/
+ private static final boolean SHOW_THREADID = true;
+ private static final boolean SHOW_TIMESTAMP = true;
/**
* Suppresses default constructor, ensuring non-instantiability.
@@ -74,39 +49,31 @@
private Printer() {
}
+ /**
+ * This method is used in the special cases which "should never happen...".
+ * And in fact if should be implemented as an assertion, but for
+ * compatibility reason it just print an error only in case of "internal"
+ * build. In time its usage should be replaced by some kind of assertion or
+ * dropped completly.
+ */
public static void err(String str) {
-
- if (err)
+ if (err) {
println(str);
- }
-
- public static void debug(String str) {
-
- if (debug)
- println(str);
+ }
}
- public static void trace(String str) {
-
- if (trace)
- println(str);
- }
-
- public static void verbose(String str) {
-
- if (verbose)
- println(str);
- }
-
- public static void release(String str) {
-
- if (release)
- println(str);
+ /**
+ * Returns {@code true} if the build of the current jdk is "internal".
+ */
+ private static boolean isBuildInternal() {
+ String javaVersion = AccessController.doPrivileged(
+ new GetPropertyAction("java.version"));
+ return javaVersion != null && javaVersion.contains("internal");
}
private static long startTime = 0;
- public static void println(String s) {
+ private static void println(String s) {
String prepend = "";
if (SHOW_THREADID) {
prepend = "thread " + Thread.currentThread().getId() + " " + prepend;
@@ -119,9 +86,4 @@
}
System.out.println(prepend + s);
}
-
- public static void println() {
- System.out.println();
- }
-
}
--- a/src/java.desktop/share/classes/com/sun/media/sound/RealTimeSequencer.java Thu Apr 25 15:19:09 2019 +0530
+++ b/src/java.desktop/share/classes/com/sun/media/sound/RealTimeSequencer.java Thu Apr 25 15:13:36 2019 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2019, 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
@@ -61,10 +61,6 @@
final class RealTimeSequencer extends AbstractMidiDevice
implements Sequencer, AutoConnectSequencer {
- /** debugging flags */
- private static final boolean DEBUG_PUMP = false;
- private static final boolean DEBUG_PUMP_ALL = false;
-
/**
* Event Dispatcher thread. Should be using a shared event
* dispatcher instance with a factory in EventDispatcher
@@ -165,9 +161,6 @@
RealTimeSequencer(){
super(info);
-
- if (Printer.trace) Printer.trace(">> RealTimeSequencer CONSTRUCTOR");
- if (Printer.trace) Printer.trace("<< RealTimeSequencer CONSTRUCTOR completed");
}
/* ****************************** SEQUENCER METHODS ******************** */
@@ -175,9 +168,6 @@
@Override
public synchronized void setSequence(Sequence sequence)
throws InvalidMidiDataException {
-
- if (Printer.trace) Printer.trace(">> RealTimeSequencer: setSequence(" + sequence +")");
-
if (sequence != this.sequence) {
if (this.sequence != null && sequence == null) {
setCaches();
@@ -216,15 +206,10 @@
playThread.setSequence(sequence);
}
}
-
- if (Printer.trace) Printer.trace("<< RealTimeSequencer: setSequence(" + sequence +") completed");
}
@Override
public synchronized void setSequence(InputStream stream) throws IOException, InvalidMidiDataException {
-
- if (Printer.trace) Printer.trace(">> RealTimeSequencer: setSequence(" + stream +")");
-
if (stream == null) {
setSequence((Sequence) null);
return;
@@ -233,9 +218,6 @@
Sequence seq = MidiSystem.getSequence(stream); // can throw IOException, InvalidMidiDataException
setSequence(seq);
-
- if (Printer.trace) Printer.trace("<< RealTimeSequencer: setSequence(" + stream +") completed");
-
}
@Override
@@ -245,8 +227,6 @@
@Override
public synchronized void start() {
- if (Printer.trace) Printer.trace(">> RealTimeSequencer: start()");
-
// sequencer not open: throw an exception
if (!isOpen()) {
throw new IllegalStateException("sequencer not open");
@@ -264,14 +244,10 @@
// start playback
implStart();
-
- if (Printer.trace) Printer.trace("<< RealTimeSequencer: start() completed");
}
@Override
public synchronized void stop() {
- if (Printer.trace) Printer.trace(">> RealTimeSequencer: stop()");
-
if (!isOpen()) {
throw new IllegalStateException("sequencer not open");
}
@@ -279,14 +255,11 @@
// not running; just return
if (running == false) {
- if (Printer.trace) Printer.trace("<< RealTimeSequencer: stop() not running!");
return;
}
// stop playback
implStop();
-
- if (Printer.trace) Printer.trace("<< RealTimeSequencer: stop() completed");
}
@Override
@@ -361,14 +334,11 @@
@Override
public float getTempoInBPM() {
- if (Printer.trace) Printer.trace(">> RealTimeSequencer: getTempoInBPM() ");
-
return (float) MidiUtils.convertTempo(getTempoInMPQ());
}
@Override
public void setTempoInBPM(float bpm) {
- if (Printer.trace) Printer.trace(">> RealTimeSequencer: setTempoInBPM() ");
if (bpm <= 0) {
// should throw IllegalArgumentException
bpm = 1.0f;
@@ -379,8 +349,6 @@
@Override
public float getTempoInMPQ() {
- if (Printer.trace) Printer.trace(">> RealTimeSequencer: getTempoInMPQ() ");
-
if (needCaching()) {
// if the sequencer is closed, return cached value
if (cacheTempoMPQ != -1) {
@@ -403,9 +371,6 @@
// should throw IllegalArgumentException
mpq = 1.0f;
}
-
- if (Printer.trace) Printer.trace(">> RealTimeSequencer: setTempoInMPQ() ");
-
if (needCaching()) {
// cache the value
cacheTempoMPQ = mpq;
@@ -424,9 +389,6 @@
// should throw IllegalArgumentException
return;
}
-
- if (Printer.trace) Printer.trace(">> RealTimeSequencer: setTempoFactor() ");
-
if (needCaching()) {
cacheTempoFactor = factor;
} else {
@@ -438,8 +400,6 @@
@Override
public float getTempoFactor() {
- if (Printer.trace) Printer.trace(">> RealTimeSequencer: getTempoFactor() ");
-
if (needCaching()) {
if (cacheTempoFactor != -1) {
return cacheTempoFactor;
@@ -451,8 +411,6 @@
@Override
public long getTickLength() {
- if (Printer.trace) Printer.trace(">> RealTimeSequencer: getTickLength() ");
-
if (sequence == null) {
return 0;
}
@@ -462,8 +420,6 @@
@Override
public synchronized long getTickPosition() {
- if (Printer.trace) Printer.trace(">> RealTimeSequencer: getTickPosition() ");
-
if (getDataPump() == null || sequence == null) {
return 0;
}
@@ -477,9 +433,6 @@
// should throw IllegalArgumentException
return;
}
-
- if (Printer.trace) Printer.trace(">> RealTimeSequencer: setTickPosition("+tick+") ");
-
if (getDataPump() == null) {
if (tick != 0) {
// throw new InvalidStateException("cannot set position in closed state");
@@ -496,8 +449,6 @@
@Override
public long getMicrosecondLength() {
- if (Printer.trace) Printer.trace(">> RealTimeSequencer: getMicrosecondLength() ");
-
if (sequence == null) {
return 0;
}
@@ -507,8 +458,6 @@
@Override
public long getMicrosecondPosition() {
- if (Printer.trace) Printer.trace(">> RealTimeSequencer: getMicrosecondPosition() ");
-
if (getDataPump() == null || sequence == null) {
return 0;
}
@@ -523,9 +472,6 @@
// should throw IllegalArgumentException
return;
}
-
- if (Printer.trace) Printer.trace(">> RealTimeSequencer: setMicrosecondPosition("+microseconds+") ");
-
if (getDataPump() == null) {
if (microseconds != 0) {
// throw new InvalidStateException("cannot set position in closed state");
@@ -750,8 +696,6 @@
@Override
protected void implOpen() throws MidiUnavailableException {
- if (Printer.trace) Printer.trace(">> RealTimeSequencer: implOpen()");
-
//openInternalSynth();
// create PlayThread
@@ -771,11 +715,9 @@
if (doAutoConnectAtNextOpen) {
doAutoConnect();
}
- if (Printer.trace) Printer.trace("<< RealTimeSequencer: implOpen() succeeded");
}
private void doAutoConnect() {
- if (Printer.trace) Printer.trace(">> RealTimeSequencer: doAutoConnect()");
Receiver rec = null;
// first try to connect to the default synthesizer
// IMPORTANT: this code needs to be synch'ed with
@@ -813,7 +755,6 @@
getTransmitter().setReceiver(rec);
} catch (Exception e) {}
}
- if (Printer.trace) Printer.trace("<< RealTimeSequencer: doAutoConnect() succeeded");
}
private synchronized void propagateCaches() {
@@ -840,8 +781,6 @@
@Override
protected synchronized void implClose() {
- if (Printer.trace) Printer.trace(">> RealTimeSequencer: implClose() ");
-
if (playThread == null) {
if (Printer.err) Printer.err("RealTimeSequencer.implClose() called, but playThread not instanciated!");
} else {
@@ -873,13 +812,9 @@
} catch (Exception e) {}
autoConnectedReceiver = null;
}
-
- if (Printer.trace) Printer.trace("<< RealTimeSequencer: implClose() completed");
}
void implStart() {
- if (Printer.trace) Printer.trace(">> RealTimeSequencer: implStart()");
-
if (playThread == null) {
if (Printer.err) Printer.err("RealTimeSequencer.implStart() called, but playThread not instanciated!");
return;
@@ -890,12 +825,9 @@
running = true;
playThread.start();
}
- if (Printer.trace) Printer.trace("<< RealTimeSequencer: implStart() completed");
}
void implStop() {
- if (Printer.trace) Printer.trace(">> RealTimeSequencer: implStop()");
-
if (playThread == null) {
if (Printer.err) Printer.err("RealTimeSequencer.implStop() called, but playThread not instanciated!");
return;
@@ -906,7 +838,6 @@
running = false;
playThread.stop();
}
- if (Printer.trace) Printer.trace("<< RealTimeSequencer: implStop() completed");
}
private static EventDispatcher getEventDispatcher() {
@@ -931,7 +862,6 @@
void sendMetaEvents(MidiMessage message) {
if (metaEventListeners.size() == 0) return;
- //if (Printer.debug) Printer.debug("sending a meta event");
getEventDispatcher().sendAudioEvents(message, metaEventListeners);
}
@@ -942,10 +872,7 @@
int size = controllerEventListeners.size();
if (size == 0) return;
- //if (Printer.debug) Printer.debug("sending a controller event");
-
if (! (message instanceof ShortMessage)) {
- if (Printer.debug) Printer.debug("sendControllerEvents: message is NOT instanceof ShortMessage!");
return;
}
ShortMessage msg = (ShortMessage) message;
@@ -1296,9 +1223,6 @@
synchronized(lock) {
lock.notifyAll();
}
-
- if (Printer.debug) Printer.debug(" ->Started MIDI play thread");
-
}
// waits until stopped
@@ -1374,12 +1298,6 @@
// ignore
}
}
- if (Printer.debug) {
- Printer.debug("Exited main pump loop because: ");
- if (EOM) Printer.debug(" -> EOM is reached");
- if (!running) Printer.debug(" -> running was set to false");
- if (interrupted) Printer.debug(" -> interrupted was set to true");
- }
playThreadImplStop();
if (wasRunning) {
@@ -1406,7 +1324,6 @@
}
}
} // end of while(!EOM && !interrupted && running)
- if (Printer.debug) Printer.debug("end of play thread");
}
}
@@ -1562,7 +1479,6 @@
done++;
}
}
- if (DEBUG_PUMP) Printer.println(" noteOff: sent "+done+" messages.");
}
private boolean[] makeDisabledArray() {
@@ -1649,7 +1565,6 @@
// this happens when messages are removed
// from the track while this method executes
}
- if (DEBUG_PUMP) Printer.println(" sendNoteOffIfOn: sent "+done+" messages.");
}
/**
@@ -1720,7 +1635,6 @@
if (event.getTick() >= endTick) {
if (doReindex && (trackNum < trackReadPos.length)) {
trackReadPos[trackNum] = (i > 0)?(i-1):0;
- if (DEBUG_PUMP) Printer.println(" chaseEvents: setting trackReadPos["+trackNum+"] = "+trackReadPos[trackNum]);
}
break;
}
@@ -1773,14 +1687,12 @@
getTransmitterList().sendMessage((ShortMessage.CONTROL_CHANGE | ch) | (64 << 8), -1);
}
}
- if (DEBUG_PUMP) Printer.println(" chaseTrackEvents track "+trackNum+": sent "+numControllersSent+" controllers.");
}
/**
* chase controllers and program for all tracks.
*/
synchronized void chaseEvents(long startTick, long endTick) {
- if (DEBUG_PUMP) Printer.println(">> chaseEvents from tick "+startTick+".."+(endTick-1));
byte[][] tempArray = new byte[128][16];
for (int t = 0; t < tracks.length; t++) {
if ((trackDisabled == null)
@@ -1790,7 +1702,6 @@
chaseTrackEvents(t, startTick, endTick, true, tempArray);
}
}
- if (DEBUG_PUMP) Printer.println("<< chaseEvents");
}
// playback related methods (pumping)
@@ -1827,7 +1738,6 @@
private void ReindexTrack(int trackNum, long tick) {
if (trackNum < trackReadPos.length && trackNum < tracks.length) {
trackReadPos[trackNum] = MidiUtils.tick2index(tracks[trackNum], tick);
- if (DEBUG_PUMP) Printer.println(" reindexTrack: setting trackReadPos["+trackNum+"] = "+trackReadPos[trackNum]);
}
}
@@ -1913,13 +1823,11 @@
// need to re-find indexes in tracks?
if (needReindex) {
- if (DEBUG_PUMP) Printer.println("Need to re-index at "+currMillis+" millis. TargetTick="+targetTick);
if (trackReadPos.length < tracks.length) {
trackReadPos = new int[tracks.length];
}
for (int t = 0; t < tracks.length; t++) {
ReindexTrack(t, targetTick);
- if (DEBUG_PUMP_ALL) Printer.println(" Setting trackReadPos["+t+"]="+trackReadPos[t]);
}
needReindex = false;
checkPointMillis = 0;
@@ -1932,13 +1840,9 @@
checkPointMillis = currMillis;
targetTick = lastTick;
checkPointTick = targetTick;
- if (DEBUG_PUMP) Printer.println("New checkpoint to "+currMillis+" millis. "
- +"TargetTick="+targetTick
- +" new tempo="+MidiUtils.convertTempo(currTempo)+"bpm");
} else {
// calculate current tick based on current time in milliseconds
targetTick = checkPointTick + millis2tick(currMillis - checkPointMillis);
- if (DEBUG_PUMP_ALL) Printer.println("targetTick = "+targetTick+" at "+currMillis+" millis");
if ((loopEnd != -1)
&& ((loopCount > 0 && currLoopCounter > 0)
|| (loopCount == LOOP_CONTINUOUSLY))) {
@@ -1947,15 +1851,6 @@
// only play until loop end
targetTick = loopEnd - 1;
doLoop = true;
- if (DEBUG_PUMP) Printer.println("set doLoop to true. lastTick="+lastTick
- +" targetTick="+targetTick
- +" loopEnd="+loopEnd
- +" jumping to loopStart="+loopStart
- +" new currLoopCounter="+currLoopCounter);
- if (DEBUG_PUMP) Printer.println(" currMillis="+currMillis
- +" checkPointMillis="+checkPointMillis
- +" checkPointTick="+checkPointTick);
-
}
}
lastTick = targetTick;
@@ -1994,28 +1889,9 @@
if (readPos >= size) {
finishedTracks++;
}
- if (DEBUG_PUMP_ALL) {
- System.out.print(" pumped track "+t+" ("+size+" events) "
- +" from index: "+trackReadPos[t]
- +" to "+(readPos-1));
- System.out.print(" -> ticks: ");
- if (trackReadPos[t] < size) {
- System.out.print(""+(thisTrack.get(trackReadPos[t]).getTick()));
- } else {
- System.out.print("EOT");
- }
- System.out.print(" to ");
- if (readPos < size) {
- System.out.print(""+(thisTrack.get(readPos-1).getTick()));
- } else {
- System.out.print("EOT");
- }
- System.out.println();
- }
trackReadPos[t] = readPos;
} catch(Exception e) {
- if (Printer.debug) Printer.debug("Exception in Sequencer pump!");
- if (Printer.debug) e.printStackTrace();
+ if (Printer.err) e.printStackTrace();
if (e instanceof ArrayIndexOutOfBoundsException) {
needReindex = true;
changesPending = true;
@@ -2043,10 +1919,6 @@
if (loopCount != LOOP_CONTINUOUSLY) {
currLoopCounter--;
}
- if (DEBUG_PUMP) Printer.println("Execute loop: lastTick="+lastTick
- +" loopEnd="+loopEnd
- +" jumping to loopStart="+loopStart
- +" new currLoopCounter="+currLoopCounter);
setTickPos(loopStart);
// now patch the checkPointMillis so that
// it points to the exact beginning of when the loop was finished
@@ -2058,9 +1930,6 @@
checkPointMillis = oldCheckPointMillis + tick2millis(loopEndTick - checkPointTick);
checkPointTick = loopStart;
- if (DEBUG_PUMP) Printer.println(" Setting currMillis="+currMillis
- +" new checkPointMillis="+checkPointMillis
- +" new checkPointTick="+checkPointTick);
// no need for reindexing, is done in setTickPos
needReindex = false;
changesPending = false;