[fix](trx-rs): fix FT4 7.5s slot rollover timing
Use millisecond-based slot indexing for FT4 decode windows in\nforeground and background decoders to avoid premature 7s resets.\n\nCo-authored-by: OpenAI Codex <codex@openai.com> Signed-off-by: Stanislaw Grams <stanislawgrams@gmail.com>
This commit is contained in:
@@ -1811,12 +1811,12 @@ pub async fn run_ft4_decoder(
|
|||||||
recv = pcm_rx.recv() => {
|
recv = pcm_rx.recv() => {
|
||||||
match recv {
|
match recv {
|
||||||
Ok(frame) => {
|
Ok(frame) => {
|
||||||
let now = match std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH) {
|
let now_ms = match std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH) {
|
||||||
Ok(dur) => dur.as_secs() as i64,
|
Ok(dur) => dur.as_millis() as i64,
|
||||||
Err(_) => 0,
|
Err(_) => 0,
|
||||||
};
|
};
|
||||||
// FT4 slot period is 7.5s; use now * 2 / 15 for integer slot index
|
// FT4 slot period is 7.5s
|
||||||
let slot = now * 2 / 15;
|
let slot = now_ms / 7_500;
|
||||||
if slot != last_slot {
|
if slot != last_slot {
|
||||||
last_slot = slot;
|
last_slot = slot;
|
||||||
decoder.reset();
|
decoder.reset();
|
||||||
@@ -2426,13 +2426,14 @@ async fn run_background_ft4_decoder(
|
|||||||
loop {
|
loop {
|
||||||
match pcm_rx.recv().await {
|
match pcm_rx.recv().await {
|
||||||
Ok(frame) => {
|
Ok(frame) => {
|
||||||
let now = match std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH)
|
let now_ms =
|
||||||
|
match std::time::SystemTime::now().duration_since(std::time::UNIX_EPOCH)
|
||||||
{
|
{
|
||||||
Ok(dur) => dur.as_secs() as i64,
|
Ok(dur) => dur.as_millis() as i64,
|
||||||
Err(_) => 0,
|
Err(_) => 0,
|
||||||
};
|
};
|
||||||
// FT4 slot period is 7.5s; use now * 2 / 15 for integer slot index
|
// FT4 slot period is 7.5s
|
||||||
let slot = now * 2 / 15;
|
let slot = now_ms / 7_500;
|
||||||
if slot != last_slot {
|
if slot != last_slot {
|
||||||
last_slot = slot;
|
last_slot = slot;
|
||||||
decoder.reset();
|
decoder.reset();
|
||||||
|
|||||||
Reference in New Issue
Block a user