6321N/A * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. 0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 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 * 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 * 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. 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 0N/A * EventDispatcher. Used by various classes in the Java Sound implementation 0N/A * @author David Rivas 0N/A * @author Kara Kytle 0N/A * @author Florian Bomers 0N/A * time of inactivity until the auto closing clips 0N/A * Thread object for this EventDispatcher instance 0N/A * support for auto-closing Clips 0N/A * support for monitoring data lines 0N/A * Approximate interval between calls to LineMonitor.checkLine 0N/A * This start() method starts an event thread if one is not already active. 0N/A "Java Sound Event Dispatcher",
// name 0N/A * Invoked when there is at least one event in the queue. 0N/A * Implement this as a callback to process one event. 0N/A // process an LineEvent 0N/A // process a MetaMessage 0N/A // process a Controller or Mode Event 0N/A // Controller and Mode events have status byte 0xBc, where 0N/A // c is the channel they are sent on. 0N/A * Wait until there is something in the event queue to process. Then 0N/A * dispatch the event to the listeners.The entire method does not 0N/A * need to be synchronized since this includes taking the event out 0N/A * from the queue and processing the event. We only need to provide 0N/A * exclusive access over the code where an event is removed from the 0N/A synchronized (
this) {
0N/A // Wait till there is an event in the event queue. 0N/A // Remove the event from the queue and dispatch it to the listeners. 0N/A }
// end of synchronized 0N/A * Queue the given event in the event queue. 0N/A * A loop to dispatch events. 0N/A * Send audio and MIDI events. 0N/A * go through the list of registered auto-closing 0N/A * Clip instances and close them, if appropriate 0N/A * This method is called in regular intervals 0N/A * called from auto-closing clips when one of their open() method is called 0N/A synchronized (
this) {
0N/A // this is only for the case that the first clip is set to autoclosing, 0N/A // and it is already open, and nothing is done with it. 0N/A // EventDispatcher.process() method would block in wait() and 0N/A // never close this first clip, keeping the device open. 0N/A * called from auto-closing clips when their closed() method is called 0N/A // nothing to do -- is removed from arraylist above 0N/A // ////////////////////////// Line Monitoring Support /////////////////// // 0N/A * go through the list of registered line monitors 0N/A * and call their checkLine method 0N/A * This method is called in regular intervals 0N/A * Add this LineMonitor instance to the list of monitors 0N/A synchronized (
this) {
0N/A // need to interrupt the infinite wait() 0N/A * Remove this LineMonitor instance from the list of monitors 0N/A // /////////////////////////////////// INNER CLASSES ////////////////////////////////////////// // 0N/A * Container for an event and a set of listeners to deliver it to. 0N/A * Create a new instance of this event Info class 0N/A * @param event the event to be dispatched 0N/A * @param listeners listener list; will be copied 0N/A }
// class EventInfo 0N/A * Container for a clip with its expiration time 0N/A * Create a new instance of this clip Info class 0N/A * Interface that a class that wants to get regular 0N/A * line monitor events implements 0N/A * Called by event dispatcher in regular intervals 0N/A}
// class EventDispatcher