1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192
/* * @(#)Port.java 1.27 05/11/17 * * Copyright 2006 Sun Microsystems, Inc. All rights reserved. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. */ package javax.sound.sampled; /** * Ports are simple lines for input or output of audio to or from audio devices. * Common examples of ports that act as source lines (mixer inputs) include the microphone, * line input, and CD-ROM drive. Ports that act as target lines (mixer outputs) include the * speaker, headphone, and line output. You can access port using a <code>{@link Port.Info}</code> * object. * * @author Kara Kytle * @version 1.27, 05/11/17 * @since 1.3 */ public interface Port extends Line { // INNER CLASSES /** * The <code>Port.Info</code> class extends <code>{@link Line.Info}</code> * with additional information specific to ports, including the port's name * and whether it is a source or a target for its mixer. * By definition, a port acts as either a source or a target to its mixer, * but not both. (Audio input ports are sources; audio output ports are targets.) * <p> * To learn what ports are available, you can retrieve port info objects through the * <code>{@link Mixer#getSourceLineInfo getSourceLineInfo}</code> and * <code>{@link Mixer#getTargetLineInfo getTargetLineInfo}</code> * methods of the <code>Mixer</code> interface. Instances of the * <code>Port.Info</code> class may also be constructed and used to obtain * lines matching the parameters specified in the <code>Port.Info</code> object. * * @author Kara Kytle * @version 1.27, 05/11/17 * @since 1.3 */ public static class Info extends Line.Info { // AUDIO PORT TYPE DEFINES // SOURCE PORTS /** * A type of port that gets audio from a built-in microphone or a microphone jack. */ public static final Info MICROPHONE = new Info(Port.class,"MICROPHONE", true); /** * A type of port that gets audio from a line-level audio input jack. */ public static final Info LINE_IN = new Info(Port.class,"LINE_IN", true); /** * A type of port that gets audio from a CD-ROM drive. */ public static final Info COMPACT_DISC = new Info(Port.class,"COMPACT_DISC", true); // TARGET PORTS /** * A type of port that sends audio to a built-in speaker or a speaker jack. */ public static final Info SPEAKER = new Info(Port.class,"SPEAKER", false); /** * A type of port that sends audio to a headphone jack. */ public static final Info HEADPHONE = new Info(Port.class,"HEADPHONE", false); /** * A type of port that sends audio to a line-level audio output jack. */ public static final Info LINE_OUT = new Info(Port.class,"LINE_OUT", false); // FUTURE DIRECTIONS... // telephone // DAT // DVD // INSTANCE VARIABLES private String name; private boolean isSource; // CONSTRUCTOR /** * Constructs a port's info object from the information given. * This constructor is typically used by an implementation * of Java Sound to describe a supported line. * * @param lineClass the class of the port described by the info object. * @param name the string that names the port * @param isSource <code>true</code> if the port is a source port (such * as a microphone), <code>false</code> if the port is a target port * (such as a speaker). */ public Info(Class<?> lineClass, String name, boolean isSource) { super(lineClass); this.name = name; this.isSource = isSource; } // METHODS /** * Obtains the name of the port. * @return the string that names the port */ public String getName() { return name; } /** * Indicates whether the port is a source or a target for its mixer. * @return <code>true</code> if the port is a source port (such * as a microphone), <code>false</code> if the port is a target port * (such as a speaker). */ public boolean isSource() { return isSource; } /** * Indicates whether this info object specified matches this one. * To match, the match requirements of the superclass must be * met and the types must be equal. * @param info the info object for which the match is queried */ public boolean matches(Line.Info info) { if (! (super.matches(info)) ) { return false; } if (!(name.equals(((Info)info).getName())) ) { return false; } if (! (isSource == ((Info)info).isSource()) ) { return false; } return true; } /** * Finalizes the equals method */ public final boolean equals(Object obj) { return super.equals(obj); } /** * Finalizes the hashCode method */ public final int hashCode() { return super.hashCode(); } /** * Provides a <code>String</code> representation * of the port. * @return a string that describes the port */ public final String toString() { return (name + ((isSource == true) ? " source" : " target") + " port"); } } // class Info }