mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-17 08:40:52 +00:00
fix (or at least improve) simultaneous tts initiation crash
This commit is contained in:
parent
a998cf06c4
commit
71d9cc38af
5 changed files with 9 additions and 5 deletions
|
|
@ -79,7 +79,7 @@ fn xmain() -> ! {
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
Some(api::Opcode::PauseStream) => xous::msg_scalar_unpack!(msg, _, _, _, _, {
|
Some(api::Opcode::PauseStream) => xous::msg_scalar_unpack!(msg, _, _, _, _, {
|
||||||
if codec.is_on() && codec.is_init() {
|
if codec.is_on() && codec.is_init() && codec.is_live() {
|
||||||
codec.drain(); // this will suppress any future callbacks from firing
|
codec.drain(); // this will suppress any future callbacks from firing
|
||||||
while codec.can_play() {
|
while codec.can_play() {
|
||||||
xous::yield_slice();
|
xous::yield_slice();
|
||||||
|
|
@ -90,7 +90,7 @@ fn xmain() -> ! {
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
Some(api::Opcode::AbortStream) => xous::msg_scalar_unpack!(msg, _, _, _, _, {
|
Some(api::Opcode::AbortStream) => xous::msg_scalar_unpack!(msg, _, _, _, _, {
|
||||||
if codec.is_on() && codec.is_init() {
|
if codec.is_on() && codec.is_init() && codec.is_live() {
|
||||||
codec.audio_i2s_stop();
|
codec.audio_i2s_stop();
|
||||||
} else {
|
} else {
|
||||||
log::error!("attempted to abort a stream on an uninitialized codec, ignoring!")
|
log::error!("attempted to abort a stream on an uninitialized codec, ignoring!")
|
||||||
|
|
|
||||||
|
|
@ -281,7 +281,7 @@ impl<'a> Menu<'a> {
|
||||||
self.gam.redraw().unwrap();
|
self.gam.redraw().unwrap();
|
||||||
#[cfg(feature="tts")]
|
#[cfg(feature="tts")]
|
||||||
{
|
{
|
||||||
// self.tts.tts_simple(&self.name).unwrap();
|
self.tts.tts_simple(&self.name).unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn num_items(&self) -> usize {
|
fn num_items(&self) -> usize {
|
||||||
|
|
|
||||||
|
|
@ -41,5 +41,6 @@ chrono = "0.4"
|
||||||
[features]
|
[features]
|
||||||
debugprint = []
|
debugprint = []
|
||||||
braille = [] # used for braille mode, so console isn't overwhelmed with status
|
braille = [] # used for braille mode, so console isn't overwhelmed with status
|
||||||
|
tts = []
|
||||||
# default = ["debugprint"] # "debugprint"
|
# default = ["debugprint"] # "debugprint"
|
||||||
default = []
|
default = []
|
||||||
|
|
|
||||||
|
|
@ -7,11 +7,13 @@ use num_traits::*;
|
||||||
|
|
||||||
use crate::StatusOpcode;
|
use crate::StatusOpcode;
|
||||||
|
|
||||||
|
#[allow(unused_variables)] // quiets a warning about unused com that is emitted in tts config. Would be nice to make this more targeted...
|
||||||
pub fn create_main_menu(keys: Arc<Mutex<RootKeys>>, status_conn: xous::CID, com: &com::Com) {
|
pub fn create_main_menu(keys: Arc<Mutex<RootKeys>>, status_conn: xous::CID, com: &com::Com) {
|
||||||
let key_conn = keys.lock().unwrap().conn();
|
let key_conn = keys.lock().unwrap().conn();
|
||||||
|
|
||||||
let mut menuitems = Vec::<MenuItem>::new();
|
let mut menuitems = Vec::<MenuItem>::new();
|
||||||
|
|
||||||
|
#[cfg(not(feature="tts"))] // no backlight on versions with no display
|
||||||
menuitems.push(MenuItem {
|
menuitems.push(MenuItem {
|
||||||
name: String::from_str(t!("mainmenu.backlighton", xous::LANG)),
|
name: String::from_str(t!("mainmenu.backlighton", xous::LANG)),
|
||||||
action_conn: Some(com.conn()),
|
action_conn: Some(com.conn()),
|
||||||
|
|
@ -20,6 +22,7 @@ pub fn create_main_menu(keys: Arc<Mutex<RootKeys>>, status_conn: xous::CID, com:
|
||||||
close_on_select: true,
|
close_on_select: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
#[cfg(not(feature="tts"))]
|
||||||
menuitems.push(MenuItem {
|
menuitems.push(MenuItem {
|
||||||
name: String::from_str(t!("mainmenu.backlightoff", xous::LANG)),
|
name: String::from_str(t!("mainmenu.backlightoff", xous::LANG)),
|
||||||
action_conn: Some(com.conn()),
|
action_conn: Some(com.conn()),
|
||||||
|
|
@ -95,6 +98,7 @@ pub fn create_main_menu(keys: Arc<Mutex<RootKeys>>, status_conn: xous::CID, com:
|
||||||
close_on_select: true,
|
close_on_select: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
#[cfg(not(feature="tts"))]
|
||||||
menuitems.push(MenuItem {
|
menuitems.push(MenuItem {
|
||||||
name: String::from_str(t!("mainmenu.kbd", xous::LANG)),
|
name: String::from_str(t!("mainmenu.kbd", xous::LANG)),
|
||||||
action_conn: Some(status_conn),
|
action_conn: Some(status_conn),
|
||||||
|
|
|
||||||
|
|
@ -111,6 +111,7 @@ fn xmain() -> ! {
|
||||||
synth_done.store(false, Ordering::SeqCst);
|
synth_done.store(false, Ordering::SeqCst);
|
||||||
tts_be.tts_simple(msg.text.as_str().unwrap()).unwrap();
|
tts_be.tts_simple(msg.text.as_str().unwrap()).unwrap();
|
||||||
just_initiated = true;
|
just_initiated = true;
|
||||||
|
log::debug!("resuming codec");
|
||||||
codec.resume().unwrap();
|
codec.resume().unwrap();
|
||||||
},
|
},
|
||||||
Some(Opcode::CodecCb) => msg_scalar_unpack!(msg, free_play, _available_rec, _, routing_id, {
|
Some(Opcode::CodecCb) => msg_scalar_unpack!(msg, free_play, _available_rec, _, routing_id, {
|
||||||
|
|
@ -158,8 +159,6 @@ fn xmain() -> ! {
|
||||||
if (locked_buf.len() == 0) && synth_done.load(Ordering::SeqCst) {
|
if (locked_buf.len() == 0) && synth_done.load(Ordering::SeqCst) {
|
||||||
codec.pause().unwrap();
|
codec.pause().unwrap();
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
codec.pause().unwrap(); // this should stop callbacks from occurring too.
|
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
Some(Opcode::CodecStop) => {
|
Some(Opcode::CodecStop) => {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue