< prev index next >
src/java.desktop/share/classes/com/sun/media/sound/AbstractDataLine.java
Print this page
@@ -30,11 +30,10 @@
import javax.sound.sampled.Control;
import javax.sound.sampled.DataLine;
import javax.sound.sampled.LineEvent;
import javax.sound.sampled.LineUnavailableException;
-
/**
* AbstractDataLine
*
* @author Kara Kytle
*/
@@ -145,40 +144,39 @@
if (Printer.trace) Printer.trace("< AbstractDataLine.open(format, bufferSize) completed");
}
}
-
public final void open(AudioFormat format) throws LineUnavailableException {
open(format, AudioSystem.NOT_SPECIFIED);
}
-
/**
* This implementation always returns 0.
*/
+ @Override
public int available() {
return 0;
}
-
/**
* This implementation does nothing.
*/
+ @Override
public void drain() {
if (Printer.trace) Printer.trace("AbstractDataLine: drain");
}
-
/**
* This implementation does nothing.
*/
+ @Override
public void flush() {
if (Printer.trace) Printer.trace("AbstractDataLine: flush");
}
-
+ @Override
public final void start() {
//$$fb 2001-10-09: Bug #4517739: avoiding deadlock by synchronizing to mixer !
synchronized(mixer) {
if (Printer.trace) Printer.trace("> "+getClass().getName()+".start() - AbstractDataLine");
@@ -198,11 +196,11 @@
}
if (Printer.trace) Printer.trace("< "+getClass().getName()+".start() - AbstractDataLine");
}
-
+ @Override
public final void stop() {
//$$fb 2001-10-09: Bug #4517739: avoiding deadlock by synchronizing to mixer !
synchronized(mixer) {
if (Printer.trace) Printer.trace("> "+getClass().getName()+".stop() - AbstractDataLine");
@@ -243,34 +241,36 @@
// isStartedRunning() method, defined below. I have not changed
// the variable names at this point, since 'running' is accessed
// in MixerSourceLine and MixerClip, and I want to touch as little
// code as possible to change isStarted() back to isRunning().
+ @Override
public final boolean isRunning() {
return started;
}
+ @Override
public final boolean isActive() {
return active;
}
-
+ @Override
public final long getMicrosecondPosition() {
long microseconds = getLongFramePosition();
if (microseconds != AudioSystem.NOT_SPECIFIED) {
microseconds = Toolkit.frames2micros(getFormat(), microseconds);
}
return microseconds;
}
-
+ @Override
public final AudioFormat getFormat() {
return format;
}
-
+ @Override
public final int getBufferSize() {
return bufferSize;
}
/**
@@ -281,15 +281,15 @@
}
/**
* This implementation returns AudioSystem.NOT_SPECIFIED.
*/
+ @Override
public final float getLevel() {
return (float)AudioSystem.NOT_SPECIFIED;
}
-
// HELPER METHODS
/**
* running is true after start is called and before stop is called,
* regardless of whether data is actually being presented.
@@ -315,23 +315,16 @@
//boolean sendEvents = false;
//long position = getLongFramePosition();
synchronized (this) {
- //if (Printer.debug) Printer.debug(" AbstractDataLine: setActive: this.active: " + this.active);
- //if (Printer.debug) Printer.debug(" active: " + active);
-
if (this.active != active) {
this.active = active;
//sendEvents = true;
}
}
- //if (Printer.debug) Printer.debug(" this.active: " + this.active);
- //if (Printer.debug) Printer.debug(" sendEvents: " + sendEvents);
-
-
// $$kk: 11.19.99: take ACTIVE / INACTIVE / EOM events out;
// putting them in is technically an API change.
// do not generate ACTIVE / INACTIVE events for now
// if (sendEvents) {
//
@@ -354,22 +347,16 @@
boolean sendEvents = false;
long position = getLongFramePosition();
synchronized (this) {
- //if (Printer.debug) Printer.debug(" AbstractDataLine: setStarted: this.started: " + this.started);
- //if (Printer.debug) Printer.debug(" started: " + started);
-
if (this.started != started) {
this.started = started;
sendEvents = true;
}
}
- //if (Printer.debug) Printer.debug(" this.started: " + this.started);
- //if (Printer.debug) Printer.debug(" sendEvents: " + sendEvents);
-
if (sendEvents) {
if (started) {
sendEvents(new LineEvent(this, LineEvent.Type.START, position));
} else {
@@ -377,11 +364,10 @@
}
}
if (Printer.trace) Printer.trace("< AbstractDataLine: setStarted completed");
}
-
/**
* This method generates a STOP event and sets the started state to false.
* It is here for historic reasons when an EOM event existed.
*/
final void setEOM() {
@@ -391,35 +377,33 @@
// better use setStarted() to send STOP event.
setStarted(false);
if (Printer.trace) Printer.trace("< AbstractDataLine: setEOM() completed");
}
-
-
-
// OVERRIDES OF ABSTRACT LINE METHODS
/**
* Try to open the line with the current format and buffer size values.
* If the line is not open, these will be the defaults. If the
* line is open, this should return quietly because the values
* requested will match the current ones.
*/
+ @Override
public final void open() throws LineUnavailableException {
if (Printer.trace) Printer.trace("> "+getClass().getName()+".open() - AbstractDataLine");
// this may throw a LineUnavailableException.
open(format, bufferSize);
if (Printer.trace) Printer.trace("< "+getClass().getName()+".open() - AbstractDataLine");
}
-
/**
* 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.
*/
+ @Override
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.");
@@ -443,16 +427,10 @@
}
}
if (Printer.trace) Printer.trace("< "+getClass().getName()+".close() - in AbstractDataLine");
}
-
- // IMPLEMENTATIONS OF ABSTRACT LINE ABSTRACE METHODS
-
-
- // ABSTRACT METHODS
-
abstract void implOpen(AudioFormat format, int bufferSize) throws LineUnavailableException;
abstract void implClose();
abstract void implStart();
abstract void implStop();
< prev index next >