mirror of
https://github.com/nonoo/kappanhang.git
synced 2026-04-21 06:13:43 +00:00
Do not send silence frames to the radio
This commit is contained in:
parent
b86459b244
commit
4f3734957c
2 changed files with 16 additions and 0 deletions
|
|
@ -97,6 +97,10 @@ func (a *audioStruct) recLoop(deinitNeededChan, deinitFinishedChan chan bool) {
|
|||
}
|
||||
}
|
||||
|
||||
// Do not send silence frames to the radio unnecessarily
|
||||
if allZero(frameBuf[:n]) {
|
||||
continue
|
||||
}
|
||||
buf.Write(frameBuf[:n])
|
||||
|
||||
for buf.Len() >= len(frameBuf) {
|
||||
|
|
@ -167,6 +171,7 @@ func (a *audioStruct) init(devName string) error {
|
|||
a.sink.Rate = audioSampleRate
|
||||
a.sink.Format = "s16le"
|
||||
a.sink.Channels = 1
|
||||
a.sink.UseSystemClockForTiming = true
|
||||
a.sink.SetProperty("device.buffering.buffer_size", (audioSampleRate*16)/10)
|
||||
a.sink.SetProperty("device.description", "kappanhang: "+devName)
|
||||
|
||||
|
|
|
|||
11
util.go
Normal file
11
util.go
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
package main
|
||||
|
||||
// Checks if all bytes are zeros
|
||||
func allZero(s []byte) bool {
|
||||
for _, v := range s {
|
||||
if v != 0 {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue