Commit Graph

20 Commits

Author SHA1 Message Date
Michael Connor Buchan f39f86aa13 FFI: Pass pointer to uninit Features struct in tts_supported_features()
This is done because the ABI for returning struct values isn't well
defined.
2022-07-23 13:41:39 +01:00
mcb2003 6155937f06 FFI: Use rename crate::Tts instead of crate::TTS. 2021-09-28 09:38:20 +01:00
mcb2003 6b726463cd FFI: Use std::os::raw::c_char instead of i8 or libc's c_char
This fixes an issue where the string pointer type in the generated bindings was const int8_t *. This works the same way, but could be confusing.
2021-03-06 13:08:31 +00:00
mcb2003 b972f44bc9 FFI: Don't use libc for C types like char and float
This insures the correct C standards are followed, but doesn't work on
wasm32-unknown-unknown targets, because there *is* no libc. Given that
the definition of `char` and `float` are very universal anyway, it makes
sense to just use `i8` and `f32`.
2021-03-06 11:30:42 +00:00
mcb2003 060a057c0f FFI: Take only const pointers to TTS objects when we don't modify them. 2021-03-06 09:36:45 +00:00
mcb2003 bab977c0ea FFI:: Fix spelling error in doc comments. 2020-12-31 15:31:46 +00:00
mcb2003 a868aa670a FFI: Add module level doc comment. 2020-12-31 13:54:15 +00:00
mcb2003 989b6bb310 FFI: Implement tts_is_speaking() function. 2020-12-31 13:54:15 +00:00
mcb2003 0ffa4c6afe FFI: Allow getting and setting volume, and getting min, normal and max volume. 2020-12-31 13:54:15 +00:00
mcb2003 32c9327f5c FFI: Allow getting and setting pitch, and getting min, normal and max pitch. 2020-12-31 13:54:15 +00:00
mcb2003 cf35c19c57 FFI: Allow getting and setting rate, and getting min, normal and max rate. 2020-12-31 13:54:15 +00:00
mcb2003 729ece9a07 FFI: Make all functions with unsafe blocks completely unsafe.
This is better than using unsafe blocks inside the functions, as that
tells the compiler that the unsafeness won't leak out of the block,
which isn't true in this case as we're dealing with another unsafe
language.
2020-12-31 13:54:15 +00:00
mcb2003 0905f6d6c6 FFI: Implement tts_stop() function. 2020-12-31 13:54:15 +00:00
mcb2003 05a065c6d3 FFI: Implement tts_speak()
The tts_speak() function has an additional parameter that, if not NULL,
will be filled with a pointer to an UtteranceId. If this is specified,
the caller must also call tts_free_utterance() to deallocate the
UtteranceId when they're done with it.
2020-12-31 13:54:15 +00:00
mcb2003 53f352e1a8 FFI: Update documentation comments to match their Rust equivilents. 2020-12-31 13:54:15 +00:00
mcb2003 f6546303f8 FFI: Allow determining TTS supported Features from C/C++ 2020-12-31 13:54:15 +00:00
mcb2003 8e86afb444 FFI: Implement tts_new(backend)
This required giving the Backends enum and Features struct a C
representation.
2020-12-31 13:54:15 +00:00
mcb2003 5e7ab42f59 FFI: Implement tts_default() constructor and tts_free() destructor
* tts_default() allocates a new TTS struct via it's default() constructor, returning a pointer to it or NULL on error.
* tts_free(tts) destroys the TTS pointed to by tts. If tts is NULL, this
  function does nothing.
2020-12-31 13:54:15 +00:00
mcb2003 c5bbbfcfd7 FFI: Create error handling code and LAST_ERROR static
Any errors reported will cause the C API functions to return an error
value (NULL or -1). The caller can then use:

* const char* tts_get_error() to get a pointer to a string describing
  the error
* void tts_clear_error() to deallocate any currently stored error
message.
2020-12-31 13:54:15 +00:00
mcb2003 0ca3100a97 FFI: Create ffi Cargo feature and include ffi module. 2020-12-31 13:54:15 +00:00