Skip to content

Commit

Permalink
Fix log spam in SRS receiver
Browse files Browse the repository at this point in the history
  • Loading branch information
dharmab committed Aug 31, 2024
1 parent 615da8b commit 259e9d9
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pkg/simpleradio/audio/receive.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,17 +128,17 @@ func (c *audioClient) receiveVoice(ctx context.Context, in <-chan []byte, out ch
c.updateLastRX(vp)
}
case <-t.C:
// Check if there is enough in the buffer and that we've consumed all queued packets. Then check if we've passed the receive deadline.
// Check if there anything the buffer and that we've consumed all queued packets. Then check if we've passed the receive deadline.
// If so, we have a tranmission ready to publish for audio decoding.
// 25 packets * 40ms = 1s which is the minimum whisper can transcribe anyway.
if len(in) == 0 && time.Now().After(c.lastRx.deadline) {
if len(buf) > 0 && len(in) == 0 && time.Now().After(c.lastRx.deadline) {
log.Trace().Int("bufferLength", len(buf)).Uint64("lastPacketID", c.lastRx.packetNumber).Str("lastOrigin", string(c.lastRx.origin)).Msg("passed receive deadline with packets in buffer")
// 25 packets * 40ms = 1s which is the minimum whisper can transcribe anyway.
if len(buf) > 25 {
audio := make([]voice.VoicePacket, len(buf))
copy(audio, buf)
out <- audio
} else {
log.Warn().Int("bufferLength", len(buf)).Msg("audio in buffer is too short to publish, discarding buffer")
log.Debug().Int("bufferLength", len(buf)).Msg("audio in buffer is too short to publish, discarding buffer")
}
// Reset receiver state
buf = make([]voice.VoicePacket, 0)
Expand Down

0 comments on commit 259e9d9

Please sign in to comment.