1
0
mirror of https://github.com/ndarilek/tts-rs.git synced 2024-11-17 10:49:38 +00:00

Rename ns_speech_synthesizer backend to appkit.

This commit is contained in:
Nolan Darilek 2020-08-13 06:46:16 -05:00
parent 1d7018a558
commit cc2a4c12f7
3 changed files with 10 additions and 12 deletions

View File

@ -9,9 +9,9 @@ use objc::*;
use crate::{Backend, Error, Features};
pub struct NSSpeechSynthesizerBackend(*mut Object, *mut Object);
pub struct AppKit(*mut Object, *mut Object);
impl NSSpeechSynthesizerBackend {
impl AppKit {
pub fn new() -> Self {
info!("Initializing NSSpeechSynthesizer backend");
unsafe {
@ -85,12 +85,12 @@ impl NSSpeechSynthesizerBackend {
let strings: id = msg_send![class!(NSMutableArray), new];
delegate_obj.as_mut().unwrap().set_ivar("strings", strings);
let _: Object = msg_send![obj, setDelegate: delegate_obj];
NSSpeechSynthesizerBackend(obj, delegate_obj)
AppKit(obj, delegate_obj)
}
}
}
impl Backend for NSSpeechSynthesizerBackend {
impl Backend for AppKit {
fn supported_features(&self) -> Features {
Features {
stop: true,
@ -197,7 +197,7 @@ impl Backend for NSSpeechSynthesizerBackend {
}
}
impl Drop for NSSpeechSynthesizerBackend {
impl Drop for AppKit {
fn drop(&mut self) {
unsafe {
let _: Object = msg_send![self.0, release];

View File

@ -11,7 +11,7 @@ pub(crate) mod winrt;
mod web;
#[cfg(target_os = "macos")]
mod ns_speech_synthesizer;
mod appkit;
#[cfg(target_os = "linux")]
pub use self::speech_dispatcher::*;
@ -23,4 +23,4 @@ pub use self::tolk::*;
pub use self::web::*;
#[cfg(target_os = "macos")]
pub use self::ns_speech_synthesizer::*;
pub use self::appkit::*;

View File

@ -24,7 +24,7 @@ pub enum Backends {
#[cfg(windows)]
WinRT,
#[cfg(target_os = "macos")]
NSSpeechSynthesizer,
AppKit,
}
pub struct Features {
@ -109,9 +109,7 @@ impl TTS {
Ok(TTS(Box::new(tts)))
}
#[cfg(target_os = "macos")]
Backends::NSSpeechSynthesizer => {
Ok(TTS(Box::new(backends::NSSpeechSynthesizerBackend::new())))
}
Backends::AppKit => Ok(TTS(Box::new(backends::AppKit::new()))),
}
}
@ -127,7 +125,7 @@ impl TTS {
#[cfg(target_arch = "wasm32")]
let tts = TTS::new(Backends::Web);
#[cfg(target_os = "macos")]
let tts = TTS::new(Backends::NSSpeechSynthesizer);
let tts = TTS::new(Backends::AppKit);
tts
}