mirror of
https://codeberg.org/libreboot/lbmk.git
synced 2026-07-17 18:34:57 +02:00
util/nvmutil: further clean up decode_pulse()
Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
@@ -113,27 +113,26 @@ static void
|
|||||||
decode_pulse(void)
|
decode_pulse(void)
|
||||||
{
|
{
|
||||||
size_t n;
|
size_t n;
|
||||||
size_t frame_size;
|
int next_ringpos;
|
||||||
|
|
||||||
int next_ringpos = (ringpos + SAMPLES_PER_FRAME) % MAX_SAMPLES;
|
next_ringpos = (ringpos + SAMPLES_PER_FRAME) % MAX_SAMPLES;
|
||||||
|
|
||||||
freq_data -= pulse[ringpos];
|
freq_data -= pulse[ringpos];
|
||||||
freq_data += pulse[next_ringpos];
|
freq_data += pulse[next_ringpos];
|
||||||
freq_separator -= pulse[next_ringpos];
|
freq_separator -= pulse[next_ringpos];
|
||||||
|
|
||||||
frame_size = sizeof(frame[0]);
|
n = fread(&frame[ringpos], 1, sizeof(frame[0]), stdin);
|
||||||
n = fread(&frame[ringpos], 1, frame_size, stdin);
|
if (n != sizeof(frame[0])) {
|
||||||
|
|
||||||
if (n != frame_size) {
|
|
||||||
if (feof(stdin))
|
if (feof(stdin))
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
if (ferror(stdin))
|
err(errno, "stdin read");
|
||||||
err(errno, "Could not read from frame.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pulse[ringpos] = (abs(frame[ringpos]) > THRESHOLD) ? 1 : 0;
|
pulse[ringpos] = (abs(frame[ringpos]) > THRESHOLD) ? 1 : 0;
|
||||||
freq_separator += pulse[ringpos++];
|
|
||||||
ringpos %= MAX_SAMPLES;
|
freq_separator += pulse[ringpos];
|
||||||
|
ringpos = (ringpos + 1) % MAX_SAMPLES;
|
||||||
|
|
||||||
++sample_count;
|
++sample_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user