1
0
mirror of https://github.com/ndarilek/tts-rs.git synced 2024-11-25 09:19:37 +00:00

FFI: Implement tts_is_speaking() function.

This commit is contained in:
mcb2003 2020-12-12 20:44:44 +00:00
parent a2c13dd21f
commit f421dd9362

View File

@ -322,3 +322,28 @@ pub unsafe extern "C" fn tts_set_volume(tts: *mut TTS, volume: c_float) -> bool
}
}
}
/// fills `speaking` with a bool indicating whether this speech synthesizer is speaking.
/// Returns true on success, false on error (likely that the backend doesn't support speaking
/// status) or if `tts` is NULL.
/// If `speaking` is NULL, returns this value instead, meaning you can't tell the difference
/// between an error occuring and the synth not speaking.
#[no_mangle]
pub unsafe extern "C" fn tts_is_speaking(tts: *mut TTS, speaking: *mut bool) -> bool {
if tts.is_null() {
return false;
}
match tts.as_ref().unwrap().is_speaking() {
Ok(s) => {
if speaking.is_null() {
return s;
}
*speaking = s;
true
}
Err(e) => {
set_last_error(e.to_string()).unwrap();
false
}
}
}