< prev index next >
src/java.desktop/share/classes/com/sun/media/sound/SoftMainMixer.java
Print this page
@@ -20,19 +20,20 @@
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
+
package com.sun.media.sound;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashSet;
import java.util.Iterator;
+import java.util.Map.Entry;
import java.util.Set;
import java.util.TreeMap;
-import java.util.Map.Entry;
import javax.sound.midi.MidiMessage;
import javax.sound.midi.Patch;
import javax.sound.midi.ShortMessage;
import javax.sound.sampled.AudioInputStream;
@@ -72,40 +73,41 @@
private boolean pusher_silent = false;
private int pusher_silent_count = 0;
private long sample_pos = 0;
boolean readfully = true;
private final Object control_mutex;
- private SoftSynthesizer synth;
+ private final SoftSynthesizer synth;
private float samplerate = 44100;
private int nrofchannels = 2;
private SoftVoice[] voicestatus = null;
- private SoftAudioBuffer[] buffers;
- private SoftReverb reverb;
- private SoftAudioProcessor chorus;
- private SoftAudioProcessor agc;
+ private final SoftAudioBuffer[] buffers;
+ private final SoftReverb reverb;
+ private final SoftAudioProcessor chorus;
+ private final SoftAudioProcessor agc;
private long msec_buffer_len = 0;
private int buffer_len = 0;
- TreeMap<Long, Object> midimessages = new TreeMap<Long, Object>();
+ TreeMap<Long, Object> midimessages = new TreeMap<>();
private int delay_midievent = 0;
private int max_delay_midievent = 0;
double last_volume_left = 1.0;
double last_volume_right = 1.0;
- private double[] co_master_balance = new double[1];
- private double[] co_master_volume = new double[1];
- private double[] co_master_coarse_tuning = new double[1];
- private double[] co_master_fine_tuning = new double[1];
- private AudioInputStream ais;
+ private final double[] co_master_balance = new double[1];
+ private final double[] co_master_volume = new double[1];
+ private final double[] co_master_coarse_tuning = new double[1];
+ private final double[] co_master_fine_tuning = new double[1];
+ private final AudioInputStream ais;
private Set<SoftChannelMixerContainer> registeredMixers = null;
private Set<ModelChannelMixer> stoppedMixers = null;
private SoftChannelMixerContainer[] cur_registeredMixers = null;
SoftControl co_master = new SoftControl() {
double[] balance = co_master_balance;
double[] volume = co_master_volume;
double[] coarse_tuning = co_master_coarse_tuning;
double[] fine_tuning = co_master_fine_tuning;
+ @Override
public double[] get(int instance, String name) {
if (name == null)
return null;
if (name.equals("balance"))
return balance;
@@ -775,17 +777,17 @@
* (1000000.0 / samplerate));
}
public void stopMixer(ModelChannelMixer mixer) {
if (stoppedMixers == null)
- stoppedMixers = new HashSet<ModelChannelMixer>();
+ stoppedMixers = new HashSet<>();
stoppedMixers.add(mixer);
}
public void registerMixer(ModelChannelMixer mixer) {
if (registeredMixers == null)
- registeredMixers = new HashSet<SoftChannelMixerContainer>();
+ registeredMixers = new HashSet<>();
SoftChannelMixerContainer mixercontainer = new SoftChannelMixerContainer();
mixercontainer.buffers = new SoftAudioBuffer[6];
for (int i = 0; i < mixercontainer.buffers.length; i++) {
mixercontainer.buffers[i] =
new SoftAudioBuffer(buffer_len, synth.getFormat());
@@ -881,10 +883,11 @@
for (int i = 0; i < nrofchannels; i++)
buffers[i].get(bbuffer, i);
bbuffer_pos = 0;
}
+ @Override
public int read(byte[] b, int off, int len) {
int bbuffer_len = bbuffer.length;
int offlen = off + len;
int orgoff = off;
byte[] bbuffer = this.bbuffer;
@@ -901,21 +904,24 @@
}
}
return len;
}
+ @Override
public int read() throws IOException {
int ret = read(single);
if (ret == -1)
return -1;
return single[0] & 0xFF;
}
+ @Override
public int available() {
return bbuffer.length - bbuffer_pos;
}
+ @Override
public void close() {
SoftMainMixer.this.synth.close();
}
};
< prev index next >