From 5bb99f636ad194d76714d59499bf844755281f1c 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/spkmodem-decode.c') diff --git a/util/spkmodem_decode/spkmodem-decode.c b/util/spkmodem_decode/spkmodem-decode.c index 14ddee11..36b424b8 100644 --- a/util/spkmodem_decode/spkmodem-decode.c +++ b/util/spkmodem_decode/spkmodem-decode.c @@ -332,16 +332,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