diff --git a/src/backends/av_foundation.rs b/src/backends/av_foundation.rs index 84c8824..58af2f6 100644 --- a/src/backends/av_foundation.rs +++ b/src/backends/av_foundation.rs @@ -66,6 +66,24 @@ impl AvFoundation { } } + extern "C" fn speech_synthesizer_did_cancel_speech_utterance( + this: &Object, + _: Sel, + _synth: *const Object, + utterance: id, + ) { + unsafe { + let backend_id: u64 = *this.get_ivar("backend_id"); + let backend_id = BackendId::AvFoundation(backend_id); + let mut callbacks = CALLBACKS.lock().unwrap(); + let callbacks = callbacks.get_mut(&backend_id).unwrap(); + if let Some(callback) = callbacks.utterance_stop.as_mut() { + let utterance_id = UtteranceId::AvFoundation(utterance); + callback(utterance_id); + } + } + } + unsafe { decl.add_method( sel!(speechSynthesizer:didStartSpeechUtterance:), @@ -77,6 +95,11 @@ impl AvFoundation { speech_synthesizer_did_finish_speech_utterance as extern "C" fn(&Object, Sel, *const Object, id) -> (), ); + decl.add_method( + sel!(speechSynthesizer:didCancelSpeechUtterance:), + speech_synthesizer_did_cancel_speech_utterance + as extern "C" fn(&Object, Sel, *const Object, id) -> (), + ); } let delegate_class = decl.register();