|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.sun.speech.engine.BaseEngine
Supports the JSAPI 1.0 Engine interface.
Actual JSAPI implementations might want to extend or modify this
implementation.
| Field Summary | |
protected javax.speech.AudioManager |
audioManager
The AudioManager for this Engine. |
protected static long |
CLEAR_ALL_STATE
Utility state for clearing the engineState. |
protected java.util.Collection |
engineListeners
List of EngineListeners registered for
EngineEvents on this Engine. |
protected javax.speech.EngineModeDesc |
engineModeDesc
The EngineModeDesc for this Engine. |
protected javax.speech.EngineProperties |
engineProperties
The EngineProperties for this Engine. |
protected long |
engineState
A bitmask holding the current state of this Engine. |
protected java.lang.Object |
engineStateLock
An Object used for synchronizing access to
engineState. |
| Fields inherited from interface javax.speech.Engine |
ALLOCATED, ALLOCATING_RESOURCES, DEALLOCATED, DEALLOCATING_RESOURCES, PAUSED, RESUMED |
| Constructor Summary | |
BaseEngine()
Creates a new Engine in the
DEALLOCATED state. |
|
BaseEngine(javax.speech.EngineModeDesc desc)
Creates a new Engine in the
DEALLOCATED state. |
|
| Method Summary | |
void |
addEngineListener(javax.speech.EngineListener listener)
Requests notification of EngineEvents from this
Engine. |
void |
allocate()
Allocates the resources required for this Engine and
puts it into the ALLOCATED state. |
protected void |
checkEngineState(long state)
Convenience method that throws an EngineStateError
if any of the bits in the passed state are set in the
state. |
protected abstract BaseEngineProperties |
createEngineProperties()
Factory constructor for EngineProperties object. |
void |
deallocate()
Frees the resources of this Engine that were
acquired during allocation and during operation and return this
Engine to the DEALLOCATED. |
void |
dispatchSpeechEvent(javax.speech.SpeechEvent event)
Dispatches a SpeechEvent.
|
void |
fireEngineAllocated(javax.speech.EngineEvent event)
Utility function that sends an ENGINE_ALLOCATED
event to all EngineListeners registered with this
Engine. |
void |
fireEngineAllocatingResources(javax.speech.EngineEvent event)
Utility function that sends an ENGINE_ALLOCATING_RESOURCES event to all
EngineListeners registered with this
Engine. |
void |
fireEngineDeallocated(javax.speech.EngineEvent event)
Utility function that sends an ENGINE_DEALLOCATED event to all
EngineListeners registered with this
Engine. |
void |
fireEngineDeallocatingResources(javax.speech.EngineEvent event)
Utility function that sends a ENGINE_DEALLOCATING_RESOURCES event to all
EngineListeners registered with this
Engine. |
void |
fireEnginePaused(javax.speech.EngineEvent event)
Utility function that sends an ENGINE_PAUSED event
to all
EngineListeners registered with this
Engine. |
void |
fireEngineResumed(javax.speech.EngineEvent event)
Utility function that sends an ENGINE_RESUMED event
to all
EngineListeners registered with this
Engine. |
javax.speech.AudioManager |
getAudioManager()
Returns an object that provides management of the audio input or output of this Engine. |
javax.speech.EngineModeDesc |
getEngineModeDesc()
Gets the current operating properties and mode of this Engine. |
javax.speech.EngineProperties |
getEngineProperties()
Gets the EngineProperties of this Engine.
|
long |
getEngineState()
Returns a or'ed set of flags indicating the current state of this Engine.
|
javax.speech.VocabManager |
getVocabManager()
Returns an object that provides management of the vocabulary for this Engine. |
protected abstract void |
handleAllocate()
Called from the allocate method. |
protected abstract void |
handleDeallocate()
Called from the deallocate method. |
protected abstract void |
handlePause()
Called from the pause method. |
protected abstract void |
handleResume()
Called from the resume method. |
void |
pause()
Pauses the audio stream for this Engine and put
this Engine into the PAUSED state. |
protected void |
postEngineAllocated(long oldState,
long newState)
Utility function that generates an ENGINE_ALLOCATED event and posts it
to the event queue. |
protected void |
postEngineAllocatingResources(long oldState,
long newState)
Utility function that generates an ENGINE_ALLOCATING_RESOURCES event and
posts it to the event queue. |
protected void |
postEngineDeallocated(long oldState,
long newState)
Utility function that generates an ENGINE_DEALLOCATED event and posts it
to the event queue. |
protected void |
postEngineDeallocatingResources(long oldState,
long newState)
Utility function that generates ENGINE_DEALLOCATING_RESOURCES event and
posts it to the event queue. |
protected void |
postEnginePaused(long oldState,
long newState)
Utility function that generates an ENGINE_PAUSED event and posts it
to the event queue. |
protected void |
postEngineResumed(long oldState,
long newState)
Utility function that generates an ENGINE_RESUMED
event and posts it to the event queue. |
void |
removeEngineListener(javax.speech.EngineListener listener)
Removes an EngineListener from the list of
EngineListeners. |
void |
resume()
Resumes the audio stream for this Engine and put
this Engine into the RESUMED state. |
protected void |
setEngineModeDesc(javax.speech.EngineModeDesc desc)
Sets the current operating properties and mode of this Engine. |
protected long[] |
setEngineState(long clear,
long set)
Updates this Engine state by clearing defined bits,
then setting other specified bits. |
protected java.lang.String |
stateToString(long state)
Returns a String of the names of all the
Engine states in the given Engine
state. |
boolean |
testEngineState(long state)
Returns true if this state of this
Engine matches the specified state.
|
java.lang.String |
toString()
Returns the engine name and mode for debug purposes. |
void |
waitEngineState(long state)
Blocks the calling thread until this Engine
is in a specified state.
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
protected long engineState
Engine.
protected java.lang.Object engineStateLock
Object used for synchronizing access to
engineState.
engineStateprotected java.util.Collection engineListeners
EngineListeners registered for
EngineEvents on this Engine.
protected javax.speech.AudioManager audioManager
AudioManager for this Engine.
protected javax.speech.EngineModeDesc engineModeDesc
EngineModeDesc for this Engine.
protected javax.speech.EngineProperties engineProperties
EngineProperties for this Engine.
protected static final long CLEAR_ALL_STATE
engineState.
| Constructor Detail |
public BaseEngine()
Engine in the
DEALLOCATED state.
public BaseEngine(javax.speech.EngineModeDesc desc)
Engine in the
DEALLOCATED state.
desc - the operating mode of this Engine| Method Detail |
public long getEngineState()
Engine.
An EngineEvent is issued each time this
Engine changes state.
The getEngineState method can be called successfully
in any Engine state.
getEngineState in interface javax.speech.EngineEnginegetEngineState(),
waitEngineState(long)
public void waitEngineState(long state)
throws java.lang.InterruptedException,
java.lang.IllegalArgumentException
Engine
is in a specified state.
All state bits specified in the state parameter
must be set in order for the method to return, as defined
for the testEngineState method. If the state
parameter defines an unreachable state
(e.g. PAUSED | RESUMED) an exception is thrown.
The waitEngineState method can be called successfully
in any Engine state.
waitEngineState in interface javax.speech.Enginestate - a bitmask of the state to wait for
java.lang.InterruptedException - if another thread has interrupted this thread.
java.lang.IllegalArgumentException - if the specified state is unreachabletestEngineState(long),
getEngineState()
public boolean testEngineState(long state)
throws java.lang.IllegalArgumentException
true if this state of this
Engine matches the specified state.
The test performed is not an exact match to the current
state. Only the specified states are tested. For
example the following returns true only if the
Synthesizer queue is empty, irrespective
of the pause/resume and allocation states.
if (synth.testEngineState(Synthesizer.QUEUE_EMPTY)) ...
The testEngineState method is equivalent to:
if ((engine.getEngineState() & state) == state)
The testEngineState method can be called
successfully in any Engine state.
testEngineState in interface javax.speech.Enginestate - a bitmask of the states to test for
true if this Engine matches
state; otherwise false
java.lang.IllegalArgumentException - if the specified state is unreachable
protected long[] setEngineState(long clear,
long set)
Engine state by clearing defined bits,
then setting other specified bits.
public void allocate()
throws javax.speech.EngineException,
javax.speech.EngineStateError
Engine and
puts it into the ALLOCATED state. When this method
returns successfully the ALLOCATED bit of this
Engine state is set, and the
testEngineState(Engine.ALLOCATED) method returns
true.
During the processing of the method, this Engine is
temporarily in the ALLOCATING_RESOURCES state.
allocate in interface javax.speech.Enginejavax.speech.EngineException - if this Engine cannot be allocated
javax.speech.EngineStateError - if this Engine is in the
DEALLOCATING_RESOURCES statedeallocate()
protected abstract void handleAllocate()
throws javax.speech.EngineException
allocate method. Override this in
subclasses.
javax.speech.EngineException - if problems are encounteredallocate()
public void deallocate()
throws javax.speech.EngineException,
javax.speech.EngineStateError
Engine that were
acquired during allocation and during operation and return this
Engine to the DEALLOCATED. When this
method returns the DEALLOCATED bit of this
Engine state is set so the
testEngineState(Engine.DEALLOCATED) method returns
true.
During the processing of the method, this
Engine is temporarily in the
DEALLOCATING_RESOURCES state.
A deallocated engine can be re-started with a subsequent
call to allocate.
deallocate in interface javax.speech.Enginejavax.speech.EngineException - if this Engine cannot be
deallocated
javax.speech.EngineStateError - if this Engine is in the
ALLOCATING_RESOURCES stateallocate()
protected abstract void handleDeallocate()
throws javax.speech.EngineException
deallocate method. Override this in
subclasses.
javax.speech.EngineException - if this Engine cannot be
deallocated.
public void pause()
throws javax.speech.EngineStateError
Engine and put
this Engine into the PAUSED state.
pause in interface javax.speech.Enginejavax.speech.EngineStateError - if this Engine is in the
DEALLOCATING_RESOURCES or
DEALLOCATED state.protected abstract void handlePause()
pause method. Override this in subclasses.
public void resume()
throws javax.speech.AudioException,
javax.speech.EngineStateError
Engine and put
this Engine into the RESUMED state.
resume in interface javax.speech.Enginejavax.speech.AudioException - if unable to gain access to the audio channel
javax.speech.EngineStateError - if this Engine is in the
DEALLOCATING_RESOURCES or
DEALLOCATED stateprotected abstract void handleResume()
resume method. Override in subclasses.
public javax.speech.AudioManager getAudioManager()
Engine.
getAudioManager in interface javax.speech.EngineEngine
public javax.speech.VocabManager getVocabManager()
throws javax.speech.EngineStateError
Engine. Returns null if this
Engine does not support vocabulary management.
getVocabManager in interface javax.speech.EngineEngine
javax.speech.EngineStateError - if this Engine in the
DEALLOCATING_RESOURCES or
DEALLOCATED statepublic javax.speech.EngineProperties getEngineProperties()
EngineProperties of this Engine.
Must be set in subclasses.
getEngineProperties in interface javax.speech.EngineEngineProperties of this Engine.
public javax.speech.EngineModeDesc getEngineModeDesc()
throws java.lang.SecurityException
Engine.
getEngineModeDesc in interface javax.speech.EngineEngine
java.lang.SecurityExceptionprotected void setEngineModeDesc(javax.speech.EngineModeDesc desc)
Engine.
desc - the new operating mode of this Enginepublic void addEngineListener(javax.speech.EngineListener listener)
EngineEvents from this
Engine.
addEngineListener in interface javax.speech.Enginelistener - the listener to add.public void removeEngineListener(javax.speech.EngineListener listener)
EngineListener from the list of
EngineListeners.
removeEngineListener in interface javax.speech.Enginelistener - the listener to remove.
protected void postEngineAllocated(long oldState,
long newState)
ENGINE_ALLOCATED event and posts it
to the event queue. Eventually
fireEngineAllocated will be called
by the dispatchSpeechEvent as a result of this
action.
oldState - the old state of this EnginenewState - the new state of this EnginefireEngineAllocated(javax.speech.EngineEvent),
dispatchSpeechEvent(javax.speech.SpeechEvent)public void fireEngineAllocated(javax.speech.EngineEvent event)
ENGINE_ALLOCATED
event to all EngineListeners registered with this
Engine. Called by dispatchSpeechEvent.
event - the ENGINE_ALLOCATED eventpostEngineAllocated(long, long),
dispatchSpeechEvent(javax.speech.SpeechEvent)
protected void postEngineAllocatingResources(long oldState,
long newState)
ENGINE_ALLOCATING_RESOURCES event and
posts it to the event queue. Eventually
fireEngineAllocatingResources
will be called by dispatchSpeechEvent as a
result of this action.
oldState - the old state of this EnginenewState - the new state of this EnginefireEngineAllocatingResources(javax.speech.EngineEvent),
dispatchSpeechEvent(javax.speech.SpeechEvent)public void fireEngineAllocatingResources(javax.speech.EngineEvent event)
ENGINE_ALLOCATING_RESOURCES event to all
EngineListeners registered with this
Engine. Called by dispatchSpeechEvent.
event - the ENGINE_ALLOCATING_RESOURCES eventpostEngineAllocatingResources(long, long),
dispatchSpeechEvent(javax.speech.SpeechEvent)
protected void postEngineDeallocated(long oldState,
long newState)
ENGINE_DEALLOCATED event and posts it
to the event queue. Eventually
fireEngineDeallocated will be called
by dispatchSpeechEvent as a result of this action.
oldState - the old state of this EnginenewState - the new state of this EnginefireEngineDeallocated(javax.speech.EngineEvent),
dispatchSpeechEvent(javax.speech.SpeechEvent)public void fireEngineDeallocated(javax.speech.EngineEvent event)
ENGINE_DEALLOCATED event to all
EngineListeners registered with this
Engine. Called by dispatchSpeechEvent.
event - the ENGINE_DEALLOCATED eventpostEngineDeallocated(long, long),
dispatchSpeechEvent(javax.speech.SpeechEvent)
protected void postEngineDeallocatingResources(long oldState,
long newState)
ENGINE_DEALLOCATING_RESOURCES event and
posts it to the event queue. Eventually
fireEngineAllocatingResources will be called
by dispatchSpeechEvent as a result of this action.
oldState - the old state of this EnginenewState - the new state of this EnginefireEngineDeallocatingResources(javax.speech.EngineEvent),
dispatchSpeechEvent(javax.speech.SpeechEvent)public void fireEngineDeallocatingResources(javax.speech.EngineEvent event)
ENGINE_DEALLOCATING_RESOURCES event to all
EngineListeners registered with this
Engine. Called by dispatchSpeechEvent.
event - the ENGINE_DEALLOCATING_RESOURCES eventpostEngineDeallocatingResources(long, long),
dispatchSpeechEvent(javax.speech.SpeechEvent)
protected void postEnginePaused(long oldState,
long newState)
ENGINE_PAUSED event and posts it
to the event queue. Eventually
fireEnginePaused will be called
by dispatchSpeechEvent as a result of this action.
oldState - the old state of this EnginenewState - the new state of this EnginefireEnginePaused(javax.speech.EngineEvent),
dispatchSpeechEvent(javax.speech.SpeechEvent)public void fireEnginePaused(javax.speech.EngineEvent event)
ENGINE_PAUSED event
to all
EngineListeners registered with this
Engine. Called by dispatchSpeechEvent.
event - the ENGINE_PAUSED eventpostEnginePaused(long, long),
dispatchSpeechEvent(javax.speech.SpeechEvent)
protected void postEngineResumed(long oldState,
long newState)
ENGINE_RESUMED
event and posts it to the event queue. Eventually
fireEngineResumed will be called
by dispatchSpeechEvent as a result of this action.
oldState - the old state of this EnginenewState - the new state of this EnginefireEngineResumed(javax.speech.EngineEvent),
dispatchSpeechEvent(javax.speech.SpeechEvent)public void fireEngineResumed(javax.speech.EngineEvent event)
ENGINE_RESUMED event
to all
EngineListeners registered with this
Engine. Called by dispatchSpeechEvent.
event - the ENGINE_RESUMED eventpostEngineResumed(long, long),
dispatchSpeechEvent(javax.speech.SpeechEvent)protected abstract BaseEngineProperties createEngineProperties()
BaseEngineProperties object specific to
a subclass.
protected void checkEngineState(long state)
throws javax.speech.EngineStateError
EngineStateError
if any of the bits in the passed state are set in the
state.
state - the Engine state to check
javax.speech.EngineStateError - if any of the bits in the passed state
are set in the stateprotected java.lang.String stateToString(long state)
String of the names of all the
Engine states in the given Engine
state.
state - the bitmask of states
String containing the names of all the
states set in statepublic void dispatchSpeechEvent(javax.speech.SpeechEvent event)
SpeechEvent.
The dispatcher should notify all EngineListeners
from this method. The SpeechEvent was added
via the various post methods of this class.
dispatchSpeechEvent in interface SpeechEventDispatcherevent - the SpeechEvent to dispatchpostEngineAllocatingResources(long, long),
postEngineAllocated(long, long),
postEngineDeallocatingResources(long, long),
postEngineDeallocated(long, long),
postEnginePaused(long, long),
postEngineResumed(long, long)public java.lang.String toString()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||