From f2822db9dd1e7787fe4209f5795d9595d435fecf Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Mon, 5 Jun 2023 15:38:36 +0100 Subject: util/spkmodem-recv: make ringpos a global variable there's no point passing it as argument to a function. it's used across more than one function, so make it global Signed-off-by: Leah Rowe --- util/spkmodem_recv/spkmodem-recv.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'util') diff --git a/util/spkmodem_recv/spkmodem-recv.c b/util/spkmodem_recv/spkmodem-recv.c index bb73f999..923694e8 100644 --- a/util/spkmodem_recv/spkmodem-recv.c +++ b/util/spkmodem_recv/spkmodem-recv.c @@ -23,12 +23,12 @@ #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; +int ringpos, debug, freq_data, freq_separator, sample_count, ascii_bit = 7; char ascii = 0; void handle_audio(void); void fetch_sample(void); -void read_frame(int ringpos); +void read_frame(void); int set_ascii_bit(void); void print_char(void); void print_stats(void); @@ -75,14 +75,13 @@ handle_audio(void) void fetch_sample(void) { - static int ringpos = 0; freq_data -= pulse[ringpos]; freq_data += pulse[(ringpos + SAMPLES_PER_FRAME) % (2 * SAMPLES_PER_FRAME)]; freq_separator -= pulse[(ringpos + SAMPLES_PER_FRAME) % (2 * SAMPLES_PER_FRAME)]; - read_frame(ringpos); + read_frame(); if ((pulse[ringpos] = (abs(frame[ringpos]) > THRESHOLD) ? 1 : 0)) ++freq_separator; ++ringpos; @@ -91,7 +90,7 @@ fetch_sample(void) } void -read_frame(int ringpos) +read_frame(void) { if ((fread(frame + ringpos, 1, sizeof(frame[0]), stdin) != sizeof(frame[0])) || (ferror(stdin) != 0)) -- cgit v1.2.1