Skip to content

Commit 807e2fc

Browse files
committed
Fix weird coding errors I made.
1 parent 2afcdd1 commit 807e2fc

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

src/main.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,10 @@ typedef struct {
7272

7373
unsigned int program;
7474
unsigned int audio_ready;
75+
unsigned int audio_packets_valid;
7576
unsigned int audio_packets;
7677
unsigned int audio_bytes;
7778
unsigned int audio_errors;
78-
unsigned int audio_errors_valid;
7979
int done;
8080
} state_t;
8181

@@ -347,20 +347,20 @@ static void callback(const nrsc5_event_t *evt, void *opaque)
347347
st->audio_packets++;
348348
st->audio_bytes += evt->hdc.count * sizeof(evt->hdc.data[0]);
349349
if (evt->hdc.flags & NRSC5_PKT_FLAGS_CRC_ERROR)
350-
st->audio_errors_valid++;
351-
else
352350
st->audio_errors++;
351+
else
352+
st->audio_packets_valid;
353353

354-
if (st->audio_packets >= 32) {
355-
log_info("Audio bit rate: %.1f kbps", (float)st->audio_bytes * 8 * NRSC5_SAMPLE_RATE_AUDIO / NRSC5_AUDIO_FRAME_SAMPLES / st->audio_packets / 1000);
356-
st->audio_packets = 0;
354+
if (st->audio_packets_valid >= 32) {
355+
log_info("Audio bit rate: %.1f kbps", (float)st->audio_bytes * 8 * NRSC5_SAMPLE_RATE_AUDIO / NRSC5_AUDIO_FRAME_SAMPLES / st->audio_packets_valid / 1000);
356+
st->audio_packets_valid = 0;
357357
st->audio_bytes = 0;
358-
st->audio_errors_valid = 0;
359358
}
360-
if (st->audio_errors >= 32)
359+
if (st->audio_packets >= 32)
361360
{
362-
if (st->audio_errors_valid > 0)
363-
log_warn("Audio packet CRC mismatches: %d", st->audio_errors_valid);
361+
if (st->audio_errors > 0)
362+
log_warn("Audio packet CRC mismatches: %d", st->audio_errors);
363+
st->audio_packets = 0;
364364
st->audio_errors = 0;
365365
}
366366
}

support/cli.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,11 +238,11 @@ def callback(self, evt_type, evt):
238238
/ nrsc5.AUDIO_FRAME_SAMPLES / self.audio_packets_valid / 1000)
239239
self.audio_packets_valid = 0
240240
self.audio_bytes = 0
241-
self.audio_errors = 0
242241
if self.audio_packets >= 32:
243242
if self.audio_errors > 0:
244243
logging.warning("Audio packet CRC mismatches: %d", self.audio_errors)
245244
self.audio_packets = 0
245+
self.audio_errors = 0
246246
elif evt_type == nrsc5.EventType.AUDIO:
247247
if evt.program == self.args.program:
248248
if self.args.o:

0 commit comments

Comments
 (0)