1 /*
2 * Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
123 * one-based numbering.
124 * <p>
125 * Note that this field is relevant only to certain events generated by data
126 * lines, such as {@code START} and {@code STOP}. For events generated by
127 * lines that do not count sample frames, and for any other events for which
128 * this value is not known, the position value should be
129 * {@link AudioSystem#NOT_SPECIFIED}.
130 *
131 * @return the line's position as a sample frame number
132 */
133 /*
134 * $$kk: 04.20.99: note to myself: should make sure our implementation is
135 * consistent with this.
136 * which is a reasonable definition....
137 */
138 public final long getFramePosition() {
139 return position;
140 }
141
142 /**
143 * Obtains a string representation of the event. The contents of the string
144 * may vary between implementations of Java Sound.
145 *
146 * @return a string describing the event
147 */
148 @Override
149 public String toString() {
150 String sType = "";
151 if (type != null) sType = type.toString()+" ";
152 String sLine;
153 if (getLine() == null) {
154 sLine = "null";
155 } else {
156 sLine = getLine().toString();
157 }
158 return new String(sType + "event from line " + sLine);
159 }
160
161 /**
162 * The LineEvent.Type inner class identifies what kind of event occurred on
163 * a line. Static instances are provided for the common types (OPEN, CLOSE,
164 * START, and STOP).
165 *
166 * @see LineEvent#getType()
167 */
168 public static class Type {
169
170 /**
171 * Type name.
172 */
173 private final String name;
174
175 /**
176 * Constructs a new event type.
177 *
178 * @param name name of the type
190 * @param obj the reference object with which to compare
191 * @return {@code true} if the specified object is equal to this event
192 * type; {@code false} otherwise
193 */
194 @Override
195 public final boolean equals(Object obj) {
196 return super.equals(obj);
197 }
198
199 /**
200 * Returns a hash code value for this event type.
201 *
202 * @return a hash code value for this event type
203 */
204 @Override
205 public final int hashCode() {
206 return super.hashCode();
207 }
208
209 /**
210 * Returns the type name as the string representation.
211 *
212 * @return the type name as the string representation
213 */
214 @Override
215 public String toString() {
216 return name;
217 }
218
219 // LINE EVENT TYPE DEFINES
220
221 /**
222 * A type of event that is sent when a line opens, reserving system
223 * resources for itself.
224 *
225 * @see #CLOSE
226 * @see Line#open
227 */
228 public static final Type OPEN = new Type("Open");
229
230 /**
231 * A type of event that is sent when a line closes, freeing the system
232 * resources it had obtained when it was opened.
|
1 /*
2 * Copyright (c) 1999, 2020, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
123 * one-based numbering.
124 * <p>
125 * Note that this field is relevant only to certain events generated by data
126 * lines, such as {@code START} and {@code STOP}. For events generated by
127 * lines that do not count sample frames, and for any other events for which
128 * this value is not known, the position value should be
129 * {@link AudioSystem#NOT_SPECIFIED}.
130 *
131 * @return the line's position as a sample frame number
132 */
133 /*
134 * $$kk: 04.20.99: note to myself: should make sure our implementation is
135 * consistent with this.
136 * which is a reasonable definition....
137 */
138 public final long getFramePosition() {
139 return position;
140 }
141
142 /**
143 * Returns a string representation of the event.
144 *
145 * @return a string representation of the event
146 */
147 @Override
148 public String toString() {
149 return String.format("%s event from line %s", type, getLine());
150 }
151
152 /**
153 * The LineEvent.Type inner class identifies what kind of event occurred on
154 * a line. Static instances are provided for the common types (OPEN, CLOSE,
155 * START, and STOP).
156 *
157 * @see LineEvent#getType()
158 */
159 public static class Type {
160
161 /**
162 * Type name.
163 */
164 private final String name;
165
166 /**
167 * Constructs a new event type.
168 *
169 * @param name name of the type
181 * @param obj the reference object with which to compare
182 * @return {@code true} if the specified object is equal to this event
183 * type; {@code false} otherwise
184 */
185 @Override
186 public final boolean equals(Object obj) {
187 return super.equals(obj);
188 }
189
190 /**
191 * Returns a hash code value for this event type.
192 *
193 * @return a hash code value for this event type
194 */
195 @Override
196 public final int hashCode() {
197 return super.hashCode();
198 }
199
200 /**
201 * Returns type's name as the string representation of the event type.
202 *
203 * @return a string representation of the event type
204 */
205 @Override
206 public String toString() {
207 return name;
208 }
209
210 // LINE EVENT TYPE DEFINES
211
212 /**
213 * A type of event that is sent when a line opens, reserving system
214 * resources for itself.
215 *
216 * @see #CLOSE
217 * @see Line#open
218 */
219 public static final Type OPEN = new Type("Open");
220
221 /**
222 * A type of event that is sent when a line closes, freeing the system
223 * resources it had obtained when it was opened.
|