/*
* 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.
*/
/**
* EventDispatcher. Used by various classes in the Java Sound implementation
* to send events.
*
* @author David Rivas
* @author Kara Kytle
* @author Florian Bomers
*/
/**
* time of inactivity until the auto closing clips
* are closed
*/
/**
* List of events
*/
/**
* Thread object for this EventDispatcher instance
*/
/*
* support for auto-closing Clips
*/
/*
* support for monitoring data lines
*/
/**
* Approximate interval between calls to LineMonitor.checkLine
*/
/**
* This start() method starts an event thread if one is not already active.
*/
synchronized void start() {
"Java Sound Event Dispatcher", // name
true, // daemon
-1, // priority
true); // doStart
}
}
/**
* Invoked when there is at least one event in the queue.
* Implement this as a callback to process one event.
*/
// process an LineEvent
for (int i = 0; i < count; i++) {
try {
} catch (Throwable t) {
}
}
return;
}
// process a MetaMessage
for (int i = 0; i < count; i++) {
try {
} catch (Throwable t) {
}
}
return;
}
// process a Controller or Mode Event
// Controller and Mode events have status byte 0xBc, where
// c is the channel they are sent on.
for (int i = 0; i < count; i++) {
try {
} catch (Throwable t) {
}
}
}
return;
}
}
/**
* Wait until there is something in the event queue to process. Then
* dispatch the event to the listeners.The entire method does not
* need to be synchronized since this includes taking the event out
* from the queue and processing the event. We only need to provide
* exclusive access over the code where an event is removed from the
*queue.
*/
void dispatchEvents() {
synchronized (this) {
// Wait till there is an event in the event queue.
try {
int waitTime = AUTO_CLOSE_TIME;
}
} else {
wait();
}
}
} catch (InterruptedException e) {
}
// Remove the event from the queue and dispatch it to the listeners.
}
} // end of synchronized
} else {
}
monitorLines();
}
}
}
/**
* Queue the given event in the event queue.
*/
notifyAll();
}
/**
* A loop to dispatch events.
*/
public void run() {
while (true) {
try {
} catch (Throwable t) {
}
}
}
/**
* Send audio and MIDI events.
*/
// nothing to do
return;
}
start();
}
/*
* go through the list of registered auto-closing
* Clip instances and close them, if appropriate
*
* This method is called in regular intervals
*/
private void closeAutoClosingClips() {
synchronized(autoClosingClips) {
if (Printer.debug)Printer.debug("> EventDispatcher.closeAutoClosingClips ("+autoClosingClips.size()+" clips)");
// sanity check
}
} else {
}
} else {
}
}
}
if (Printer.debug)Printer.debug("< EventDispatcher.closeAutoClosingClips ("+autoClosingClips.size()+" clips)");
}
synchronized(autoClosingClips) {
return i;
}
}
}
return -1;
}
/**
* called from auto-closing clips when one of their open() method is called
*/
int index = 0;
synchronized(autoClosingClips) {
if (index == -1) {
}
}
if (index == -1) {
synchronized (this) {
// this is only for the case that the first clip is set to autoclosing,
// and it is already open, and nothing is done with it.
// EventDispatcher.process() method would block in wait() and
// never close this first clip, keeping the device open.
notifyAll();
}
}
if (Printer.debug)Printer.debug("< EventDispatcher.autoClosingClipOpened finished("+autoClosingClips.size()+" clips)");
}
/**
* called from auto-closing clips when their closed() method is called
*/
// nothing to do -- is removed from arraylist above
}
// ////////////////////////// Line Monitoring Support /////////////////// //
/*
* go through the list of registered line monitors
* and call their checkLine method
*
* This method is called in regular intervals
*/
private void monitorLines() {
synchronized(lineMonitors) {
if (Printer.debug)Printer.debug("> EventDispatcher.monitorLines ("+lineMonitors.size()+" monitors)");
}
}
if (Printer.debug)Printer.debug("< EventDispatcher.monitorLines("+lineMonitors.size()+" monitors)");
}
/**
* Add this LineMonitor instance to the list of monitors
*/
synchronized(lineMonitors) {
if (Printer.trace)Printer.trace("< EventDispatcher.addLineMonitor finished -- this monitor already exists!");
return;
}
}
synchronized (this) {
// need to interrupt the infinite wait()
notifyAll();
}
if (Printer.debug)Printer.debug("< EventDispatcher.addLineMonitor finished -- now ("+lineMonitors.size()+" monitors)");
}
/**
* Remove this LineMonitor instance from the list of monitors
*/
synchronized(lineMonitors) {
if (Printer.trace)Printer.trace("< EventDispatcher.removeLineMonitor finished -- this monitor does not exist!");
return;
}
}
if (Printer.debug)Printer.debug("< EventDispatcher.removeLineMonitor finished -- now ("+lineMonitors.size()+" monitors)");
}
// /////////////////////////////////// INNER CLASSES ////////////////////////////////////////// //
/**
* Container for an event and a set of listeners to deliver it to.
*/
private class EventInfo {
/**
* Create a new instance of this event Info class
* @param event the event to be dispatched
* @param listeners listener list; will be copied
*/
}
return event;
}
int getListenerCount() {
}
}
} // class EventInfo
/**
* Container for a clip with its expiration time
*/
private class ClipInfo {
private final long expiration;
/**
* Create a new instance of this clip Info class
*/
}
return clip;
}
return currTime > expiration;
}
} // class ClipInfo
/**
* Interface that a class that wants to get regular
* line monitor events implements
*/
interface LineMonitor {
/**
* Called by event dispatcher in regular intervals
*/
public void checkLine();
}
} // class EventDispatcher