mirror of https://github.com/ndarilek/tts-rs.git
Merge a55463dac8
into 5c528f1d8e
This commit is contained in:
commit
bde29226a0
|
@ -8,7 +8,7 @@ use core_foundation::base::TCFType;
|
|||
use core_foundation::string::CFString;
|
||||
use lazy_static::lazy_static;
|
||||
use log::{info, trace};
|
||||
use objc::runtime::{Object, Sel};
|
||||
use objc::runtime::{Class, Object, Sel};
|
||||
use objc::{class, declare::ClassDecl, msg_send, sel, sel_impl};
|
||||
use oxilangtag::LanguageTag;
|
||||
|
||||
|
@ -25,13 +25,7 @@ pub(crate) struct AvFoundation {
|
|||
voice: Option<Voice>,
|
||||
}
|
||||
|
||||
lazy_static! {
|
||||
static ref NEXT_BACKEND_ID: Mutex<u64> = Mutex::new(0);
|
||||
}
|
||||
|
||||
impl AvFoundation {
|
||||
pub(crate) fn new() -> Result<Self, Error> {
|
||||
info!("Initializing AVFoundation backend");
|
||||
fn make_speech_sythesizer_delegate() -> Result<&'static Class, Error> {
|
||||
let mut decl = ClassDecl::new("MyNSSpeechSynthesizerDelegate", class!(NSObject))
|
||||
.ok_or(Error::OperationFailed)?;
|
||||
decl.add_ivar::<u64>("backend_id");
|
||||
|
@ -126,8 +120,19 @@ impl AvFoundation {
|
|||
);
|
||||
}
|
||||
|
||||
let delegate_class = decl.register();
|
||||
let delegate_obj: *mut Object = unsafe { msg_send![delegate_class, new] };
|
||||
Ok(decl.register())
|
||||
}
|
||||
|
||||
lazy_static! {
|
||||
static ref NEXT_BACKEND_ID: Mutex<u64> = Mutex::new(0);
|
||||
static ref DELEGATE_CLASS: &'static Class = make_speech_sythesizer_delegate().unwrap();
|
||||
}
|
||||
|
||||
impl AvFoundation {
|
||||
pub(crate) fn new() -> Result<Self, Error> {
|
||||
info!("Initializing AVFoundation backend");
|
||||
|
||||
let delegate_obj: *mut Object = unsafe { msg_send![*DELEGATE_CLASS, new] };
|
||||
let mut backend_id = NEXT_BACKEND_ID.lock().unwrap();
|
||||
let rv = unsafe {
|
||||
trace!("Creating synth");
|
||||
|
|
Loading…
Reference in New Issue