From 1f510120a57083f2baecbd2b6aad37988399b1b1 Mon Sep 17 00:00:00 2001 From: Nolan Darilek Date: Fri, 12 Mar 2021 05:58:30 -0600 Subject: [PATCH] Add trace logging in AVFoundation backend. --- src/backends/av_foundation.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/backends/av_foundation.rs b/src/backends/av_foundation.rs index 6e5f38d..3dcc7dc 100644 --- a/src/backends/av_foundation.rs +++ b/src/backends/av_foundation.rs @@ -37,16 +37,22 @@ impl AvFoundation { _synth: *const Object, utterance: id, ) { + trace!("speech_synthesizer_did_start_speech_utterance"); unsafe { let backend_id: u64 = *this.get_ivar("backend_id"); let backend_id = BackendId::AvFoundation(backend_id); + trace!("Locking callbacks"); let mut callbacks = CALLBACKS.lock().unwrap(); + trace!("Locked"); let callbacks = callbacks.get_mut(&backend_id).unwrap(); if let Some(callback) = callbacks.utterance_begin.as_mut() { + trace!("Calling utterance_begin"); let utterance_id = UtteranceId::AvFoundation(utterance); callback(utterance_id); + trace!("Called"); } } + trace!("Done speech_synthesizer_did_start_speech_utterance"); } extern "C" fn speech_synthesizer_did_finish_speech_utterance( @@ -55,16 +61,22 @@ impl AvFoundation { _synth: *const Object, utterance: id, ) { + trace!("speech_synthesizer_did_finish_speech_utterance"); unsafe { let backend_id: u64 = *this.get_ivar("backend_id"); let backend_id = BackendId::AvFoundation(backend_id); + trace!("Locking callbacks"); let mut callbacks = CALLBACKS.lock().unwrap(); + trace!("Locked"); let callbacks = callbacks.get_mut(&backend_id).unwrap(); if let Some(callback) = callbacks.utterance_end.as_mut() { + trace!("Calling utterance_end"); let utterance_id = UtteranceId::AvFoundation(utterance); callback(utterance_id); + trace!("Called"); } } + trace!("Done speech_synthesizer_did_finish_speech_utterance"); } extern "C" fn speech_synthesizer_did_cancel_speech_utterance( @@ -73,16 +85,22 @@ impl AvFoundation { _synth: *const Object, utterance: id, ) { + trace!("speech_synthesizer_did_cancel_speech_utterance"); unsafe { let backend_id: u64 = *this.get_ivar("backend_id"); let backend_id = BackendId::AvFoundation(backend_id); + trace!("Locking callbacks"); let mut callbacks = CALLBACKS.lock().unwrap(); + trace!("Locked"); let callbacks = callbacks.get_mut(&backend_id).unwrap(); if let Some(callback) = callbacks.utterance_stop.as_mut() { + trace!("Calling utterance_stop"); let utterance_id = UtteranceId::AvFoundation(utterance); callback(utterance_id); + trace!("Called"); } } + trace!("Done speech_synthesizer_did_cancel_speech_utterance"); } unsafe {