/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* 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.
*/
/**
* Abstract Mixer. Implements Mixer (with abstract methods) and specifies
* some other common methods for use by our implementation.
*
* @author Kara Kytle
*/
//$$fb 2002-07-26: let AbstractMixer be an AbstractLine and NOT an AbstractDataLine!
// STATIC VARIABLES
// IMMUTABLE PROPERTIES
/**
* Info object describing this mixer.
*/
/**
* source lines provided by this mixer
*/
/**
* target lines provided by this mixer
*/
/**
* if any line of this mixer is started
*/
private boolean started = false;
/**
* if this mixer had been opened manually with open()
* If it was, then it won't be closed automatically,
* only when close() is called manually.
*/
private boolean manuallyOpened = false;
/**
* Supported formats for the mixer.
*/
//$$fb DELETE
//protected Vector formats = new Vector();
// STATE VARIABLES
/**
* Source lines (ports) currently open
*/
/**
* Target lines currently open.
*/
/**
* Constructs a new AbstractMixer.
* @param mixer the mixer with which this line is associated
* @param controls set of supported controls
*/
// Line.Info, AbstractMixer, Control[]
// setup the line part
this.mixer = this;
}
// setup the mixer part
this.sourceLineInfo = sourceLineInfo;
this.targetLineInfo = targetLineInfo;
}
// MIXER METHODS
return mixerInfo;
}
return localArray;
}
return localArray;
}
int i;
}
}
}
return returnedArray;
}
int i;
}
}
}
return returnedArray;
}
int i;
return true;
}
}
return true;
}
}
return false;
}
protected abstract void implStart();
protected abstract void implStop();
protected abstract void implClose();
Line[] localLines;
synchronized(sourceLines) {
}
}
return localLines;
}
Line[] localLines;
synchronized(targetLines) {
}
}
return localLines;
}
/**
* Default implementation always throws an exception.
*/
throw new IllegalArgumentException("Synchronization not supported by this mixer.");
}
/**
* Default implementation always throws an exception.
*/
throw new IllegalArgumentException("Synchronization not supported by this mixer.");
}
/**
* Default implementation always returns false.
*/
boolean maintainSync) {
return false;
}
// OVERRIDES OF ABSTRACT DATA LINE METHODS
/**
* This implementation tries to open the mixer with its current format and buffer size settings.
*/
open(true);
}
/**
* This implementation tries to open the mixer with its current format and buffer size settings.
*/
if (!isOpen()) {
implOpen();
// if the mixer is not currently open, set open to true and send event
setOpen(true);
if (manual) {
manuallyOpened = true;
}
}
}
// METHOD FOR INTERNAL IMPLEMENTATION USE
/**
* The default implementation of this method just determines whether
* this line is a source or target line, calls open(no-arg) on the
* mixer, and adds the line to the appropriate vector.
* The mixer may be opened at a format different than the line's
* format if it is a DataLine.
*/
// $$kk: 06.11.99: ignore ourselves for now
return;
}
// source line?
// call the no-arg open method for the mixer; it should open at its
// default format if it is not open yet
open(false);
// we opened successfully! add the line to the list
}
} else {
// target line?
// call the no-arg open method for the mixer; it should open at its
// default format if it is not open yet
open(false);
// we opened successfully! add the line to the list
}
} else {
}
}
}
/**
* Removes this line from the list of open source lines and
* open target lines, if it exists in either.
* If the list is now empty, closes the mixer.
*/
// $$kk: 06.11.99: ignore ourselves for now
return;
}
if (Printer.debug) Printer.debug("AbstractMixer: close(line): sourceLines.size() now: " + sourceLines.size());
if (Printer.debug) Printer.debug("AbstractMixer: close(line): targetLines.size() now: " + targetLines.size());
close();
}
}
/**
* Close all lines and then close this mixer.
*/
public final synchronized void close() {
if (isOpen()) {
// close all source lines
localLines[i].close();
}
// close all target lines
localLines = getTargetLines();
localLines[i].close();
}
implClose();
// set the open state to false and send events
setOpen(false);
}
manuallyOpened = false;
}
/**
* Starts the mixer.
*/
// $$kk: 06.11.99: ignore ourselves for now
return;
}
// we just start the mixer regardless of anything else here.
if (!started) {
implStart();
started = true;
}
}
/**
* Stops the mixer if this was the last running line.
*/
// $$kk: 06.11.99: ignore ourselves for now
return;
}
// if any other open line is running, return
// this covers clips and source data lines
if (Printer.trace) Printer.trace("<< AbstractMixer: stop(" + line + ") found running sourceLine: " + sourceLine);
return;
}
}
}
// if any other open line is running, return
// this covers target data lines
if (Printer.trace) Printer.trace("<< AbstractMixer: stop(" + line + ") found running targetLine: " + targetLine);
return;
}
}
}
// otherwise, stop
started = false;
implStop();
}
/**
* Determines whether this is a source line for this mixer.
* Right now this just checks whether it's supported, but should
* check whether it actually belongs to this mixer....
*/
return true;
}
}
return false;
}
/**
* Determines whether this is a target line for this mixer.
* Right now this just checks whether it's supported, but should
* check whether it actually belongs to this mixer....
*/
return true;
}
}
return false;
}
/**
* Returns the first complete Line.Info object it finds that
* matches the one specified, or null if no matching Line.Info
* object is found.
*/
return null;
}
// $$kk: 05.31.99: need to change this so that
// the format and buffer size get set in the
// returned info object for data lines??
return sourceLineInfo[i];
}
}
return targetLineInfo[i];
}
}
return null;
}
}