diff options
author | Leah Rowe <leah@libreboot.org> | 2023-06-05 02:05:36 +0100 |
---|---|---|
committer | Leah Rowe <leah@libreboot.org> | 2023-06-05 02:05:36 +0100 |
commit | 334bfedfd4917f6b76e5dac919698ac9bb213af1 (patch) | |
tree | fd4c897f3a046483da8d9fcc9b8c08ef30459c90 /util | |
parent | 4a6b5827779979873209f887cc5ee4b4f6e67936 (diff) |
util/spkmodem-recv: simplify sample_cnt/char reset
Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'util')
-rw-r--r-- | util/spkmodem_recv/spkmodem-recv.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/util/spkmodem_recv/spkmodem-recv.c b/util/spkmodem_recv/spkmodem-recv.c index 82ea5a63..bb73f999 100644 --- a/util/spkmodem_recv/spkmodem-recv.c +++ b/util/spkmodem_recv/spkmodem-recv.c @@ -20,6 +20,7 @@ #define THRESHOLD 500 #define ERR() (errno = errno ? errno : ECANCELED) +#define reset_char() ascii = 0, ascii_bit = 7 signed short frame[2 * SAMPLES_PER_FRAME], pulse[2 * SAMPLES_PER_FRAME]; int debug, freq_data, freq_separator, sample_count, ascii_bit = 7; @@ -56,10 +57,8 @@ main(int argc, char *argv[]) void handle_audio(void) { - if (sample_count > (3 * SAMPLES_PER_FRAME)) { - ascii_bit = 7; - ascii = sample_count = 0; - } + if (sample_count > (3 * SAMPLES_PER_FRAME)) + sample_count = reset_char(); if ((freq_separator <= FREQ_SEP_MIN) || (freq_separator >= FREQ_SEP_MAX) || (freq_data <= FREQ_DATA_MIN) || (freq_data >= FREQ_DATA_MAX)) { fetch_sample(); @@ -116,8 +115,7 @@ print_char(void) printf("<%c, %x>", ascii, ascii); else printf("%c", ascii); - ascii_bit = 7; - ascii = 0; + reset_char(); } void |