mirror of
https://github.com/ndarilek/tts-rs.git
synced 2024-11-17 09:09:38 +00:00
Switch to using MediaPlaybackItem as WinRT utterance ID.
This commit is contained in:
parent
4816ec575c
commit
f5f11b7cdf
|
@ -1,7 +1,4 @@
|
|||
#[cfg(windows)]
|
||||
use std::sync::Mutex;
|
||||
|
||||
use lazy_static::lazy_static;
|
||||
use log::{info, trace};
|
||||
|
||||
use tts_winrt_bindings::windows::media::core::MediaSource;
|
||||
|
@ -24,10 +21,6 @@ pub struct WinRT {
|
|||
playback_list: MediaPlaybackList,
|
||||
}
|
||||
|
||||
lazy_static! {
|
||||
static ref NEXT_UTTERANCE_ID: Mutex<u64> = Mutex::new(0);
|
||||
}
|
||||
|
||||
impl WinRT {
|
||||
pub fn new() -> std::result::Result<Self, Error> {
|
||||
info!("Initializing WinRT backend");
|
||||
|
@ -83,13 +76,11 @@ impl Backend for WinRT {
|
|||
self.reinit_player()?;
|
||||
}
|
||||
}
|
||||
self.playback_list.items()?.append(item)?;
|
||||
self.playback_list.items()?.append(&item)?;
|
||||
if !self.is_speaking()? {
|
||||
self.player.play()?;
|
||||
}
|
||||
let mut utterance_id = NEXT_UTTERANCE_ID.lock().unwrap();
|
||||
*utterance_id += 1;
|
||||
Ok(Some(UtteranceId::WinRT(*utterance_id)))
|
||||
Ok(Some(UtteranceId::WinRT(item)))
|
||||
}
|
||||
|
||||
fn stop(&mut self) -> std::result::Result<(), Error> {
|
||||
|
|
|
@ -23,6 +23,9 @@ use libc::c_char;
|
|||
use objc::{class, msg_send, sel, sel_impl};
|
||||
use thiserror::Error;
|
||||
|
||||
#[cfg(windows)]
|
||||
use tts_winrt_bindings::windows::media::playback::MediaPlaybackItem;
|
||||
|
||||
mod backends;
|
||||
|
||||
pub enum Backends {
|
||||
|
@ -40,14 +43,14 @@ pub enum Backends {
|
|||
AvFoundation,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub enum UtteranceId {
|
||||
#[cfg(target_os = "linux")]
|
||||
SpeechDispatcher(i32),
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
Web(u64),
|
||||
#[cfg(windows)]
|
||||
WinRT(u64),
|
||||
WinRT(MediaPlaybackItem),
|
||||
}
|
||||
|
||||
pub struct Features {
|
||||
|
|
Loading…
Reference in New Issue
Block a user