From 0b9199bc253215359bcaf253ba26f4683687b578 Mon Sep 17 00:00:00 2001 From: bunnie Date: Fri, 21 Apr 2023 13:43:50 +0800 Subject: [PATCH] fix regression due to #366 Boxing the `Codec` object and sticking it on the heap causes audio playback to hard-lock (no kp, no other explanation given). Not sure what the issue is, but a cleaner fix is arguably to simply increase the stack size so the objects can be allocated there. I suspect the problem may have to do with how the FIFO structures are memory-mapped and somehow this does not play nice with Box (there are `unsafe` routines within it). --- services/codec/src/main.rs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/services/codec/src/main.rs b/services/codec/src/main.rs index 818ab3be8..50f8e3e27 100644 --- a/services/codec/src/main.rs +++ b/services/codec/src/main.rs @@ -20,7 +20,17 @@ struct ScalarCallback { cb_to_client_id: u32, } -fn main() -> ! { +fn main () -> ! { + let stack_size = 256 * 1024; + std::thread::Builder::new() + .stack_size(stack_size) + .spawn(wrapped_main) + .unwrap() + .join() + .unwrap() +} + +fn wrapped_main() -> ! { log_server::init_wait().unwrap(); log::set_max_level(log::LevelFilter::Info); info!("my PID is {}", xous::process::id()); @@ -31,7 +41,7 @@ fn main() -> ! { log::trace!("registered with NS -- {:?}", codec_sid); let codec_conn = xous::connect(codec_sid).expect("couldn't make connection for the codec implementation"); - let mut codec = Box::new(Codec::new(codec_conn, &xns)); + let mut codec = Codec::new(codec_conn, &xns); let ticktimer = ticktimer_server::Ticktimer::new().unwrap(); log::trace!("ready to accept requests");