< prev index next >

src/java.desktop/share/classes/com/sun/media/sound/AbstractDataLine.java

Print this page

        

*** 30,40 **** import javax.sound.sampled.Control; import javax.sound.sampled.DataLine; import javax.sound.sampled.LineEvent; import javax.sound.sampled.LineUnavailableException; - /** * AbstractDataLine * * @author Kara Kytle */ --- 30,39 ----
*** 145,184 **** 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. */ public int available() { return 0; } - /** * This implementation does nothing. */ public void drain() { if (Printer.trace) Printer.trace("AbstractDataLine: drain"); } - /** * This implementation does nothing. */ public void flush() { if (Printer.trace) Printer.trace("AbstractDataLine: flush"); } ! 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"); --- 144,182 ---- 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,208 **** } if (Printer.trace) Printer.trace("< "+getClass().getName()+".start() - AbstractDataLine"); } ! 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"); --- 196,206 ---- } 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,276 **** // 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(). public final boolean isRunning() { return started; } public final boolean isActive() { return active; } ! public final long getMicrosecondPosition() { long microseconds = getLongFramePosition(); if (microseconds != AudioSystem.NOT_SPECIFIED) { microseconds = Toolkit.frames2micros(getFormat(), microseconds); } return microseconds; } ! public final AudioFormat getFormat() { return format; } ! public final int getBufferSize() { return bufferSize; } /** --- 241,276 ---- // 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,295 **** } /** * This implementation returns AudioSystem.NOT_SPECIFIED. */ 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. --- 281,295 ---- } /** * 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,337 **** //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) { // --- 315,330 ----
*** 354,375 **** 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 { --- 347,362 ----
*** 377,387 **** } } 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() { --- 364,373 ----
*** 391,425 **** // 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. */ 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. */ 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."); --- 377,409 ---- // 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,458 **** } } 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(); --- 427,436 ----
< prev index next >