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