Conversation
|
Some thoughts on logging:
|
|
Thanks for the feedback. I will update based on this feedback.
Oopsy. I didn't do that on purpose!
That's a good idea. I've already seen the CLI get spammed very quickly.
I can always remove it. I only included it to bring back the original behavior since "ignoring partial pdu" used to be logged. I cannot think of any other reason to include it. |
I suspect the old "ignoring partial pdu" message (removed in #427) was just there to help with debugging during the initial development of nrsc5. I didn't ever need it for anything myself, even while debugging. After thinking about it some more, I don't think it's worth including the |
Do you mean to still include |
|
The latter. I don't see a need to report anything other than CRC errors. |
…-buffer. This doesn't report half packets, and doesn't save corrupted packets.
cfe1b7c to
4b6b003
Compare
|
Okay, I removed reporting half packets. This also now doesn't save packets with crc errors since there is no point to keep them in elastic-buffer. I also squashed commits to make looking at the changes a lot easier. |
|
Thanks. I'll do a bit more testing and a final code review, but it may not be until Monday. |
|
Okay I updated changes based on your feedback. Apoglizes if you saw my comments posted twice. The Github mobile app is sending my comments twice for some reason. |
|
One last issue I just noticed: the presence of zero-length HDC packets pushes down the calculated audio bit rate: I'll have to think about how best to handle that. |
|
Maybe we should change the bit rate calculation to count & average valid packets only (which would match the previous behaviour), and aggregate CRC mismatches separately. |
|
Or do we take this as a sign that zero-length packets are a potentially disruptive API change and report CRC errors in a new event type instead? |
|
To be honest, I'm not too worried about this particular API change being disruptive. We can always number the next release 4.0.0 so it's clear there's an API change that clients need to be mindful of. |
Oh crap, you are right. I think if you wanted to report NRSC5_EVENT_HDC and NRSC5_EVENT_AUDIO packet-for-packet so that the audio stream could be exactly recovered from the HDC stream if desire, I think this should be dealt with instead of creating a new event for crcs. |
|
Yeah, keeping information about the HDC stream in one place seems like the way to go. We could make a new HDC2 event and deprecate the old one, but that seems like overkill for an event type that's probably not used for much (yet). |
|
Should I add a check to only add to audio_bytes if its a valid packet? |
|
Another behaviour change in the API clients is that |
Hmm, that change wouldn't do anything since not adding zero is the same as adding zero. 😄 We'd also need to skip incrementing |
Oh, right! 😄. I was asking without looking at the code. I am not sure if adding another field for counting audio packets specifically for crc errors would be a good idea. It may be printed in the console at a different rate if that's the case. |
|
Actually, no. Ignore what I am saying. This would be fine actually. |
|
Is something like this fine? To count valid packets and all audio_packets?? elif evt_type == nrsc5.EventType.HDC:
if evt.program == self.args.program:
if self.args.dump_hdc:
self.hdc_output.write(self.adts_header(len(evt.data)))
self.hdc_output.write(evt.data)
self.audio_packets += 1
self.audio_bytes += len(evt.data)
if evt.flags & nrsc5.PacketFlags.CRC_ERROR:
self.audio_errors += 1
else:
self.audio_packets_valid += 1
if self.audio_packets_valid >= 32:
logging.info("Audio bit rate: %.1f kbps", self.audio_bytes * 8 * nrsc5.SAMPLE_RATE_AUDIO
/ nrsc5.AUDIO_FRAME_SAMPLES / self.audio_packets_valid / 1000)
self.audio_packets_valid = 0
self.audio_bytes = 0
self.audio_errors = 0
if self.audio_packets >= 32:
if self.audio_errors > 0:
logging.warning("Audio packet CRC mismatches: %d", self.audio_errors)
self.audio_packets = 0 |
|
Yeah, I think that would work. I don't think it's a big deal if CRC errors are reported at a different cadence as the audio bit rate. |
|
Alright, I have made the changes separating regular packets and full packets (?) if thats how it should be called? |
|
The updated code doesn't seem to work properly: |
|
Looking better, I'm now seeing the expected output from both clients. |
807e2fc to
4af1695
Compare
|
I am so glad you do testing. Thanks for checking. I do this thing where I only test on either the python cli or the c client. 😄 I rebased and squashed two commits trying to fix it. Should work now. |
|
Yep, all is looking good and I'm seeing the same audio bit rates as before. I'll get this merged once CI is happy. |
|
Thank you! |
|
Nice, this has eliminated almost 90% of the lines logged by libnrsc5 while playing back my library of recordings! |
|
WOW! That's a lot of logging! |
This is my implementation of providing CRC errors in the API.
I moved the logic for partial packets into the elastic buffer. This is to hopefully reduce code complexity. Elastic buffer is basically another packet store.
I also made a packet_ref_t to hopefully reduce argument calls when pushing packets into the elastic buffer.