internal static SpeechEvent TryCreateSpeechEvent(ISpEventSource sapiEventSource, bool additionalSapiFeatures, SpeechAudioFormatInfo audioFormat) { SpeechEvent result = null; uint pulFetched; if (additionalSapiFeatures) { SPEVENTEX pEventArray; ((ISpEventSource2)sapiEventSource).GetEventsEx(1u, out pEventArray, out pulFetched); if (pulFetched == 1) { result = new SpeechEvent(pEventArray); } } else { SPEVENT pEventArray2; sapiEventSource.GetEvents(1u, out pEventArray2, out pulFetched); if (pulFetched == 1) { result = new SpeechEvent(pEventArray2, audioFormat); } } return(result); }
// This tries to get an event from the ISpEventSource. // If there are no events queued then null is returned. // Otherwise a new SpeechEvent is created and returned. internal static SpeechEvent TryCreateSpeechEvent(ISpEventSource sapiEventSource, bool additionalSapiFeatures, SpeechAudioFormatInfo audioFormat) { uint fetched; SpeechEvent speechEvent = null; if (additionalSapiFeatures) { SPEVENTEX sapiEventEx; ((ISpEventSource2)sapiEventSource).GetEventsEx(1, out sapiEventEx, out fetched); if (fetched == 1) { speechEvent = new SpeechEvent(sapiEventEx); } } else { SPEVENT sapiEvent; sapiEventSource.GetEvents(1, out sapiEvent, out fetched); if (fetched == 1) { speechEvent = new SpeechEvent(sapiEvent, audioFormat); } } return(speechEvent); }
internal void SendNotification(object ignored) { lock (this) { if (_sapiEventSourceReference != null) { ISpEventSource spEventSource = (ISpEventSource)_sapiEventSourceReference.Target; if (spEventSource != null) { List <SpeechEvent> list = new List <SpeechEvent>(); SpeechEvent item; while ((item = SpeechEvent.TryCreateSpeechEvent(spEventSource, _additionalSapiFeatures, _audioFormat)) != null) { list.Add(item); } _dispatcher.Post(list.ToArray()); } } } }
internal void SendNotification(object ignored) { lock (this) { // Call dispatchEventDelegate for each SAPI event currently queued. if (_sapiEventSourceReference != null) { ISpEventSource sapiEventSource = (ISpEventSource)_sapiEventSourceReference.Target; if (sapiEventSource != null) { List <SpeechEvent> speechEvents = new(); SpeechEvent speechEvent; while (null != (speechEvent = SpeechEvent.TryCreateSpeechEvent(sapiEventSource, _additionalSapiFeatures, _audioFormat))) { speechEvents.Add(speechEvent); } _dispatcher.Post(speechEvents.ToArray()); } } } }