提交 27d3451a 编写于 作者: S serb

8005980: [findbugs] More com.sun.media.sound.* warnings

Reviewed-by: art, prr
上级 a3ba31ae
......@@ -25,6 +25,8 @@
package com.sun.media.sound;
import java.util.Arrays;
import javax.sound.sampled.*;
/**
......@@ -46,11 +48,11 @@ public final class DataPusher implements Runnable {
private final AudioFormat format;
// stream as source data
private AudioInputStream ais = null;
private final AudioInputStream ais;
// byte array as source data
private byte[] audioData = null;
private int audioDataByteLength = 0;
private final byte[] audioData;
private final int audioDataByteLength;
private int pos;
private int newPos = -1;
private boolean looping;
......@@ -67,16 +69,22 @@ public final class DataPusher implements Runnable {
private final int BUFFER_SIZE = 16384;
public DataPusher(SourceDataLine sourceLine, AudioFormat format, byte[] audioData, int byteLength) {
this.audioData = audioData;
this.audioDataByteLength = byteLength;
this.format = format;
this.source = sourceLine;
this(sourceLine, format, null, audioData, byteLength);
}
public DataPusher(SourceDataLine sourceLine, AudioInputStream ais) {
this(sourceLine, ais.getFormat(), ais, null, 0);
}
private DataPusher(final SourceDataLine source, final AudioFormat format,
final AudioInputStream ais, final byte[] audioData,
final int audioDataByteLength) {
this.source = source;
this.format = format;
this.ais = ais;
this.format = ais.getFormat();
this.source = sourceLine;
this.audioDataByteLength = audioDataByteLength;
this.audioData = audioData == null ? null : Arrays.copyOf(audioData,
audioData.length);
}
public synchronized void start() {
......
......@@ -24,6 +24,8 @@
*/
package com.sun.media.sound;
import java.util.Arrays;
/**
* A standard director who chooses performers
* by there keyfrom,keyto,velfrom,velto properties.
......@@ -32,17 +34,16 @@ package com.sun.media.sound;
*/
public final class ModelStandardDirector implements ModelDirector {
ModelPerformer[] performers;
ModelDirectedPlayer player;
boolean noteOnUsed = false;
boolean noteOffUsed = false;
private final ModelPerformer[] performers;
private final ModelDirectedPlayer player;
private boolean noteOnUsed = false;
private boolean noteOffUsed = false;
public ModelStandardDirector(ModelPerformer[] performers,
ModelDirectedPlayer player) {
this.performers = performers;
public ModelStandardDirector(final ModelPerformer[] performers,
final ModelDirectedPlayer player) {
this.performers = Arrays.copyOf(performers, performers.length);
this.player = player;
for (int i = 0; i < performers.length; i++) {
ModelPerformer p = performers[i];
for (final ModelPerformer p : this.performers) {
if (p.isReleaseTriggered()) {
noteOffUsed = true;
} else {
......
......@@ -24,6 +24,8 @@
*/
package com.sun.media.sound;
import java.util.Arrays;
/**
* A standard indexed director who chooses performers
* by there keyfrom,keyto,velfrom,velto properties.
......@@ -32,22 +34,21 @@ package com.sun.media.sound;
*/
public final class ModelStandardIndexedDirector implements ModelDirector {
ModelPerformer[] performers;
ModelDirectedPlayer player;
boolean noteOnUsed = false;
boolean noteOffUsed = false;
private final ModelPerformer[] performers;
private final ModelDirectedPlayer player;
private boolean noteOnUsed = false;
private boolean noteOffUsed = false;
// Variables needed for index
byte[][] trantables;
int[] counters;
int[][] mat;
private byte[][] trantables;
private int[] counters;
private int[][] mat;
public ModelStandardIndexedDirector(ModelPerformer[] performers,
ModelDirectedPlayer player) {
this.performers = performers;
public ModelStandardIndexedDirector(final ModelPerformer[] performers,
final ModelDirectedPlayer player) {
this.performers = Arrays.copyOf(performers, performers.length);
this.player = player;
for (int i = 0; i < performers.length; i++) {
ModelPerformer p = performers[i];
for (final ModelPerformer p : this.performers) {
if (p.isReleaseTriggered()) {
noteOffUsed = true;
} else {
......
......@@ -38,7 +38,7 @@ import javax.sound.sampled.LineEvent;
import javax.sound.sampled.LineUnavailableException;
/**
* Clip implemention for the SoftMixingMixer.
* Clip implementation for the SoftMixingMixer.
*
* @author Karl Helgason
*/
......@@ -357,7 +357,9 @@ public final class SoftMixingClip extends SoftMixingDataLine implements Clip {
throw new IllegalArgumentException(
"Buffer size does not represent an integral number of sample frames!");
this.data = data;
if (data != null) {
this.data = Arrays.copyOf(data, data.length);
}
this.offset = offset;
this.bufferSize = bufferSize;
this.format = format;
......
......@@ -26,6 +26,8 @@
package sun.audio;
import java.io.*;
import java.util.Arrays;
import javax.sound.sampled.*;
......@@ -65,12 +67,11 @@ public final class AudioData {
/**
* Constructor
*/
public AudioData(byte buffer[]) {
this.buffer = buffer;
// if we cannot extract valid format information, we resort to assuming the data will be 8k mono u-law
// in order to provide maximal backwards compatibility....
this.format = DEFAULT_FORMAT;
public AudioData(final byte[] buffer) {
// if we cannot extract valid format information, we resort to assuming
// the data will be 8k mono u-law in order to provide maximal backwards
// compatibility....
this(DEFAULT_FORMAT, buffer);
// okay, we need to extract the format and the byte buffer of data
try {
......@@ -90,9 +91,10 @@ public final class AudioData {
* Non-public constructor; this is the one we use in ADS and CADS
* constructors.
*/
AudioData(AudioFormat format, byte[] buffer) {
AudioData(final AudioFormat format, final byte[] buffer) {
this.format = format;
this.buffer = buffer;
if (buffer != null) {
this.buffer = Arrays.copyOf(buffer, buffer.length);
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册