0N/A/*
2362N/A * Copyright (c) 1999, 2004, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/Apackage javax.sound.sampled;
0N/A
0N/A
0N/A/**
0N/A * Ports are simple lines for input or output of audio to or from audio devices.
0N/A * Common examples of ports that act as source lines (mixer inputs) include the microphone,
0N/A * line input, and CD-ROM drive. Ports that act as target lines (mixer outputs) include the
0N/A * speaker, headphone, and line output. You can access port using a <code>{@link Port.Info}</code>
0N/A * object.
0N/A *
0N/A * @author Kara Kytle
0N/A * @since 1.3
0N/A */
0N/Apublic interface Port extends Line {
0N/A
0N/A
0N/A // INNER CLASSES
0N/A
0N/A
0N/A /**
0N/A * The <code>Port.Info</code> class extends <code>{@link Line.Info}</code>
0N/A * with additional information specific to ports, including the port's name
0N/A * and whether it is a source or a target for its mixer.
0N/A * By definition, a port acts as either a source or a target to its mixer,
0N/A * but not both. (Audio input ports are sources; audio output ports are targets.)
0N/A * <p>
0N/A * To learn what ports are available, you can retrieve port info objects through the
0N/A * <code>{@link Mixer#getSourceLineInfo getSourceLineInfo}</code> and
0N/A * <code>{@link Mixer#getTargetLineInfo getTargetLineInfo}</code>
0N/A * methods of the <code>Mixer</code> interface. Instances of the
0N/A * <code>Port.Info</code> class may also be constructed and used to obtain
0N/A * lines matching the parameters specified in the <code>Port.Info</code> object.
0N/A *
0N/A * @author Kara Kytle
0N/A * @since 1.3
0N/A */
0N/A public static class Info extends Line.Info {
0N/A
0N/A
0N/A // AUDIO PORT TYPE DEFINES
0N/A
0N/A
0N/A // SOURCE PORTS
0N/A
0N/A /**
0N/A * A type of port that gets audio from a built-in microphone or a microphone jack.
0N/A */
0N/A public static final Info MICROPHONE = new Info(Port.class,"MICROPHONE", true);
0N/A
0N/A /**
0N/A * A type of port that gets audio from a line-level audio input jack.
0N/A */
0N/A public static final Info LINE_IN = new Info(Port.class,"LINE_IN", true);
0N/A
0N/A /**
0N/A * A type of port that gets audio from a CD-ROM drive.
0N/A */
0N/A public static final Info COMPACT_DISC = new Info(Port.class,"COMPACT_DISC", true);
0N/A
0N/A
0N/A // TARGET PORTS
0N/A
0N/A /**
0N/A * A type of port that sends audio to a built-in speaker or a speaker jack.
0N/A */
0N/A public static final Info SPEAKER = new Info(Port.class,"SPEAKER", false);
0N/A
0N/A /**
0N/A * A type of port that sends audio to a headphone jack.
0N/A */
0N/A public static final Info HEADPHONE = new Info(Port.class,"HEADPHONE", false);
0N/A
0N/A /**
0N/A * A type of port that sends audio to a line-level audio output jack.
0N/A */
0N/A public static final Info LINE_OUT = new Info(Port.class,"LINE_OUT", false);
0N/A
0N/A
0N/A // FUTURE DIRECTIONS...
0N/A
0N/A // telephone
0N/A // DAT
0N/A // DVD
0N/A
0N/A
0N/A // INSTANCE VARIABLES
0N/A
0N/A private String name;
0N/A private boolean isSource;
0N/A
0N/A
0N/A // CONSTRUCTOR
0N/A
0N/A /**
0N/A * Constructs a port's info object from the information given.
0N/A * This constructor is typically used by an implementation
0N/A * of Java Sound to describe a supported line.
0N/A *
0N/A * @param lineClass the class of the port described by the info object.
0N/A * @param name the string that names the port
0N/A * @param isSource <code>true</code> if the port is a source port (such
0N/A * as a microphone), <code>false</code> if the port is a target port
0N/A * (such as a speaker).
0N/A */
0N/A public Info(Class<?> lineClass, String name, boolean isSource) {
0N/A
0N/A super(lineClass);
0N/A this.name = name;
0N/A this.isSource = isSource;
0N/A }
0N/A
0N/A
0N/A // METHODS
0N/A
0N/A /**
0N/A * Obtains the name of the port.
0N/A * @return the string that names the port
0N/A */
0N/A public String getName() {
0N/A return name;
0N/A }
0N/A
0N/A /**
0N/A * Indicates whether the port is a source or a target for its mixer.
0N/A * @return <code>true</code> if the port is a source port (such
0N/A * as a microphone), <code>false</code> if the port is a target port
0N/A * (such as a speaker).
0N/A */
0N/A public boolean isSource() {
0N/A return isSource;
0N/A }
0N/A
0N/A /**
0N/A * Indicates whether this info object specified matches this one.
0N/A * To match, the match requirements of the superclass must be
0N/A * met and the types must be equal.
0N/A * @param info the info object for which the match is queried
0N/A */
0N/A public boolean matches(Line.Info info) {
0N/A
0N/A if (! (super.matches(info)) ) {
0N/A return false;
0N/A }
0N/A
0N/A if (!(name.equals(((Info)info).getName())) ) {
0N/A return false;
0N/A }
0N/A
0N/A if (! (isSource == ((Info)info).isSource()) ) {
0N/A return false;
0N/A }
0N/A
0N/A return true;
0N/A }
0N/A
0N/A
0N/A /**
0N/A * Finalizes the equals method
0N/A */
0N/A public final boolean equals(Object obj) {
0N/A return super.equals(obj);
0N/A }
0N/A
0N/A /**
0N/A * Finalizes the hashCode method
0N/A */
0N/A public final int hashCode() {
0N/A return super.hashCode();
0N/A }
0N/A
0N/A
0N/A
0N/A /**
0N/A * Provides a <code>String</code> representation
0N/A * of the port.
0N/A * @return a string that describes the port
0N/A */
0N/A public final String toString() {
0N/A return (name + ((isSource == true) ? " source" : " target") + " port");
0N/A }
0N/A
0N/A } // class Info
0N/A}