APIdia Launch Partner
Top Description Inners Fields Constructors Methods
com.sun.media.sound

pack-priv final Class EventDispatcher

extends Object
implements Runnable
Class Inheritance
All Implemented Interfaces
java.lang.Runnable
Imports
java.util.ArrayList, .List, javax.sound.midi.ControllerEventListener, .MetaEventListener, .MetaMessage, .ShortMessage, javax.sound.sampled.LineEvent, .LineListener

EventDispatcher. Used by various classes in the Java Sound implementation to send events.
Authors
David Rivas, Kara Kytle, Florian Bomers

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
EventDispatcher.ClipInfo

Container for a clip with its expiration time.

private static class
EventDispatcher.EventInfo

Container for an event and a set of listeners to deliver it to.

pack-priv static interface
EventDispatcher.LineMonitor

Interface that a class that wants to get regular line monitor events implements.

Field Summary

Modifier and TypeField and Description
private static final int
AUTO_CLOSE_TIME

time of inactivity until the auto closing clips are closed.

private final ArrayList<EventDispatcher.ClipInfo>
private final ArrayList<EventDispatcher.EventInfo>
eventQueue

List of events.

pack-priv static final int
LINE_MONITOR_TIME

Approximate interval between calls to LineMonitor.checkLine

private final ArrayList<EventDispatcher.LineMonitor>
private Thread
thread

Thread object for this EventDispatcher instance.

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
pack-priv void
addLineMonitor(EventDispatcher.LineMonitor lm)

Add this LineMonitor instance to the list of monitors.

pack-priv void
autoClosingClipClosed(AutoClosingClip clip)

called from auto-closing clips when their closed() method is called.

pack-priv void
autoClosingClipOpened(AutoClosingClip clip)

called from auto-closing clips when one of their open() method is called.

private void
pack-priv void
dispatchEvents()

Wait until there is something in the event queue to process.

private int
private void
private synchronized void
postEvent(EventDispatcher.EventInfo eventInfo)

Queue the given event in the event queue.

pack-priv void
processEvent(EventDispatcher.EventInfo eventInfo)

Invoked when there is at least one event in the queue.

pack-priv void
removeLineMonitor(EventDispatcher.LineMonitor lm)

Remove this LineMonitor instance from the list of monitors.

public void
run()

Implements java.lang.Runnable.run.

A loop to dispatch events.

pack-priv void
sendAudioEvents(Object event, List<Object> listeners)

Send audio and MIDI events.

pack-priv synchronized void
start()

This start() method starts an event thread if one is not already active.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

AUTO_CLOSE_TIMEback to summary
private static final int AUTO_CLOSE_TIME

time of inactivity until the auto closing clips are closed.

autoClosingClipsback to summary
private final ArrayList<EventDispatcher.ClipInfo> autoClosingClips
eventQueueback to summary
private final ArrayList<EventDispatcher.EventInfo> eventQueue

List of events.

LINE_MONITOR_TIMEback to summary
pack-priv static final int LINE_MONITOR_TIME

Approximate interval between calls to LineMonitor.checkLine

lineMonitorsback to summary
private final ArrayList<EventDispatcher.LineMonitor> lineMonitors
threadback to summary
private Thread thread

Thread object for this EventDispatcher instance.

Constructor Detail

EventDispatcherback to summary
pack-priv EventDispatcher()

Method Detail

addLineMonitorback to summary
pack-priv void addLineMonitor(EventDispatcher.LineMonitor lm)

Add this LineMonitor instance to the list of monitors.

autoClosingClipClosedback to summary
pack-priv void autoClosingClipClosed(AutoClosingClip clip)

called from auto-closing clips when their closed() method is called.

autoClosingClipOpenedback to summary
pack-priv void autoClosingClipOpened(AutoClosingClip clip)

called from auto-closing clips when one of their open() method is called.

closeAutoClosingClipsback to summary
private void closeAutoClosingClips()
dispatchEventsback to summary
pack-priv void dispatchEvents()

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.

getAutoClosingClipIndexback to summary
private int getAutoClosingClipIndex(AutoClosingClip clip)
monitorLinesback to summary
private void monitorLines()
postEventback to summary
private synchronized void postEvent(EventDispatcher.EventInfo eventInfo)

Queue the given event in the event queue.

processEventback to summary
pack-priv void processEvent(EventDispatcher.EventInfo eventInfo)

Invoked when there is at least one event in the queue. Implement this as a callback to process one event.

removeLineMonitorback to summary
pack-priv void removeLineMonitor(EventDispatcher.LineMonitor lm)

Remove this LineMonitor instance from the list of monitors.

runback to summary
public void run()

Implements java.lang.Runnable.run.

A loop to dispatch events.

Annotations
@Override
sendAudioEventsback to summary
pack-priv void sendAudioEvents(Object event, List<Object> listeners)

Send audio and MIDI events.

startback to summary
pack-priv synchronized void start()

This start() method starts an event thread if one is not already active.

com.sun.media.sound back to summary

private Class EventDispatcher.ClipInfo

extends Object
Class Inheritance

Container for a clip with its expiration time.

Field Summary

Modifier and TypeField and Description
private final AutoClosingClip
private final long

Constructor Summary

AccessConstructor and Description
pack-priv
ClipInfo(AutoClosingClip clip)

Create a new instance of this clip Info class.

Method Summary

Modifier and TypeMethod and Description
pack-priv AutoClosingClip
pack-priv boolean
isExpired(long currTime)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

clipback to summary
private final AutoClosingClip clip
expirationback to summary
private final long expiration

Constructor Detail

ClipInfoback to summary
pack-priv ClipInfo(AutoClosingClip clip)

Create a new instance of this clip Info class.

Method Detail

getClipback to summary
pack-priv AutoClosingClip getClip()
isExpiredback to summary
pack-priv boolean isExpired(long currTime)
com.sun.media.sound back to summary

private Class EventDispatcher.EventInfo

extends Object
Class Inheritance

Container for an event and a set of listeners to deliver it to.

Field Summary

Modifier and TypeField and Description
private final Object
private final Object[]

Constructor Summary

AccessConstructor and Description
pack-priv
EventInfo(Object
the event to be dispatched
event
,
List<Object>
listener list; will be copied
listeners
)

Create a new instance of this event Info class

Method Summary

Modifier and TypeMethod and Description
pack-priv Object
pack-priv Object
getListener(int index)

pack-priv int
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

eventback to summary
private final Object event
listenersback to summary
private final Object[] listeners

Constructor Detail

EventInfoback to summary
pack-priv EventInfo(Object event, List<Object> listeners)

Create a new instance of this event Info class

Parameters
event:Object

the event to be dispatched

listeners:List<Object>

listener list; will be copied

Method Detail

getEventback to summary
pack-priv Object getEvent()
getListenerback to summary
pack-priv Object getListener(int index)
getListenerCountback to summary
pack-priv int getListenerCount()
com.sun.media.sound back to summary

pack-priv Interface EventDispatcher.LineMonitor

Known Direct Implementers
com.sun.media.sound.DirectAudioDevice.DirectDL

Interface that a class that wants to get regular line monitor events implements.

Method Summary

Modifier and TypeMethod and Description
public void
checkLine()

Called by event dispatcher in regular intervals.

Method Detail

checkLineback to summary
public void checkLine()

Called by event dispatcher in regular intervals.