1
0
mirror of https://github.com/ndarilek/tts-rs.git synced 2024-07-22 04:29:37 +00:00

Implement FnMut callbacks on AV Foundation, and fix warnings.

This commit is contained in:
Nolan Darilek 2020-09-25 11:12:44 -05:00
parent 1f22843086
commit 589c613bbe

View File

@ -33,15 +33,15 @@ impl AvFoundation {
extern "C" fn speech_synthesizer_did_start_speech_utterance(
this: &Object,
_: Sel,
synth: *const Object,
_synth: *const Object,
utterance: id,
) {
unsafe {
let backend_id: u64 = *this.get_ivar("backend_id");
let backend_id = BackendId::AvFoundation(backend_id);
let callbacks = CALLBACKS.lock().unwrap();
let callbacks = callbacks.get(&backend_id).unwrap();
if let Some(callback) = callbacks.utterance_begin {
let mut callbacks = CALLBACKS.lock().unwrap();
let callbacks = callbacks.get_mut(&backend_id).unwrap();
if let Some(callback) = callbacks.utterance_begin.as_mut() {
let utterance_id = UtteranceId::AvFoundation(utterance);
callback(utterance_id);
}
@ -51,15 +51,15 @@ impl AvFoundation {
extern "C" fn speech_synthesizer_did_finish_speech_utterance(
this: &Object,
_: Sel,
synth: *const Object,
_synth: *const Object,
utterance: id,
) {
unsafe {
let backend_id: u64 = *this.get_ivar("backend_id");
let backend_id = BackendId::AvFoundation(backend_id);
let callbacks = CALLBACKS.lock().unwrap();
let callbacks = callbacks.get(&backend_id).unwrap();
if let Some(callback) = callbacks.utterance_end {
let mut callbacks = CALLBACKS.lock().unwrap();
let callbacks = callbacks.get_mut(&backend_id).unwrap();
if let Some(callback) = callbacks.utterance_end.as_mut() {
let utterance_id = UtteranceId::AvFoundation(utterance);
callback(utterance_id);
}