From e0c7d59246cf36644d494eced76e4b9d96ff1ded Mon Sep 17 00:00:00 2001 From: Sergey Bylokhov Date: Fri, 29 Mar 2013 22:07:56 +0400 Subject: [PATCH] 8006328: Improve robustness of sound classes 8009057: Improve MIDI event handling Reviewed-by: amenkov, art, skoivu --- .../com/sun/media/sound/AbstractDataLine.java | 45 +++--- .../com/sun/media/sound/AbstractLine.java | 69 +++++---- .../sun/media/sound/AbstractMidiDevice.java | 44 +++--- .../sound/AbstractMidiDeviceProvider.java | 16 +-- .../com/sun/media/sound/AbstractMixer.java | 54 ++++--- .../com/sun/media/sound/AiffFileFormat.java | 10 +- .../com/sun/media/sound/AiffFileReader.java | 36 ++--- .../com/sun/media/sound/AiffFileWriter.java | 14 +- .../com/sun/media/sound/AlawCodec.java | 14 +- .../com/sun/media/sound/AuFileFormat.java | 6 +- .../com/sun/media/sound/AuFileReader.java | 34 +---- .../com/sun/media/sound/AuFileWriter.java | 16 +-- .../media/sound/AudioFileSoundbankReader.java | 4 +- .../sun/media/sound/AudioFloatConverter.java | 39 ++--- .../sound/AudioFloatFormatConverter.java | 51 +++---- .../media/sound/AudioFloatInputStream.java | 26 ++-- .../sound/AudioSynthesizerPropertyInfo.java | 4 +- .../classes/com/sun/media/sound/DLSInfo.java | 4 +- .../com/sun/media/sound/DLSInstrument.java | 18 +-- .../com/sun/media/sound/DLSModulator.java | 16 +-- .../com/sun/media/sound/DLSRegion.java | 28 ++-- .../com/sun/media/sound/DLSSample.java | 14 +- .../com/sun/media/sound/DLSSampleLoop.java | 10 +- .../com/sun/media/sound/DLSSampleOptions.java | 14 +- .../com/sun/media/sound/DLSSoundbank.java | 12 +- .../sun/media/sound/DLSSoundbankReader.java | 4 +- .../com/sun/media/sound/DataPusher.java | 8 +- .../sun/media/sound/DirectAudioDevice.java | 44 +++--- .../sound/DirectAudioDeviceProvider.java | 68 ++++----- .../sun/media/sound/EmergencySoundbank.java | 4 +- .../com/sun/media/sound/EventDispatcher.java | 34 ++--- .../classes/com/sun/media/sound/FFT.java | 12 +- .../com/sun/media/sound/FastShortMessage.java | 6 +- .../sun/media/sound/JARSoundbankReader.java | 22 +-- .../com/sun/media/sound/JDK13Services.java | 16 +-- .../sun/media/sound/JSSecurityManager.java | 103 +------------- .../sun/media/sound/JavaSoundAudioClip.java | 12 +- .../sound/MidiDeviceReceiverEnvelope.java | 4 +- .../sound/MidiDeviceTransmitterEnvelope.java | 4 +- .../com/sun/media/sound/MidiInDevice.java | 9 +- .../sun/media/sound/MidiInDeviceProvider.java | 15 +- .../com/sun/media/sound/MidiOutDevice.java | 6 +- .../media/sound/MidiOutDeviceProvider.java | 15 +- .../com/sun/media/sound/MidiUtils.java | 11 +- .../com/sun/media/sound/ModelByteBuffer.java | 8 +- .../media/sound/ModelByteBufferWavetable.java | 12 +- .../sun/media/sound/ModelConnectionBlock.java | 4 +- .../com/sun/media/sound/ModelDestination.java | 4 +- .../com/sun/media/sound/ModelIdentifier.java | 4 +- .../com/sun/media/sound/ModelInstrument.java | 8 +- .../sound/ModelInstrumentComparator.java | 4 +- .../media/sound/ModelMappedInstrument.java | 6 +- .../com/sun/media/sound/ModelPatch.java | 4 +- .../com/sun/media/sound/ModelPerformer.java | 6 +- .../com/sun/media/sound/ModelSource.java | 4 +- .../media/sound/ModelStandardDirector.java | 4 +- .../sound/ModelStandardIndexedDirector.java | 4 +- .../media/sound/ModelStandardTransform.java | 4 +- .../com/sun/media/sound/PCMtoPCMCodec.java | 10 +- .../classes/com/sun/media/sound/Platform.java | 25 +++- .../com/sun/media/sound/PortMixer.java | 28 ++-- .../sun/media/sound/PortMixerProvider.java | 46 +++--- .../classes/com/sun/media/sound/Printer.java | 10 +- .../media/sound/RIFFInvalidDataException.java | 4 +- .../sound/RIFFInvalidFormatException.java | 4 +- .../com/sun/media/sound/RIFFReader.java | 8 +- .../com/sun/media/sound/RIFFWriter.java | 16 +-- .../sun/media/sound/RealTimeSequencer.java | 78 +++++----- .../sound/RealTimeSequencerProvider.java | 4 +- .../com/sun/media/sound/SF2GlobalRegion.java | 4 +- .../com/sun/media/sound/SF2Instrument.java | 22 +-- .../sun/media/sound/SF2InstrumentRegion.java | 6 +- .../classes/com/sun/media/sound/SF2Layer.java | 10 +- .../com/sun/media/sound/SF2LayerRegion.java | 6 +- .../com/sun/media/sound/SF2Modulator.java | 14 +- .../com/sun/media/sound/SF2Sample.java | 24 ++-- .../com/sun/media/sound/SF2Soundbank.java | 36 ++--- .../sun/media/sound/SF2SoundbankReader.java | 4 +- .../media/sound/SoftAbstractResampler.java | 6 +- .../com/sun/media/sound/SoftAudioBuffer.java | 4 +- .../com/sun/media/sound/SoftAudioPusher.java | 8 +- .../com/sun/media/sound/SoftChannel.java | 44 +++--- .../com/sun/media/sound/SoftChannelProxy.java | 4 +- .../com/sun/media/sound/SoftChorus.java | 14 +- .../sun/media/sound/SoftCubicResampler.java | 4 +- .../media/sound/SoftEnvelopeGenerator.java | 38 ++--- .../com/sun/media/sound/SoftFilter.java | 6 +- .../com/sun/media/sound/SoftInstrument.java | 8 +- .../sun/media/sound/SoftJitterCorrector.java | 8 +- .../sun/media/sound/SoftLanczosResampler.java | 4 +- .../com/sun/media/sound/SoftLimiter.java | 4 +- .../sun/media/sound/SoftLinearResampler.java | 4 +- .../sun/media/sound/SoftLinearResampler2.java | 4 +- .../sound/SoftLowFrequencyOscillator.java | 24 ++-- .../com/sun/media/sound/SoftMainMixer.java | 26 ++-- .../media/sound/SoftMidiAudioFileReader.java | 4 +- .../com/sun/media/sound/SoftMixingClip.java | 8 +- .../sun/media/sound/SoftMixingDataLine.java | 88 ++++++------ .../sun/media/sound/SoftMixingMainMixer.java | 34 ++--- .../com/sun/media/sound/SoftMixingMixer.java | 34 ++--- .../media/sound/SoftMixingMixerProvider.java | 6 +- .../media/sound/SoftMixingSourceDataLine.java | 10 +- .../com/sun/media/sound/SoftPerformer.java | 4 +- .../sun/media/sound/SoftPointResampler.java | 4 +- .../com/sun/media/sound/SoftProvider.java | 8 +- .../com/sun/media/sound/SoftReceiver.java | 14 +- .../com/sun/media/sound/SoftReverb.java | 10 +- .../com/sun/media/sound/SoftShortMessage.java | 4 +- .../sun/media/sound/SoftSincResampler.java | 4 +- .../com/sun/media/sound/SoftSynthesizer.java | 60 ++++---- .../com/sun/media/sound/SoftTuning.java | 6 +- .../com/sun/media/sound/SoftVoice.java | 134 +++++++++--------- .../media/sound/StandardMidiFileReader.java | 29 +--- .../media/sound/StandardMidiFileWriter.java | 10 +- .../classes/com/sun/media/sound/SunCodec.java | 18 +-- .../com/sun/media/sound/SunFileReader.java | 33 ++--- .../com/sun/media/sound/SunFileWriter.java | 17 ++- .../classes/com/sun/media/sound/Toolkit.java | 9 +- .../com/sun/media/sound/UlawCodec.java | 9 +- .../media/sound/WaveExtensibleFileReader.java | 14 +- .../com/sun/media/sound/WaveFileFormat.java | 22 +-- .../com/sun/media/sound/WaveFileReader.java | 36 ++--- .../com/sun/media/sound/WaveFileWriter.java | 14 +- .../sun/media/sound/WaveFloatFileReader.java | 4 +- .../sun/media/sound/WaveFloatFileWriter.java | 8 +- .../classes/javax/sound/midi/MetaMessage.java | 18 +-- .../classes/javax/sound/sampled/Mixer.java | 8 +- .../share/classes/sun/audio/AudioData.java | 4 +- .../classes/sun/audio/AudioDataStream.java | 10 +- .../share/classes/sun/audio/AudioDevice.java | 16 +-- .../share/classes/sun/audio/AudioPlayer.java | 15 +- .../share/classes/sun/audio/AudioStream.java | 14 +- .../sun/audio/AudioStreamSequence.java | 7 +- .../sun/audio/AudioTranslatorStream.java | 9 +- .../sun/audio/ContinuousAudioDataStream.java | 7 +- .../audio/InvalidAudioFormatException.java | 8 +- 136 files changed, 1082 insertions(+), 1329 deletions(-) diff --git a/jdk/src/share/classes/com/sun/media/sound/AbstractDataLine.java b/jdk/src/share/classes/com/sun/media/sound/AbstractDataLine.java index 560961cdc19..0cea4c6cc3f 100644 --- a/jdk/src/share/classes/com/sun/media/sound/AbstractDataLine.java +++ b/jdk/src/share/classes/com/sun/media/sound/AbstractDataLine.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2013, 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,15 +25,12 @@ package com.sun.media.sound; -import java.util.Vector; - import javax.sound.sampled.AudioFormat; import javax.sound.sampled.AudioSystem; import javax.sound.sampled.Control; import javax.sound.sampled.DataLine; import javax.sound.sampled.LineEvent; import javax.sound.sampled.LineUnavailableException; -import javax.sound.sampled.Mixer; /** @@ -46,13 +43,13 @@ abstract class AbstractDataLine extends AbstractLine implements DataLine { // DEFAULTS // default format - protected /*final*/ AudioFormat defaultFormat; + private final AudioFormat defaultFormat; // default buffer size in bytes - protected /*final*/ int defaultBufferSize; + private final int defaultBufferSize; // the lock for synchronization - protected Object lock = new Object(); + protected final Object lock = new Object(); // STATE @@ -103,7 +100,7 @@ abstract class AbstractDataLine extends AbstractLine implements DataLine { // DATA LINE METHODS - public void open(AudioFormat format, int bufferSize) throws LineUnavailableException { + 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()); @@ -152,7 +149,7 @@ abstract class AbstractDataLine extends AbstractLine implements DataLine { } - public void open(AudioFormat format) throws LineUnavailableException { + public final void open(AudioFormat format) throws LineUnavailableException { open(format, AudioSystem.NOT_SPECIFIED); } @@ -181,7 +178,7 @@ abstract class AbstractDataLine extends AbstractLine implements DataLine { } - public void start() { + 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"); @@ -205,7 +202,7 @@ abstract class AbstractDataLine extends AbstractLine implements DataLine { } - public void stop() { + public final void stop() { //$$fb 2001-10-09: Bug #4517739: avoiding deadlock by synchronizing to mixer ! synchronized(mixer) { @@ -249,16 +246,16 @@ abstract class AbstractDataLine extends AbstractLine implements DataLine { // in MixerSourceLine and MixerClip, and I want to touch as little // code as possible to change isStarted() back to isRunning(). - public boolean isRunning() { + public final boolean isRunning() { return started; } - public boolean isActive() { + public final boolean isActive() { return active; } - public long getMicrosecondPosition() { + public final long getMicrosecondPosition() { long microseconds = getLongFramePosition(); if (microseconds != AudioSystem.NOT_SPECIFIED) { @@ -268,26 +265,26 @@ abstract class AbstractDataLine extends AbstractLine implements DataLine { } - public AudioFormat getFormat() { + public final AudioFormat getFormat() { return format; } - public int getBufferSize() { + public final int getBufferSize() { return bufferSize; } /** * This implementation does NOT change the buffer size */ - public int setBufferSize(int newSize) { + public final int setBufferSize(int newSize) { return getBufferSize(); } /** * This implementation returns AudioSystem.NOT_SPECIFIED. */ - public float getLevel() { + public final float getLevel() { return (float)AudioSystem.NOT_SPECIFIED; } @@ -304,7 +301,7 @@ abstract class AbstractDataLine extends AbstractLine implements DataLine { // it to isStartedRunning(). This is part of backing out the // change denied in RFE 4297981. - protected boolean isStartedRunning() { + final boolean isStartedRunning() { return running; } @@ -312,7 +309,7 @@ abstract class AbstractDataLine extends AbstractLine implements DataLine { * This method sets the active state and generates * events if it changes. */ - protected void setActive(boolean active) { + final void setActive(boolean active) { if (Printer.trace) Printer.trace("> AbstractDataLine: setActive(" + active + ")"); @@ -351,7 +348,7 @@ abstract class AbstractDataLine extends AbstractLine implements DataLine { * This method sets the started state and generates * events if it changes. */ - protected void setStarted(boolean started) { + final void setStarted(boolean started) { if (Printer.trace) Printer.trace("> AbstractDataLine: setStarted(" + started + ")"); @@ -388,7 +385,7 @@ abstract class AbstractDataLine extends AbstractLine implements DataLine { * This method generates a STOP event and sets the started state to false. * It is here for historic reasons when an EOM event existed. */ - protected void setEOM() { + final void setEOM() { if (Printer.trace) Printer.trace("> AbstractDataLine: setEOM()"); //$$fb 2002-04-21: sometimes, 2 STOP events are generated. @@ -408,7 +405,7 @@ abstract class AbstractDataLine extends AbstractLine implements DataLine { * line is open, this should return quietly because the values * requested will match the current ones. */ - public void open() throws LineUnavailableException { + public final void open() throws LineUnavailableException { if (Printer.trace) Printer.trace("> "+getClass().getName()+".open() - AbstractDataLine"); @@ -422,7 +419,7 @@ abstract class AbstractDataLine extends AbstractLine implements DataLine { * This should also stop the line. The closed line should not be running or active. * After we close the line, we reset the format and buffer size to the defaults. */ - public void close() { + 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."); diff --git a/jdk/src/share/classes/com/sun/media/sound/AbstractLine.java b/jdk/src/share/classes/com/sun/media/sound/AbstractLine.java index d9860c9b68a..e6a7ba2d9cb 100644 --- a/jdk/src/share/classes/com/sun/media/sound/AbstractLine.java +++ b/jdk/src/share/classes/com/sun/media/sound/AbstractLine.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2013, 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,11 +25,12 @@ package com.sun.media.sound; +import java.util.Map; import java.util.Vector; +import java.util.WeakHashMap; import javax.sound.sampled.AudioSystem; import javax.sound.sampled.Control; -import javax.sound.sampled.Mixer; import javax.sound.sampled.Line; import javax.sound.sampled.LineEvent; import javax.sound.sampled.LineListener; @@ -43,28 +44,17 @@ import javax.sound.sampled.LineUnavailableException; */ abstract class AbstractLine implements Line { - protected Line.Info info; + protected final Line.Info info; protected Control[] controls; - protected AbstractMixer mixer; + AbstractMixer mixer; private boolean open = false; - private Vector listeners = new Vector(); + private final Vector listeners = new Vector(); /** - * Global event thread + * Contains event dispatcher per thread group. */ - private static final EventDispatcher eventDispatcher; - - static { - // create and start the global event thread - - // $$kk: 12.21.98: - // 1) probably don't want a single global event queue - // 2) need a way to stop this thread when the engine is done - - eventDispatcher = new EventDispatcher(); - eventDispatcher.start(); - } - + private static final Map dispatchers = + new WeakHashMap<>(); /** * Constructs a new AbstractLine. @@ -85,18 +75,17 @@ abstract class AbstractLine implements Line { // LINE METHODS - public Line.Info getLineInfo() { + public final Line.Info getLineInfo() { return info; } - public boolean isOpen() { + public final boolean isOpen() { return open; } - public void addLineListener(LineListener listener) { - + public final void addLineListener(LineListener listener) { synchronized(listeners) { if ( ! (listeners.contains(listener)) ) { listeners.addElement(listener); @@ -109,7 +98,7 @@ abstract class AbstractLine implements Line { * Removes an audio listener. * @param listener listener to remove */ - public void removeLineListener(LineListener listener) { + public final void removeLineListener(LineListener listener) { listeners.removeElement(listener); } @@ -120,8 +109,7 @@ abstract class AbstractLine implements Line { * array of length 0. * @return control set */ - public Control[] getControls() { - + public final Control[] getControls() { Control[] returnedArray = new Control[controls.length]; for (int i = 0; i < controls.length; i++) { @@ -132,8 +120,7 @@ abstract class AbstractLine implements Line { } - public boolean isControlSupported(Control.Type controlType) { - + public final boolean isControlSupported(Control.Type controlType) { // protect against a NullPointerException if (controlType == null) { return false; @@ -149,8 +136,7 @@ abstract class AbstractLine implements Line { } - public Control getControl(Control.Type controlType) { - + public final Control getControl(Control.Type controlType) { // protect against a NullPointerException if (controlType != null) { @@ -172,7 +158,7 @@ abstract class AbstractLine implements Line { * This method sets the open state and generates * events if it changes. */ - protected void setOpen(boolean open) { + final void setOpen(boolean open) { if (Printer.trace) Printer.trace("> "+getClass().getName()+" (AbstractLine): setOpen(" + open + ") this.open: " + this.open); @@ -200,8 +186,8 @@ abstract class AbstractLine implements Line { /** * Send line events. */ - protected void sendEvents(LineEvent event) { - eventDispatcher.sendAudioEvents(event, listeners); + final void sendEvents(LineEvent event) { + getEventDispatcher().sendAudioEvents(event, listeners); } @@ -227,12 +213,23 @@ abstract class AbstractLine implements Line { // $$kk: 06.03.99: returns the mixer used in construction. // this is a hold-over from when there was a public method like // this on line and should be fixed!! - protected AbstractMixer getMixer() { + final AbstractMixer getMixer() { return mixer; } - protected EventDispatcher getEventDispatcher() { - return eventDispatcher; + final EventDispatcher getEventDispatcher() { + // create and start the global event thread + //TODO need a way to stop this thread when the engine is done + final ThreadGroup tg = Thread.currentThread().getThreadGroup(); + synchronized (dispatchers) { + EventDispatcher eventDispatcher = dispatchers.get(tg); + if (eventDispatcher == null) { + eventDispatcher = new EventDispatcher(); + dispatchers.put(tg, eventDispatcher); + eventDispatcher.start(); + } + return eventDispatcher; + } } // ABSTRACT METHODS diff --git a/jdk/src/share/classes/com/sun/media/sound/AbstractMidiDevice.java b/jdk/src/share/classes/com/sun/media/sound/AbstractMidiDevice.java index dacefba8f49..104af874ea5 100644 --- a/jdk/src/share/classes/com/sun/media/sound/AbstractMidiDevice.java +++ b/jdk/src/share/classes/com/sun/media/sound/AbstractMidiDevice.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2013, 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,12 +60,12 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice // DEVICE ATTRIBUTES - private MidiDevice.Info info; + private final MidiDevice.Info info; // DEVICE STATE - protected /*private*/ boolean open = false; + private boolean open = false; private int openRefCount; /** List of Receivers and Transmitters that opened the device implicitely. @@ -102,7 +102,7 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice // MIDI DEVICE METHODS - public MidiDevice.Info getDeviceInfo() { + public final MidiDevice.Info getDeviceInfo() { return info; } @@ -111,7 +111,7 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice * opened the the device implicitly from closing it. The only way to close the device after * this call is a call to close(). */ - public void open() throws MidiUnavailableException { + public final void open() throws MidiUnavailableException { if (Printer.trace) Printer.trace("> AbstractMidiDevice: open()"); synchronized(this) { openRefCount = -1; @@ -159,7 +159,7 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice } - public void close() { + public final void close() { if (Printer.trace) Printer.trace("> AbstractMidiDevice: close()"); synchronized (this) { doClose(); @@ -181,7 +181,7 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice * @param object The object that might have been opening the device implicitely (for now, * this may be a Transmitter or receiver). */ - public void closeInternal(Object object) { + public final void closeInternal(Object object) { if (Printer.trace) Printer.trace("> AbstractMidiDevice: closeInternal()"); synchronized(this) { if (getOpenKeepingObjects().remove(object)) { @@ -197,7 +197,7 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice } - public void doClose() { + public final void doClose() { if (Printer.trace) Printer.trace("> AbstractMidiDevice: doClose()"); synchronized(this) { if (isOpen()) { @@ -209,7 +209,7 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice } - public boolean isOpen() { + public final boolean isOpen() { return open; } @@ -329,7 +329,7 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice // HELPER METHODS - long getId() { + final long getId() { return id; } @@ -339,7 +339,8 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice /** Retrieve a Receiver and open the device implicitly. This method is called by MidiSystem.getReceiver(). */ - public Receiver getReceiverReferenceCounting() throws MidiUnavailableException { + public final Receiver getReceiverReferenceCounting() + throws MidiUnavailableException { /* Keep this order of commands! If getReceiver() throws an exception, openInternal() should not be called! */ @@ -355,7 +356,8 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice /** Retrieve a Transmitter and open the device implicitly. This method is called by MidiSystem.getTransmitter(). */ - public Transmitter getTransmitterReferenceCounting() throws MidiUnavailableException { + public final Transmitter getTransmitterReferenceCounting() + throws MidiUnavailableException { /* Keep this order of commands! If getTransmitter() throws an exception, openInternal() should not be called! */ @@ -422,7 +424,7 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice /** Return the internal list of Transmitters, possibly creating it first. */ - protected TransmitterList getTransmitterList() { + final TransmitterList getTransmitterList() { synchronized (traRecLock) { if (transmitterList == null) { transmitterList = new TransmitterList(); @@ -462,7 +464,7 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice /** * close this device if discarded by the garbage collector */ - protected void finalize() { + protected final void finalize() { close(); } @@ -534,7 +536,7 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice * Also, it has some optimizations regarding sending to the Receivers, * for known Receivers, and managing itself in the TransmitterList. */ - protected class BasicTransmitter implements MidiDeviceTransmitter { + class BasicTransmitter implements MidiDeviceTransmitter { private Receiver receiver = null; TransmitterList tlist = null; @@ -546,7 +548,7 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice this.tlist = tlist; } - public void setReceiver(Receiver receiver) { + 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); @@ -554,7 +556,7 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice } } - public Receiver getReceiver() { + public final Receiver getReceiver() { return receiver; } @@ -564,7 +566,7 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice * Therefore, subclasses that override this method must call * 'super.close()'. */ - public void close() { + public final void close() { AbstractMidiDevice.this.closeInternal(this); if (tlist != null) { tlist.receiverChanged(this, this.receiver, null); @@ -573,7 +575,7 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice } } - public MidiDevice getMidiDevice() { + public final MidiDevice getMidiDevice() { return AbstractMidiDevice.this; } @@ -583,9 +585,9 @@ abstract class AbstractMidiDevice implements MidiDevice, ReferenceCountingDevice /** * a class to manage a list of transmitters */ - class TransmitterList { + final class TransmitterList { - private ArrayList transmitters = new ArrayList(); + private final ArrayList transmitters = new ArrayList(); private MidiOutDevice.MidiOutReceiver midiOutReceiver; // how many transmitters must be present for optimized diff --git a/jdk/src/share/classes/com/sun/media/sound/AbstractMidiDeviceProvider.java b/jdk/src/share/classes/com/sun/media/sound/AbstractMidiDeviceProvider.java index a098eadf5c9..3d0d1af514a 100644 --- a/jdk/src/share/classes/com/sun/media/sound/AbstractMidiDeviceProvider.java +++ b/jdk/src/share/classes/com/sun/media/sound/AbstractMidiDeviceProvider.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2013, 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 @@ -36,7 +36,7 @@ import javax.sound.midi.spi.MidiDeviceProvider; */ public abstract class AbstractMidiDeviceProvider extends MidiDeviceProvider { - private static boolean enabled; + private static final boolean enabled; /** * Create objects representing all MIDI output devices on the system. @@ -52,7 +52,7 @@ public abstract class AbstractMidiDeviceProvider extends MidiDeviceProvider { } - synchronized void readDeviceInfos() { + final synchronized void readDeviceInfos() { Info[] infos = getInfoCache(); MidiDevice[] devices = getDeviceCache(); if (!enabled) { @@ -118,7 +118,7 @@ public abstract class AbstractMidiDeviceProvider extends MidiDeviceProvider { } - public MidiDevice.Info[] getDeviceInfo() { + public final MidiDevice.Info[] getDeviceInfo() { readDeviceInfos(); Info[] infos = getInfoCache(); MidiDevice.Info[] localArray = new MidiDevice.Info[infos.length]; @@ -127,7 +127,7 @@ public abstract class AbstractMidiDeviceProvider extends MidiDeviceProvider { } - public MidiDevice getDevice(MidiDevice.Info info) { + public final MidiDevice getDevice(MidiDevice.Info info) { if (info instanceof Info) { readDeviceInfos(); MidiDevice[] devices = getDeviceCache(); @@ -164,7 +164,7 @@ public abstract class AbstractMidiDeviceProvider extends MidiDeviceProvider { this.index = index; } - boolean equalStrings(Info info) { + final boolean equalStrings(Info info) { return (info != null && getName().equals(info.getName()) && getVendor().equals(info.getVendor()) @@ -172,11 +172,11 @@ public abstract class AbstractMidiDeviceProvider extends MidiDeviceProvider { && getVersion().equals(info.getVersion())); } - int getIndex() { + final int getIndex() { return index; } - void setIndex(int index) { + final void setIndex(int index) { this.index = index; } diff --git a/jdk/src/share/classes/com/sun/media/sound/AbstractMixer.java b/jdk/src/share/classes/com/sun/media/sound/AbstractMixer.java index c4f2b6078d0..1055fc6859e 100644 --- a/jdk/src/share/classes/com/sun/media/sound/AbstractMixer.java +++ b/jdk/src/share/classes/com/sun/media/sound/AbstractMixer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2013, 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 @@ -27,14 +27,9 @@ package com.sun.media.sound; import java.util.Vector; -import javax.sound.sampled.AudioFormat; -import javax.sound.sampled.AudioSystem; import javax.sound.sampled.Control; -import javax.sound.sampled.DataLine; import javax.sound.sampled.Mixer; import javax.sound.sampled.Line; -import javax.sound.sampled.LineEvent; -import javax.sound.sampled.LineListener; import javax.sound.sampled.LineUnavailableException; /** @@ -95,13 +90,13 @@ abstract class AbstractMixer extends AbstractLine implements Mixer { /** * Source lines (ports) currently open */ - protected Vector sourceLines = new Vector(); + private final Vector sourceLines = new Vector(); /** * Target lines currently open. */ - protected Vector targetLines = new Vector(); + private final Vector targetLines = new Vector(); /** @@ -133,19 +128,19 @@ abstract class AbstractMixer extends AbstractLine implements Mixer { // MIXER METHODS - public Mixer.Info getMixerInfo() { + public final Mixer.Info getMixerInfo() { return mixerInfo; } - public Line.Info[] getSourceLineInfo() { + public final Line.Info[] getSourceLineInfo() { Line.Info[] localArray = new Line.Info[sourceLineInfo.length]; System.arraycopy(sourceLineInfo, 0, localArray, 0, sourceLineInfo.length); return localArray; } - public Line.Info[] getTargetLineInfo() { + public final Line.Info[] getTargetLineInfo() { Line.Info[] localArray = new Line.Info[targetLineInfo.length]; System.arraycopy(targetLineInfo, 0, localArray, 0, targetLineInfo.length); @@ -153,7 +148,7 @@ abstract class AbstractMixer extends AbstractLine implements Mixer { } - public Line.Info[] getSourceLineInfo(Line.Info info) { + public final Line.Info[] getSourceLineInfo(Line.Info info) { int i; Vector vec = new Vector(); @@ -174,7 +169,7 @@ abstract class AbstractMixer extends AbstractLine implements Mixer { } - public Line.Info[] getTargetLineInfo(Line.Info info) { + public final Line.Info[] getTargetLineInfo(Line.Info info) { int i; Vector vec = new Vector(); @@ -195,7 +190,7 @@ abstract class AbstractMixer extends AbstractLine implements Mixer { } - public boolean isLineSupported(Line.Info info) { + public final boolean isLineSupported(Line.Info info) { int i; @@ -227,7 +222,7 @@ abstract class AbstractMixer extends AbstractLine implements Mixer { protected abstract void implClose(); - public Line[] getSourceLines() { + public final Line[] getSourceLines() { Line[] localLines; @@ -244,7 +239,7 @@ abstract class AbstractMixer extends AbstractLine implements Mixer { } - public Line[] getTargetLines() { + public final Line[] getTargetLines() { Line[] localLines; @@ -264,7 +259,7 @@ abstract class AbstractMixer extends AbstractLine implements Mixer { /** * Default implementation always throws an exception. */ - public void synchronize(Line[] lines, boolean maintainSync) { + public final void synchronize(Line[] lines, boolean maintainSync) { throw new IllegalArgumentException("Synchronization not supported by this mixer."); } @@ -272,7 +267,7 @@ abstract class AbstractMixer extends AbstractLine implements Mixer { /** * Default implementation always throws an exception. */ - public void unsynchronize(Line[] lines) { + public final void unsynchronize(Line[] lines) { throw new IllegalArgumentException("Synchronization not supported by this mixer."); } @@ -280,7 +275,8 @@ abstract class AbstractMixer extends AbstractLine implements Mixer { /** * Default implementation always returns false. */ - public boolean isSynchronizationSupported(Line[] lines, boolean maintainSync) { + public final boolean isSynchronizationSupported(Line[] lines, + boolean maintainSync) { return false; } @@ -290,14 +286,14 @@ abstract class AbstractMixer extends AbstractLine implements Mixer { /** * This implementation tries to open the mixer with its current format and buffer size settings. */ - public synchronized void open() throws LineUnavailableException { + public final synchronized void open() throws LineUnavailableException { open(true); } /** * This implementation tries to open the mixer with its current format and buffer size settings. */ - protected synchronized void open(boolean manual) throws LineUnavailableException { + final synchronized void open(boolean manual) throws LineUnavailableException { if (Printer.trace) Printer.trace(">> AbstractMixer: open()"); if (!isOpen()) { implOpen(); @@ -322,7 +318,7 @@ abstract class AbstractMixer extends AbstractLine implements Mixer { * The mixer may be opened at a format different than the line's * format if it is a DataLine. */ - protected synchronized void open(Line line) throws LineUnavailableException { + final synchronized void open(Line line) throws LineUnavailableException { if (Printer.trace) Printer.trace(">> AbstractMixer: open(line = " + line + ")"); @@ -367,7 +363,7 @@ abstract class AbstractMixer extends AbstractLine implements Mixer { * open target lines, if it exists in either. * If the list is now empty, closes the mixer. */ - protected synchronized void close(Line line) { + final synchronized void close(Line line) { if (Printer.trace) Printer.trace(">> AbstractMixer: close(" + line + ")"); @@ -396,7 +392,7 @@ abstract class AbstractMixer extends AbstractLine implements Mixer { /** * Close all lines and then close this mixer. */ - public synchronized void close() { + public final synchronized void close() { if (Printer.trace) Printer.trace(">> AbstractMixer: close()"); if (isOpen()) { // close all source lines @@ -423,7 +419,7 @@ abstract class AbstractMixer extends AbstractLine implements Mixer { /** * Starts the mixer. */ - protected synchronized void start(Line line) { + final synchronized void start(Line line) { if (Printer.trace) Printer.trace(">> AbstractMixer: start(" + line + ")"); @@ -447,7 +443,7 @@ abstract class AbstractMixer extends AbstractLine implements Mixer { /** * Stops the mixer if this was the last running line. */ - protected synchronized void stop(Line line) { + final synchronized void stop(Line line) { if (Printer.trace) Printer.trace(">> AbstractMixer: stop(" + line + ")"); @@ -501,7 +497,7 @@ abstract class AbstractMixer extends AbstractLine implements Mixer { * Right now this just checks whether it's supported, but should * check whether it actually belongs to this mixer.... */ - boolean isSourceLine(Line.Info info) { + final boolean isSourceLine(Line.Info info) { for (int i = 0; i < sourceLineInfo.length; i++) { if (info.matches(sourceLineInfo[i])) { @@ -518,7 +514,7 @@ abstract class AbstractMixer extends AbstractLine implements Mixer { * Right now this just checks whether it's supported, but should * check whether it actually belongs to this mixer.... */ - boolean isTargetLine(Line.Info info) { + final boolean isTargetLine(Line.Info info) { for (int i = 0; i < targetLineInfo.length; i++) { if (info.matches(targetLineInfo[i])) { @@ -535,7 +531,7 @@ abstract class AbstractMixer extends AbstractLine implements Mixer { * matches the one specified, or null if no matching Line.Info * object is found. */ - Line.Info getLineInfo(Line.Info info) { + final Line.Info getLineInfo(Line.Info info) { if (info == null) { return null; } diff --git a/jdk/src/share/classes/com/sun/media/sound/AiffFileFormat.java b/jdk/src/share/classes/com/sun/media/sound/AiffFileFormat.java index c632b79389e..8d5e7f07468 100644 --- a/jdk/src/share/classes/com/sun/media/sound/AiffFileFormat.java +++ b/jdk/src/share/classes/com/sun/media/sound/AiffFileFormat.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2013, 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 @@ -35,7 +35,7 @@ import javax.sound.sampled.AudioFormat; * @author Jan Borgersen */ -class AiffFileFormat extends AudioFileFormat { +final class AiffFileFormat extends AudioFileFormat { static final int AIFF_MAGIC = 1179603533; @@ -62,13 +62,13 @@ class AiffFileFormat extends AudioFileFormat { //$$fb 2001-07-13: added management of header size in this class /** header size in bytes */ - private int headerSize=AIFF_HEADERSIZE; + private final int headerSize=AIFF_HEADERSIZE; /** comm chunk size in bytes, inclusive magic and length field */ - private int commChunkSize=26; + private final int commChunkSize=26; /** FVER chunk size in bytes, inclusive magic and length field */ - private int fverChunkSize=0; + private final int fverChunkSize=0; AiffFileFormat( AudioFileFormat aff ) { this( aff.getType(), aff.getByteLength(), aff.getFormat(), aff.getFrameLength() ); diff --git a/jdk/src/share/classes/com/sun/media/sound/AiffFileReader.java b/jdk/src/share/classes/com/sun/media/sound/AiffFileReader.java index dd480aa8d3d..93d425e862c 100644 --- a/jdk/src/share/classes/com/sun/media/sound/AiffFileReader.java +++ b/jdk/src/share/classes/com/sun/media/sound/AiffFileReader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2013, 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,28 +25,17 @@ package com.sun.media.sound; -import java.util.Vector; -import java.io.File; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.IOException; -import java.io.EOFException; -import java.net.URL; -import java.net.MalformedURLException; - -import java.io.BufferedInputStream; -import java.io.BufferedOutputStream; import java.io.DataInputStream; -import java.io.FileInputStream; import java.io.DataOutputStream; -import java.io.FileOutputStream; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.SequenceInputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; import javax.sound.sampled.AudioFileFormat; -import javax.sound.sampled.AudioInputStream; import javax.sound.sampled.AudioFormat; +import javax.sound.sampled.AudioInputStream; import javax.sound.sampled.AudioSystem; import javax.sound.sampled.UnsupportedAudioFileException; @@ -58,19 +47,10 @@ import javax.sound.sampled.UnsupportedAudioFileException; * @author Jan Borgersen * @author Florian Bomers */ -public class AiffFileReader extends SunFileReader { +public final class AiffFileReader extends SunFileReader { private static final int MAX_READ_LENGTH = 8; - - /** - * AIFF parser type - */ - public static final AudioFileFormat.Type types[] = { - AudioFileFormat.Type.AIFF - }; - - /** * Constructs a new AiffParser object. */ diff --git a/jdk/src/share/classes/com/sun/media/sound/AiffFileWriter.java b/jdk/src/share/classes/com/sun/media/sound/AiffFileWriter.java index 1bce488d4ed..0f79728291e 100644 --- a/jdk/src/share/classes/com/sun/media/sound/AiffFileWriter.java +++ b/jdk/src/share/classes/com/sun/media/sound/AiffFileWriter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2013, 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,21 +50,13 @@ import javax.sound.sampled.AudioSystem; * * @author Jan Borgersen */ -public class AiffFileWriter extends SunFileWriter { - - /** - * AIFF type - */ - private static final AudioFileFormat.Type aiffTypes[] = { - AudioFileFormat.Type.AIFF - }; - +public final class AiffFileWriter extends SunFileWriter { /** * Constructs a new AiffFileWriter object. */ public AiffFileWriter() { - super(aiffTypes); + super(new AudioFileFormat.Type[]{AudioFileFormat.Type.AIFF}); } diff --git a/jdk/src/share/classes/com/sun/media/sound/AlawCodec.java b/jdk/src/share/classes/com/sun/media/sound/AlawCodec.java index bece256bc41..dc868b0b2cb 100644 --- a/jdk/src/share/classes/com/sun/media/sound/AlawCodec.java +++ b/jdk/src/share/classes/com/sun/media/sound/AlawCodec.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2013, 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,14 +25,12 @@ package com.sun.media.sound; -import java.io.InputStream; import java.io.IOException; - import java.util.Vector; import javax.sound.sampled.AudioFormat; -import javax.sound.sampled.AudioSystem; import javax.sound.sampled.AudioInputStream; +import javax.sound.sampled.AudioSystem; /** @@ -40,12 +38,12 @@ import javax.sound.sampled.AudioInputStream; * * @author Kara Kytle */ -public class AlawCodec extends SunCodec { +public final class AlawCodec extends SunCodec { /* Tables used for A-law decoding */ - final static byte ALAW_TABH[] = new byte[256]; - final static byte ALAW_TABL[] = new byte[256]; + private static final byte[] ALAW_TABH = new byte[256]; + private static final byte[] ALAW_TABL = new byte[256]; private static final AudioFormat.Encoding[] alawEncodings = { AudioFormat.Encoding.ALAW, AudioFormat.Encoding.PCM_SIGNED }; @@ -256,7 +254,7 @@ public class AlawCodec extends SunCodec { } - class AlawCodecStream extends AudioInputStream { + final class AlawCodecStream extends AudioInputStream { // tempBuffer required only for encoding (when encode is true) private static final int tempBufferSize = 64; diff --git a/jdk/src/share/classes/com/sun/media/sound/AuFileFormat.java b/jdk/src/share/classes/com/sun/media/sound/AuFileFormat.java index 3beb517556a..185efb9e6b0 100644 --- a/jdk/src/share/classes/com/sun/media/sound/AuFileFormat.java +++ b/jdk/src/share/classes/com/sun/media/sound/AuFileFormat.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2013, 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 @@ -36,7 +36,7 @@ import javax.sound.sampled.AudioFormat; * @author Jan Borgersen */ -class AuFileFormat extends AudioFileFormat { +final class AuFileFormat extends AudioFileFormat { // magic numbers static final int AU_SUN_MAGIC = 0x2e736e64; @@ -60,7 +60,7 @@ class AuFileFormat extends AudioFileFormat { static final int AU_HEADERSIZE = 24; - int auType; + private int auType; AuFileFormat( AudioFileFormat aff ) { diff --git a/jdk/src/share/classes/com/sun/media/sound/AuFileReader.java b/jdk/src/share/classes/com/sun/media/sound/AuFileReader.java index 119ba6fbb0a..d755d516efd 100644 --- a/jdk/src/share/classes/com/sun/media/sound/AuFileReader.java +++ b/jdk/src/share/classes/com/sun/media/sound/AuFileReader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2013, 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,28 +25,17 @@ package com.sun.media.sound; -import java.util.Vector; -import java.io.File; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.IOException; -import java.io.EOFException; -import java.net.URL; -import java.net.MalformedURLException; - import java.io.BufferedInputStream; -import java.io.BufferedOutputStream; import java.io.DataInputStream; +import java.io.File; import java.io.FileInputStream; -import java.io.DataOutputStream; -import java.io.FileOutputStream; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.SequenceInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; import javax.sound.sampled.AudioFileFormat; -import javax.sound.sampled.AudioInputStream; import javax.sound.sampled.AudioFormat; +import javax.sound.sampled.AudioInputStream; import javax.sound.sampled.AudioSystem; import javax.sound.sampled.UnsupportedAudioFileException; @@ -58,16 +47,7 @@ import javax.sound.sampled.UnsupportedAudioFileException; * @author Jan Borgersen * @author Florian Bomers */ -public class AuFileReader extends SunFileReader { - - /** - * AU reader type - */ - - public static final AudioFileFormat.Type types[] = { - AudioFileFormat.Type.AU - }; - +public final class AuFileReader extends SunFileReader { /** * Constructs a new AuFileReader object. diff --git a/jdk/src/share/classes/com/sun/media/sound/AuFileWriter.java b/jdk/src/share/classes/com/sun/media/sound/AuFileWriter.java index 6d89d84bff0..15a7a90decf 100644 --- a/jdk/src/share/classes/com/sun/media/sound/AuFileWriter.java +++ b/jdk/src/share/classes/com/sun/media/sound/AuFileWriter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2013, 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,28 +49,18 @@ import javax.sound.sampled.AudioSystem; * * @author Jan Borgersen */ -public class AuFileWriter extends SunFileWriter { +public final class AuFileWriter extends SunFileWriter { //$$fb value for length field if length is not known public final static int UNKNOWN_SIZE=-1; - /** - * AU type - */ - private static final AudioFileFormat.Type auTypes[] = { - AudioFileFormat.Type.AU - }; - - /** * Constructs a new AuFileWriter object. */ public AuFileWriter() { - super(auTypes); + super(new AudioFileFormat.Type[]{AudioFileFormat.Type.AU}); } - - public AudioFileFormat.Type[] getAudioFileTypes(AudioInputStream stream) { AudioFileFormat.Type[] filetypes = new AudioFileFormat.Type[types.length]; diff --git a/jdk/src/share/classes/com/sun/media/sound/AudioFileSoundbankReader.java b/jdk/src/share/classes/com/sun/media/sound/AudioFileSoundbankReader.java index b3ef6d82fc7..11b0fa6ee6e 100644 --- a/jdk/src/share/classes/com/sun/media/sound/AudioFileSoundbankReader.java +++ b/jdk/src/share/classes/com/sun/media/sound/AudioFileSoundbankReader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2013, 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,7 +43,7 @@ import javax.sound.sampled.UnsupportedAudioFileException; * * @author Karl Helgason */ -public class AudioFileSoundbankReader extends SoundbankReader { +public final class AudioFileSoundbankReader extends SoundbankReader { public Soundbank getSoundbank(URL url) throws InvalidMidiDataException, IOException { diff --git a/jdk/src/share/classes/com/sun/media/sound/AudioFloatConverter.java b/jdk/src/share/classes/com/sun/media/sound/AudioFloatConverter.java index 95068ed6126..9b850e03ad3 100644 --- a/jdk/src/share/classes/com/sun/media/sound/AudioFloatConverter.java +++ b/jdk/src/share/classes/com/sun/media/sound/AudioFloatConverter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2013, 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 @@ -51,7 +51,7 @@ public abstract class AudioFloatConverter { private static class AudioFloatLSBFilter extends AudioFloatConverter { - private AudioFloatConverter converter; + private final AudioFloatConverter converter; final private int offset; @@ -61,8 +61,7 @@ public abstract class AudioFloatConverter { private byte[] mask_buffer; - public AudioFloatLSBFilter(AudioFloatConverter converter, - AudioFormat format) { + AudioFloatLSBFilter(AudioFloatConverter converter, AudioFormat format) { int bits = format.getSampleSizeInBits(); boolean bigEndian = format.isBigEndian(); this.converter = converter; @@ -740,7 +739,7 @@ public abstract class AudioFloatConverter { final int xbytes; - public AudioFloatConversion32xSL(int xbytes) { + AudioFloatConversion32xSL(int xbytes) { this.xbytes = xbytes; } @@ -781,7 +780,7 @@ public abstract class AudioFloatConverter { final int xbytes; - public AudioFloatConversion32xSB(int xbytes) { + AudioFloatConversion32xSB(int xbytes) { this.xbytes = xbytes; } @@ -823,7 +822,7 @@ public abstract class AudioFloatConverter { final int xbytes; - public AudioFloatConversion32xUL(int xbytes) { + AudioFloatConversion32xUL(int xbytes) { this.xbytes = xbytes; } @@ -866,7 +865,7 @@ public abstract class AudioFloatConverter { final int xbytes; - public AudioFloatConversion32xUB(int xbytes) { + AudioFloatConversion32xUB(int xbytes) { this.xbytes = xbytes; } @@ -1008,49 +1007,51 @@ public abstract class AudioFloatConverter { private AudioFormat format; - public AudioFormat getFormat() { + public final AudioFormat getFormat() { return format; } public abstract float[] toFloatArray(byte[] in_buff, int in_offset, float[] out_buff, int out_offset, int out_len); - public float[] toFloatArray(byte[] in_buff, float[] out_buff, + public final float[] toFloatArray(byte[] in_buff, float[] out_buff, int out_offset, int out_len) { return toFloatArray(in_buff, 0, out_buff, out_offset, out_len); } - public float[] toFloatArray(byte[] in_buff, int in_offset, + public final float[] toFloatArray(byte[] in_buff, int in_offset, float[] out_buff, int out_len) { return toFloatArray(in_buff, in_offset, out_buff, 0, out_len); } - public float[] toFloatArray(byte[] in_buff, float[] out_buff, int out_len) { + public final float[] toFloatArray(byte[] in_buff, float[] out_buff, + int out_len) { return toFloatArray(in_buff, 0, out_buff, 0, out_len); } - public float[] toFloatArray(byte[] in_buff, float[] out_buff) { + public final float[] toFloatArray(byte[] in_buff, float[] out_buff) { return toFloatArray(in_buff, 0, out_buff, 0, out_buff.length); } public abstract byte[] toByteArray(float[] in_buff, int in_offset, int in_len, byte[] out_buff, int out_offset); - public byte[] toByteArray(float[] in_buff, int in_len, byte[] out_buff, - int out_offset) { + public final byte[] toByteArray(float[] in_buff, int in_len, + byte[] out_buff, int out_offset) { return toByteArray(in_buff, 0, in_len, out_buff, out_offset); } - public byte[] toByteArray(float[] in_buff, int in_offset, int in_len, - byte[] out_buff) { + public final byte[] toByteArray(float[] in_buff, int in_offset, int in_len, + byte[] out_buff) { return toByteArray(in_buff, in_offset, in_len, out_buff, 0); } - public byte[] toByteArray(float[] in_buff, int in_len, byte[] out_buff) { + public final byte[] toByteArray(float[] in_buff, int in_len, + byte[] out_buff) { return toByteArray(in_buff, 0, in_len, out_buff, 0); } - public byte[] toByteArray(float[] in_buff, byte[] out_buff) { + public final byte[] toByteArray(float[] in_buff, byte[] out_buff) { return toByteArray(in_buff, 0, in_buff.length, out_buff, 0); } } diff --git a/jdk/src/share/classes/com/sun/media/sound/AudioFloatFormatConverter.java b/jdk/src/share/classes/com/sun/media/sound/AudioFloatFormatConverter.java index 0b73dca0666..a161fc5db42 100644 --- a/jdk/src/share/classes/com/sun/media/sound/AudioFloatFormatConverter.java +++ b/jdk/src/share/classes/com/sun/media/sound/AudioFloatFormatConverter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2013, 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 @@ -42,19 +42,19 @@ import javax.sound.sampled.spi.FormatConversionProvider; * * @author Karl Helgason */ -public class AudioFloatFormatConverter extends FormatConversionProvider { +public final class AudioFloatFormatConverter extends FormatConversionProvider { private static class AudioFloatFormatConverterInputStream extends InputStream { - private AudioFloatConverter converter; + private final AudioFloatConverter converter; - private AudioFloatInputStream stream; + private final AudioFloatInputStream stream; private float[] readfloatbuffer; - private int fsize = 0; + private final int fsize; - public AudioFloatFormatConverterInputStream(AudioFormat targetFormat, + AudioFloatFormatConverterInputStream(AudioFormat targetFormat, AudioFloatInputStream stream) { this.stream = stream; converter = AudioFloatConverter.getConverter(targetFormat); @@ -116,17 +116,17 @@ public class AudioFloatFormatConverter extends FormatConversionProvider { private static class AudioFloatInputStreamChannelMixer extends AudioFloatInputStream { - private int targetChannels; + private final int targetChannels; - private int sourceChannels; + private final int sourceChannels; - private AudioFloatInputStream ais; + private final AudioFloatInputStream ais; - private AudioFormat targetFormat; + private final AudioFormat targetFormat; private float[] conversion_buffer; - public AudioFloatInputStreamChannelMixer(AudioFloatInputStream ais, + AudioFloatInputStreamChannelMixer(AudioFloatInputStream ais, int targetChannels) { this.sourceChannels = ais.getFormat().getChannels(); this.targetChannels = targetChannels; @@ -226,37 +226,37 @@ public class AudioFloatFormatConverter extends FormatConversionProvider { private static class AudioFloatInputStreamResampler extends AudioFloatInputStream { - private AudioFloatInputStream ais; + private final AudioFloatInputStream ais; - private AudioFormat targetFormat; + private final AudioFormat targetFormat; private float[] skipbuffer; private SoftAbstractResampler resampler; - private float[] pitch = new float[1]; + private final float[] pitch = new float[1]; - private float[] ibuffer2; + private final float[] ibuffer2; - private float[][] ibuffer; + private final float[][] ibuffer; private float ibuffer_index = 0; private int ibuffer_len = 0; - private int nrofchannels = 0; + private final int nrofchannels; private float[][] cbuffer; - private int buffer_len = 512; + private final int buffer_len = 512; - private int pad; + private final int pad; - private int pad2; + private final int pad2; - private float[] ix = new float[1]; + private final float[] ix = new float[1]; - private int[] ox = new int[1]; + private final int[] ox = new int[1]; private float[][] mark_ibuffer = null; @@ -264,7 +264,7 @@ public class AudioFloatFormatConverter extends FormatConversionProvider { private int mark_ibuffer_len = 0; - public AudioFloatInputStreamResampler(AudioFloatInputStream ais, + AudioFloatInputStreamResampler(AudioFloatInputStream ais, AudioFormat format) { this.ais = ais; AudioFormat sourceFormat = ais.getFormat(); @@ -468,8 +468,9 @@ public class AudioFloatFormatConverter extends FormatConversionProvider { } - private Encoding[] formats = { Encoding.PCM_SIGNED, Encoding.PCM_UNSIGNED, - Encoding.PCM_FLOAT }; + private final Encoding[] formats = {Encoding.PCM_SIGNED, + Encoding.PCM_UNSIGNED, + Encoding.PCM_FLOAT}; public AudioInputStream getAudioInputStream(Encoding targetEncoding, AudioInputStream sourceStream) { diff --git a/jdk/src/share/classes/com/sun/media/sound/AudioFloatInputStream.java b/jdk/src/share/classes/com/sun/media/sound/AudioFloatInputStream.java index 41f6d818dbc..a4fd10429c4 100644 --- a/jdk/src/share/classes/com/sun/media/sound/AudioFloatInputStream.java +++ b/jdk/src/share/classes/com/sun/media/sound/AudioFloatInputStream.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2013, 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 @@ -48,14 +48,14 @@ public abstract class AudioFloatInputStream { private int pos = 0; private int markpos = 0; - private AudioFloatConverter converter; - private AudioFormat format; - private byte[] buffer; - private int buffer_offset; - private int buffer_len; - private int framesize_pc; + private final AudioFloatConverter converter; + private final AudioFormat format; + private final byte[] buffer; + private final int buffer_offset; + private final int buffer_len; + private final int framesize_pc; - public BytaArrayAudioFloatInputStream(AudioFloatConverter converter, + BytaArrayAudioFloatInputStream(AudioFloatConverter converter, byte[] buffer, int offset, int len) { this.converter = converter; this.format = converter.getFormat(); @@ -125,12 +125,12 @@ public abstract class AudioFloatInputStream { private static class DirectAudioFloatInputStream extends AudioFloatInputStream { - private AudioInputStream stream; + private final AudioInputStream stream; private AudioFloatConverter converter; - private int framesize_pc; // framesize / channels + private final int framesize_pc; // framesize / channels private byte[] buffer; - public DirectAudioFloatInputStream(AudioInputStream stream) { + DirectAudioFloatInputStream(AudioInputStream stream) { converter = AudioFloatConverter.getConverter(stream.getFormat()); if (converter == null) { AudioFormat format = stream.getFormat(); @@ -255,11 +255,11 @@ public abstract class AudioFloatInputStream { public abstract int read(float[] b, int off, int len) throws IOException; - public int read(float[] b) throws IOException { + public final int read(float[] b) throws IOException { return read(b, 0, b.length); } - public float read() throws IOException { + public final float read() throws IOException { float[] b = new float[1]; int ret = read(b, 0, 1); if (ret == -1 || ret == 0) diff --git a/jdk/src/share/classes/com/sun/media/sound/AudioSynthesizerPropertyInfo.java b/jdk/src/share/classes/com/sun/media/sound/AudioSynthesizerPropertyInfo.java index baa04f082a4..9a3ef9970ca 100644 --- a/jdk/src/share/classes/com/sun/media/sound/AudioSynthesizerPropertyInfo.java +++ b/jdk/src/share/classes/com/sun/media/sound/AudioSynthesizerPropertyInfo.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2013, 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 @@ -29,7 +29,7 @@ package com.sun.media.sound; * * @author Karl Helgason */ -public class AudioSynthesizerPropertyInfo { +public final class AudioSynthesizerPropertyInfo { /** * Constructs a AudioSynthesizerPropertyInfo object with a given diff --git a/jdk/src/share/classes/com/sun/media/sound/DLSInfo.java b/jdk/src/share/classes/com/sun/media/sound/DLSInfo.java index 9ea567c4fdc..708bf4b04ca 100644 --- a/jdk/src/share/classes/com/sun/media/sound/DLSInfo.java +++ b/jdk/src/share/classes/com/sun/media/sound/DLSInfo.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2013, 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 @@ -30,7 +30,7 @@ package com.sun.media.sound; * * @author Karl Helgason */ -public class DLSInfo { +public final class DLSInfo { /** * (INAM) Title or subject. diff --git a/jdk/src/share/classes/com/sun/media/sound/DLSInstrument.java b/jdk/src/share/classes/com/sun/media/sound/DLSInstrument.java index fe9fde7fefe..c7e6188a25c 100644 --- a/jdk/src/share/classes/com/sun/media/sound/DLSInstrument.java +++ b/jdk/src/share/classes/com/sun/media/sound/DLSInstrument.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2013, 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,15 +40,15 @@ import javax.sound.midi.Patch; * * @author Karl Helgason */ -public class DLSInstrument extends ModelInstrument { +public final class DLSInstrument extends ModelInstrument { - protected int preset = 0; - protected int bank = 0; - protected boolean druminstrument = false; - protected byte[] guid = null; - protected DLSInfo info = new DLSInfo(); - protected List regions = new ArrayList(); - protected List modulators = new ArrayList(); + int preset = 0; + int bank = 0; + boolean druminstrument = false; + byte[] guid = null; + DLSInfo info = new DLSInfo(); + List regions = new ArrayList(); + List modulators = new ArrayList(); public DLSInstrument() { super(null, null, null, null); diff --git a/jdk/src/share/classes/com/sun/media/sound/DLSModulator.java b/jdk/src/share/classes/com/sun/media/sound/DLSModulator.java index 11b0da628cb..4cfa7d42a13 100644 --- a/jdk/src/share/classes/com/sun/media/sound/DLSModulator.java +++ b/jdk/src/share/classes/com/sun/media/sound/DLSModulator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2013, 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 @@ -33,7 +33,7 @@ package com.sun.media.sound; * * @author Karl Helgason */ -public class DLSModulator { +public final class DLSModulator { // DLS1 Destinations public static final int CONN_DST_NONE = 0x000; // 0 @@ -102,12 +102,12 @@ public class DLSModulator { public static final int DST_FORMAT_CENT = 1; public static final int DST_FORMAT_TIMECENT = 2; public static final int DST_FORMAT_PERCENT = 3; - protected int source; - protected int control; - protected int destination; - protected int transform; - protected int scale; - protected int version = 1; + int source; + int control; + int destination; + int transform; + int scale; + int version = 1; public int getControl() { return control; diff --git a/jdk/src/share/classes/com/sun/media/sound/DLSRegion.java b/jdk/src/share/classes/com/sun/media/sound/DLSRegion.java index 254bebef539..3ef1e845c87 100644 --- a/jdk/src/share/classes/com/sun/media/sound/DLSRegion.java +++ b/jdk/src/share/classes/com/sun/media/sound/DLSRegion.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2013, 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 @@ -36,21 +36,21 @@ import java.util.List; * * @author Karl Helgason */ -public class DLSRegion { +public final class DLSRegion { public final static int OPTION_SELFNONEXCLUSIVE = 0x0001; - protected List modulators = new ArrayList(); - protected int keyfrom; - protected int keyto; - protected int velfrom; - protected int velto; - protected int options; - protected int exclusiveClass; - protected int fusoptions; - protected int phasegroup; - protected long channel; - protected DLSSample sample = null; - protected DLSSampleOptions sampleoptions; + List modulators = new ArrayList(); + int keyfrom; + int keyto; + int velfrom; + int velto; + int options; + int exclusiveClass; + int fusoptions; + int phasegroup; + long channel; + DLSSample sample = null; + DLSSampleOptions sampleoptions; public List getModulators() { return modulators; diff --git a/jdk/src/share/classes/com/sun/media/sound/DLSSample.java b/jdk/src/share/classes/com/sun/media/sound/DLSSample.java index 28327e68f6c..047783dfdab 100644 --- a/jdk/src/share/classes/com/sun/media/sound/DLSSample.java +++ b/jdk/src/share/classes/com/sun/media/sound/DLSSample.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2013, 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,13 +40,13 @@ import javax.sound.sampled.AudioInputStream; * * @author Karl Helgason */ -public class DLSSample extends SoundbankResource { +public final class DLSSample extends SoundbankResource { - protected byte[] guid = null; - protected DLSInfo info = new DLSInfo(); - protected DLSSampleOptions sampleoptions; - protected ModelByteBuffer data; - protected AudioFormat format; + byte[] guid = null; + DLSInfo info = new DLSInfo(); + DLSSampleOptions sampleoptions; + ModelByteBuffer data; + AudioFormat format; public DLSSample(Soundbank soundBank) { super(soundBank, null, AudioInputStream.class); diff --git a/jdk/src/share/classes/com/sun/media/sound/DLSSampleLoop.java b/jdk/src/share/classes/com/sun/media/sound/DLSSampleLoop.java index f78d7c14ffd..091e38385dd 100644 --- a/jdk/src/share/classes/com/sun/media/sound/DLSSampleLoop.java +++ b/jdk/src/share/classes/com/sun/media/sound/DLSSampleLoop.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2013, 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 @@ -29,13 +29,13 @@ package com.sun.media.sound; * * @author Karl Helgason */ -public class DLSSampleLoop { +public final class DLSSampleLoop { public final static int LOOP_TYPE_FORWARD = 0; public final static int LOOP_TYPE_RELEASE = 1; - protected long type; - protected long start; - protected long length; + long type; + long start; + long length; public long getLength() { return length; diff --git a/jdk/src/share/classes/com/sun/media/sound/DLSSampleOptions.java b/jdk/src/share/classes/com/sun/media/sound/DLSSampleOptions.java index b2e1b9b3adc..059f318f414 100644 --- a/jdk/src/share/classes/com/sun/media/sound/DLSSampleOptions.java +++ b/jdk/src/share/classes/com/sun/media/sound/DLSSampleOptions.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2013, 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 @@ -34,13 +34,13 @@ import java.util.List; * * @author Karl Helgason */ -public class DLSSampleOptions { +public final class DLSSampleOptions { - protected int unitynote; - protected short finetune; - protected int attenuation; - protected long options; - protected List loops = new ArrayList(); + int unitynote; + short finetune; + int attenuation; + long options; + List loops = new ArrayList(); public int getAttenuation() { return attenuation; diff --git a/jdk/src/share/classes/com/sun/media/sound/DLSSoundbank.java b/jdk/src/share/classes/com/sun/media/sound/DLSSoundbank.java index 2b490dd6061..87247ba686a 100644 --- a/jdk/src/share/classes/com/sun/media/sound/DLSSoundbank.java +++ b/jdk/src/share/classes/com/sun/media/sound/DLSSoundbank.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2013, 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 @@ -51,7 +51,7 @@ import javax.sound.sampled.AudioFormat.Encoding; * * @author Karl Helgason */ -public class DLSSoundbank implements Soundbank { +public final class DLSSoundbank implements Soundbank { static private class DLSID { long i1; @@ -69,7 +69,7 @@ public class DLSSoundbank implements Soundbank { private DLSID() { } - public DLSID(long i1, int s1, int s2, int x1, int x2, int x3, int x4, + DLSID(long i1, int s1, int s2, int x1, int x2, int x3, int x4, int x5, int x6, int x7, int x8) { this.i1 = i1; this.s1 = s1; @@ -174,10 +174,10 @@ public class DLSSoundbank implements Soundbank { private long major = -1; private long minor = -1; - private DLSInfo info = new DLSInfo(); + private final DLSInfo info = new DLSInfo(); - private List instruments = new ArrayList(); - private List samples = new ArrayList(); + private final List instruments = new ArrayList(); + private final List samples = new ArrayList(); private boolean largeFormat = false; private File sampleFile; diff --git a/jdk/src/share/classes/com/sun/media/sound/DLSSoundbankReader.java b/jdk/src/share/classes/com/sun/media/sound/DLSSoundbankReader.java index 0f51aad0ba1..0bba5d49532 100644 --- a/jdk/src/share/classes/com/sun/media/sound/DLSSoundbankReader.java +++ b/jdk/src/share/classes/com/sun/media/sound/DLSSoundbankReader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2013, 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 @@ -39,7 +39,7 @@ import javax.sound.midi.spi.SoundbankReader; * * @author Karl Helgason */ -public class DLSSoundbankReader extends SoundbankReader { +public final class DLSSoundbankReader extends SoundbankReader { public Soundbank getSoundbank(URL url) throws InvalidMidiDataException, IOException { diff --git a/jdk/src/share/classes/com/sun/media/sound/DataPusher.java b/jdk/src/share/classes/com/sun/media/sound/DataPusher.java index 2d4802521af..814a0150ba7 100644 --- a/jdk/src/share/classes/com/sun/media/sound/DataPusher.java +++ b/jdk/src/share/classes/com/sun/media/sound/DataPusher.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2013, 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 @@ -37,13 +37,13 @@ import javax.sound.sampled.*; * @author Florian Bomers */ -public class DataPusher implements Runnable { +public final class DataPusher implements Runnable { private static final int AUTO_CLOSE_TIME = 5000; private static final boolean DEBUG = false; - private SourceDataLine source = null; - private AudioFormat format = null; + private final SourceDataLine source; + private final AudioFormat format; // stream as source data private AudioInputStream ais = null; diff --git a/jdk/src/share/classes/com/sun/media/sound/DirectAudioDevice.java b/jdk/src/share/classes/com/sun/media/sound/DirectAudioDevice.java index 7b5e5339e36..d6556f65f80 100644 --- a/jdk/src/share/classes/com/sun/media/sound/DirectAudioDevice.java +++ b/jdk/src/share/classes/com/sun/media/sound/DirectAudioDevice.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2013, 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 @@ -42,7 +42,7 @@ import javax.sound.sampled.*; * * @author Florian Bomers */ -class DirectAudioDevice extends AbstractMixer { +final class DirectAudioDevice extends AbstractMixer { // CONSTANTS private static final int CLIP_BUFFER_TIME = 1000; // in milliseconds @@ -335,8 +335,8 @@ class DirectAudioDevice extends AbstractMixer { * but isFormatSupported() also returns true * for formats with wrong endianness. */ - private static class DirectDLI extends DataLine.Info { - AudioFormat[] hardwareFormats; + private static final class DirectDLI extends DataLine.Info { + final AudioFormat[] hardwareFormats; private DirectDLI(Class clazz, AudioFormat[] formatArray, AudioFormat[] hardwareFormatArray, @@ -370,12 +370,12 @@ class DirectAudioDevice extends AbstractMixer { * Private inner class as base class for direct lines */ private static class DirectDL extends AbstractDataLine implements EventDispatcher.LineMonitor { - protected int mixerIndex; - protected int deviceID; + protected final int mixerIndex; + protected final int deviceID; protected long id; protected int waitTime; protected volatile boolean flushing = false; - protected boolean isSource; // true for SourceDataLine, false for TargetDataLine + protected final boolean isSource; // true for SourceDataLine, false for TargetDataLine protected volatile long bytePosition; protected volatile boolean doIO = false; // true in between start() and stop() calls protected volatile boolean stoppedWritten = false; // true if a write occured in stopped state @@ -387,10 +387,10 @@ class DirectAudioDevice extends AbstractMixer { protected int softwareConversionSize = 0; protected AudioFormat hardwareFormat; - private Gain gainControl = new Gain(); - private Mute muteControl = new Mute(); - private Balance balanceControl = new Balance(); - private Pan panControl = new Pan(); + private final Gain gainControl = new Gain(); + private final Mute muteControl = new Mute(); + private final Balance balanceControl = new Balance(); + private final Pan panControl = new Pan(); private float leftGain, rightGain; protected volatile boolean noService = false; // do not run the nService method @@ -829,7 +829,7 @@ class DirectAudioDevice extends AbstractMixer { /////////////////// CONTROLS ///////////////////////////// - protected class Gain extends FloatControl { + protected final class Gain extends FloatControl { private float linearGain = 1.0f; @@ -862,7 +862,7 @@ class DirectAudioDevice extends AbstractMixer { } // class Gain - private class Mute extends BooleanControl { + private final class Mute extends BooleanControl { private Mute() { super(BooleanControl.Type.MUTE, false, "True", "False"); @@ -874,7 +874,7 @@ class DirectAudioDevice extends AbstractMixer { } } // class Mute - private class Balance extends FloatControl { + private final class Balance extends FloatControl { private Balance() { super(FloatControl.Type.BALANCE, -1.0f, 1.0f, (1.0f / 128.0f), -1, 0.0f, @@ -893,7 +893,7 @@ class DirectAudioDevice extends AbstractMixer { } // class Balance - private class Pan extends FloatControl { + private final class Pan extends FloatControl { private Pan() { super(FloatControl.Type.PAN, -1.0f, 1.0f, (1.0f / 128.0f), -1, 0.0f, @@ -918,7 +918,8 @@ class DirectAudioDevice extends AbstractMixer { /** * Private inner class representing a SourceDataLine */ - private static class DirectSDL extends DirectDL implements SourceDataLine { + private static final class DirectSDL extends DirectDL + implements SourceDataLine { // CONSTRUCTOR private DirectSDL(DataLine.Info info, @@ -934,7 +935,8 @@ class DirectAudioDevice extends AbstractMixer { /** * Private inner class representing a TargetDataLine */ - private static class DirectTDL extends DirectDL implements TargetDataLine { + private static final class DirectTDL extends DirectDL + implements TargetDataLine { // CONSTRUCTOR private DirectTDL(DataLine.Info info, @@ -1012,7 +1014,9 @@ class DirectAudioDevice extends AbstractMixer { * Private inner class representing a Clip * This clip is realized in software only */ - private static class DirectClip extends DirectDL implements Clip, Runnable, AutoClosingClip { + 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 @@ -1045,7 +1049,7 @@ class DirectAudioDevice extends AbstractMixer { byte[] newData = new byte[bufferSize]; System.arraycopy(data, offset, newData, 0, bufferSize); - open(format, data, bufferSize / format.getFrameSize()); + open(format, newData, bufferSize / format.getFrameSize()); } // this method does not copy the data array @@ -1443,7 +1447,7 @@ class DirectAudioDevice extends AbstractMixer { * which allows retrieval of the internal array */ private static class DirectBAOS extends ByteArrayOutputStream { - public DirectBAOS() { + DirectBAOS() { super(); } diff --git a/jdk/src/share/classes/com/sun/media/sound/DirectAudioDeviceProvider.java b/jdk/src/share/classes/com/sun/media/sound/DirectAudioDeviceProvider.java index 2f51ac44c09..c306dc78c66 100644 --- a/jdk/src/share/classes/com/sun/media/sound/DirectAudioDeviceProvider.java +++ b/jdk/src/share/classes/com/sun/media/sound/DirectAudioDeviceProvider.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2013, 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,8 +25,6 @@ package com.sun.media.sound; -import java.util.Vector; - import javax.sound.sampled.Mixer; import javax.sound.sampled.spi.MixerProvider; @@ -36,7 +34,7 @@ import javax.sound.sampled.spi.MixerProvider; * * @author Florian Bomers */ -public class DirectAudioDeviceProvider extends MixerProvider { +public final class DirectAudioDeviceProvider extends MixerProvider { // STATIC VARIABLES @@ -66,16 +64,17 @@ public class DirectAudioDeviceProvider extends MixerProvider { * Required public no-arg constructor. */ public DirectAudioDeviceProvider() { - //if (Printer.trace) Printer.trace("DirectAudioDeviceProvider: constructor"); - if (Platform.isDirectAudioEnabled()) { - init(); - } else { - infos = new DirectAudioDeviceInfo[0]; - devices = new DirectAudioDevice[0]; + synchronized (DirectAudioDeviceProvider.class) { + if (Platform.isDirectAudioEnabled()) { + init(); + } else { + infos = new DirectAudioDeviceInfo[0]; + devices = new DirectAudioDevice[0]; + } } } - private synchronized static void init() { + private static void init() { // get the number of input devices int numDevices = nGetNumDevices(); @@ -94,36 +93,39 @@ public class DirectAudioDeviceProvider extends MixerProvider { } public Mixer.Info[] getMixerInfo() { - Mixer.Info[] localArray = new Mixer.Info[infos.length]; - System.arraycopy(infos, 0, localArray, 0, infos.length); - return localArray; + synchronized (DirectAudioDeviceProvider.class) { + Mixer.Info[] localArray = new Mixer.Info[infos.length]; + System.arraycopy(infos, 0, localArray, 0, infos.length); + return localArray; + } } public Mixer getMixer(Mixer.Info info) { - // if the default device is asked, we provide the mixer - // with SourceDataLine's - if (info == null) { + synchronized (DirectAudioDeviceProvider.class) { + // if the default device is asked, we provide the mixer + // with SourceDataLine's + if (info == null) { + for (int i = 0; i < infos.length; i++) { + Mixer mixer = getDevice(infos[i]); + if (mixer.getSourceLineInfo().length > 0) { + return mixer; + } + } + } + // otherwise get the first mixer that matches + // the requested info object for (int i = 0; i < infos.length; i++) { - Mixer mixer = getDevice(infos[i]); - if (mixer.getSourceLineInfo().length > 0) { - return mixer; + if (infos[i].equals(info)) { + return getDevice(infos[i]); } } } - // otherwise get the first mixer that matches - // the requested info object - for (int i = 0; i < infos.length; i++) { - if (infos[i].equals(info)) { - return getDevice(infos[i]); - } - } - throw new IllegalArgumentException("Mixer " + info.toString() + " not supported by this provider."); } - private Mixer getDevice(DirectAudioDeviceInfo info) { + private static Mixer getDevice(DirectAudioDeviceInfo info) { int index = info.getIndex(); if (devices[index] == null) { devices[index] = new DirectAudioDevice(info); @@ -139,12 +141,12 @@ public class DirectAudioDeviceProvider extends MixerProvider { * making native references to a particular device. * This constructor is called from native. */ - static class DirectAudioDeviceInfo extends Mixer.Info { - private int index; - private int maxSimulLines; + static final class DirectAudioDeviceInfo extends Mixer.Info { + private final int index; + private final int maxSimulLines; // For ALSA, the deviceID contains the encoded card index, device index, and sub-device-index - private int deviceID; + private final int deviceID; private DirectAudioDeviceInfo(int index, int deviceID, int maxSimulLines, String name, String vendor, diff --git a/jdk/src/share/classes/com/sun/media/sound/EmergencySoundbank.java b/jdk/src/share/classes/com/sun/media/sound/EmergencySoundbank.java index 5271782d094..587d3ff7ebe 100644 --- a/jdk/src/share/classes/com/sun/media/sound/EmergencySoundbank.java +++ b/jdk/src/share/classes/com/sun/media/sound/EmergencySoundbank.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2013, 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 @@ -35,7 +35,7 @@ import javax.sound.sampled.AudioFormat; * * @author Karl Helgason */ -public class EmergencySoundbank { +public final class EmergencySoundbank { private final static String[] general_midi_instruments = { "Acoustic Grand Piano", diff --git a/jdk/src/share/classes/com/sun/media/sound/EventDispatcher.java b/jdk/src/share/classes/com/sun/media/sound/EventDispatcher.java index e6d1401b946..54b948af168 100644 --- a/jdk/src/share/classes/com/sun/media/sound/EventDispatcher.java +++ b/jdk/src/share/classes/com/sun/media/sound/EventDispatcher.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2013, 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,19 +25,15 @@ package com.sun.media.sound; -import java.util.EventObject; import java.util.ArrayList; import java.util.List; -import javax.sound.sampled.Clip; -import javax.sound.sampled.Line; -import javax.sound.sampled.LineEvent; -import javax.sound.sampled.LineListener; - +import javax.sound.midi.ControllerEventListener; +import javax.sound.midi.MetaEventListener; import javax.sound.midi.MetaMessage; import javax.sound.midi.ShortMessage; -import javax.sound.midi.MetaEventListener; -import javax.sound.midi.ControllerEventListener; +import javax.sound.sampled.LineEvent; +import javax.sound.sampled.LineListener; @@ -49,7 +45,7 @@ import javax.sound.midi.ControllerEventListener; * @author Kara Kytle * @author Florian Bomers */ -class EventDispatcher implements Runnable { +final class EventDispatcher implements Runnable { /** * time of inactivity until the auto closing clips @@ -61,7 +57,7 @@ class EventDispatcher implements Runnable { /** * List of events */ - private ArrayList eventQueue = new ArrayList(); + private final ArrayList eventQueue = new ArrayList(); /** @@ -73,12 +69,12 @@ class EventDispatcher implements Runnable { /* * support for auto-closing Clips */ - private ArrayList autoClosingClips = new ArrayList(); + private final ArrayList autoClosingClips = new ArrayList(); /* * support for monitoring data lines */ - private ArrayList lineMonitors = new ArrayList(); + private final ArrayList lineMonitors = new ArrayList(); /** * Approximate interval between calls to LineMonitor.checkLine @@ -105,7 +101,7 @@ class EventDispatcher implements Runnable { * Invoked when there is at least one event in the queue. * Implement this as a callback to process one event. */ - protected void processEvent(EventInfo eventInfo) { + void processEvent(EventInfo eventInfo) { int count = eventInfo.getListenerCount(); // process an LineEvent @@ -166,7 +162,7 @@ class EventDispatcher implements Runnable { * exclusive access over the code where an event is removed from the *queue. */ - protected void dispatchEvents() { + void dispatchEvents() { EventInfo eventInfo = null; @@ -388,8 +384,8 @@ class EventDispatcher implements Runnable { */ private class EventInfo { - private Object event; - private Object[] listeners; + private final Object event; + private final Object[] listeners; /** * Create a new instance of this event Info class @@ -421,8 +417,8 @@ class EventDispatcher implements Runnable { */ private class ClipInfo { - private AutoClosingClip clip; - private long expiration; + private final AutoClosingClip clip; + private final long expiration; /** * Create a new instance of this clip Info class diff --git a/jdk/src/share/classes/com/sun/media/sound/FFT.java b/jdk/src/share/classes/com/sun/media/sound/FFT.java index f9e56b6a20f..b378c8cc65d 100644 --- a/jdk/src/share/classes/com/sun/media/sound/FFT.java +++ b/jdk/src/share/classes/com/sun/media/sound/FFT.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2013, 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 @@ -31,11 +31,11 @@ package com.sun.media.sound; */ public final class FFT { - private double[] w; - private int fftFrameSize; - private int sign; - private int[] bitm_array; - private int fftFrameSize2; + private final double[] w; + private final int fftFrameSize; + private final int sign; + private final int[] bitm_array; + private final int fftFrameSize2; // Sign = -1 is FFT, 1 is IFFT (inverse FFT) // Data = Interlaced double array to be transformed. diff --git a/jdk/src/share/classes/com/sun/media/sound/FastShortMessage.java b/jdk/src/share/classes/com/sun/media/sound/FastShortMessage.java index 39f85da154c..54307f238a4 100644 --- a/jdk/src/share/classes/com/sun/media/sound/FastShortMessage.java +++ b/jdk/src/share/classes/com/sun/media/sound/FastShortMessage.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2013, 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 @@ -35,13 +35,13 @@ import javax.sound.midi.*; final class FastShortMessage extends ShortMessage { private int packedMsg; - public FastShortMessage(int packedMsg) throws InvalidMidiDataException { + FastShortMessage(int packedMsg) throws InvalidMidiDataException { this.packedMsg = packedMsg; getDataLength(packedMsg & 0xFF); // to check for validity } /** Creates a FastShortMessage from this ShortMessage */ - public FastShortMessage(ShortMessage msg) { + FastShortMessage(ShortMessage msg) { this.packedMsg = msg.getStatus() | (msg.getData1() << 8) | (msg.getData2() << 16); diff --git a/jdk/src/share/classes/com/sun/media/sound/JARSoundbankReader.java b/jdk/src/share/classes/com/sun/media/sound/JARSoundbankReader.java index 9c369a62706..32fc90ffbb7 100644 --- a/jdk/src/share/classes/com/sun/media/sound/JARSoundbankReader.java +++ b/jdk/src/share/classes/com/sun/media/sound/JARSoundbankReader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2013, 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 @@ -36,14 +36,16 @@ import javax.sound.midi.InvalidMidiDataException; import javax.sound.midi.Soundbank; import javax.sound.midi.spi.SoundbankReader; +import sun.reflect.misc.ReflectUtil; + /** - * JarSoundbankReader is used to read sounbank object from jar files. + * JarSoundbankReader is used to read soundbank object from jar files. * * @author Karl Helgason */ -public class JARSoundbankReader extends SoundbankReader { +public final class JARSoundbankReader extends SoundbankReader { - public boolean isZIP(URL url) { + private static boolean isZIP(URL url) { boolean ok = false; try { InputStream stream = url.openStream(); @@ -81,14 +83,14 @@ public class JARSoundbankReader extends SoundbankReader { while (line != null) { if (!line.startsWith("#")) { try { - Class c = Class.forName(line.trim(), true, ucl); - Object o = c.newInstance(); - if (o instanceof Soundbank) { + Class c = Class.forName(line.trim(), false, ucl); + if (Soundbank.class.isAssignableFrom(c)) { + Object o = ReflectUtil.newInstance(c); soundbanks.add((Soundbank) o); } - } catch (ClassNotFoundException e) { - } catch (InstantiationException e) { - } catch (IllegalAccessException e) { + } catch (ClassNotFoundException ignored) { + } catch (InstantiationException ignored) { + } catch (IllegalAccessException ignored) { } } line = r.readLine(); diff --git a/jdk/src/share/classes/com/sun/media/sound/JDK13Services.java b/jdk/src/share/classes/com/sun/media/sound/JDK13Services.java index f11b5e3e26f..85b1de618d6 100644 --- a/jdk/src/share/classes/com/sun/media/sound/JDK13Services.java +++ b/jdk/src/share/classes/com/sun/media/sound/JDK13Services.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2013, 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 @@ -31,16 +31,6 @@ import java.util.List; import java.util.Map; import java.util.Properties; -import javax.sound.sampled.spi.AudioFileReader; -import javax.sound.sampled.spi.AudioFileWriter; -import javax.sound.sampled.spi.FormatConversionProvider; -import javax.sound.sampled.spi.MixerProvider; - -import javax.sound.midi.spi.MidiFileReader; -import javax.sound.midi.spi.MidiFileWriter; -import javax.sound.midi.spi.SoundbankReader; -import javax.sound.midi.spi.MidiDeviceProvider; - import javax.sound.midi.Receiver; import javax.sound.midi.Sequencer; import javax.sound.midi.Synthesizer; @@ -62,7 +52,7 @@ import javax.sound.sampled.TargetDataLine; * * @author Matthias Pfisterer */ -public class JDK13Services { +public final class JDK13Services { /** The default for the length of the period to hold the cache. This value is given in milliseconds. It is equivalent to @@ -80,7 +70,7 @@ public class JDK13Services { Class objects of the provider type (MixerProvider, MidiDeviceProvider ...) are used as keys. The values are instances of ProviderCache. */ - private static Map providersCacheMap = new HashMap(); + private static final Map providersCacheMap = new HashMap(); /** The length of the period to hold the cache. diff --git a/jdk/src/share/classes/com/sun/media/sound/JSSecurityManager.java b/jdk/src/share/classes/com/sun/media/sound/JSSecurityManager.java index 8e7928dbe65..280e92aec68 100644 --- a/jdk/src/share/classes/com/sun/media/sound/JSSecurityManager.java +++ b/jdk/src/share/classes/com/sun/media/sound/JSSecurityManager.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2013, 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 @@ -47,7 +47,7 @@ import javax.sound.sampled.AudioPermission; * * @author Matthias Pfisterer */ -class JSSecurityManager { +final class JSSecurityManager { /** Prevent instantiation. */ @@ -73,30 +73,6 @@ class JSSecurityManager { } } - - static void loadLibrary(final String libName) { - try { - if (hasSecurityManager()) { - if(Printer.debug) Printer.debug("using security manager to load library"); - PrivilegedAction action = new PrivilegedAction() { - public Void run() { - System.loadLibrary(libName); - return null; - } - }; - AccessController.doPrivileged(action); - } else { - if(Printer.debug) Printer.debug("not using security manager to load library"); - System.loadLibrary(libName); - } - if (Printer.debug) Printer.debug("loaded library " + libName); - } catch (UnsatisfiedLinkError e2) { - if (Printer.err)Printer.err("UnsatisfiedLinkError loading native library " + libName); - throw(e2); - } - } - - static String getProperty(final String propertyName) { String propertyValue; if (hasSecurityManager()) { @@ -189,83 +165,13 @@ class JSSecurityManager { if(Printer.trace)Printer.trace("<< JSSecurityManager: loadPropertiesImpl() completed"); } - - private static ThreadGroup getTopmostThreadGroup() { - ThreadGroup topmostThreadGroup; - if(hasSecurityManager()) { - try { - // invoke the privileged action using 1.2 security - PrivilegedAction action = new PrivilegedAction() { - public ThreadGroup run() { - try { - return getTopmostThreadGroupImpl(); - } catch (Throwable t) { - return null; - } - } - }; - topmostThreadGroup = AccessController.doPrivileged(action); - if(Printer.debug)Printer.debug("Got topmost thread group with JDK 1.2 security"); - } catch (Exception e) { - if(Printer.debug)Printer.debug("Exception getting topmost thread group with JDK 1.2 security"); - // try without using JDK 1.2 security - topmostThreadGroup = getTopmostThreadGroupImpl(); - } - } else { - // not JDK 1.2 security, assume we already have permission - topmostThreadGroup = getTopmostThreadGroupImpl(); - } - return topmostThreadGroup; - } - - - private static ThreadGroup getTopmostThreadGroupImpl() { - if(Printer.trace)Printer.trace(">> JSSecurityManager: getTopmostThreadGroupImpl()"); - ThreadGroup g = Thread.currentThread().getThreadGroup(); - while ((g.getParent() != null) && (g.getParent().getParent() != null)) { - g = g.getParent(); - } - if(Printer.trace)Printer.trace("<< JSSecurityManager: getTopmostThreadGroupImpl() completed"); - return g; - } - - - /** Create a Thread in the topmost ThreadGroup. + /** Create a Thread in the current ThreadGroup. */ static Thread createThread(final Runnable runnable, final String threadName, final boolean isDaemon, final int priority, final boolean doStart) { - Thread thread = null; - if(hasSecurityManager()) { - PrivilegedAction action = new PrivilegedAction() { - public Thread run() { - try { - return createThreadImpl(runnable, threadName, - isDaemon, priority, - doStart); - } catch (Throwable t) { - return null; - } - } - }; - thread = AccessController.doPrivileged(action); - if(Printer.debug) Printer.debug("created thread with JDK 1.2 security"); - } else { - if(Printer.debug)Printer.debug("not using JDK 1.2 security"); - thread = createThreadImpl(runnable, threadName, isDaemon, priority, - doStart); - } - return thread; - } - - - private static Thread createThreadImpl(Runnable runnable, - String threadName, - boolean isDaemon, int priority, - boolean doStart) { - ThreadGroup threadGroup = getTopmostThreadGroupImpl(); - Thread thread = new Thread(threadGroup, runnable); + Thread thread = new Thread(runnable); if (threadName != null) { thread.setName(threadName); } @@ -279,7 +185,6 @@ class JSSecurityManager { return thread; } - static List getProviders(final Class providerClass) { List p = new ArrayList<>(); // ServiceLoader creates "lazy" iterator instance, so it doesn't, diff --git a/jdk/src/share/classes/com/sun/media/sound/JavaSoundAudioClip.java b/jdk/src/share/classes/com/sun/media/sound/JavaSoundAudioClip.java index 978fbcdae1f..0b2d9a33d52 100644 --- a/jdk/src/share/classes/com/sun/media/sound/JavaSoundAudioClip.java +++ b/jdk/src/share/classes/com/sun/media/sound/JavaSoundAudioClip.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2013, 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 @@ -28,25 +28,19 @@ package com.sun.media.sound; import java.io.IOException; import java.io.InputStream; import java.io.BufferedInputStream; -import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.applet.AudioClip; -import java.lang.InterruptedException; import javax.sound.sampled.AudioSystem; -import javax.sound.sampled.Mixer; import javax.sound.sampled.Clip; -import javax.sound.sampled.Control; import javax.sound.sampled.AudioInputStream; import javax.sound.sampled.AudioFormat; import javax.sound.sampled.DataLine; import javax.sound.sampled.SourceDataLine; import javax.sound.sampled.LineEvent; import javax.sound.sampled.LineListener; -import javax.sound.sampled.LineUnavailableException; import javax.sound.sampled.UnsupportedAudioFileException; - import javax.sound.midi.MidiSystem; import javax.sound.midi.MidiFileFormat; import javax.sound.midi.MetaMessage; @@ -63,7 +57,7 @@ import javax.sound.midi.MetaEventListener; * @author Florian Bomers */ -public class JavaSoundAudioClip implements AudioClip, MetaEventListener, LineListener { +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 @@ -476,7 +470,7 @@ public class JavaSoundAudioClip implements AudioClip, MetaEventListener, LineLis * which allows retrieval of the internal array */ private static class DirectBAOS extends ByteArrayOutputStream { - public DirectBAOS() { + DirectBAOS() { super(); } diff --git a/jdk/src/share/classes/com/sun/media/sound/MidiDeviceReceiverEnvelope.java b/jdk/src/share/classes/com/sun/media/sound/MidiDeviceReceiverEnvelope.java index 9a962bbd412..fb200208c86 100644 --- a/jdk/src/share/classes/com/sun/media/sound/MidiDeviceReceiverEnvelope.java +++ b/jdk/src/share/classes/com/sun/media/sound/MidiDeviceReceiverEnvelope.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2013, 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 @@ -33,7 +33,7 @@ import javax.sound.midi.*; * * @author Alex Menkov */ -public class MidiDeviceReceiverEnvelope implements MidiDeviceReceiver { +public final class MidiDeviceReceiverEnvelope implements MidiDeviceReceiver { private final MidiDevice device; private final Receiver receiver; diff --git a/jdk/src/share/classes/com/sun/media/sound/MidiDeviceTransmitterEnvelope.java b/jdk/src/share/classes/com/sun/media/sound/MidiDeviceTransmitterEnvelope.java index e20d430a042..eca630a6c8c 100644 --- a/jdk/src/share/classes/com/sun/media/sound/MidiDeviceTransmitterEnvelope.java +++ b/jdk/src/share/classes/com/sun/media/sound/MidiDeviceTransmitterEnvelope.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2013, 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 @@ -33,7 +33,7 @@ import javax.sound.midi.*; * * @author Alex Menkov */ -public class MidiDeviceTransmitterEnvelope implements MidiDeviceTransmitter { +public final class MidiDeviceTransmitterEnvelope implements MidiDeviceTransmitter { private final MidiDevice device; private final Transmitter transmitter; diff --git a/jdk/src/share/classes/com/sun/media/sound/MidiInDevice.java b/jdk/src/share/classes/com/sun/media/sound/MidiInDevice.java index 3867f2d51cc..373870f4c9e 100644 --- a/jdk/src/share/classes/com/sun/media/sound/MidiInDevice.java +++ b/jdk/src/share/classes/com/sun/media/sound/MidiInDevice.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2013, 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,9 +25,6 @@ package com.sun.media.sound; -import java.util.ArrayList; -import java.util.List; - import javax.sound.midi.*; @@ -39,7 +36,7 @@ import javax.sound.midi.*; * @author Kara Kytle * @author Florian Bomers */ -class MidiInDevice extends AbstractMidiDevice implements Runnable { +final class MidiInDevice extends AbstractMidiDevice implements Runnable { private Thread midiInThread = null; @@ -127,7 +124,7 @@ class MidiInDevice extends AbstractMidiDevice implements Runnable { * An own class to distinguish the class name from * the transmitter of other devices */ - private class MidiInTransmitter extends BasicTransmitter { + private final class MidiInTransmitter extends BasicTransmitter { private MidiInTransmitter() { super(); } diff --git a/jdk/src/share/classes/com/sun/media/sound/MidiInDeviceProvider.java b/jdk/src/share/classes/com/sun/media/sound/MidiInDeviceProvider.java index b7a391eef18..e15616f14f0 100644 --- a/jdk/src/share/classes/com/sun/media/sound/MidiInDeviceProvider.java +++ b/jdk/src/share/classes/com/sun/media/sound/MidiInDeviceProvider.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2013, 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 @@ -26,7 +26,6 @@ package com.sun.media.sound; import javax.sound.midi.MidiDevice; -import javax.sound.midi.spi.MidiDeviceProvider; /** @@ -35,15 +34,15 @@ import javax.sound.midi.spi.MidiDeviceProvider; * @author Kara Kytle * @author Florian Bomers */ -public class MidiInDeviceProvider extends AbstractMidiDeviceProvider { +public final class MidiInDeviceProvider extends AbstractMidiDeviceProvider { /** Cache of info objects for all MIDI output devices on the system. */ - static Info[] infos = null; + private static Info[] infos = null; /** Cache of open MIDI input devices on the system. */ - static MidiDevice[] devices = null; + private static MidiDevice[] devices = null; - private static boolean enabled; + private static final boolean enabled; // STATIC @@ -106,8 +105,8 @@ public class MidiInDeviceProvider extends AbstractMidiDeviceProvider { * previous instance may still exist and be open / in use / etc., * the new instance will not reflect that state... */ - static class MidiInDeviceInfo extends AbstractMidiDeviceProvider.Info { - private Class providerClass; + static final class MidiInDeviceInfo extends AbstractMidiDeviceProvider.Info { + private final Class providerClass; private MidiInDeviceInfo(int index, Class providerClass) { super(nGetName(index), nGetVendor(index), nGetDescription(index), nGetVersion(index), index); diff --git a/jdk/src/share/classes/com/sun/media/sound/MidiOutDevice.java b/jdk/src/share/classes/com/sun/media/sound/MidiOutDevice.java index a9193005e5f..4559c9b59e9 100644 --- a/jdk/src/share/classes/com/sun/media/sound/MidiOutDevice.java +++ b/jdk/src/share/classes/com/sun/media/sound/MidiOutDevice.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2013, 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 @@ -36,7 +36,7 @@ import javax.sound.midi.*; * @author Kara Kytle * @author Florian Bomers */ -class MidiOutDevice extends AbstractMidiDevice { +final class MidiOutDevice extends AbstractMidiDevice { // CONSTRUCTOR @@ -101,7 +101,7 @@ class MidiOutDevice extends AbstractMidiDevice { // INNER CLASSES - class MidiOutReceiver extends AbstractReceiver { + final class MidiOutReceiver extends AbstractReceiver { void implSend(final MidiMessage message, final long timeStamp) { final int length = message.getLength(); diff --git a/jdk/src/share/classes/com/sun/media/sound/MidiOutDeviceProvider.java b/jdk/src/share/classes/com/sun/media/sound/MidiOutDeviceProvider.java index baaee06c92a..ebe2880f026 100644 --- a/jdk/src/share/classes/com/sun/media/sound/MidiOutDeviceProvider.java +++ b/jdk/src/share/classes/com/sun/media/sound/MidiOutDeviceProvider.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2013, 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 @@ -26,7 +26,6 @@ package com.sun.media.sound; import javax.sound.midi.MidiDevice; -import javax.sound.midi.spi.MidiDeviceProvider; /** @@ -35,15 +34,15 @@ import javax.sound.midi.spi.MidiDeviceProvider; * @author Kara Kytle * @author Florian Bomers */ -public class MidiOutDeviceProvider extends AbstractMidiDeviceProvider { +public final class MidiOutDeviceProvider extends AbstractMidiDeviceProvider { /** Cache of info objects for all MIDI output devices on the system. */ - static Info[] infos = null; + private static Info[] infos = null; /** Cache of open MIDI output devices on the system. */ - static MidiDevice[] devices = null; + private static MidiDevice[] devices = null; - private static boolean enabled; + private final static boolean enabled; // STATIC @@ -104,8 +103,8 @@ public class MidiOutDeviceProvider extends AbstractMidiDeviceProvider { * previous instance may still exist and be open / in use / etc., * the new instance will not reflect that state... */ - static class MidiOutDeviceInfo extends AbstractMidiDeviceProvider.Info { - private Class providerClass; + static final class MidiOutDeviceInfo extends AbstractMidiDeviceProvider.Info { + private final Class providerClass; private MidiOutDeviceInfo(int index, Class providerClass) { super(nGetName(index), nGetVendor(index), nGetDescription(index), nGetVersion(index), index); diff --git a/jdk/src/share/classes/com/sun/media/sound/MidiUtils.java b/jdk/src/share/classes/com/sun/media/sound/MidiUtils.java index 281b40e20bf..a3f62efd29e 100644 --- a/jdk/src/share/classes/com/sun/media/sound/MidiUtils.java +++ b/jdk/src/share/classes/com/sun/media/sound/MidiUtils.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2013, 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 @@ -36,12 +36,17 @@ import java.util.ArrayList; * * @author Florian Bomers */ -public class MidiUtils { +public final class MidiUtils { public final static int DEFAULT_TEMPO_MPQ = 500000; // 120bpm public final static int META_END_OF_TRACK_TYPE = 0x2F; public final static int META_TEMPO_TYPE = 0x51; + /** + * Suppresses default constructor, ensuring non-instantiability. + */ + private MidiUtils() { + } /** return true if the passed message is Meta End Of Track */ public static boolean isMetaEndOfTrack(MidiMessage midiMsg) { @@ -262,7 +267,7 @@ public class MidiUtils { } - public static class TempoCache { + public static final class TempoCache { long[] ticks; int[] tempos; // in MPQ // index in ticks/tempos at the snapshot diff --git a/jdk/src/share/classes/com/sun/media/sound/ModelByteBuffer.java b/jdk/src/share/classes/com/sun/media/sound/ModelByteBuffer.java index 522fe66c592..9ba89f20491 100644 --- a/jdk/src/share/classes/com/sun/media/sound/ModelByteBuffer.java +++ b/jdk/src/share/classes/com/sun/media/sound/ModelByteBuffer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2013, 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 @@ -38,7 +38,7 @@ import java.util.Collection; * * @author Karl Helgason */ -public class ModelByteBuffer { +public final class ModelByteBuffer { private ModelByteBuffer root = this; private File file; @@ -49,12 +49,12 @@ public class ModelByteBuffer { private class RandomFileInputStream extends InputStream { - private RandomAccessFile raf; + private final RandomAccessFile raf; private long left; private long mark = 0; private long markleft = 0; - public RandomFileInputStream() throws IOException { + RandomFileInputStream() throws IOException { raf = new RandomAccessFile(root.file, "r"); raf.seek(root.fileoffset + arrayOffset()); left = capacity(); diff --git a/jdk/src/share/classes/com/sun/media/sound/ModelByteBufferWavetable.java b/jdk/src/share/classes/com/sun/media/sound/ModelByteBufferWavetable.java index 3d411b4e5c1..33515f400d8 100644 --- a/jdk/src/share/classes/com/sun/media/sound/ModelByteBufferWavetable.java +++ b/jdk/src/share/classes/com/sun/media/sound/ModelByteBufferWavetable.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2013, 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 @@ -36,18 +36,18 @@ import javax.sound.sampled.AudioFormat.Encoding; * * @author Karl Helgason */ -public class ModelByteBufferWavetable implements ModelWavetable { +public final class ModelByteBufferWavetable implements ModelWavetable { private class Buffer8PlusInputStream extends InputStream { - private boolean bigendian; - private int framesize_pc; + private final boolean bigendian; + private final int framesize_pc; int pos = 0; int pos2 = 0; int markpos = 0; int markpos2 = 0; - public Buffer8PlusInputStream() { + Buffer8PlusInputStream() { framesize_pc = format.getFrameSize() / format.getChannels(); bigendian = format.isBigEndian(); } @@ -127,7 +127,7 @@ public class ModelByteBufferWavetable implements ModelWavetable { private float loopStart = -1; private float loopLength = -1; - private ModelByteBuffer buffer; + private final ModelByteBuffer buffer; private ModelByteBuffer buffer8 = null; private AudioFormat format = null; private float pitchcorrection = 0; diff --git a/jdk/src/share/classes/com/sun/media/sound/ModelConnectionBlock.java b/jdk/src/share/classes/com/sun/media/sound/ModelConnectionBlock.java index 3f21aa0b9d6..05a438fac8e 100644 --- a/jdk/src/share/classes/com/sun/media/sound/ModelConnectionBlock.java +++ b/jdk/src/share/classes/com/sun/media/sound/ModelConnectionBlock.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2013, 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 @@ -34,7 +34,7 @@ import java.util.Arrays; * * @author Karl Helgason */ -public class ModelConnectionBlock { +public final class ModelConnectionBlock { // // source1 * source2 * scale -> destination diff --git a/jdk/src/share/classes/com/sun/media/sound/ModelDestination.java b/jdk/src/share/classes/com/sun/media/sound/ModelDestination.java index 53cd0666d6f..f1fe44e5c66 100644 --- a/jdk/src/share/classes/com/sun/media/sound/ModelDestination.java +++ b/jdk/src/share/classes/com/sun/media/sound/ModelDestination.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2013, 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 @@ -30,7 +30,7 @@ package com.sun.media.sound; * * @author Karl Helgason */ -public class ModelDestination { +public final class ModelDestination { public static final ModelIdentifier DESTINATION_NONE = null; public static final ModelIdentifier DESTINATION_KEYNUMBER diff --git a/jdk/src/share/classes/com/sun/media/sound/ModelIdentifier.java b/jdk/src/share/classes/com/sun/media/sound/ModelIdentifier.java index 4996c4605cd..2e07fa13efc 100644 --- a/jdk/src/share/classes/com/sun/media/sound/ModelIdentifier.java +++ b/jdk/src/share/classes/com/sun/media/sound/ModelIdentifier.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2013, 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 @@ -30,7 +30,7 @@ package com.sun.media.sound; * * @author Karl Helgason */ -public class ModelIdentifier { +public final class ModelIdentifier { /* * Object Variable diff --git a/jdk/src/share/classes/com/sun/media/sound/ModelInstrument.java b/jdk/src/share/classes/com/sun/media/sound/ModelInstrument.java index 75c5a75f5a2..27e82c9fa6e 100644 --- a/jdk/src/share/classes/com/sun/media/sound/ModelInstrument.java +++ b/jdk/src/share/classes/com/sun/media/sound/ModelInstrument.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2013, 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,7 @@ public abstract class ModelInstrument extends Instrument { } // Get General MIDI 2 Alias patch for this instrument. - public Patch getPatchAlias() { + public final Patch getPatchAlias() { Patch patch = getPatch(); int program = patch.getProgram(); int bank = patch.getBank(); @@ -87,7 +87,7 @@ public abstract class ModelInstrument extends Instrument { // Return name of all the keys. // This information is generated from ModelPerformer.getName() // returned from getPerformers(). - public String[] getKeys() { + public final String[] getKeys() { String[] keys = new String[128]; for (ModelPerformer performer : getPerformers()) { for (int k = performer.getKeyFrom(); k <= performer.getKeyTo(); k++) { @@ -104,7 +104,7 @@ public abstract class ModelInstrument extends Instrument { // Return what channels this instrument will probably response // on General MIDI synthesizer. - public boolean[] getChannels() { + public final boolean[] getChannels() { boolean percussion = false; if (getPatch() instanceof ModelPatch) percussion = ((ModelPatch)getPatch()).isPercussion(); diff --git a/jdk/src/share/classes/com/sun/media/sound/ModelInstrumentComparator.java b/jdk/src/share/classes/com/sun/media/sound/ModelInstrumentComparator.java index 40ca6c4aa7f..3eb68d9ea24 100644 --- a/jdk/src/share/classes/com/sun/media/sound/ModelInstrumentComparator.java +++ b/jdk/src/share/classes/com/sun/media/sound/ModelInstrumentComparator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2013, 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 @@ -34,7 +34,7 @@ import javax.sound.midi.Patch; * * @author Karl Helgason */ -public class ModelInstrumentComparator implements Comparator { +public final class ModelInstrumentComparator implements Comparator { public int compare(Instrument arg0, Instrument arg1) { Patch p0 = arg0.getPatch(); diff --git a/jdk/src/share/classes/com/sun/media/sound/ModelMappedInstrument.java b/jdk/src/share/classes/com/sun/media/sound/ModelMappedInstrument.java index d7cacd9620a..ed0e978a869 100644 --- a/jdk/src/share/classes/com/sun/media/sound/ModelMappedInstrument.java +++ b/jdk/src/share/classes/com/sun/media/sound/ModelMappedInstrument.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2013, 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 @@ -33,9 +33,9 @@ import javax.sound.sampled.AudioFormat; * * @author Karl Helgason */ -public class ModelMappedInstrument extends ModelInstrument { +public final class ModelMappedInstrument extends ModelInstrument { - private ModelInstrument ins; + private final ModelInstrument ins; public ModelMappedInstrument(ModelInstrument ins, Patch patch) { super(ins.getSoundbank(), patch, ins.getName(), ins.getDataClass()); diff --git a/jdk/src/share/classes/com/sun/media/sound/ModelPatch.java b/jdk/src/share/classes/com/sun/media/sound/ModelPatch.java index 3cb8f087160..d8cfc611c86 100644 --- a/jdk/src/share/classes/com/sun/media/sound/ModelPatch.java +++ b/jdk/src/share/classes/com/sun/media/sound/ModelPatch.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2013, 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 @@ -33,7 +33,7 @@ import javax.sound.midi.Patch; * * @author Karl Helgason */ -public class ModelPatch extends Patch { +public final class ModelPatch extends Patch { private boolean percussion = false; diff --git a/jdk/src/share/classes/com/sun/media/sound/ModelPerformer.java b/jdk/src/share/classes/com/sun/media/sound/ModelPerformer.java index 289f1e31ea8..661070c0d74 100644 --- a/jdk/src/share/classes/com/sun/media/sound/ModelPerformer.java +++ b/jdk/src/share/classes/com/sun/media/sound/ModelPerformer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2013, 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 @@ -33,9 +33,9 @@ import java.util.List; * * @author Karl Helgason */ -public class ModelPerformer { +public final class ModelPerformer { - private List oscillators = new ArrayList(); + private final List oscillators = new ArrayList(); private List connectionBlocks = new ArrayList(); private int keyFrom = 0; diff --git a/jdk/src/share/classes/com/sun/media/sound/ModelSource.java b/jdk/src/share/classes/com/sun/media/sound/ModelSource.java index b7d8cf8e9dc..f64f9c8b364 100644 --- a/jdk/src/share/classes/com/sun/media/sound/ModelSource.java +++ b/jdk/src/share/classes/com/sun/media/sound/ModelSource.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2013, 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 @@ -30,7 +30,7 @@ package com.sun.media.sound; * * @author Karl Helgason */ -public class ModelSource { +public final class ModelSource { public static final ModelIdentifier SOURCE_NONE = null; public static final ModelIdentifier SOURCE_NOTEON_KEYNUMBER = diff --git a/jdk/src/share/classes/com/sun/media/sound/ModelStandardDirector.java b/jdk/src/share/classes/com/sun/media/sound/ModelStandardDirector.java index f5a00629a5a..e64d94cd472 100644 --- a/jdk/src/share/classes/com/sun/media/sound/ModelStandardDirector.java +++ b/jdk/src/share/classes/com/sun/media/sound/ModelStandardDirector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2013, 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 @@ -30,7 +30,7 @@ package com.sun.media.sound; * * @author Karl Helgason */ -public class ModelStandardDirector implements ModelDirector { +public final class ModelStandardDirector implements ModelDirector { ModelPerformer[] performers; ModelDirectedPlayer player; diff --git a/jdk/src/share/classes/com/sun/media/sound/ModelStandardIndexedDirector.java b/jdk/src/share/classes/com/sun/media/sound/ModelStandardIndexedDirector.java index d5181e39cee..a5171eb1fce 100644 --- a/jdk/src/share/classes/com/sun/media/sound/ModelStandardIndexedDirector.java +++ b/jdk/src/share/classes/com/sun/media/sound/ModelStandardIndexedDirector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2013, 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 @@ -30,7 +30,7 @@ package com.sun.media.sound; * * @author Karl Helgason */ -public class ModelStandardIndexedDirector implements ModelDirector { +public final class ModelStandardIndexedDirector implements ModelDirector { ModelPerformer[] performers; ModelDirectedPlayer player; diff --git a/jdk/src/share/classes/com/sun/media/sound/ModelStandardTransform.java b/jdk/src/share/classes/com/sun/media/sound/ModelStandardTransform.java index e857fdab4a6..c3e7fcb9b9b 100644 --- a/jdk/src/share/classes/com/sun/media/sound/ModelStandardTransform.java +++ b/jdk/src/share/classes/com/sun/media/sound/ModelStandardTransform.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2013, 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 @@ -36,7 +36,7 @@ package com.sun.media.sound; * * @author Karl Helgason */ -public class ModelStandardTransform implements ModelTransform { +public final class ModelStandardTransform implements ModelTransform { public static final boolean DIRECTION_MIN2MAX = false; public static final boolean DIRECTION_MAX2MIN = true; diff --git a/jdk/src/share/classes/com/sun/media/sound/PCMtoPCMCodec.java b/jdk/src/share/classes/com/sun/media/sound/PCMtoPCMCodec.java index 7fd9e7354a5..9a4f1a874b3 100644 --- a/jdk/src/share/classes/com/sun/media/sound/PCMtoPCMCodec.java +++ b/jdk/src/share/classes/com/sun/media/sound/PCMtoPCMCodec.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2013, 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,14 +25,12 @@ package com.sun.media.sound; -import java.io.InputStream; import java.io.IOException; - import java.util.Vector; import javax.sound.sampled.AudioFormat; -import javax.sound.sampled.AudioSystem; import javax.sound.sampled.AudioInputStream; +import javax.sound.sampled.AudioSystem; /** @@ -40,7 +38,7 @@ import javax.sound.sampled.AudioInputStream; * * @author Jan Borgersen */ -public class PCMtoPCMCodec extends SunCodec { +public final class PCMtoPCMCodec extends SunCodec { private static final AudioFormat.Encoding[] inputEncodings = { @@ -356,7 +354,7 @@ public class PCMtoPCMCodec extends SunCodec { private final int PCM_UNSIGNED_BE2SIGNED_LE = 7; private final int PCM_SIGNED_BE2UNSIGNED_LE = 8; - private int sampleSizeInBytes = 0; + private final int sampleSizeInBytes; private int conversionType = 0; diff --git a/jdk/src/share/classes/com/sun/media/sound/Platform.java b/jdk/src/share/classes/com/sun/media/sound/Platform.java index b24cd388ba4..766e485f120 100644 --- a/jdk/src/share/classes/com/sun/media/sound/Platform.java +++ b/jdk/src/share/classes/com/sun/media/sound/Platform.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2013, 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,8 @@ package com.sun.media.sound; +import java.security.AccessController; +import java.security.PrivilegedAction; import java.util.StringTokenizer; @@ -35,7 +37,7 @@ import java.util.StringTokenizer; * @author Kara Kytle * @author Florian Bomers */ -class Platform { +final class Platform { // STATIC FINAL CHARACTERISTICS @@ -157,7 +159,13 @@ class Platform { try { // load the main library - JSSecurityManager.loadLibrary(libNameMain); + AccessController.doPrivileged(new PrivilegedAction() { + @Override + public Void run() { + System.loadLibrary(libNameMain); + return null; + } + }); // just for the heck of it... loadedLibs |= LIB_MAIN; } catch (SecurityException e) { @@ -171,9 +179,16 @@ class Platform { // the string is the libraries, separated by white space StringTokenizer st = new StringTokenizer(extraLibs); while (st.hasMoreTokens()) { - String lib = st.nextToken(); + final String lib = st.nextToken(); try { - JSSecurityManager.loadLibrary(lib); + AccessController.doPrivileged(new PrivilegedAction() { + @Override + public Void run() { + System.loadLibrary(lib); + return null; + } + }); + if (lib.equals(libNameALSA)) { loadedLibs |= LIB_ALSA; if (Printer.debug) Printer.debug("Loaded ALSA lib successfully."); diff --git a/jdk/src/share/classes/com/sun/media/sound/PortMixer.java b/jdk/src/share/classes/com/sun/media/sound/PortMixer.java index a85d54fbcf5..2ef76cbf488 100644 --- a/jdk/src/share/classes/com/sun/media/sound/PortMixer.java +++ b/jdk/src/share/classes/com/sun/media/sound/PortMixer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2013, 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,7 +41,7 @@ import javax.sound.sampled.FloatControl; * * @author Florian Bomers */ -class PortMixer extends AbstractMixer { +final class PortMixer extends AbstractMixer { // CONSTANTS private static final int SRC_UNKNOWN = 0x01; @@ -228,8 +228,10 @@ class PortMixer extends AbstractMixer { /** * Private inner class representing a Port for the PortMixer. */ - private static class PortMixerPort extends AbstractLine implements Port { - private int portIndex; + private static final class PortMixerPort extends AbstractLine + implements Port { + + private final int portIndex; private long id; // CONSTRUCTOR @@ -342,9 +344,9 @@ class PortMixer extends AbstractMixer { /** * Private inner class representing a BooleanControl for PortMixerPort */ - private static class BoolCtrl extends BooleanControl { + private static final class BoolCtrl extends BooleanControl { // the handle to the native control function - private long controlID; + private final long controlID; private boolean closed = false; private static BooleanControl.Type createType(String name) { @@ -386,7 +388,7 @@ class PortMixer extends AbstractMixer { /** * inner class for custom types */ - private static class BCT extends BooleanControl.Type { + private static final class BCT extends BooleanControl.Type { private BCT(String name) { super(name); } @@ -396,7 +398,7 @@ class PortMixer extends AbstractMixer { /** * Private inner class representing a CompoundControl for PortMixerPort */ - private static class CompCtrl extends CompoundControl { + private static final class CompCtrl extends CompoundControl { private CompCtrl(String name, Control[] controls) { super(new CCT(name), controls); } @@ -404,7 +406,7 @@ class PortMixer extends AbstractMixer { /** * inner class for custom compound control types */ - private static class CCT extends CompoundControl.Type { + private static final class CCT extends CompoundControl.Type { private CCT(String name) { super(name); } @@ -414,9 +416,9 @@ class PortMixer extends AbstractMixer { /** * Private inner class representing a BooleanControl for PortMixerPort */ - private static class FloatCtrl extends FloatControl { + private static final class FloatCtrl extends FloatControl { // the handle to the native control function - private long controlID; + private final long controlID; private boolean closed = false; // predefined float control types. See also Ports.h @@ -462,7 +464,7 @@ class PortMixer extends AbstractMixer { /** * inner class for custom types */ - private static class FCT extends FloatControl.Type { + private static final class FCT extends FloatControl.Type { private FCT(String name) { super(name); } @@ -472,7 +474,7 @@ class PortMixer extends AbstractMixer { /** * Private inner class representing a port info */ - private static class PortInfo extends Port.Info { + private static final class PortInfo extends Port.Info { private PortInfo(String name, boolean isSource) { super(Port.class, name, isSource); } diff --git a/jdk/src/share/classes/com/sun/media/sound/PortMixerProvider.java b/jdk/src/share/classes/com/sun/media/sound/PortMixerProvider.java index 8f63256e596..a8ef40f8a0f 100644 --- a/jdk/src/share/classes/com/sun/media/sound/PortMixerProvider.java +++ b/jdk/src/share/classes/com/sun/media/sound/PortMixerProvider.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2013, 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,8 +25,6 @@ package com.sun.media.sound; -import java.util.Vector; - import javax.sound.sampled.Mixer; import javax.sound.sampled.spi.MixerProvider; @@ -36,7 +34,7 @@ import javax.sound.sampled.spi.MixerProvider; * * @author Florian Bomers */ -public class PortMixerProvider extends MixerProvider { +public final class PortMixerProvider extends MixerProvider { // STATIC VARIABLES @@ -66,16 +64,17 @@ public class PortMixerProvider extends MixerProvider { * Required public no-arg constructor. */ public PortMixerProvider() { - //if (Printer.trace) Printer.trace("PortMixerProvider: constructor"); - if (Platform.isPortsEnabled()) { - init(); - } else { - infos = new PortMixerInfo[0]; - devices = new PortMixer[0]; + synchronized (PortMixerProvider.class) { + if (Platform.isPortsEnabled()) { + init(); + } else { + infos = new PortMixerInfo[0]; + devices = new PortMixer[0]; + } } } - private static synchronized void init() { + private static void init() { // get the number of input devices int numDevices = nGetNumDevices(); @@ -95,23 +94,28 @@ public class PortMixerProvider extends MixerProvider { } public Mixer.Info[] getMixerInfo() { - Mixer.Info[] localArray = new Mixer.Info[infos.length]; - System.arraycopy(infos, 0, localArray, 0, infos.length); - return localArray; + synchronized (PortMixerProvider.class) { + Mixer.Info[] localArray = new Mixer.Info[infos.length]; + System.arraycopy(infos, 0, localArray, 0, infos.length); + return localArray; + } } public Mixer getMixer(Mixer.Info info) { - for (int i = 0; i < infos.length; i++) { - if (infos[i].equals(info)) { - return getDevice(infos[i]); + synchronized (PortMixerProvider.class) { + for (int i = 0; i < infos.length; i++) { + if (infos[i].equals(info)) { + return getDevice(infos[i]); + } } } - throw new IllegalArgumentException("Mixer " + info.toString() + " not supported by this provider."); + throw new IllegalArgumentException("Mixer " + info.toString() + + " not supported by this provider."); } - private Mixer getDevice(PortMixerInfo info) { + private static Mixer getDevice(PortMixerInfo info) { int index = info.getIndex(); if (devices[index] == null) { devices[index] = new PortMixer(info); @@ -127,8 +131,8 @@ public class PortMixerProvider extends MixerProvider { * making native references to a particular device. * This constructor is called from native. */ - static class PortMixerInfo extends Mixer.Info { - private int index; + static final class PortMixerInfo extends Mixer.Info { + private final int index; private PortMixerInfo(int index, String name, String vendor, String description, String version) { super("Port " + name, vendor, description, version); diff --git a/jdk/src/share/classes/com/sun/media/sound/Printer.java b/jdk/src/share/classes/com/sun/media/sound/Printer.java index 33570e5df54..7d50b72bf7f 100644 --- a/jdk/src/share/classes/com/sun/media/sound/Printer.java +++ b/jdk/src/share/classes/com/sun/media/sound/Printer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2013, 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 @@ -32,7 +32,7 @@ package com.sun.media.sound; * @author David Rivas * @author Kara Kytle */ -class Printer { +final class Printer { static final boolean err = false; static final boolean debug = false; @@ -68,6 +68,12 @@ class Printer { release = on; }*/ + /** + * Suppresses default constructor, ensuring non-instantiability. + */ + private Printer() { + } + public static void err(String str) { if (err) diff --git a/jdk/src/share/classes/com/sun/media/sound/RIFFInvalidDataException.java b/jdk/src/share/classes/com/sun/media/sound/RIFFInvalidDataException.java index fd2ce1d311c..195ceedde08 100644 --- a/jdk/src/share/classes/com/sun/media/sound/RIFFInvalidDataException.java +++ b/jdk/src/share/classes/com/sun/media/sound/RIFFInvalidDataException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2013, 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 @@ -29,7 +29,7 @@ package com.sun.media.sound; * * @author Karl Helgason */ -public class RIFFInvalidDataException extends InvalidDataException { +public final class RIFFInvalidDataException extends InvalidDataException { private static final long serialVersionUID = 1L; diff --git a/jdk/src/share/classes/com/sun/media/sound/RIFFInvalidFormatException.java b/jdk/src/share/classes/com/sun/media/sound/RIFFInvalidFormatException.java index 925c579803e..7b8d755509f 100644 --- a/jdk/src/share/classes/com/sun/media/sound/RIFFInvalidFormatException.java +++ b/jdk/src/share/classes/com/sun/media/sound/RIFFInvalidFormatException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2013, 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 @@ -30,7 +30,7 @@ package com.sun.media.sound; * * @author Karl Helgason */ -public class RIFFInvalidFormatException extends InvalidFormatException { +public final class RIFFInvalidFormatException extends InvalidFormatException { private static final long serialVersionUID = 1L; diff --git a/jdk/src/share/classes/com/sun/media/sound/RIFFReader.java b/jdk/src/share/classes/com/sun/media/sound/RIFFReader.java index 8e73675bf05..7969a5d4fce 100644 --- a/jdk/src/share/classes/com/sun/media/sound/RIFFReader.java +++ b/jdk/src/share/classes/com/sun/media/sound/RIFFReader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2013, 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 @@ -33,11 +33,11 @@ import java.io.InputStream; * * @author Karl Helgason */ -public class RIFFReader extends InputStream { +public final class RIFFReader extends InputStream { - private RIFFReader root; + private final RIFFReader root; private long filepointer = 0; - private String fourcc; + private final String fourcc; private String riff_type = null; private long ckSize = 0; private InputStream stream; diff --git a/jdk/src/share/classes/com/sun/media/sound/RIFFWriter.java b/jdk/src/share/classes/com/sun/media/sound/RIFFWriter.java index 5f91ffa90f4..a417d6a16dc 100644 --- a/jdk/src/share/classes/com/sun/media/sound/RIFFWriter.java +++ b/jdk/src/share/classes/com/sun/media/sound/RIFFWriter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2013, 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 @@ -35,7 +35,7 @@ import java.io.RandomAccessFile; * * @author Karl Helgason */ -public class RIFFWriter extends OutputStream { +public final class RIFFWriter extends OutputStream { private interface RandomAccessWriter { @@ -60,11 +60,11 @@ public class RIFFWriter extends OutputStream { RandomAccessFile raf; - public RandomAccessFileWriter(File file) throws FileNotFoundException { + RandomAccessFileWriter(File file) throws FileNotFoundException { this.raf = new RandomAccessFile(file, "rw"); } - public RandomAccessFileWriter(String name) throws FileNotFoundException { + RandomAccessFileWriter(String name) throws FileNotFoundException { this.raf = new RandomAccessFile(name, "rw"); } @@ -107,9 +107,9 @@ public class RIFFWriter extends OutputStream { int length = 0; int pos = 0; byte[] s; - OutputStream stream; + final OutputStream stream; - public RandomAccessByteWriter(OutputStream stream) { + RandomAccessByteWriter(OutputStream stream) { this.stream = stream; } @@ -163,8 +163,8 @@ public class RIFFWriter extends OutputStream { } private int chunktype = 0; // 0=RIFF, 1=LIST; 2=CHUNK private RandomAccessWriter raf; - private long chunksizepointer; - private long startpointer; + private final long chunksizepointer; + private final long startpointer; private RIFFWriter childchunk = null; private boolean open = true; private boolean writeoverride = false; diff --git a/jdk/src/share/classes/com/sun/media/sound/RealTimeSequencer.java b/jdk/src/share/classes/com/sun/media/sound/RealTimeSequencer.java index 93b7b0612eb..168b1b3656d 100644 --- a/jdk/src/share/classes/com/sun/media/sound/RealTimeSequencer.java +++ b/jdk/src/share/classes/com/sun/media/sound/RealTimeSequencer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2013, 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,14 +25,13 @@ package com.sun.media.sound; -import java.io.ByteArrayOutputStream; -import java.io.ByteArrayInputStream; -import java.io.DataOutputStream; import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; import java.util.List; +import java.util.Map; +import java.util.WeakHashMap; import javax.sound.midi.*; @@ -46,7 +45,8 @@ import javax.sound.midi.*; /* TODO: * - rename PlayThread to PlayEngine (because isn't a thread) */ -class RealTimeSequencer extends AbstractMidiDevice implements Sequencer, AutoConnectSequencer { +final class RealTimeSequencer extends AbstractMidiDevice + implements Sequencer, AutoConnectSequencer { // STATIC VARIABLES @@ -58,7 +58,8 @@ class RealTimeSequencer extends AbstractMidiDevice implements Sequencer, AutoCon * Event Dispatcher thread. Should be using a shared event * dispatcher instance with a factory in EventDispatcher */ - private static final EventDispatcher eventDispatcher; + private static final Map dispatchers = + new WeakHashMap<>(); /** * All RealTimeSequencers share this info object. @@ -66,11 +67,11 @@ class RealTimeSequencer extends AbstractMidiDevice implements Sequencer, AutoCon static final RealTimeSequencerInfo info = new RealTimeSequencerInfo(); - private static Sequencer.SyncMode[] masterSyncModes = { Sequencer.SyncMode.INTERNAL_CLOCK }; - private static Sequencer.SyncMode[] slaveSyncModes = { Sequencer.SyncMode.NO_SYNC }; + private static final Sequencer.SyncMode[] masterSyncModes = { Sequencer.SyncMode.INTERNAL_CLOCK }; + private static final Sequencer.SyncMode[] slaveSyncModes = { Sequencer.SyncMode.NO_SYNC }; - private static Sequencer.SyncMode masterSyncMode = Sequencer.SyncMode.INTERNAL_CLOCK; - private static Sequencer.SyncMode slaveSyncMode = Sequencer.SyncMode.NO_SYNC; + private static final Sequencer.SyncMode masterSyncMode = Sequencer.SyncMode.INTERNAL_CLOCK; + private static final Sequencer.SyncMode slaveSyncMode = Sequencer.SyncMode.NO_SYNC; /** @@ -100,7 +101,7 @@ class RealTimeSequencer extends AbstractMidiDevice implements Sequencer, AutoCon private boolean[] trackSolo = null; /** tempo cache for getMicrosecondPosition */ - private MidiUtils.TempoCache tempoCache = new MidiUtils.TempoCache(); + private final MidiUtils.TempoCache tempoCache = new MidiUtils.TempoCache(); /** * True if the sequence is running. @@ -121,7 +122,7 @@ class RealTimeSequencer extends AbstractMidiDevice implements Sequencer, AutoCon /** * List of tracks to which we're recording */ - private List recordingTracks = new ArrayList(); + private final List recordingTracks = new ArrayList(); private long loopStart = 0; @@ -132,13 +133,13 @@ class RealTimeSequencer extends AbstractMidiDevice implements Sequencer, AutoCon /** * Meta event listeners */ - private ArrayList metaEventListeners = new ArrayList(); + private final ArrayList metaEventListeners = new ArrayList(); /** * Control change listeners */ - private ArrayList controllerEventListeners = new ArrayList(); + private final ArrayList controllerEventListeners = new ArrayList(); /** automatic connection support */ @@ -151,16 +152,9 @@ class RealTimeSequencer extends AbstractMidiDevice implements Sequencer, AutoCon Receiver autoConnectedReceiver = null; - static { - // create and start the global event thread - eventDispatcher = new EventDispatcher(); - eventDispatcher.start(); - } - - /* ****************************** CONSTRUCTOR ****************************** */ - protected RealTimeSequencer() throws MidiUnavailableException { + RealTimeSequencer() throws MidiUnavailableException { super(info); if (Printer.trace) Printer.trace(">> RealTimeSequencer CONSTRUCTOR"); @@ -574,7 +568,7 @@ class RealTimeSequencer extends AbstractMidiDevice implements Sequencer, AutoCon return returnedModes; } - protected int getTrackCount() { + int getTrackCount() { Sequence seq = getSequence(); if (seq != null) { // $$fb wish there was a nicer way to get the number of tracks... @@ -872,7 +866,7 @@ class RealTimeSequencer extends AbstractMidiDevice implements Sequencer, AutoCon if (Printer.trace) Printer.trace("<< RealTimeSequencer: implClose() completed"); } - protected void implStart() { + void implStart() { if (Printer.trace) Printer.trace(">> RealTimeSequencer: implStart()"); if (playThread == null) { @@ -889,7 +883,7 @@ class RealTimeSequencer extends AbstractMidiDevice implements Sequencer, AutoCon } - protected void implStop() { + void implStop() { if (Printer.trace) Printer.trace(">> RealTimeSequencer: implStop()"); if (playThread == null) { @@ -905,22 +899,36 @@ class RealTimeSequencer extends AbstractMidiDevice implements Sequencer, AutoCon if (Printer.trace) Printer.trace("<< RealTimeSequencer: implStop() completed"); } + private static EventDispatcher getEventDispatcher() { + // create and start the global event thread + //TODO need a way to stop this thread when the engine is done + final ThreadGroup tg = Thread.currentThread().getThreadGroup(); + synchronized (dispatchers) { + EventDispatcher eventDispatcher = dispatchers.get(tg); + if (eventDispatcher == null) { + eventDispatcher = new EventDispatcher(); + dispatchers.put(tg, eventDispatcher); + eventDispatcher.start(); + } + return eventDispatcher; + } + } /** * Send midi player events. * must not be synchronized on "this" */ - protected void sendMetaEvents(MidiMessage message) { + void sendMetaEvents(MidiMessage message) { if (metaEventListeners.size() == 0) return; //if (Printer.debug) Printer.debug("sending a meta event"); - eventDispatcher.sendAudioEvents(message, metaEventListeners); + getEventDispatcher().sendAudioEvents(message, metaEventListeners); } /** * Send midi player events. */ - protected void sendControllerEvents(MidiMessage message) { + void sendControllerEvents(MidiMessage message) { int size = controllerEventListeners.size(); if (size == 0) return; @@ -942,7 +950,7 @@ class RealTimeSequencer extends AbstractMidiDevice implements Sequencer, AutoCon } } } - eventDispatcher.sendAudioEvents(message, sendToListeners); + getEventDispatcher().sendAudioEvents(message, sendToListeners); } @@ -1024,7 +1032,7 @@ class RealTimeSequencer extends AbstractMidiDevice implements Sequencer, AutoCon } - class SequencerReceiver extends AbstractReceiver { + final class SequencerReceiver extends AbstractReceiver { void implSend(MidiMessage message, long timeStamp) { if (recording) { @@ -1092,7 +1100,7 @@ class RealTimeSequencer extends AbstractMidiDevice implements Sequencer, AutoCon // easier to deal with than turning all the // ints into objects to use a Vector int [] controllers; - ControllerEventListener listener; + final ControllerEventListener listener; private ControllerListElement(ControllerEventListener listener, int[] controllers) { @@ -1197,7 +1205,7 @@ class RealTimeSequencer extends AbstractMidiDevice implements Sequencer, AutoCon static class RecordingTrack { - private Track track; + private final Track track; private int channel; RecordingTrack(Track track, int channel) { @@ -1237,15 +1245,15 @@ class RealTimeSequencer extends AbstractMidiDevice implements Sequencer, AutoCon } - class PlayThread implements Runnable { + final class PlayThread implements Runnable { private Thread thread; - private Object lock = new Object(); + private final Object lock = new Object(); /** true if playback is interrupted (in close) */ boolean interrupted = false; boolean isPumping = false; - private DataPump dataPump = new DataPump(); + private final DataPump dataPump = new DataPump(); PlayThread() { diff --git a/jdk/src/share/classes/com/sun/media/sound/RealTimeSequencerProvider.java b/jdk/src/share/classes/com/sun/media/sound/RealTimeSequencerProvider.java index 643ccf27215..d2724955a0c 100644 --- a/jdk/src/share/classes/com/sun/media/sound/RealTimeSequencerProvider.java +++ b/jdk/src/share/classes/com/sun/media/sound/RealTimeSequencerProvider.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2013, 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 @@ -34,7 +34,7 @@ import javax.sound.midi.spi.MidiDeviceProvider; * * @author Florian Bomers */ -public class RealTimeSequencerProvider extends MidiDeviceProvider { +public final class RealTimeSequencerProvider extends MidiDeviceProvider { public MidiDevice.Info[] getDeviceInfo() { diff --git a/jdk/src/share/classes/com/sun/media/sound/SF2GlobalRegion.java b/jdk/src/share/classes/com/sun/media/sound/SF2GlobalRegion.java index 365a558ea17..22ed404ddf8 100644 --- a/jdk/src/share/classes/com/sun/media/sound/SF2GlobalRegion.java +++ b/jdk/src/share/classes/com/sun/media/sound/SF2GlobalRegion.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2013, 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 @@ -29,5 +29,5 @@ package com.sun.media.sound; * * @author Karl Helgason */ -public class SF2GlobalRegion extends SF2Region { +public final class SF2GlobalRegion extends SF2Region { } diff --git a/jdk/src/share/classes/com/sun/media/sound/SF2Instrument.java b/jdk/src/share/classes/com/sun/media/sound/SF2Instrument.java index e96b85c14ed..580882ba765 100644 --- a/jdk/src/share/classes/com/sun/media/sound/SF2Instrument.java +++ b/jdk/src/share/classes/com/sun/media/sound/SF2Instrument.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2013, 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 @@ -36,16 +36,16 @@ import javax.sound.midi.Patch; * * @author Karl Helgason */ -public class SF2Instrument extends ModelInstrument { +public final class SF2Instrument extends ModelInstrument { - protected String name = ""; - protected int preset = 0; - protected int bank = 0; - protected long library = 0; - protected long genre = 0; - protected long morphology = 0; - protected SF2GlobalRegion globalregion = null; - protected List regions + String name = ""; + int preset = 0; + int bank = 0; + long library = 0; + long genre = 0; + long morphology = 0; + SF2GlobalRegion globalregion = null; + List regions = new ArrayList(); public SF2Instrument() { @@ -730,7 +730,7 @@ public class SF2Instrument extends ModelInstrument { return msrc; } - protected static ModelDestination convertDestination(int dst, + static ModelDestination convertDestination(int dst, double[] amountcorrection, ModelSource[] extrasrc) { ModelIdentifier id = null; switch (dst) { diff --git a/jdk/src/share/classes/com/sun/media/sound/SF2InstrumentRegion.java b/jdk/src/share/classes/com/sun/media/sound/SF2InstrumentRegion.java index ae01e5177fd..87a62c42e05 100644 --- a/jdk/src/share/classes/com/sun/media/sound/SF2InstrumentRegion.java +++ b/jdk/src/share/classes/com/sun/media/sound/SF2InstrumentRegion.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2013, 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 @@ -29,9 +29,9 @@ package com.sun.media.sound; * * @author Karl Helgason */ -public class SF2InstrumentRegion extends SF2Region { +public final class SF2InstrumentRegion extends SF2Region { - protected SF2Layer layer; + SF2Layer layer; public SF2Layer getLayer() { return layer; diff --git a/jdk/src/share/classes/com/sun/media/sound/SF2Layer.java b/jdk/src/share/classes/com/sun/media/sound/SF2Layer.java index 6c3f1450917..e0bc76a4f9d 100644 --- a/jdk/src/share/classes/com/sun/media/sound/SF2Layer.java +++ b/jdk/src/share/classes/com/sun/media/sound/SF2Layer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2013, 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 @@ -34,11 +34,11 @@ import javax.sound.midi.SoundbankResource; * * @author Karl Helgason */ -public class SF2Layer extends SoundbankResource { +public final class SF2Layer extends SoundbankResource { - protected String name = ""; - protected SF2GlobalRegion globalregion = null; - protected List regions = new ArrayList(); + String name = ""; + SF2GlobalRegion globalregion = null; + List regions = new ArrayList(); public SF2Layer(SF2Soundbank soundBank) { super(soundBank, null, null); diff --git a/jdk/src/share/classes/com/sun/media/sound/SF2LayerRegion.java b/jdk/src/share/classes/com/sun/media/sound/SF2LayerRegion.java index 8b2caadb870..8833e384c3e 100644 --- a/jdk/src/share/classes/com/sun/media/sound/SF2LayerRegion.java +++ b/jdk/src/share/classes/com/sun/media/sound/SF2LayerRegion.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2013, 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 @@ -29,9 +29,9 @@ package com.sun.media.sound; * * @author Karl Helgason */ -public class SF2LayerRegion extends SF2Region { +public final class SF2LayerRegion extends SF2Region { - protected SF2Sample sample; + SF2Sample sample; public SF2Sample getSample() { return sample; diff --git a/jdk/src/share/classes/com/sun/media/sound/SF2Modulator.java b/jdk/src/share/classes/com/sun/media/sound/SF2Modulator.java index c412ced8d24..2d85032ce4d 100644 --- a/jdk/src/share/classes/com/sun/media/sound/SF2Modulator.java +++ b/jdk/src/share/classes/com/sun/media/sound/SF2Modulator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2013, 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 @@ -29,7 +29,7 @@ package com.sun.media.sound; * * @author Karl Helgason */ -public class SF2Modulator { +public final class SF2Modulator { public final static int SOURCE_NONE = 0; public final static int SOURCE_NOTE_ON_VELOCITY = 2; @@ -49,11 +49,11 @@ public class SF2Modulator { public final static int SOURCE_TYPE_SWITCH = 1024 * 3; public final static int TRANSFORM_LINEAR = 0; public final static int TRANSFORM_ABSOLUTE = 2; - protected int sourceOperator; - protected int destinationOperator; - protected short amount; - protected int amountSourceOperator; - protected int transportOperator; + int sourceOperator; + int destinationOperator; + short amount; + int amountSourceOperator; + int transportOperator; public short getAmount() { return amount; diff --git a/jdk/src/share/classes/com/sun/media/sound/SF2Sample.java b/jdk/src/share/classes/com/sun/media/sound/SF2Sample.java index f3112c7fa2a..4a2f0fc58d7 100644 --- a/jdk/src/share/classes/com/sun/media/sound/SF2Sample.java +++ b/jdk/src/share/classes/com/sun/media/sound/SF2Sample.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2013, 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 @@ -36,18 +36,18 @@ import javax.sound.sampled.AudioInputStream; * * @author Karl Helgason */ -public class SF2Sample extends SoundbankResource { +public final class SF2Sample extends SoundbankResource { - protected String name = ""; - protected long startLoop = 0; - protected long endLoop = 0; - protected long sampleRate = 44100; - protected int originalPitch = 60; - protected byte pitchCorrection = 0; - protected int sampleLink = 0; - protected int sampleType = 0; - protected ModelByteBuffer data; - protected ModelByteBuffer data24; + String name = ""; + long startLoop = 0; + long endLoop = 0; + long sampleRate = 44100; + int originalPitch = 60; + byte pitchCorrection = 0; + int sampleLink = 0; + int sampleType = 0; + ModelByteBuffer data; + ModelByteBuffer data24; public SF2Sample(Soundbank soundBank) { super(soundBank, null, AudioInputStream.class); diff --git a/jdk/src/share/classes/com/sun/media/sound/SF2Soundbank.java b/jdk/src/share/classes/com/sun/media/sound/SF2Soundbank.java index 914199edfd9..688ba1dafaa 100644 --- a/jdk/src/share/classes/com/sun/media/sound/SF2Soundbank.java +++ b/jdk/src/share/classes/com/sun/media/sound/SF2Soundbank.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2013, 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,40 +50,40 @@ import javax.sound.midi.SoundbankResource; * * @author Karl Helgason */ -public class SF2Soundbank implements Soundbank { +public final class SF2Soundbank implements Soundbank { // version of the Sound Font RIFF file - protected int major = 2; - protected int minor = 1; + int major = 2; + int minor = 1; // target Sound Engine - protected String targetEngine = "EMU8000"; + String targetEngine = "EMU8000"; // Sound Font Bank Name - protected String name = "untitled"; + String name = "untitled"; // Sound ROM Name - protected String romName = null; + String romName = null; // Sound ROM Version - protected int romVersionMajor = -1; - protected int romVersionMinor = -1; + int romVersionMajor = -1; + int romVersionMinor = -1; // Date of Creation of the Bank - protected String creationDate = null; + String creationDate = null; // Sound Designers and Engineers for the Bank - protected String engineers = null; + String engineers = null; // Product for which the Bank was intended - protected String product = null; + String product = null; // Copyright message - protected String copyright = null; + String copyright = null; // Comments - protected String comments = null; + String comments = null; // The SoundFont tools used to create and alter the bank - protected String tools = null; + String tools = null; // The Sample Data loaded from the SoundFont private ModelByteBuffer sampleData = null; private ModelByteBuffer sampleData24 = null; private File sampleFile = null; private boolean largeFormat = false; - private List instruments = new ArrayList(); - private List layers = new ArrayList(); - private List samples = new ArrayList(); + private final List instruments = new ArrayList(); + private final List layers = new ArrayList(); + private final List samples = new ArrayList(); public SF2Soundbank() { } diff --git a/jdk/src/share/classes/com/sun/media/sound/SF2SoundbankReader.java b/jdk/src/share/classes/com/sun/media/sound/SF2SoundbankReader.java index 120f1dbf740..a61094fb4df 100644 --- a/jdk/src/share/classes/com/sun/media/sound/SF2SoundbankReader.java +++ b/jdk/src/share/classes/com/sun/media/sound/SF2SoundbankReader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2013, 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 @@ -38,7 +38,7 @@ import javax.sound.midi.spi.SoundbankReader; * * @author Karl Helgason */ -public class SF2SoundbankReader extends SoundbankReader { +public final class SF2SoundbankReader extends SoundbankReader { public Soundbank getSoundbank(URL url) throws InvalidMidiDataException, IOException { diff --git a/jdk/src/share/classes/com/sun/media/sound/SoftAbstractResampler.java b/jdk/src/share/classes/com/sun/media/sound/SoftAbstractResampler.java index b0857fd1d02..45c83553457 100644 --- a/jdk/src/share/classes/com/sun/media/sound/SoftAbstractResampler.java +++ b/jdk/src/share/classes/com/sun/media/sound/SoftAbstractResampler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2013, 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,7 +67,7 @@ public abstract class SoftAbstractResampler implements SoftResampler { float samplerateconv = 1; float pitchcorrection = 0; - public ModelAbstractResamplerStream() { + ModelAbstractResamplerStream() { pad = getPadding(); pad2 = getPadding() * 2; ibuffer = new float[2][sector_size + pad2]; @@ -384,7 +384,7 @@ public abstract class SoftAbstractResampler implements SoftResampler { float in_end, float[] pitch, float pitchstep, float[] out, int[] out_offset, int out_end); - public SoftResamplerStreamer openStreamer() { + public final SoftResamplerStreamer openStreamer() { return new ModelAbstractResamplerStream(); } } diff --git a/jdk/src/share/classes/com/sun/media/sound/SoftAudioBuffer.java b/jdk/src/share/classes/com/sun/media/sound/SoftAudioBuffer.java index 1a3faf28e37..45b2d0f1d9c 100644 --- a/jdk/src/share/classes/com/sun/media/sound/SoftAudioBuffer.java +++ b/jdk/src/share/classes/com/sun/media/sound/SoftAudioBuffer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2013, 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 @@ -33,7 +33,7 @@ import javax.sound.sampled.AudioFormat; * * @author Karl Helgason */ -public class SoftAudioBuffer { +public final class SoftAudioBuffer { private int size; private float[] buffer; diff --git a/jdk/src/share/classes/com/sun/media/sound/SoftAudioPusher.java b/jdk/src/share/classes/com/sun/media/sound/SoftAudioPusher.java index 7f96ec4709d..1a07a23ec6f 100644 --- a/jdk/src/share/classes/com/sun/media/sound/SoftAudioPusher.java +++ b/jdk/src/share/classes/com/sun/media/sound/SoftAudioPusher.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2013, 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 @@ -34,13 +34,13 @@ import javax.sound.sampled.SourceDataLine; * * @author Karl Helgason */ -public class SoftAudioPusher implements Runnable { +public final class SoftAudioPusher implements Runnable { private volatile boolean active = false; private SourceDataLine sourceDataLine = null; private Thread audiothread; - private AudioInputStream ais; - private byte[] buffer; + private final AudioInputStream ais; + private final byte[] buffer; public SoftAudioPusher(SourceDataLine sourceDataLine, AudioInputStream ais, int workbuffersizer) { diff --git a/jdk/src/share/classes/com/sun/media/sound/SoftChannel.java b/jdk/src/share/classes/com/sun/media/sound/SoftChannel.java index 70208f78e7d..667b9cc3741 100644 --- a/jdk/src/share/classes/com/sun/media/sound/SoftChannel.java +++ b/jdk/src/share/classes/com/sun/media/sound/SoftChannel.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2013, 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 @@ -39,7 +39,7 @@ import javax.sound.midi.Patch; * * @author Karl Helgason */ -public class SoftChannel implements MidiChannel, ModelDirectedPlayer { +public final class SoftChannel implements MidiChannel, ModelDirectedPlayer { private static boolean[] dontResetControls = new boolean[128]; static { @@ -90,15 +90,15 @@ public class SoftChannel implements MidiChannel, ModelDirectedPlayer { private static final int RPN_NULL_VALUE = (127 << 7) + 127; private int rpn_control = RPN_NULL_VALUE; private int nrpn_control = RPN_NULL_VALUE; - protected double portamento_time = 1; // keyschanges per control buffer time - protected int[] portamento_lastnote = new int[128]; - protected int portamento_lastnote_ix = 0; + double portamento_time = 1; // keyschanges per control buffer time + int[] portamento_lastnote = new int[128]; + int portamento_lastnote_ix = 0; private boolean portamento = false; private boolean mono = false; private boolean mute = false; private boolean solo = false; private boolean solomute = false; - private Object control_mutex; + private final Object control_mutex; private int channel; private SoftVoice[] voices; private int bank; @@ -111,21 +111,21 @@ public class SoftChannel implements MidiChannel, ModelDirectedPlayer { private int pitchbend; private double[] co_midi_pitch = new double[1]; private double[] co_midi_channel_pressure = new double[1]; - protected SoftTuning tuning = new SoftTuning(); - protected int tuning_bank = 0; - protected int tuning_program = 0; - protected SoftInstrument current_instrument = null; - protected ModelChannelMixer current_mixer = null; - protected ModelDirector current_director = null; + SoftTuning tuning = new SoftTuning(); + int tuning_bank = 0; + int tuning_program = 0; + SoftInstrument current_instrument = null; + ModelChannelMixer current_mixer = null; + ModelDirector current_director = null; // Controller Destination Settings - protected int cds_control_number = -1; - protected ModelConnectionBlock[] cds_control_connections = null; - protected ModelConnectionBlock[] cds_channelpressure_connections = null; - protected ModelConnectionBlock[] cds_polypressure_connections = null; - protected boolean sustain = false; - protected boolean[][] keybasedcontroller_active = null; - protected double[][] keybasedcontroller_value = null; + int cds_control_number = -1; + ModelConnectionBlock[] cds_control_connections = null; + ModelConnectionBlock[] cds_channelpressure_connections = null; + ModelConnectionBlock[] cds_polypressure_connections = null; + boolean sustain = false; + boolean[][] keybasedcontroller_active = null; + double[][] keybasedcontroller_value = null; private class MidiControlObject implements SoftControl { double[] pitch = co_midi_pitch; @@ -336,7 +336,7 @@ public class SoftChannel implements MidiChannel, ModelDirectedPlayer { } - protected void initVoice(SoftVoice voice, SoftPerformer p, int voiceID, + void initVoice(SoftVoice voice, SoftPerformer p, int voiceID, int noteNumber, int velocity, int delay, ModelConnectionBlock[] connectionBlocks, ModelChannelMixer channelmixer, boolean releaseTriggered) { if (voice.active) { @@ -414,7 +414,7 @@ public class SoftChannel implements MidiChannel, ModelDirectedPlayer { /* A special noteOn with delay parameter, which is used to * start note within control buffers. */ - protected void noteOn(int noteNumber, int velocity, int delay) { + void noteOn(int noteNumber, int velocity, int delay) { noteNumber = restrict7Bit(noteNumber); velocity = restrict7Bit(velocity); noteOn_internal(noteNumber, velocity, delay); @@ -707,7 +707,7 @@ public class SoftChannel implements MidiChannel, ModelDirectedPlayer { } } - protected void applyInstrumentCustomization() { + void applyInstrumentCustomization() { if (cds_control_connections == null && cds_channelpressure_connections == null && cds_polypressure_connections == null) { diff --git a/jdk/src/share/classes/com/sun/media/sound/SoftChannelProxy.java b/jdk/src/share/classes/com/sun/media/sound/SoftChannelProxy.java index 045e50162c3..d5d8726fee9 100644 --- a/jdk/src/share/classes/com/sun/media/sound/SoftChannelProxy.java +++ b/jdk/src/share/classes/com/sun/media/sound/SoftChannelProxy.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2013, 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 @@ -32,7 +32,7 @@ import javax.sound.midi.MidiChannel; * * @author Karl Helgason */ -public class SoftChannelProxy implements MidiChannel { +public final class SoftChannelProxy implements MidiChannel { private MidiChannel channel = null; diff --git a/jdk/src/share/classes/com/sun/media/sound/SoftChorus.java b/jdk/src/share/classes/com/sun/media/sound/SoftChorus.java index bc04ca8eb2d..81b0e8209c7 100644 --- a/jdk/src/share/classes/com/sun/media/sound/SoftChorus.java +++ b/jdk/src/share/classes/com/sun/media/sound/SoftChorus.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2013, 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 @@ -32,11 +32,11 @@ import java.util.Arrays; * * @author Karl Helgason */ -public class SoftChorus implements SoftAudioProcessor { +public final class SoftChorus implements SoftAudioProcessor { private static class VariableDelay { - private float[] delaybuffer; + private final float[] delaybuffer; private int rovepos = 0; private float gain = 1; private float rgain = 0; @@ -44,7 +44,7 @@ public class SoftChorus implements SoftAudioProcessor { private float lastdelay = 0; private float feedback = 0; - public VariableDelay(int maxbuffersize) { + VariableDelay(int maxbuffersize) { delaybuffer = new float[maxbuffersize]; } @@ -119,10 +119,10 @@ public class SoftChorus implements SoftAudioProcessor { private double phase_step = 0; private double depth = 0; private VariableDelay vdelay; - private double samplerate; - private double controlrate; + private final double samplerate; + private final double controlrate; - public LFODelay(double samplerate, double controlrate) { + LFODelay(double samplerate, double controlrate) { this.samplerate = samplerate; this.controlrate = controlrate; // vdelay = new VariableDelay((int)(samplerate*4)); diff --git a/jdk/src/share/classes/com/sun/media/sound/SoftCubicResampler.java b/jdk/src/share/classes/com/sun/media/sound/SoftCubicResampler.java index 60df6ba8cee..4eeb817fc3d 100644 --- a/jdk/src/share/classes/com/sun/media/sound/SoftCubicResampler.java +++ b/jdk/src/share/classes/com/sun/media/sound/SoftCubicResampler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2013, 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 @@ -29,7 +29,7 @@ package com.sun.media.sound; * * @author Karl Helgason */ -public class SoftCubicResampler extends SoftAbstractResampler { +public final class SoftCubicResampler extends SoftAbstractResampler { public int getPadding() { return 3; diff --git a/jdk/src/share/classes/com/sun/media/sound/SoftEnvelopeGenerator.java b/jdk/src/share/classes/com/sun/media/sound/SoftEnvelopeGenerator.java index d60c17021b2..7214ec0dd20 100644 --- a/jdk/src/share/classes/com/sun/media/sound/SoftEnvelopeGenerator.java +++ b/jdk/src/share/classes/com/sun/media/sound/SoftEnvelopeGenerator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2013, 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 @@ -29,7 +29,7 @@ package com.sun.media.sound; * * @author Karl Helgason */ -public class SoftEnvelopeGenerator implements SoftProcess { +public final class SoftEnvelopeGenerator implements SoftProcess { public final static int EG_OFF = 0; public final static int EG_DELAY = 1; @@ -42,23 +42,23 @@ public class SoftEnvelopeGenerator implements SoftProcess { public final static int EG_END = 8; int max_count = 10; int used_count = 0; - private int[] stage = new int[max_count]; - private int[] stage_ix = new int[max_count]; - private double[] stage_v = new double[max_count]; - private int[] stage_count = new int[max_count]; - private double[][] on = new double[max_count][1]; - private double[][] active = new double[max_count][1]; - private double[][] out = new double[max_count][1]; - private double[][] delay = new double[max_count][1]; - private double[][] attack = new double[max_count][1]; - private double[][] hold = new double[max_count][1]; - private double[][] decay = new double[max_count][1]; - private double[][] sustain = new double[max_count][1]; - private double[][] release = new double[max_count][1]; - private double[][] shutdown = new double[max_count][1]; - private double[][] release2 = new double[max_count][1]; - private double[][] attack2 = new double[max_count][1]; - private double[][] decay2 = new double[max_count][1]; + private final int[] stage = new int[max_count]; + private final int[] stage_ix = new int[max_count]; + private final double[] stage_v = new double[max_count]; + private final int[] stage_count = new int[max_count]; + private final double[][] on = new double[max_count][1]; + private final double[][] active = new double[max_count][1]; + private final double[][] out = new double[max_count][1]; + private final double[][] delay = new double[max_count][1]; + private final double[][] attack = new double[max_count][1]; + private final double[][] hold = new double[max_count][1]; + private final double[][] decay = new double[max_count][1]; + private final double[][] sustain = new double[max_count][1]; + private final double[][] release = new double[max_count][1]; + private final double[][] shutdown = new double[max_count][1]; + private final double[][] release2 = new double[max_count][1]; + private final double[][] attack2 = new double[max_count][1]; + private final double[][] decay2 = new double[max_count][1]; private double control_time = 0; public void reset() { diff --git a/jdk/src/share/classes/com/sun/media/sound/SoftFilter.java b/jdk/src/share/classes/com/sun/media/sound/SoftFilter.java index b194345bca4..187fa20508e 100644 --- a/jdk/src/share/classes/com/sun/media/sound/SoftFilter.java +++ b/jdk/src/share/classes/com/sun/media/sound/SoftFilter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2013, 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 @@ -33,7 +33,7 @@ package com.sun.media.sound; * * @author Karl Helgason */ -public class SoftFilter { +public final class SoftFilter { public final static int FILTERTYPE_LP6 = 0x00; public final static int FILTERTYPE_LP12 = 0x01; @@ -55,7 +55,7 @@ public class SoftFilter { // 0x30 = NP, Notch or Band Elimination Filter // private int filtertype = FILTERTYPE_LP6; - private float samplerate; + private final float samplerate; private float x1; private float x2; private float y1; diff --git a/jdk/src/share/classes/com/sun/media/sound/SoftInstrument.java b/jdk/src/share/classes/com/sun/media/sound/SoftInstrument.java index 78f8926b5c2..0423448743d 100644 --- a/jdk/src/share/classes/com/sun/media/sound/SoftInstrument.java +++ b/jdk/src/share/classes/com/sun/media/sound/SoftInstrument.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2013, 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 @@ -32,12 +32,12 @@ import javax.sound.midi.MidiChannel; * * @author Karl Helgason */ -public class SoftInstrument extends Instrument { +public final class SoftInstrument extends Instrument { private SoftPerformer[] performers; private ModelPerformer[] modelperformers; - private Object data; - private ModelInstrument ins; + private final Object data; + private final ModelInstrument ins; public SoftInstrument(ModelInstrument ins) { super(ins.getSoundbank(), ins.getPatch(), ins.getName(), diff --git a/jdk/src/share/classes/com/sun/media/sound/SoftJitterCorrector.java b/jdk/src/share/classes/com/sun/media/sound/SoftJitterCorrector.java index 3f60d2dafc2..0f5ff294574 100644 --- a/jdk/src/share/classes/com/sun/media/sound/SoftJitterCorrector.java +++ b/jdk/src/share/classes/com/sun/media/sound/SoftJitterCorrector.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2013, 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 @@ -36,7 +36,7 @@ import javax.sound.sampled.AudioInputStream; * * @author Karl Helgason */ -public class SoftJitterCorrector extends AudioInputStream { +public final class SoftJitterCorrector extends AudioInputStream { private static class JitterStream extends InputStream { @@ -48,7 +48,7 @@ public class SoftJitterCorrector extends AudioInputStream { int writepos = 0; int readpos = 0; byte[][] buffers; - Object buffers_mutex = new Object(); + private final Object buffers_mutex = new Object(); // Adapative Drift Statistics int w_count = 1000; @@ -112,7 +112,7 @@ public class SoftJitterCorrector extends AudioInputStream { } } - public JitterStream(AudioInputStream s, int buffersize, + JitterStream(AudioInputStream s, int buffersize, int smallbuffersize) { this.w_count = 10 * (buffersize / smallbuffersize); if (w_count < 100) diff --git a/jdk/src/share/classes/com/sun/media/sound/SoftLanczosResampler.java b/jdk/src/share/classes/com/sun/media/sound/SoftLanczosResampler.java index 0567464ce37..1d2d3619698 100644 --- a/jdk/src/share/classes/com/sun/media/sound/SoftLanczosResampler.java +++ b/jdk/src/share/classes/com/sun/media/sound/SoftLanczosResampler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2013, 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 @@ -29,7 +29,7 @@ package com.sun.media.sound; * * @author Karl Helgason */ -public class SoftLanczosResampler extends SoftAbstractResampler { +public final class SoftLanczosResampler extends SoftAbstractResampler { float[][] sinc_table; int sinc_table_fsize = 2000; diff --git a/jdk/src/share/classes/com/sun/media/sound/SoftLimiter.java b/jdk/src/share/classes/com/sun/media/sound/SoftLimiter.java index f699a4db31d..7c74a18e1c0 100644 --- a/jdk/src/share/classes/com/sun/media/sound/SoftLimiter.java +++ b/jdk/src/share/classes/com/sun/media/sound/SoftLimiter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2013, 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 @@ -30,7 +30,7 @@ package com.sun.media.sound; * * @author Karl Helgason */ -public class SoftLimiter implements SoftAudioProcessor { +public final class SoftLimiter implements SoftAudioProcessor { float lastmax = 0; float gain = 1; diff --git a/jdk/src/share/classes/com/sun/media/sound/SoftLinearResampler.java b/jdk/src/share/classes/com/sun/media/sound/SoftLinearResampler.java index acfb8d9b060..eb2b98d3772 100644 --- a/jdk/src/share/classes/com/sun/media/sound/SoftLinearResampler.java +++ b/jdk/src/share/classes/com/sun/media/sound/SoftLinearResampler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2013, 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 @@ -29,7 +29,7 @@ package com.sun.media.sound; * * @author Karl Helgason */ -public class SoftLinearResampler extends SoftAbstractResampler { +public final class SoftLinearResampler extends SoftAbstractResampler { public int getPadding() { return 2; diff --git a/jdk/src/share/classes/com/sun/media/sound/SoftLinearResampler2.java b/jdk/src/share/classes/com/sun/media/sound/SoftLinearResampler2.java index 34dfd9dd89a..67f1b6b2c32 100644 --- a/jdk/src/share/classes/com/sun/media/sound/SoftLinearResampler2.java +++ b/jdk/src/share/classes/com/sun/media/sound/SoftLinearResampler2.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2013, 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 @@ -31,7 +31,7 @@ package com.sun.media.sound; * * @author Karl Helgason */ -public class SoftLinearResampler2 extends SoftAbstractResampler { +public final class SoftLinearResampler2 extends SoftAbstractResampler { public int getPadding() { return 2; diff --git a/jdk/src/share/classes/com/sun/media/sound/SoftLowFrequencyOscillator.java b/jdk/src/share/classes/com/sun/media/sound/SoftLowFrequencyOscillator.java index 87617717f6b..a0a8bbe1697 100644 --- a/jdk/src/share/classes/com/sun/media/sound/SoftLowFrequencyOscillator.java +++ b/jdk/src/share/classes/com/sun/media/sound/SoftLowFrequencyOscillator.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2013, 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 @@ -29,21 +29,21 @@ package com.sun.media.sound; * * @author Karl Helgason */ -public class SoftLowFrequencyOscillator implements SoftProcess { +public final class SoftLowFrequencyOscillator implements SoftProcess { - private int max_count = 10; + private final int max_count = 10; private int used_count = 0; - private double[][] out = new double[max_count][1]; - private double[][] delay = new double[max_count][1]; - private double[][] delay2 = new double[max_count][1]; - private double[][] freq = new double[max_count][1]; - private int[] delay_counter = new int[max_count]; - private double[] sin_phase = new double[max_count]; - private double[] sin_stepfreq = new double[max_count]; - private double[] sin_step = new double[max_count]; + private final double[][] out = new double[max_count][1]; + private final double[][] delay = new double[max_count][1]; + private final double[][] delay2 = new double[max_count][1]; + private final double[][] freq = new double[max_count][1]; + private final int[] delay_counter = new int[max_count]; + private final double[] sin_phase = new double[max_count]; + private final double[] sin_stepfreq = new double[max_count]; + private final double[] sin_step = new double[max_count]; private double control_time = 0; private double sin_factor = 0; - private static double PI2 = 2.0 * Math.PI; + private static final double PI2 = 2.0 * Math.PI; public SoftLowFrequencyOscillator() { // If sin_step is 0 then sin_stepfreq must be -INF diff --git a/jdk/src/share/classes/com/sun/media/sound/SoftMainMixer.java b/jdk/src/share/classes/com/sun/media/sound/SoftMainMixer.java index b4bbe656671..02ce9e02518 100644 --- a/jdk/src/share/classes/com/sun/media/sound/SoftMainMixer.java +++ b/jdk/src/share/classes/com/sun/media/sound/SoftMainMixer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2013, 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,7 +43,7 @@ import javax.sound.sampled.AudioSystem; * * @author Karl Helgason */ -public class SoftMainMixer { +public final class SoftMainMixer { // A private class thats contains a ModelChannelMixer and it's private buffers. // This becomes necessary when we want to have separate delay buffers for each channel mixer. @@ -67,13 +67,13 @@ public class SoftMainMixer { public final static int CHANNEL_RIGHT_DRY = 11; public final static int CHANNEL_SCRATCH1 = 12; public final static int CHANNEL_SCRATCH2 = 13; - protected boolean active_sensing_on = false; + boolean active_sensing_on = false; private long msec_last_activity = -1; private boolean pusher_silent = false; private int pusher_silent_count = 0; private long sample_pos = 0; - protected boolean readfully = true; - private Object control_mutex; + boolean readfully = true; + private final Object control_mutex; private SoftSynthesizer synth; private float samplerate = 44100; private int nrofchannels = 2; @@ -84,7 +84,7 @@ public class SoftMainMixer { private SoftAudioProcessor agc; private long msec_buffer_len = 0; private int buffer_len = 0; - protected TreeMap midimessages = new TreeMap(); + TreeMap midimessages = new TreeMap(); private int delay_midievent = 0; private int max_delay_midievent = 0; double last_volume_left = 1.0; @@ -97,7 +97,7 @@ public class SoftMainMixer { private Set registeredMixers = null; private Set stoppedMixers = null; private SoftChannelMixerContainer[] cur_registeredMixers = null; - protected SoftControl co_master = new SoftControl() { + SoftControl co_master = new SoftControl() { double[] balance = co_master_balance; double[] volume = co_master_volume; @@ -438,7 +438,7 @@ public class SoftMainMixer { delay_midievent = 0; } - protected void processAudioBuffers() { + void processAudioBuffers() { if(synth.weakstream != null && synth.weakstream.silent_samples != 0) { @@ -859,16 +859,16 @@ public class SoftMainMixer { InputStream in = new InputStream() { - private SoftAudioBuffer[] buffers = SoftMainMixer.this.buffers; - private int nrofchannels + private final SoftAudioBuffer[] buffers = SoftMainMixer.this.buffers; + private final int nrofchannels = SoftMainMixer.this.synth.getFormat().getChannels(); - private int buffersize = buffers[0].getSize(); - private byte[] bbuffer = new byte[buffersize + private final int buffersize = buffers[0].getSize(); + private final byte[] bbuffer = new byte[buffersize * (SoftMainMixer.this.synth.getFormat() .getSampleSizeInBits() / 8) * nrofchannels]; private int bbuffer_pos = 0; - private byte[] single = new byte[1]; + private final byte[] single = new byte[1]; public void fillBuffer() { /* diff --git a/jdk/src/share/classes/com/sun/media/sound/SoftMidiAudioFileReader.java b/jdk/src/share/classes/com/sun/media/sound/SoftMidiAudioFileReader.java index 999e2560c0c..48ae72fcb02 100644 --- a/jdk/src/share/classes/com/sun/media/sound/SoftMidiAudioFileReader.java +++ b/jdk/src/share/classes/com/sun/media/sound/SoftMidiAudioFileReader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2013, 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,7 +50,7 @@ import javax.sound.sampled.spi.AudioFileReader; * * @author Karl Helgason */ -public class SoftMidiAudioFileReader extends AudioFileReader { +public final class SoftMidiAudioFileReader extends AudioFileReader { public static final Type MIDI = new Type("MIDI", "mid"); private static AudioFormat format = new AudioFormat(44100, 16, 2, true, false); diff --git a/jdk/src/share/classes/com/sun/media/sound/SoftMixingClip.java b/jdk/src/share/classes/com/sun/media/sound/SoftMixingClip.java index 229cdbff6f2..bcf67f3b554 100644 --- a/jdk/src/share/classes/com/sun/media/sound/SoftMixingClip.java +++ b/jdk/src/share/classes/com/sun/media/sound/SoftMixingClip.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2013, 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 @@ -42,7 +42,7 @@ import javax.sound.sampled.LineUnavailableException; * * @author Karl Helgason */ -public class SoftMixingClip extends SoftMixingDataLine implements Clip { +public final class SoftMixingClip extends SoftMixingDataLine implements Clip { private AudioFormat format; @@ -50,7 +50,7 @@ public class SoftMixingClip extends SoftMixingDataLine implements Clip { private byte[] data; - private InputStream datastream = new InputStream() { + private final InputStream datastream = new InputStream() { public int read() throws IOException { byte[] b = new byte[1]; @@ -162,7 +162,7 @@ public class SoftMixingClip extends SoftMixingDataLine implements Clip { private AudioFloatInputStream afis; - protected SoftMixingClip(SoftMixingMixer mixer, DataLine.Info info) { + SoftMixingClip(SoftMixingMixer mixer, DataLine.Info info) { super(mixer, info); } diff --git a/jdk/src/share/classes/com/sun/media/sound/SoftMixingDataLine.java b/jdk/src/share/classes/com/sun/media/sound/SoftMixingDataLine.java index baaf9e844d9..b7793062764 100644 --- a/jdk/src/share/classes/com/sun/media/sound/SoftMixingDataLine.java +++ b/jdk/src/share/classes/com/sun/media/sound/SoftMixingDataLine.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2013, 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,22 +50,22 @@ public abstract class SoftMixingDataLine implements DataLine { "Chorus Send") { }; - protected static class AudioFloatInputStreamResampler extends + protected static final class AudioFloatInputStreamResampler extends AudioFloatInputStream { - private AudioFloatInputStream ais; + private final AudioFloatInputStream ais; - private AudioFormat targetFormat; + private final AudioFormat targetFormat; private float[] skipbuffer; private SoftAbstractResampler resampler; - private float[] pitch = new float[1]; + private final float[] pitch = new float[1]; - private float[] ibuffer2; + private final float[] ibuffer2; - private float[][] ibuffer; + private final float[][] ibuffer; private float ibuffer_index = 0; @@ -75,15 +75,15 @@ public abstract class SoftMixingDataLine implements DataLine { private float[][] cbuffer; - private int buffer_len = 512; + private final int buffer_len = 512; - private int pad; + private final int pad; - private int pad2; + private final int pad2; - private float[] ix = new float[1]; + private final float[] ix = new float[1]; - private int[] ox = new int[1]; + private final int[] ox = new int[1]; private float[][] mark_ibuffer = null; @@ -294,7 +294,7 @@ public abstract class SoftMixingDataLine implements DataLine { } - private class Gain extends FloatControl { + private final class Gain extends FloatControl { private Gain() { @@ -308,7 +308,7 @@ public abstract class SoftMixingDataLine implements DataLine { } } - private class Mute extends BooleanControl { + private final class Mute extends BooleanControl { private Mute() { super(BooleanControl.Type.MUTE, false, "True", "False"); @@ -320,7 +320,7 @@ public abstract class SoftMixingDataLine implements DataLine { } } - private class ApplyReverb extends BooleanControl { + private final class ApplyReverb extends BooleanControl { private ApplyReverb() { super(BooleanControl.Type.APPLY_REVERB, false, "True", "False"); @@ -333,7 +333,7 @@ public abstract class SoftMixingDataLine implements DataLine { } - private class Balance extends FloatControl { + private final class Balance extends FloatControl { private Balance() { super(FloatControl.Type.BALANCE, -1.0f, 1.0f, (1.0f / 128.0f), -1, @@ -347,7 +347,7 @@ public abstract class SoftMixingDataLine implements DataLine { } - private class Pan extends FloatControl { + private final class Pan extends FloatControl { private Pan() { super(FloatControl.Type.PAN, -1.0f, 1.0f, (1.0f / 128.0f), -1, @@ -365,7 +365,7 @@ public abstract class SoftMixingDataLine implements DataLine { } - private class ReverbSend extends FloatControl { + private final class ReverbSend extends FloatControl { private ReverbSend() { super(FloatControl.Type.REVERB_SEND, -80f, 6.0206f, 80f / 128.0f, @@ -379,7 +379,7 @@ public abstract class SoftMixingDataLine implements DataLine { } - private class ChorusSend extends FloatControl { + private final class ChorusSend extends FloatControl { private ChorusSend() { super(CHORUS_SEND, -80f, 6.0206f, 80f / 128.0f, -1, -80f, "dB", @@ -393,43 +393,43 @@ public abstract class SoftMixingDataLine implements DataLine { } - private Gain gain_control = new Gain(); + private final Gain gain_control = new Gain(); - private Mute mute_control = new Mute(); + private final Mute mute_control = new Mute(); - private Balance balance_control = new Balance(); + private final Balance balance_control = new Balance(); - private Pan pan_control = new Pan(); + private final Pan pan_control = new Pan(); - private ReverbSend reverbsend_control = new ReverbSend(); + private final ReverbSend reverbsend_control = new ReverbSend(); - private ChorusSend chorussend_control = new ChorusSend(); + private final ChorusSend chorussend_control = new ChorusSend(); - private ApplyReverb apply_reverb = new ApplyReverb(); + private final ApplyReverb apply_reverb = new ApplyReverb(); - private Control[] controls; + private final Control[] controls; - protected float leftgain = 1; + float leftgain = 1; - protected float rightgain = 1; + float rightgain = 1; - protected float eff1gain = 0; + float eff1gain = 0; - protected float eff2gain = 0; + float eff2gain = 0; - protected List listeners = new ArrayList(); + List listeners = new ArrayList(); - protected Object control_mutex; + final Object control_mutex; - protected SoftMixingMixer mixer; + SoftMixingMixer mixer; - protected DataLine.Info info; + DataLine.Info info; protected abstract void processControlLogic(); protected abstract void processAudioLogic(SoftAudioBuffer[] buffers); - protected SoftMixingDataLine(SoftMixingMixer mixer, DataLine.Info info) { + SoftMixingDataLine(SoftMixingMixer mixer, DataLine.Info info) { this.mixer = mixer; this.info = info; this.control_mutex = mixer.control_mutex; @@ -440,7 +440,7 @@ public abstract class SoftMixingDataLine implements DataLine { calcVolume(); } - protected void calcVolume() { + final void calcVolume() { synchronized (control_mutex) { double gain = Math.pow(10.0, gain_control.getValue() / 20.0); if (mute_control.getValue()) @@ -466,7 +466,7 @@ public abstract class SoftMixingDataLine implements DataLine { } } - protected void sendEvent(LineEvent event) { + final void sendEvent(LineEvent event) { if (listeners.size() == 0) return; LineListener[] listener_array = listeners @@ -476,23 +476,23 @@ public abstract class SoftMixingDataLine implements DataLine { } } - public void addLineListener(LineListener listener) { + public final void addLineListener(LineListener listener) { synchronized (control_mutex) { listeners.add(listener); } } - public void removeLineListener(LineListener listener) { + public final void removeLineListener(LineListener listener) { synchronized (control_mutex) { listeners.add(listener); } } - public javax.sound.sampled.Line.Info getLineInfo() { + public final javax.sound.sampled.Line.Info getLineInfo() { return info; } - public Control getControl(Type control) { + public final Control getControl(Type control) { if (control != null) { for (int i = 0; i < controls.length; i++) { if (controls[i].getType() == control) { @@ -504,11 +504,11 @@ public abstract class SoftMixingDataLine implements DataLine { + control); } - public Control[] getControls() { + public final Control[] getControls() { return Arrays.copyOf(controls, controls.length); } - public boolean isControlSupported(Type control) { + public final boolean isControlSupported(Type control) { if (control != null) { for (int i = 0; i < controls.length; i++) { if (controls[i].getType() == control) { diff --git a/jdk/src/share/classes/com/sun/media/sound/SoftMixingMainMixer.java b/jdk/src/share/classes/com/sun/media/sound/SoftMixingMainMixer.java index 88a37634cb5..43e796ff14f 100644 --- a/jdk/src/share/classes/com/sun/media/sound/SoftMixingMainMixer.java +++ b/jdk/src/share/classes/com/sun/media/sound/SoftMixingMainMixer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2013, 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 @@ -37,7 +37,7 @@ import javax.sound.sampled.AudioSystem; * * @author Karl Helgason */ -public class SoftMixingMainMixer { +public final class SoftMixingMainMixer { public final static int CHANNEL_LEFT = 0; @@ -63,23 +63,23 @@ public class SoftMixingMainMixer { public final static int CHANNEL_CHANNELMIXER_RIGHT = 15; - private SoftMixingMixer mixer; + private final SoftMixingMixer mixer; - private AudioInputStream ais; + private final AudioInputStream ais; - private SoftAudioBuffer[] buffers; + private final SoftAudioBuffer[] buffers; - private SoftAudioProcessor reverb; + private final SoftAudioProcessor reverb; - private SoftAudioProcessor chorus; + private final SoftAudioProcessor chorus; - private SoftAudioProcessor agc; + private final SoftAudioProcessor agc; - private int nrofchannels; + private final int nrofchannels; - private Object control_mutex; + private final Object control_mutex; - private List openLinesList = new ArrayList(); + private final List openLinesList = new ArrayList(); private SoftMixingDataLine[] openLines = new SoftMixingDataLine[0]; @@ -87,7 +87,7 @@ public class SoftMixingMainMixer { return ais; } - protected void processAudioBuffers() { + void processAudioBuffers() { for (int i = 0; i < buffers.length; i++) { buffers[i].clear(); } @@ -162,20 +162,20 @@ public class SoftMixingMainMixer { InputStream in = new InputStream() { - private SoftAudioBuffer[] buffers = SoftMixingMainMixer.this.buffers; + private final SoftAudioBuffer[] buffers = SoftMixingMainMixer.this.buffers; - private int nrofchannels = SoftMixingMainMixer.this.mixer + private final int nrofchannels = SoftMixingMainMixer.this.mixer .getFormat().getChannels(); - private int buffersize = buffers[0].getSize(); + private final int buffersize = buffers[0].getSize(); - private byte[] bbuffer = new byte[buffersize + private final byte[] bbuffer = new byte[buffersize * (SoftMixingMainMixer.this.mixer.getFormat() .getSampleSizeInBits() / 8) * nrofchannels]; private int bbuffer_pos = 0; - private byte[] single = new byte[1]; + private final byte[] single = new byte[1]; public void fillBuffer() { processAudioBuffers(); diff --git a/jdk/src/share/classes/com/sun/media/sound/SoftMixingMixer.java b/jdk/src/share/classes/com/sun/media/sound/SoftMixingMixer.java index abc31cb8fa1..9df5641ab13 100644 --- a/jdk/src/share/classes/com/sun/media/sound/SoftMixingMixer.java +++ b/jdk/src/share/classes/com/sun/media/sound/SoftMixingMixer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2013, 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 @@ -48,27 +48,27 @@ import javax.sound.sampled.Control.Type; * * @author Karl Helgason */ -public class SoftMixingMixer implements Mixer { +public final class SoftMixingMixer implements Mixer { private static class Info extends Mixer.Info { - public Info() { + Info() { super(INFO_NAME, INFO_VENDOR, INFO_DESCRIPTION, INFO_VERSION); } } - protected static final String INFO_NAME = "Gervill Sound Mixer"; + static final String INFO_NAME = "Gervill Sound Mixer"; - protected static final String INFO_VENDOR = "OpenJDK Proposal"; + static final String INFO_VENDOR = "OpenJDK Proposal"; - protected static final String INFO_DESCRIPTION = "Software Sound Mixer"; + static final String INFO_DESCRIPTION = "Software Sound Mixer"; - protected static final String INFO_VERSION = "1.0"; + static final String INFO_VERSION = "1.0"; - protected final static Mixer.Info info = new Info(); + static final Mixer.Info info = new Info(); - protected Object control_mutex = this; + final Object control_mutex = this; - protected boolean implicitOpen = false; + boolean implicitOpen = false; private boolean open = false; @@ -82,15 +82,15 @@ public class SoftMixingMixer implements Mixer { private AudioInputStream pusher_stream = null; - private float controlrate = 147f; + private final float controlrate = 147f; - private long latency = 100000; // 100 msec + private final long latency = 100000; // 100 msec - private boolean jitter_correction = false; + private final boolean jitter_correction = false; - private List listeners = new ArrayList(); + private final List listeners = new ArrayList(); - private javax.sound.sampled.Line.Info[] sourceLineInfo; + private final javax.sound.sampled.Line.Info[] sourceLineInfo; public SoftMixingMixer() { @@ -516,11 +516,11 @@ public class SoftMixingMixer implements Mixer { } } - protected float getControlRate() { + float getControlRate() { return controlrate; } - protected SoftMixingMainMixer getMainMixer() { + SoftMixingMainMixer getMainMixer() { if (!isOpen()) return null; return mainmixer; diff --git a/jdk/src/share/classes/com/sun/media/sound/SoftMixingMixerProvider.java b/jdk/src/share/classes/com/sun/media/sound/SoftMixingMixerProvider.java index 862aeff97cf..7b842f50495 100644 --- a/jdk/src/share/classes/com/sun/media/sound/SoftMixingMixerProvider.java +++ b/jdk/src/share/classes/com/sun/media/sound/SoftMixingMixerProvider.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2013, 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 @@ -33,13 +33,13 @@ import javax.sound.sampled.spi.MixerProvider; * * @author Karl Helgason */ -public class SoftMixingMixerProvider extends MixerProvider { +public final class SoftMixingMixerProvider extends MixerProvider { static SoftMixingMixer globalmixer = null; static Thread lockthread = null; - protected final static Object mutex = new Object(); + static final Object mutex = new Object(); public Mixer getMixer(Info info) { if (!(info == null || info == SoftMixingMixer.info)) { diff --git a/jdk/src/share/classes/com/sun/media/sound/SoftMixingSourceDataLine.java b/jdk/src/share/classes/com/sun/media/sound/SoftMixingSourceDataLine.java index 2f7cdbaa389..d827770a514 100644 --- a/jdk/src/share/classes/com/sun/media/sound/SoftMixingSourceDataLine.java +++ b/jdk/src/share/classes/com/sun/media/sound/SoftMixingSourceDataLine.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2013, 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,8 +41,8 @@ import javax.sound.sampled.SourceDataLine; * * @author Karl Helgason */ -public class SoftMixingSourceDataLine extends SoftMixingDataLine implements - SourceDataLine { +public final class SoftMixingSourceDataLine extends SoftMixingDataLine + implements SourceDataLine { private boolean open = false; @@ -72,7 +72,7 @@ public class SoftMixingSourceDataLine extends SoftMixingDataLine implements AudioFloatInputStream { AudioFloatInputStream ais; - public NonBlockingFloatInputStream(AudioFloatInputStream ais) { + NonBlockingFloatInputStream(AudioFloatInputStream ais) { this.ais = ais; } @@ -120,7 +120,7 @@ public class SoftMixingSourceDataLine extends SoftMixingDataLine implements } - protected SoftMixingSourceDataLine(SoftMixingMixer mixer, DataLine.Info info) { + SoftMixingSourceDataLine(SoftMixingMixer mixer, DataLine.Info info) { super(mixer, info); } diff --git a/jdk/src/share/classes/com/sun/media/sound/SoftPerformer.java b/jdk/src/share/classes/com/sun/media/sound/SoftPerformer.java index 274f8daf51c..905bdb3128e 100644 --- a/jdk/src/share/classes/com/sun/media/sound/SoftPerformer.java +++ b/jdk/src/share/classes/com/sun/media/sound/SoftPerformer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2013, 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 @@ -37,7 +37,7 @@ import java.util.Map; * * @author Karl Helgason */ -public class SoftPerformer { +public final class SoftPerformer { static ModelConnectionBlock[] defaultconnections = new ModelConnectionBlock[42]; diff --git a/jdk/src/share/classes/com/sun/media/sound/SoftPointResampler.java b/jdk/src/share/classes/com/sun/media/sound/SoftPointResampler.java index 5aff93ef90b..4256eaba255 100644 --- a/jdk/src/share/classes/com/sun/media/sound/SoftPointResampler.java +++ b/jdk/src/share/classes/com/sun/media/sound/SoftPointResampler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2013, 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 @@ -29,7 +29,7 @@ package com.sun.media.sound; * * @author Karl Helgason */ -public class SoftPointResampler extends SoftAbstractResampler { +public final class SoftPointResampler extends SoftAbstractResampler { public int getPadding() { return 100; diff --git a/jdk/src/share/classes/com/sun/media/sound/SoftProvider.java b/jdk/src/share/classes/com/sun/media/sound/SoftProvider.java index bf3c45eb7fb..9fe8ad07390 100644 --- a/jdk/src/share/classes/com/sun/media/sound/SoftProvider.java +++ b/jdk/src/share/classes/com/sun/media/sound/SoftProvider.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2013, 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 @@ -34,10 +34,10 @@ import javax.sound.midi.spi.MidiDeviceProvider; * * @author Karl Helgason */ -public class SoftProvider extends MidiDeviceProvider { +public final class SoftProvider extends MidiDeviceProvider { - protected final static Info softinfo = SoftSynthesizer.info; - private static Info[] softinfos = {softinfo}; + static final Info softinfo = SoftSynthesizer.info; + private static final Info[] softinfos = {softinfo}; public MidiDevice.Info[] getDeviceInfo() { return Arrays.copyOf(softinfos, softinfos.length); diff --git a/jdk/src/share/classes/com/sun/media/sound/SoftReceiver.java b/jdk/src/share/classes/com/sun/media/sound/SoftReceiver.java index 7edd02fdaad..9a0d9c0e84a 100644 --- a/jdk/src/share/classes/com/sun/media/sound/SoftReceiver.java +++ b/jdk/src/share/classes/com/sun/media/sound/SoftReceiver.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2013, 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 @@ -36,13 +36,13 @@ import javax.sound.midi.ShortMessage; * * @author Karl Helgason */ -public class SoftReceiver implements MidiDeviceReceiver { +public final class SoftReceiver implements MidiDeviceReceiver { - protected boolean open = true; - private Object control_mutex; - private SoftSynthesizer synth; - protected TreeMap midimessages; - protected SoftMainMixer mainmixer; + boolean open = true; + private final Object control_mutex; + private final SoftSynthesizer synth; + TreeMap midimessages; + SoftMainMixer mainmixer; public SoftReceiver(SoftSynthesizer synth) { this.control_mutex = synth.control_mutex; diff --git a/jdk/src/share/classes/com/sun/media/sound/SoftReverb.java b/jdk/src/share/classes/com/sun/media/sound/SoftReverb.java index e72a8bd495a..c30aae03f6d 100644 --- a/jdk/src/share/classes/com/sun/media/sound/SoftReverb.java +++ b/jdk/src/share/classes/com/sun/media/sound/SoftReverb.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2013, 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 @@ -33,14 +33,14 @@ import java.util.Arrays; * * @author Karl Helgason */ -public class SoftReverb implements SoftAudioProcessor { +public final class SoftReverb implements SoftAudioProcessor { private final static class Delay { private float[] delaybuffer; private int rovepos = 0; - public Delay() { + Delay() { delaybuffer = null; } @@ -77,7 +77,7 @@ public class SoftReverb implements SoftAudioProcessor { private int rovepos = 0; private float feedback; - public AllPass(int size) { + AllPass(int size) { delaybuffer = new float[size]; delaybuffersize = size; } @@ -127,7 +127,7 @@ public class SoftReverb implements SoftAudioProcessor { private float filtercoeff1 = 0; private float filtercoeff2 = 1; - public Comb(int size) { + Comb(int size) { delaybuffer = new float[size]; delaybuffersize = size; } diff --git a/jdk/src/share/classes/com/sun/media/sound/SoftShortMessage.java b/jdk/src/share/classes/com/sun/media/sound/SoftShortMessage.java index 3b5911c6a6c..f2122601c69 100644 --- a/jdk/src/share/classes/com/sun/media/sound/SoftShortMessage.java +++ b/jdk/src/share/classes/com/sun/media/sound/SoftShortMessage.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2013, 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 @@ -32,7 +32,7 @@ import javax.sound.midi.ShortMessage; * * @author Karl Helgason */ -public class SoftShortMessage extends ShortMessage { +public final class SoftShortMessage extends ShortMessage { int channel = 0; diff --git a/jdk/src/share/classes/com/sun/media/sound/SoftSincResampler.java b/jdk/src/share/classes/com/sun/media/sound/SoftSincResampler.java index e3ba92742cc..051e44120e8 100644 --- a/jdk/src/share/classes/com/sun/media/sound/SoftSincResampler.java +++ b/jdk/src/share/classes/com/sun/media/sound/SoftSincResampler.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2013, 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 @@ -31,7 +31,7 @@ package com.sun.media.sound; * * @author Karl Helgason */ -public class SoftSincResampler extends SoftAbstractResampler { +public final class SoftSincResampler extends SoftAbstractResampler { float[][][] sinc_table; int sinc_scale_size = 100; diff --git a/jdk/src/share/classes/com/sun/media/sound/SoftSynthesizer.java b/jdk/src/share/classes/com/sun/media/sound/SoftSynthesizer.java index a868bd441a2..01a64c2dddf 100644 --- a/jdk/src/share/classes/com/sun/media/sound/SoftSynthesizer.java +++ b/jdk/src/share/classes/com/sun/media/sound/SoftSynthesizer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2013, 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 @@ -66,10 +66,10 @@ import javax.sound.sampled.SourceDataLine; * * @author Karl Helgason */ -public class SoftSynthesizer implements AudioSynthesizer, +public final class SoftSynthesizer implements AudioSynthesizer, ReferenceCountingDevice { - protected static class WeakAudioStream extends InputStream + protected static final class WeakAudioStream extends InputStream { private volatile AudioInputStream stream; public SoftAudioPusher pusher = null; @@ -166,39 +166,39 @@ public class SoftSynthesizer implements AudioSynthesizer, } private static class Info extends MidiDevice.Info { - public Info() { + Info() { super(INFO_NAME, INFO_VENDOR, INFO_DESCRIPTION, INFO_VERSION); } } - protected static final String INFO_NAME = "Gervill"; - protected static final String INFO_VENDOR = "OpenJDK"; - protected static final String INFO_DESCRIPTION = "Software MIDI Synthesizer"; - protected static final String INFO_VERSION = "1.0"; - protected final static MidiDevice.Info info = new Info(); + static final String INFO_NAME = "Gervill"; + static final String INFO_VENDOR = "OpenJDK"; + static final String INFO_DESCRIPTION = "Software MIDI Synthesizer"; + static final String INFO_VERSION = "1.0"; + final static MidiDevice.Info info = new Info(); private static SourceDataLine testline = null; private static Soundbank defaultSoundBank = null; - protected WeakAudioStream weakstream = null; + WeakAudioStream weakstream = null; - protected Object control_mutex = this; + final Object control_mutex = this; - protected int voiceIDCounter = 0; + int voiceIDCounter = 0; // 0: default // 1: DLS Voice Allocation - protected int voice_allocation_mode = 0; + int voice_allocation_mode = 0; - protected boolean load_default_soundbank = false; - protected boolean reverb_light = true; - protected boolean reverb_on = true; - protected boolean chorus_on = true; - protected boolean agc_on = true; + boolean load_default_soundbank = false; + boolean reverb_light = true; + boolean reverb_on = true; + boolean chorus_on = true; + boolean agc_on = true; - protected SoftChannel[] channels; - protected SoftChannelProxy[] external_channels = null; + SoftChannel[] channels; + SoftChannelProxy[] external_channels = null; private boolean largemode = false; @@ -371,7 +371,7 @@ public class SoftSynthesizer implements AudioSynthesizer, this.format = format; } - protected void removeReceiver(Receiver recv) { + void removeReceiver(Receiver recv) { boolean perform_close = false; synchronized (control_mutex) { if (recvslist.remove(recv)) { @@ -383,13 +383,13 @@ public class SoftSynthesizer implements AudioSynthesizer, close(); } - protected SoftMainMixer getMainMixer() { + SoftMainMixer getMainMixer() { if (!isOpen()) return null; return mainmixer; } - protected SoftInstrument findInstrument(int program, int bank, int channel) { + SoftInstrument findInstrument(int program, int bank, int channel) { // Add support for GM2 banks 0x78 and 0x79 // as specified in DLS 2.2 in Section 1.4.6 @@ -450,31 +450,31 @@ public class SoftSynthesizer implements AudioSynthesizer, return null; } - protected int getVoiceAllocationMode() { + int getVoiceAllocationMode() { return voice_allocation_mode; } - protected int getGeneralMidiMode() { + int getGeneralMidiMode() { return gmmode; } - protected void setGeneralMidiMode(int gmmode) { + void setGeneralMidiMode(int gmmode) { this.gmmode = gmmode; } - protected int getDeviceID() { + int getDeviceID() { return deviceid; } - protected float getControlRate() { + float getControlRate() { return controlrate; } - protected SoftVoice[] getVoices() { + SoftVoice[] getVoices() { return voices; } - protected SoftTuning getTuning(Patch patch) { + SoftTuning getTuning(Patch patch) { String t_id = patchToString(patch); SoftTuning tuning = tunings.get(t_id); if (tuning == null) { diff --git a/jdk/src/share/classes/com/sun/media/sound/SoftTuning.java b/jdk/src/share/classes/com/sun/media/sound/SoftTuning.java index 611db14e527..b3cb6c52e91 100644 --- a/jdk/src/share/classes/com/sun/media/sound/SoftTuning.java +++ b/jdk/src/share/classes/com/sun/media/sound/SoftTuning.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2013, 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 @@ -35,10 +35,10 @@ import javax.sound.midi.Patch; * * @author Karl Helgason */ -public class SoftTuning { +public final class SoftTuning { private String name = null; - private double[] tuning = new double[128]; + private final double[] tuning = new double[128]; private Patch patch = null; public SoftTuning() { diff --git a/jdk/src/share/classes/com/sun/media/sound/SoftVoice.java b/jdk/src/share/classes/com/sun/media/sound/SoftVoice.java index b4189487877..ea2cff03531 100644 --- a/jdk/src/share/classes/com/sun/media/sound/SoftVoice.java +++ b/jdk/src/share/classes/com/sun/media/sound/SoftVoice.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2013, 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 @@ -36,7 +36,7 @@ import javax.sound.midi.VoiceStatus; * * @author Karl Helgason */ -public class SoftVoice extends VoiceStatus { +public final class SoftVoice extends VoiceStatus { public int exclusiveClass = 0; public boolean releaseTriggered = false; @@ -44,32 +44,32 @@ public class SoftVoice extends VoiceStatus { private int noteOn_velocity = 0; private int noteOff_velocity = 0; private int delay = 0; - protected ModelChannelMixer channelmixer = null; - protected double tunedKey = 0; - protected SoftTuning tuning = null; - protected SoftChannel stealer_channel = null; - protected ModelConnectionBlock[] stealer_extendedConnectionBlocks = null; - protected SoftPerformer stealer_performer = null; - protected ModelChannelMixer stealer_channelmixer = null; - protected int stealer_voiceID = -1; - protected int stealer_noteNumber = 0; - protected int stealer_velocity = 0; - protected boolean stealer_releaseTriggered = false; - protected int voiceID = -1; - protected boolean sustain = false; - protected boolean sostenuto = false; - protected boolean portamento = false; - private SoftFilter filter_left; - private SoftFilter filter_right; - private SoftProcess eg = new SoftEnvelopeGenerator(); - private SoftProcess lfo = new SoftLowFrequencyOscillator(); - protected Map objects = + ModelChannelMixer channelmixer = null; + double tunedKey = 0; + SoftTuning tuning = null; + SoftChannel stealer_channel = null; + ModelConnectionBlock[] stealer_extendedConnectionBlocks = null; + SoftPerformer stealer_performer = null; + ModelChannelMixer stealer_channelmixer = null; + int stealer_voiceID = -1; + int stealer_noteNumber = 0; + int stealer_velocity = 0; + boolean stealer_releaseTriggered = false; + int voiceID = -1; + boolean sustain = false; + boolean sostenuto = false; + boolean portamento = false; + private final SoftFilter filter_left; + private final SoftFilter filter_right; + private final SoftProcess eg = new SoftEnvelopeGenerator(); + private final SoftProcess lfo = new SoftLowFrequencyOscillator(); + Map objects = new HashMap(); - protected SoftSynthesizer synthesizer; - protected SoftInstrument instrument; - protected SoftPerformer performer; - protected SoftChannel softchannel = null; - protected boolean on = false; + SoftSynthesizer synthesizer; + SoftInstrument instrument; + SoftPerformer performer; + SoftChannel softchannel = null; + boolean on = false; private boolean audiostarted = false; private boolean started = false; private boolean stopping = false; @@ -87,7 +87,7 @@ public class SoftVoice extends VoiceStatus { private float last_out_mixer_right = 0; private float last_out_mixer_effect1 = 0; private float last_out_mixer_effect2 = 0; - protected ModelConnectionBlock[] extendedConnectionBlocks = null; + ModelConnectionBlock[] extendedConnectionBlocks = null; private ModelConnectionBlock[] connections; // Last value added to destination private double[] connections_last = new double[50]; @@ -100,10 +100,10 @@ public class SoftVoice extends VoiceStatus { private boolean soundoff = false; private float lastMuteValue = 0; private float lastSoloMuteValue = 0; - protected double[] co_noteon_keynumber = new double[1]; - protected double[] co_noteon_velocity = new double[1]; - protected double[] co_noteon_on = new double[1]; - private SoftControl co_noteon = new SoftControl() { + double[] co_noteon_keynumber = new double[1]; + double[] co_noteon_velocity = new double[1]; + double[] co_noteon_on = new double[1]; + private final SoftControl co_noteon = new SoftControl() { double[] keynumber = co_noteon_keynumber; double[] velocity = co_noteon_velocity; double[] on = co_noteon_on; @@ -119,13 +119,13 @@ public class SoftVoice extends VoiceStatus { return null; } }; - private double[] co_mixer_active = new double[1]; - private double[] co_mixer_gain = new double[1]; - private double[] co_mixer_pan = new double[1]; - private double[] co_mixer_balance = new double[1]; - private double[] co_mixer_reverb = new double[1]; - private double[] co_mixer_chorus = new double[1]; - private SoftControl co_mixer = new SoftControl() { + private final double[] co_mixer_active = new double[1]; + private final double[] co_mixer_gain = new double[1]; + private final double[] co_mixer_pan = new double[1]; + private final double[] co_mixer_balance = new double[1]; + private final double[] co_mixer_reverb = new double[1]; + private final double[] co_mixer_chorus = new double[1]; + private final SoftControl co_mixer = new SoftControl() { double[] active = co_mixer_active; double[] gain = co_mixer_gain; double[] pan = co_mixer_pan; @@ -150,8 +150,8 @@ public class SoftVoice extends VoiceStatus { return null; } }; - private double[] co_osc_pitch = new double[1]; - private SoftControl co_osc = new SoftControl() { + private final double[] co_osc_pitch = new double[1]; + private final SoftControl co_osc = new SoftControl() { double[] pitch = co_osc_pitch; public double[] get(int instance, String name) { if (name == null) @@ -161,10 +161,10 @@ public class SoftVoice extends VoiceStatus { return null; } }; - private double[] co_filter_freq = new double[1]; - private double[] co_filter_type = new double[1]; - private double[] co_filter_q = new double[1]; - private SoftControl co_filter = new SoftControl() { + private final double[] co_filter_freq = new double[1]; + private final double[] co_filter_type = new double[1]; + private final double[] co_filter_q = new double[1]; + private final SoftControl co_filter = new SoftControl() { double[] freq = co_filter_freq; double[] ftype = co_filter_type; double[] q = co_filter_q; @@ -180,8 +180,8 @@ public class SoftVoice extends VoiceStatus { return null; } }; - protected SoftResamplerStreamer resampler; - private int nrofchannels; + SoftResamplerStreamer resampler; + private final int nrofchannels; public SoftVoice(SoftSynthesizer synth) { synthesizer = synth; @@ -278,7 +278,7 @@ public class SoftVoice extends VoiceStatus { // co_mixer_gain[0] = 0; } - protected void updateTuning(SoftTuning newtuning) { + void updateTuning(SoftTuning newtuning) { tuning = newtuning; tunedKey = tuning.getTuning(note) / 100.0; if (!portamento) { @@ -293,12 +293,12 @@ public class SoftVoice extends VoiceStatus { } } - protected void setNote(int noteNumber) { + void setNote(int noteNumber) { note = noteNumber; tunedKey = tuning.getTuning(noteNumber) / 100.0; } - protected void noteOn(int noteNumber, int velocity, int delay) { + void noteOn(int noteNumber, int velocity, int delay) { sustain = false; sostenuto = false; @@ -435,7 +435,7 @@ public class SoftVoice extends VoiceStatus { } - protected void setPolyPressure(int pressure) { + void setPolyPressure(int pressure) { if(performer == null) return; int[] c = performer.midi_connections[2]; @@ -445,7 +445,7 @@ public class SoftVoice extends VoiceStatus { processConnection(c[i]); } - protected void setChannelPressure(int pressure) { + void setChannelPressure(int pressure) { if(performer == null) return; int[] c = performer.midi_connections[1]; @@ -455,7 +455,7 @@ public class SoftVoice extends VoiceStatus { processConnection(c[i]); } - protected void controlChange(int controller, int value) { + void controlChange(int controller, int value) { if(performer == null) return; int[] c = performer.midi_ctrl_connections[controller]; @@ -465,7 +465,7 @@ public class SoftVoice extends VoiceStatus { processConnection(c[i]); } - protected void nrpnChange(int controller, int value) { + void nrpnChange(int controller, int value) { if(performer == null) return; int[] c = performer.midi_nrpn_connections.get(controller); @@ -475,7 +475,7 @@ public class SoftVoice extends VoiceStatus { processConnection(c[i]); } - protected void rpnChange(int controller, int value) { + void rpnChange(int controller, int value) { if(performer == null) return; int[] c = performer.midi_rpn_connections.get(controller); @@ -485,7 +485,7 @@ public class SoftVoice extends VoiceStatus { processConnection(c[i]); } - protected void setPitchBend(int bend) { + void setPitchBend(int bend) { if(performer == null) return; int[] c = performer.midi_connections[0]; @@ -495,19 +495,19 @@ public class SoftVoice extends VoiceStatus { processConnection(c[i]); } - protected void setMute(boolean mute) { + void setMute(boolean mute) { co_mixer_gain[0] -= lastMuteValue; lastMuteValue = mute ? -960 : 0; co_mixer_gain[0] += lastMuteValue; } - protected void setSoloMute(boolean mute) { + void setSoloMute(boolean mute) { co_mixer_gain[0] -= lastSoloMuteValue; lastSoloMuteValue = mute ? -960 : 0; co_mixer_gain[0] += lastSoloMuteValue; } - protected void shutdown() { + void shutdown() { if (co_noteon_on[0] < -0.5) return; on = false; @@ -523,12 +523,12 @@ public class SoftVoice extends VoiceStatus { processConnection(c[i]); } - protected void soundOff() { + void soundOff() { on = false; soundoff = true; } - protected void noteOff(int velocity) { + void noteOff(int velocity) { if (!on) return; on = false; @@ -553,7 +553,7 @@ public class SoftVoice extends VoiceStatus { processConnection(c[i]); } - protected void redamp() { + void redamp() { if (co_noteon_on[0] > 0.5) return; if (co_noteon_on[0] < -0.5) @@ -571,7 +571,7 @@ public class SoftVoice extends VoiceStatus { processConnection(c[i]); } - protected void processControlLogic() { + void processControlLogic() { if (stopping) { active = false; stopping = false; @@ -760,9 +760,9 @@ public class SoftVoice extends VoiceStatus { } - protected void mixAudioStream(SoftAudioBuffer in, SoftAudioBuffer out, - SoftAudioBuffer dout, - float amp_from, float amp_to) { + void mixAudioStream(SoftAudioBuffer in, SoftAudioBuffer out, + SoftAudioBuffer dout, float amp_from, + float amp_to) { int bufferlen = in.getSize(); if (amp_from < 0.000000001 && amp_to < 0.000000001) return; @@ -815,7 +815,7 @@ public class SoftVoice extends VoiceStatus { } - protected void processAudioLogic(SoftAudioBuffer[] buffer) { + void processAudioLogic(SoftAudioBuffer[] buffer) { if (!audiostarted) return; diff --git a/jdk/src/share/classes/com/sun/media/sound/StandardMidiFileReader.java b/jdk/src/share/classes/com/sun/media/sound/StandardMidiFileReader.java index 5dd2c23354a..1dbd72a262a 100644 --- a/jdk/src/share/classes/com/sun/media/sound/StandardMidiFileReader.java +++ b/jdk/src/share/classes/com/sun/media/sound/StandardMidiFileReader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2013, 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 @@ -26,22 +26,13 @@ package com.sun.media.sound; import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.PipedInputStream; -import java.io.PipedOutputStream; -import java.io.ByteArrayOutputStream; -import java.io.ByteArrayInputStream; -import java.io.SequenceInputStream; import java.io.File; import java.io.FileInputStream; import java.io.InputStream; import java.io.IOException; import java.io.EOFException; -import java.io.OutputStream; -import java.io.RandomAccessFile; import java.io.BufferedInputStream; import java.net.URL; -import java.net.MalformedURLException; import javax.sound.midi.MidiFileFormat; import javax.sound.midi.InvalidMidiDataException; @@ -49,7 +40,6 @@ import javax.sound.midi.MetaMessage; import javax.sound.midi.MidiEvent; import javax.sound.midi.MidiMessage; import javax.sound.midi.Sequence; -import javax.sound.midi.ShortMessage; import javax.sound.midi.SysexMessage; import javax.sound.midi.Track; import javax.sound.midi.spi.MidiFileReader; @@ -64,23 +54,12 @@ import javax.sound.midi.spi.MidiFileReader; * @author Florian Bomers */ -public class StandardMidiFileReader extends MidiFileReader { +public final class StandardMidiFileReader extends MidiFileReader { private static final int MThd_MAGIC = 0x4d546864; // 'MThd' - private static final int MIDI_TYPE_0 = 0; - private static final int MIDI_TYPE_1 = 1; - private static final int bisBufferSize = 1024; // buffer size in buffered input streams - /** - * MIDI parser types - */ - private static final int types[] = { - MIDI_TYPE_0, - MIDI_TYPE_1 - }; - public MidiFileFormat getMidiFileFormat(InputStream stream) throws InvalidMidiDataException, IOException { return getMidiFileFormatFromStream(stream, MidiFileFormat.UNKNOWN_LENGTH, null); } @@ -253,7 +232,7 @@ public class StandardMidiFileReader extends MidiFileReader { /** * State variables during parsing of a MIDI file */ -class SMFParser { +final class SMFParser { private static final int MTrk_MAGIC = 0x4d54726b; // 'MTrk' // set to true to not allow corrupt MIDI files tombe loaded @@ -268,7 +247,7 @@ class SMFParser { private byte[] trackData = null; private int pos = 0; - public SMFParser() { + SMFParser() { } private int readUnsigned() throws IOException { diff --git a/jdk/src/share/classes/com/sun/media/sound/StandardMidiFileWriter.java b/jdk/src/share/classes/com/sun/media/sound/StandardMidiFileWriter.java index a779fd7e226..97e0dc2928a 100644 --- a/jdk/src/share/classes/com/sun/media/sound/StandardMidiFileWriter.java +++ b/jdk/src/share/classes/com/sun/media/sound/StandardMidiFileWriter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2013, 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,7 +25,6 @@ package com.sun.media.sound; -import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.PipedInputStream; import java.io.PipedOutputStream; @@ -34,18 +33,13 @@ import java.io.ByteArrayInputStream; import java.io.SequenceInputStream; import java.io.File; import java.io.FileOutputStream; -import java.io.BufferedOutputStream; import java.io.InputStream; import java.io.IOException; -import java.lang.IllegalArgumentException; import java.io.OutputStream; -import java.util.Vector; -import javax.sound.midi.MidiFileFormat; import javax.sound.midi.InvalidMidiDataException; import javax.sound.midi.MidiEvent; import javax.sound.midi.MetaMessage; -import javax.sound.midi.MidiMessage; import javax.sound.midi.Sequence; import javax.sound.midi.ShortMessage; import javax.sound.midi.SysexMessage; @@ -59,7 +53,7 @@ import javax.sound.midi.spi.MidiFileWriter; * @author Kara Kytle * @author Jan Borgersen */ -public class StandardMidiFileWriter extends MidiFileWriter { +public final class StandardMidiFileWriter extends MidiFileWriter { private static final int MThd_MAGIC = 0x4d546864; // 'MThd' private static final int MTrk_MAGIC = 0x4d54726b; // 'MTrk' diff --git a/jdk/src/share/classes/com/sun/media/sound/SunCodec.java b/jdk/src/share/classes/com/sun/media/sound/SunCodec.java index fa3940667ba..232789352c5 100644 --- a/jdk/src/share/classes/com/sun/media/sound/SunCodec.java +++ b/jdk/src/share/classes/com/sun/media/sound/SunCodec.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2013, 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,8 +25,6 @@ package com.sun.media.sound; -import java.io.InputStream; - import javax.sound.sampled.AudioFormat; import javax.sound.sampled.AudioInputStream; @@ -48,14 +46,14 @@ import javax.sound.sampled.spi.FormatConversionProvider; */ abstract class SunCodec extends FormatConversionProvider { - AudioFormat.Encoding[] inputEncodings; - AudioFormat.Encoding[] outputEncodings; + private final AudioFormat.Encoding[] inputEncodings; + private final AudioFormat.Encoding[] outputEncodings; /** * Constructs a new codec object. */ - protected SunCodec(AudioFormat.Encoding[] inputEncodings, AudioFormat.Encoding[] outputEncodings) { - + SunCodec(final AudioFormat.Encoding[] inputEncodings, + final AudioFormat.Encoding[] outputEncodings) { this.inputEncodings = inputEncodings; this.outputEncodings = outputEncodings; } @@ -63,16 +61,14 @@ abstract class SunCodec extends FormatConversionProvider { /** */ - public AudioFormat.Encoding[] getSourceEncodings() { - + public final AudioFormat.Encoding[] getSourceEncodings() { AudioFormat.Encoding[] encodings = new AudioFormat.Encoding[inputEncodings.length]; System.arraycopy(inputEncodings, 0, encodings, 0, inputEncodings.length); return encodings; } /** */ - public AudioFormat.Encoding[] getTargetEncodings() { - + public final AudioFormat.Encoding[] getTargetEncodings() { AudioFormat.Encoding[] encodings = new AudioFormat.Encoding[outputEncodings.length]; System.arraycopy(outputEncodings, 0, encodings, 0, outputEncodings.length); return encodings; diff --git a/jdk/src/share/classes/com/sun/media/sound/SunFileReader.java b/jdk/src/share/classes/com/sun/media/sound/SunFileReader.java index 67418fe679b..202b94fb15f 100644 --- a/jdk/src/share/classes/com/sun/media/sound/SunFileReader.java +++ b/jdk/src/share/classes/com/sun/media/sound/SunFileReader.java @@ -27,7 +27,6 @@ package com.sun.media.sound; import java.io.File; import java.io.InputStream; -import java.io.OutputStream; import java.io.IOException; import java.io.DataInputStream; import java.net.URL; @@ -52,7 +51,7 @@ abstract class SunFileReader extends AudioFileReader { /** * Constructs a new SunFileReader object. */ - public SunFileReader() { + SunFileReader() { } @@ -167,7 +166,7 @@ abstract class SunFileReader extends AudioFileReader { * @return 32 bits swapped value. * @exception IOException */ - protected int rllong(DataInputStream dis) throws IOException { + final int rllong(DataInputStream dis) throws IOException { int b1, b2, b3, b4 ; int i = 0; @@ -190,7 +189,7 @@ abstract class SunFileReader extends AudioFileReader { * @param int * @return 32 bits swapped value */ - protected int big2little(int i) { + final int big2little(int i) { int b1, b2, b3, b4 ; @@ -211,7 +210,7 @@ abstract class SunFileReader extends AudioFileReader { * @return the swapped value. * @exception IOException */ - protected short rlshort(DataInputStream dis) throws IOException { + final short rlshort(DataInputStream dis) throws IOException { short s=0; short high, low; @@ -232,7 +231,7 @@ abstract class SunFileReader extends AudioFileReader { * @param int * @return 16 bits swapped value */ - protected short big2littleShort(short i) { + final short big2littleShort(short i) { short high, low; @@ -244,16 +243,14 @@ abstract class SunFileReader extends AudioFileReader { return i; } - - /** Calculates the frame size for PCM frames. - * Note that this method is appropriate for non-packed samples. - * For instance, 12 bit, 2 channels will return 4 bytes, not 3. - * @param sampleSizeInBits the size of a single sample in bits - * @param channels the number of channels - * @return the size of a PCM frame in bytes. - */ - protected static int calculatePCMFrameSize(int sampleSizeInBits, - int channels) { - return ((sampleSizeInBits + 7) / 8) * channels; - } + /** Calculates the frame size for PCM frames. + * Note that this method is appropriate for non-packed samples. + * For instance, 12 bit, 2 channels will return 4 bytes, not 3. + * @param sampleSizeInBits the size of a single sample in bits + * @param channels the number of channels + * @return the size of a PCM frame in bytes. + */ + static final int calculatePCMFrameSize(int sampleSizeInBits, int channels) { + return ((sampleSizeInBits + 7) / 8) * channels; + } } diff --git a/jdk/src/share/classes/com/sun/media/sound/SunFileWriter.java b/jdk/src/share/classes/com/sun/media/sound/SunFileWriter.java index b5755389478..d771bad119e 100644 --- a/jdk/src/share/classes/com/sun/media/sound/SunFileWriter.java +++ b/jdk/src/share/classes/com/sun/media/sound/SunFileWriter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2013, 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,8 +69,7 @@ abstract class SunFileWriter extends AudioFileWriter { // new, 10.27.99 - public AudioFileFormat.Type[] getAudioFileTypes(){ - + public final AudioFileFormat.Type[] getAudioFileTypes(){ AudioFileFormat.Type[] localArray = new AudioFileFormat.Type[types.length]; System.arraycopy(types, 0, localArray, 0, types.length); return localArray; @@ -95,7 +94,7 @@ abstract class SunFileWriter extends AudioFileWriter { * @return 32 bits swapped value. * @exception IOException */ - protected int rllong(DataInputStream dis) throws IOException { + final int rllong(DataInputStream dis) throws IOException { int b1, b2, b3, b4 ; int i = 0; @@ -118,7 +117,7 @@ abstract class SunFileWriter extends AudioFileWriter { * @param int * @return 32 bits swapped value */ - protected int big2little(int i) { + final int big2little(int i) { int b1, b2, b3, b4 ; @@ -139,7 +138,7 @@ abstract class SunFileWriter extends AudioFileWriter { * @return the swapped value. * @exception IOException */ - protected short rlshort(DataInputStream dis) throws IOException { + final short rlshort(DataInputStream dis) throws IOException { short s=0; short high, low; @@ -160,7 +159,7 @@ abstract class SunFileWriter extends AudioFileWriter { * @param int * @return 16 bits swapped value */ - protected short big2littleShort(short i) { + final short big2littleShort(short i) { short high, low; @@ -177,10 +176,10 @@ abstract class SunFileWriter extends AudioFileWriter { * The class is usefull for use with SequenceInputStream to prevent * closing of the source input streams. */ - protected class NoCloseInputStream extends InputStream { + final class NoCloseInputStream extends InputStream { private final InputStream in; - public NoCloseInputStream(InputStream in) { + NoCloseInputStream(InputStream in) { this.in = in; } diff --git a/jdk/src/share/classes/com/sun/media/sound/Toolkit.java b/jdk/src/share/classes/com/sun/media/sound/Toolkit.java index 6a34d1a39a2..5d52b8fe791 100644 --- a/jdk/src/share/classes/com/sun/media/sound/Toolkit.java +++ b/jdk/src/share/classes/com/sun/media/sound/Toolkit.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2013, 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 @@ -35,8 +35,13 @@ import javax.sound.sampled.AudioSystem; * @author Kara Kytle * @author Florian Bomers */ -public class Toolkit { +public final class Toolkit { + /** + * Suppresses default constructor, ensuring non-instantiability. + */ + private Toolkit() { + } /** * Converts bytes from signed to unsigned. diff --git a/jdk/src/share/classes/com/sun/media/sound/UlawCodec.java b/jdk/src/share/classes/com/sun/media/sound/UlawCodec.java index 12e1d53740f..04fa5197b14 100644 --- a/jdk/src/share/classes/com/sun/media/sound/UlawCodec.java +++ b/jdk/src/share/classes/com/sun/media/sound/UlawCodec.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2013, 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,7 +25,6 @@ package com.sun.media.sound; -import java.io.InputStream; import java.io.IOException; import java.util.Vector; @@ -40,12 +39,12 @@ import javax.sound.sampled.AudioInputStream; * * @author Kara Kytle */ -public class UlawCodec extends SunCodec { +public final class UlawCodec extends SunCodec { /* Tables used for U-law decoding */ - final static byte ULAW_TABH[] = new byte[256]; - final static byte ULAW_TABL[] = new byte[256]; + private final static byte[] ULAW_TABH = new byte[256]; + private final static byte[] ULAW_TABL = new byte[256]; private static final AudioFormat.Encoding[] ulawEncodings = {AudioFormat.Encoding.ULAW, AudioFormat.Encoding.PCM_SIGNED}; diff --git a/jdk/src/share/classes/com/sun/media/sound/WaveExtensibleFileReader.java b/jdk/src/share/classes/com/sun/media/sound/WaveExtensibleFileReader.java index 14a1848baaf..827cef6a23a 100644 --- a/jdk/src/share/classes/com/sun/media/sound/WaveExtensibleFileReader.java +++ b/jdk/src/share/classes/com/sun/media/sound/WaveExtensibleFileReader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2013, 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 @@ -46,7 +46,7 @@ import javax.sound.sampled.spi.AudioFileReader; * * @author Karl Helgason */ -public class WaveExtensibleFileReader extends AudioFileReader { +public final class WaveExtensibleFileReader extends AudioFileReader { static private class GUID { long i1; @@ -74,7 +74,7 @@ public class WaveExtensibleFileReader extends AudioFileReader { private GUID() { } - public GUID(long i1, int s1, int s2, int x1, int x2, int x3, int x4, + GUID(long i1, int s1, int s2, int x1, int x2, int x3, int x4, int x5, int x6, int x7, int x8) { this.i1 = i1; this.s1 = s1; @@ -140,13 +140,13 @@ public class WaveExtensibleFileReader extends AudioFileReader { } - private static String[] channelnames = { "FL", "FR", "FC", "LF", + private static final String[] channelnames = { "FL", "FR", "FC", "LF", "BL", "BR", // 5.1 "FLC", "FLR", "BC", "SL", "SR", "TC", "TFL", "TFC", "TFR", "TBL", "TBC", "TBR" }; - private static String[] allchannelnames = { "w1", "w2", "w3", "w4", "w5", + private static final String[] allchannelnames = { "w1", "w2", "w3", "w4", "w5", "w6", "w7", "w8", "w9", "w10", "w11", "w12", "w13", "w14", "w15", "w16", "w17", "w18", "w19", "w20", "w21", "w22", "w23", "w24", "w25", "w26", "w27", "w28", "w29", "w30", "w31", "w32", "w33", @@ -155,10 +155,10 @@ public class WaveExtensibleFileReader extends AudioFileReader { "w52", "w53", "w54", "w55", "w56", "w57", "w58", "w59", "w60", "w61", "w62", "w63", "w64" }; - private static GUID SUBTYPE_PCM = new GUID(0x00000001, 0x0000, 0x0010, + private static final GUID SUBTYPE_PCM = new GUID(0x00000001, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71); - private static GUID SUBTYPE_IEEE_FLOAT = new GUID(0x00000003, 0x0000, + private static final GUID SUBTYPE_IEEE_FLOAT = new GUID(0x00000003, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71); private String decodeChannelMask(long channelmask) { diff --git a/jdk/src/share/classes/com/sun/media/sound/WaveFileFormat.java b/jdk/src/share/classes/com/sun/media/sound/WaveFileFormat.java index 16e4b7d9f48..af9c7160e7e 100644 --- a/jdk/src/share/classes/com/sun/media/sound/WaveFileFormat.java +++ b/jdk/src/share/classes/com/sun/media/sound/WaveFileFormat.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2013, 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,24 +25,8 @@ package com.sun.media.sound; -import java.util.Vector; -import java.io.File; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.IOException; -import java.lang.IllegalArgumentException; - -import java.io.BufferedOutputStream; -import java.io.DataOutputStream; -import java.io.FileOutputStream; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.SequenceInputStream; - import javax.sound.sampled.AudioFileFormat; -import javax.sound.sampled.AudioInputStream; import javax.sound.sampled.AudioFormat; -import javax.sound.sampled.AudioSystem; /** @@ -51,12 +35,12 @@ import javax.sound.sampled.AudioSystem; * @author Jan Borgersen */ -class WaveFileFormat extends AudioFileFormat { +final class WaveFileFormat extends AudioFileFormat { /** * Wave format type. */ - private int waveType; + private final int waveType; //$$fb 2001-07-13: added management of header size in this class //$$fb 2002-04-16: Fix for 4636355: RIFF audio headers could be _more_ spec compliant diff --git a/jdk/src/share/classes/com/sun/media/sound/WaveFileReader.java b/jdk/src/share/classes/com/sun/media/sound/WaveFileReader.java index 6386aa4100e..9ba6a6b8740 100644 --- a/jdk/src/share/classes/com/sun/media/sound/WaveFileReader.java +++ b/jdk/src/share/classes/com/sun/media/sound/WaveFileReader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2013, 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,28 +25,17 @@ package com.sun.media.sound; -import java.util.Vector; -import java.io.File; -import java.io.InputStream; -import java.io.OutputStream; -import java.io.IOException; -import java.io.EOFException; -import java.net.URL; -import java.net.MalformedURLException; - -import java.io.BufferedInputStream; -import java.io.BufferedOutputStream; import java.io.DataInputStream; +import java.io.EOFException; +import java.io.File; import java.io.FileInputStream; -import java.io.DataOutputStream; -import java.io.FileOutputStream; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.SequenceInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; import javax.sound.sampled.AudioFileFormat; -import javax.sound.sampled.AudioInputStream; import javax.sound.sampled.AudioFormat; +import javax.sound.sampled.AudioInputStream; import javax.sound.sampled.AudioSystem; import javax.sound.sampled.UnsupportedAudioFileException; @@ -59,19 +48,10 @@ import javax.sound.sampled.UnsupportedAudioFileException; * @author Jan Borgersen * @author Florian Bomers */ -public class WaveFileReader extends SunFileReader { +public final class WaveFileReader extends SunFileReader { private static final int MAX_READ_LENGTH = 12; - /** - * WAVE reader type - */ - - public static final AudioFileFormat.Type types[] = { - AudioFileFormat.Type.WAVE - }; - - /** * Constructs a new WaveFileReader object. */ diff --git a/jdk/src/share/classes/com/sun/media/sound/WaveFileWriter.java b/jdk/src/share/classes/com/sun/media/sound/WaveFileWriter.java index d4a0a6bd5bf..c5f17e1bc8d 100644 --- a/jdk/src/share/classes/com/sun/media/sound/WaveFileWriter.java +++ b/jdk/src/share/classes/com/sun/media/sound/WaveFileWriter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2013, 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,7 +50,7 @@ import javax.sound.sampled.AudioSystem; * * @author Jan Borgersen */ -public class WaveFileWriter extends SunFileWriter { +public final class WaveFileWriter extends SunFileWriter { // magic numbers static final int RIFF_MAGIC = 1380533830; @@ -73,19 +73,11 @@ public class WaveFileWriter extends SunFileWriter { static final int WAVE_FORMAT_DVI_ADPCM = 0x0011; static final int WAVE_FORMAT_SX7383 = 0x1C07; - /** - * WAVE type - */ - private static final AudioFileFormat.Type waveTypes[] = { - AudioFileFormat.Type.WAVE - }; - - /** * Constructs a new WaveFileWriter object. */ public WaveFileWriter() { - super(waveTypes); + super(new AudioFileFormat.Type[]{AudioFileFormat.Type.WAVE}); } diff --git a/jdk/src/share/classes/com/sun/media/sound/WaveFloatFileReader.java b/jdk/src/share/classes/com/sun/media/sound/WaveFloatFileReader.java index 8db4113b702..280196ef188 100644 --- a/jdk/src/share/classes/com/sun/media/sound/WaveFloatFileReader.java +++ b/jdk/src/share/classes/com/sun/media/sound/WaveFloatFileReader.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2013, 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,7 @@ import javax.sound.sampled.spi.AudioFileReader; * * @author Karl Helgason */ -public class WaveFloatFileReader extends AudioFileReader { +public final class WaveFloatFileReader extends AudioFileReader { public AudioFileFormat getAudioFileFormat(InputStream stream) throws UnsupportedAudioFileException, IOException { diff --git a/jdk/src/share/classes/com/sun/media/sound/WaveFloatFileWriter.java b/jdk/src/share/classes/com/sun/media/sound/WaveFloatFileWriter.java index a61792bacc4..2845083384a 100644 --- a/jdk/src/share/classes/com/sun/media/sound/WaveFloatFileWriter.java +++ b/jdk/src/share/classes/com/sun/media/sound/WaveFloatFileWriter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2013, 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,7 +41,7 @@ import javax.sound.sampled.spi.AudioFileWriter; * * @author Karl Helgason */ -public class WaveFloatFileWriter extends AudioFileWriter { +public final class WaveFloatFileWriter extends AudioFileWriter { public Type[] getAudioFileTypes() { return new Type[] { Type.WAVE }; @@ -86,9 +86,9 @@ public class WaveFloatFileWriter extends AudioFileWriter { } private static class NoCloseOutputStream extends OutputStream { - OutputStream out; + final OutputStream out; - public NoCloseOutputStream(OutputStream out) { + NoCloseOutputStream(OutputStream out) { this.out = out; } diff --git a/jdk/src/share/classes/javax/sound/midi/MetaMessage.java b/jdk/src/share/classes/javax/sound/midi/MetaMessage.java index f0025a432d0..b7c235565f3 100644 --- a/jdk/src/share/classes/javax/sound/midi/MetaMessage.java +++ b/jdk/src/share/classes/javax/sound/midi/MetaMessage.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2003, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2013, 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,10 +25,6 @@ package javax.sound.midi; -import java.io.ByteArrayOutputStream; -import java.io.DataOutputStream; -import java.io.IOException; - /** * A MetaMessage is a {@link MidiMessage} that is not meaningful to synthesizers, but @@ -71,14 +67,6 @@ public class MetaMessage extends MidiMessage { */ public static final int META = 0xFF; // 255 - - // Default meta message data: just the META status byte value - // $$kk: 09.09.99: need a real event here!! - - private static byte[] defaultMessage = { (byte)META, 0 }; - - - // Instance variables /** @@ -98,8 +86,8 @@ public class MetaMessage extends MidiMessage { * to set them subsequently. */ public MetaMessage() { - //super(defaultMessage); - this(defaultMessage); + // Default meta message data: just the META status byte value + this(new byte[]{(byte) META, 0}); } /** diff --git a/jdk/src/share/classes/javax/sound/sampled/Mixer.java b/jdk/src/share/classes/javax/sound/sampled/Mixer.java index a7f0081a73f..c4d0ccbef03 100644 --- a/jdk/src/share/classes/javax/sound/sampled/Mixer.java +++ b/jdk/src/share/classes/javax/sound/sampled/Mixer.java @@ -253,22 +253,22 @@ public interface Mixer extends Line { /** * Mixer name. */ - private /*final*/ String name; + private final String name; /** * Mixer vendor. */ - private /*final*/ String vendor; + private final String vendor; /** * Mixer description. */ - private /*final*/ String description; + private final String description; /** * Mixer version. */ - private /*final*/ String version; + private final String version; /** * Constructs a mixer's info object, passing it the given diff --git a/jdk/src/share/classes/sun/audio/AudioData.java b/jdk/src/share/classes/sun/audio/AudioData.java index 9e4ececdd28..023fd3a93f4 100644 --- a/jdk/src/share/classes/sun/audio/AudioData.java +++ b/jdk/src/share/classes/sun/audio/AudioData.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2002, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2013, 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 @@ -48,7 +48,7 @@ import javax.sound.sampled.*; */ -public class AudioData { +public final class AudioData { private static final AudioFormat DEFAULT_FORMAT = new AudioFormat(AudioFormat.Encoding.ULAW, diff --git a/jdk/src/share/classes/sun/audio/AudioDataStream.java b/jdk/src/share/classes/sun/audio/AudioDataStream.java index 0065e6c5c92..dcc21a88233 100644 --- a/jdk/src/share/classes/sun/audio/AudioDataStream.java +++ b/jdk/src/share/classes/sun/audio/AudioDataStream.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2002, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2013, 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 @@ -26,8 +26,6 @@ package sun.audio; import java.io.*; -import javax.sound.sampled.*; -import javax.sound.midi.*; /** * An input stream to play AudioData. @@ -39,18 +37,18 @@ import javax.sound.midi.*; */ public class AudioDataStream extends ByteArrayInputStream { - AudioData ad; + private final AudioData ad; /** * Constructor */ - public AudioDataStream(AudioData data) { + public AudioDataStream(final AudioData data) { super(data.buffer); this.ad = data; } - AudioData getAudioData() { + final AudioData getAudioData() { return ad; } } diff --git a/jdk/src/share/classes/sun/audio/AudioDevice.java b/jdk/src/share/classes/sun/audio/AudioDevice.java index 757119c27b3..05c180748f0 100644 --- a/jdk/src/share/classes/sun/audio/AudioDevice.java +++ b/jdk/src/share/classes/sun/audio/AudioDevice.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2003, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2013, 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 @@ -27,12 +27,9 @@ package sun.audio; import java.util.Hashtable; import java.util.Vector; -import java.util.Enumeration; import java.io.IOException; import java.io.InputStream; import java.io.BufferedInputStream; -import java.io.OutputStream; -import java.io.ByteArrayInputStream; import javax.sound.sampled.*; import javax.sound.midi.*; @@ -57,8 +54,7 @@ import com.sun.media.sound.Toolkit; * @author Florian Bomers */ -public class - AudioDevice { +public final class AudioDevice { private boolean DEBUG = false /*true*/ ; @@ -404,11 +400,11 @@ public class // INFO CLASS - class Info implements MetaEventListener { + final class Info implements MetaEventListener { - Sequencer sequencer; - InputStream in; - DataPusher datapusher; + final Sequencer sequencer; + final InputStream in; + final DataPusher datapusher; Info( Sequencer sequencer, InputStream in, DataPusher datapusher ) { diff --git a/jdk/src/share/classes/sun/audio/AudioPlayer.java b/jdk/src/share/classes/sun/audio/AudioPlayer.java index 28eee896d09..f6e9a30e9e8 100644 --- a/jdk/src/share/classes/sun/audio/AudioPlayer.java +++ b/jdk/src/share/classes/sun/audio/AudioPlayer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2003, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2013, 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,13 +25,7 @@ package sun.audio; -import java.util.Vector; -import java.util.Enumeration; -import java.io.IOException; import java.io.InputStream; -import java.io.OutputStream; -import java.io.FileOutputStream; - import java.security.AccessController; import java.security.PrivilegedAction; @@ -69,11 +63,10 @@ import java.security.PrivilegedAction; * @author Arthur van Hoff, Thomas Ball */ -public - class AudioPlayer extends Thread { +public final class AudioPlayer extends Thread { - private AudioDevice devAudio; - private static boolean DEBUG = false /*true*/; + private final AudioDevice devAudio; + private final static boolean DEBUG = false /*true*/; /** * The default audio player. This audio player is initialized diff --git a/jdk/src/share/classes/sun/audio/AudioStream.java b/jdk/src/share/classes/sun/audio/AudioStream.java index 7ccc4b51e75..7fdf2559b97 100644 --- a/jdk/src/share/classes/sun/audio/AudioStream.java +++ b/jdk/src/share/classes/sun/audio/AudioStream.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2002, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2013, 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 @@ -26,9 +26,7 @@ package sun.audio; import java.io.InputStream; -import java.io.DataInputStream; import java.io.FilterInputStream; -import java.io.ByteArrayInputStream; import java.io.BufferedInputStream; import java.io.IOException; @@ -41,13 +39,13 @@ import javax.sound.midi.*; */ -public class AudioStream extends FilterInputStream { +public final class AudioStream extends FilterInputStream { // AudioContainerInputStream acis; - protected AudioInputStream ais = null; - protected AudioFormat format = null; - protected MidiFileFormat midiformat = null; - protected InputStream stream = null; + AudioInputStream ais = null; + AudioFormat format = null; + MidiFileFormat midiformat = null; + InputStream stream = null; /* diff --git a/jdk/src/share/classes/sun/audio/AudioStreamSequence.java b/jdk/src/share/classes/sun/audio/AudioStreamSequence.java index f7f409d58f9..f948070c1ce 100644 --- a/jdk/src/share/classes/sun/audio/AudioStreamSequence.java +++ b/jdk/src/share/classes/sun/audio/AudioStreamSequence.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2002, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2013, 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,7 +25,6 @@ package sun.audio; -import java.io.IOException; import java.io.InputStream; import java.io.SequenceInputStream; import java.util.Enumeration; @@ -44,8 +43,8 @@ import java.util.Enumeration; * @see AudioPlayer * @author Arthur van Hoff */ -public - class AudioStreamSequence extends SequenceInputStream { +public final class AudioStreamSequence extends SequenceInputStream { + Enumeration e; InputStream in; diff --git a/jdk/src/share/classes/sun/audio/AudioTranslatorStream.java b/jdk/src/share/classes/sun/audio/AudioTranslatorStream.java index 958fca0b4fc..44c76b4d1c8 100644 --- a/jdk/src/share/classes/sun/audio/AudioTranslatorStream.java +++ b/jdk/src/share/classes/sun/audio/AudioTranslatorStream.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2002, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2013, 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 @@ -26,18 +26,15 @@ package sun.audio; import java.io.InputStream; -import java.io.DataInputStream; -import java.io.FilterInputStream; import java.io.IOException; /** * Translator for native audio formats (not implemented in this release). * */ -public - class AudioTranslatorStream extends NativeAudioStream { +public final class AudioTranslatorStream extends NativeAudioStream { - private int length = 0; + private final int length = 0; public AudioTranslatorStream(InputStream in) throws IOException { super(in); diff --git a/jdk/src/share/classes/sun/audio/ContinuousAudioDataStream.java b/jdk/src/share/classes/sun/audio/ContinuousAudioDataStream.java index 7264877aae7..e4adf18c33a 100644 --- a/jdk/src/share/classes/sun/audio/ContinuousAudioDataStream.java +++ b/jdk/src/share/classes/sun/audio/ContinuousAudioDataStream.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2002, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2013, 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 @@ -42,11 +42,10 @@ package sun.audio; * @author Arthur van Hoff */ -public - class ContinuousAudioDataStream extends AudioDataStream { +public final class ContinuousAudioDataStream extends AudioDataStream { - /** + /** * Create a continuous stream of audio. */ public ContinuousAudioDataStream(AudioData data) { diff --git a/jdk/src/share/classes/sun/audio/InvalidAudioFormatException.java b/jdk/src/share/classes/sun/audio/InvalidAudioFormatException.java index 0ff5beb9955..9b12af84a03 100644 --- a/jdk/src/share/classes/sun/audio/InvalidAudioFormatException.java +++ b/jdk/src/share/classes/sun/audio/InvalidAudioFormatException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2013, 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 @@ -29,20 +29,20 @@ import java.io.IOException; /** * Signals an invalid audio stream for the stream handler. */ -class InvalidAudioFormatException extends IOException { +final class InvalidAudioFormatException extends IOException { /** * Constructor. */ - public InvalidAudioFormatException() { + InvalidAudioFormatException() { super(); } /** * Constructor with a detail message. */ - public InvalidAudioFormatException(String s) { + InvalidAudioFormatException(String s) { super(s); } }