util/spkmodem-recv: simplify sample_cnt/char reset

Signed-off-by: Leah Rowe <leah@libreboot.org>
fsdg20230625
Leah Rowe 2023-06-05 02:05:36 +01:00
parent 4a6b582777
commit 334bfedfd4
1 changed files with 4 additions and 6 deletions

View File

@ -20,6 +20,7 @@
#define THRESHOLD 500 #define THRESHOLD 500
#define ERR() (errno = errno ? errno : ECANCELED) #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]; signed short frame[2 * SAMPLES_PER_FRAME], pulse[2 * SAMPLES_PER_FRAME];
int debug, freq_data, freq_separator, sample_count, ascii_bit = 7; int debug, freq_data, freq_separator, sample_count, ascii_bit = 7;
@ -56,10 +57,8 @@ main(int argc, char *argv[])
void void
handle_audio(void) handle_audio(void)
{ {
if (sample_count > (3 * SAMPLES_PER_FRAME)) { if (sample_count > (3 * SAMPLES_PER_FRAME))
ascii_bit = 7; sample_count = reset_char();
ascii = sample_count = 0;
}
if ((freq_separator <= FREQ_SEP_MIN) || (freq_separator >= FREQ_SEP_MAX) if ((freq_separator <= FREQ_SEP_MIN) || (freq_separator >= FREQ_SEP_MAX)
|| (freq_data <= FREQ_DATA_MIN) || (freq_data >= FREQ_DATA_MAX)) { || (freq_data <= FREQ_DATA_MIN) || (freq_data >= FREQ_DATA_MAX)) {
fetch_sample(); fetch_sample();
@ -116,8 +115,7 @@ print_char(void)
printf("<%c, %x>", ascii, ascii); printf("<%c, %x>", ascii, ascii);
else else
printf("%c", ascii); printf("%c", ascii);
ascii_bit = 7; reset_char();
ascii = 0;
} }
void void