From ae6e64d973c8ef4e1df8eee01fbee560b1bac4ac Mon Sep 17 00:00:00 2001 From: mcb2003 Date: Sat, 12 Dec 2020 19:25:36 +0000 Subject: [PATCH] FFI: Implement tts_stop() function. --- src/ffi.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/ffi.rs b/src/ffi.rs index ec349e7..6323ab6 100644 --- a/src/ffi.rs +++ b/src/ffi.rs @@ -130,3 +130,18 @@ pub extern "C" fn tts_free_utterance(utterance: *mut UtteranceId) { Box::from_raw(utterance); } } +/// Stops current speech. +/// Returns true on success, false on error or if `tts` is NULL. +#[no_mangle] +pub extern "C" fn tts_stop(tts: *mut TTS) -> bool { + if tts.is_null() { + return false; + } + match unsafe { tts.as_mut().unwrap().stop() } { + Ok(_) => true, + Err(e) => { + set_last_error(e.to_string()).unwrap(); + false + } + } +}