< prev index next >
src/java.desktop/share/classes/com/sun/media/sound/SoftMixingClip.java
Print this page
@@ -20,10 +20,11 @@
*
* 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.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
@@ -50,18 +51,20 @@
private byte[] data;
private final InputStream datastream = new InputStream() {
+ @Override
public int read() throws IOException {
byte[] b = new byte[1];
int ret = read(b);
if (ret < 0)
return ret;
return b[0] & 0xFF;
}
+ @Override
public int read(byte[] b, int off, int len) throws IOException {
if (_loopcount != 0) {
int bloopend = _loopend * framesize;
int bloopstart = _loopstart * framesize;
@@ -164,10 +167,11 @@
SoftMixingClip(SoftMixingMixer mixer, DataLine.Info info) {
super(mixer, info);
}
+ @Override
protected void processControlLogic() {
_rightgain = rightgain;
_leftgain = leftgain;
_eff1gain = eff1gain;
@@ -201,10 +205,11 @@
afis = new AudioFloatInputStreamResampler(afis, outputformat);
}
}
+ @Override
protected void processAudioLogic(SoftAudioBuffer[] buffers) {
if (_active) {
float[] left = buffers[SoftMixingMainMixer.CHANNEL_LEFT].array();
float[] right = buffers[SoftMixingMainMixer.CHANNEL_RIGHT].array();
int bufferlen = buffers[SoftMixingMainMixer.CHANNEL_LEFT].getSize();
@@ -271,19 +276,22 @@
}
}
}
+ @Override
public int getFrameLength() {
return bufferSize / format.getFrameSize();
}
+ @Override
public long getMicrosecondLength() {
return (long) (getFrameLength() * (1000000.0 / (double) getFormat()
.getSampleRate()));
}
+ @Override
public void loop(int count) {
LineEvent event = null;
synchronized (control_mutex) {
if (isOpen()) {
@@ -300,10 +308,11 @@
if (event != null)
sendEvent(event);
}
+ @Override
public void open(AudioInputStream stream) throws LineUnavailableException,
IOException {
if (isOpen()) {
throw new IllegalStateException("Clip is already open with format "
+ getFormat() + " and frame lengh of " + getFrameLength());
@@ -340,10 +349,11 @@
open(stream.getFormat(), baos.toByteArray(), 0, baos.size());
}
}
+ @Override
public void open(AudioFormat format, byte[] data, int offset, int bufferSize)
throws LineUnavailableException {
synchronized (control_mutex) {
if (isOpen()) {
throw new IllegalStateException(
@@ -383,17 +393,19 @@
mixer.getMainMixer().openLine(this);
}
}
+ @Override
public void setFramePosition(int frames) {
synchronized (control_mutex) {
frameposition_sg = true;
frameposition = frames;
}
}
+ @Override
public void setLoopPoints(int start, int end) {
synchronized (control_mutex) {
if (end != -1) {
if (end < start)
throw new IllegalArgumentException("Invalid loop points : "
@@ -412,64 +424,77 @@
loopend = end;
loop_sg = true;
}
}
+ @Override
public void setMicrosecondPosition(long microseconds) {
setFramePosition((int) (microseconds * (((double) getFormat()
.getSampleRate()) / 1000000.0)));
}
+ @Override
public int available() {
return 0;
}
+ @Override
public void drain() {
}
+ @Override
public void flush() {
}
+ @Override
public int getBufferSize() {
return bufferSize;
}
+ @Override
public AudioFormat getFormat() {
return format;
}
+ @Override
public int getFramePosition() {
synchronized (control_mutex) {
return frameposition;
}
}
+ @Override
public float getLevel() {
return AudioSystem.NOT_SPECIFIED;
}
+ @Override
public long getLongFramePosition() {
return getFramePosition();
}
+ @Override
public long getMicrosecondPosition() {
return (long) (getFramePosition() * (1000000.0 / (double) getFormat()
.getSampleRate()));
}
+ @Override
public boolean isActive() {
synchronized (control_mutex) {
return active;
}
}
+ @Override
public boolean isRunning() {
synchronized (control_mutex) {
return active;
}
}
+ @Override
public void start() {
LineEvent event = null;
synchronized (control_mutex) {
@@ -486,10 +511,11 @@
if (event != null)
sendEvent(event);
}
+ @Override
public void stop() {
LineEvent event = null;
synchronized (control_mutex) {
if (isOpen()) {
@@ -504,10 +530,11 @@
if (event != null)
sendEvent(event);
}
+ @Override
public void close() {
LineEvent event = null;
synchronized (control_mutex) {
if (!isOpen())
@@ -524,14 +551,16 @@
if (event != null)
sendEvent(event);
}
+ @Override
public boolean isOpen() {
return open;
}
+ @Override
public void open() throws LineUnavailableException {
if (data == null) {
throw new IllegalArgumentException(
"Illegal call to open() in interface Clip");
}
< prev index next >