From 9d24b78340f49a2ee6a6c990128292914417e83b Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Fri, 13 Mar 2026 01:37:02 +0000 Subject: spkmodem-decode: fix wrong sample count in handle audio, i do the number of samples per frame, and one more. e.g. 241 instead of 240. this bug is in the original GNU version too. this patch fixes it. this means that the output could slowly go out of sync with calculated timings. the patch fixes that. in practise, the decoder is not that sensitive, and the code would adjust anyway (automatic timing adjustment), but ideally we want to not *cause* such issues even if we mitigate them. Signed-off-by: Leah Rowe --- util/spkmodem_decode/spkmodem-decode.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'util/spkmodem_decode') diff --git a/util/spkmodem_decode/spkmodem-decode.c b/util/spkmodem_decode/spkmodem-decode.c index e86939a2..04c8102f 100644 --- a/util/spkmodem_decode/spkmodem-decode.c +++ b/util/spkmodem_decode/spkmodem-decode.c @@ -336,16 +336,17 @@ handle_audio(struct decoder_state *st) if (st->sample_count >= (3 * SAMPLES_PER_FRAME)) reset_char(st); + st->sample_count = 0; + + /* process exactly one frame */ + for (sample = 0; sample < SAMPLES_PER_FRAME; sample++) + decode_pulse(st); + select_separator_tone(st); - decode_pulse(st); if (set_ascii_bit(st) < 0) print_char(st); - st->sample_count = 0; - for (sample = 0; sample < SAMPLES_PER_FRAME; sample++) - decode_pulse(st); - /* Detect tone per each frame */ detect_tone(st); } -- cgit v1.2.1