mirror of
https://github.com/nonoo/kappanhang.git
synced 2026-01-20 23:50:29 +01:00
Report audio monitor status on the status bar
This commit is contained in:
parent
e1ef8cd31f
commit
c1ded2e3a2
|
|
@ -52,11 +52,13 @@ func (a *audioStruct) defaultSoundCardStreamDeinit() {
|
|||
func (a *audioStruct) togglePlaybackToDefaultSoundcard() {
|
||||
if a.defaultSoundCardStream == nil {
|
||||
log.Print("turned on audio playback")
|
||||
statusLog.reportAudioMon(true)
|
||||
ss := pulse.SampleSpec{Format: pulse.SAMPLE_S16LE, Rate: 48000, Channels: 1}
|
||||
a.defaultSoundCardStream, _ = pulse.Playback("kappanhang", a.devName, &ss)
|
||||
} else {
|
||||
a.defaultSoundCardStreamDeinit()
|
||||
log.Print("turned off audio playback")
|
||||
statusLog.reportAudioMon(false)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
36
statuslog.go
36
statuslog.go
|
|
@ -20,8 +20,9 @@ type statusLogData struct {
|
|||
filter string
|
||||
txPowerStr string
|
||||
|
||||
startTime time.Time
|
||||
rttStr string
|
||||
startTime time.Time
|
||||
rttStr string
|
||||
audioMonStr string
|
||||
}
|
||||
|
||||
type statusLogStruct struct {
|
||||
|
|
@ -40,6 +41,10 @@ type statusLogStruct struct {
|
|||
tx string
|
||||
tune string
|
||||
}
|
||||
audioMon struct {
|
||||
on string
|
||||
off string
|
||||
}
|
||||
}
|
||||
|
||||
data *statusLogData
|
||||
|
|
@ -57,6 +62,20 @@ func (s *statusLogStruct) reportRTTLatency(l time.Duration) {
|
|||
s.data.rttStr = fmt.Sprint(l.Milliseconds())
|
||||
}
|
||||
|
||||
func (s *statusLogStruct) reportAudioMon(enabled bool) {
|
||||
s.mutex.Lock()
|
||||
defer s.mutex.Unlock()
|
||||
|
||||
if s.data == nil {
|
||||
return
|
||||
}
|
||||
if enabled {
|
||||
s.data.audioMonStr = s.preGenerated.audioMon.on
|
||||
} else {
|
||||
s.data.audioMonStr = s.preGenerated.audioMon.off
|
||||
}
|
||||
}
|
||||
|
||||
func (s *statusLogStruct) reportFrequency(f float64) {
|
||||
s.mutex.Lock()
|
||||
defer s.mutex.Unlock()
|
||||
|
|
@ -149,7 +168,7 @@ func (s *statusLogStruct) update() {
|
|||
txPowerStr = " txpwr " + s.data.txPowerStr
|
||||
}
|
||||
s.data.line1 = fmt.Sprint("state ", s.data.stateStr, " freq: ", fmt.Sprintf("%f", s.data.frequency/1000000),
|
||||
modeStr, filterStr, txPowerStr)
|
||||
modeStr, filterStr, txPowerStr, " audiomon ", s.data.audioMonStr)
|
||||
|
||||
up, down, lost, retransmits := netstat.get()
|
||||
lostStr := "0"
|
||||
|
|
@ -211,9 +230,10 @@ func (s *statusLogStruct) startPeriodicPrint() {
|
|||
s.initIfNeeded()
|
||||
|
||||
s.data = &statusLogData{
|
||||
stateStr: s.preGenerated.stateStr.unknown,
|
||||
startTime: time.Now(),
|
||||
rttStr: "?",
|
||||
stateStr: s.preGenerated.stateStr.unknown,
|
||||
startTime: time.Now(),
|
||||
rttStr: "?",
|
||||
audioMonStr: s.preGenerated.audioMon.off,
|
||||
}
|
||||
|
||||
s.stopChan = make(chan bool)
|
||||
|
|
@ -252,9 +272,13 @@ func (s *statusLogStruct) initIfNeeded() {
|
|||
c := color.New(color.FgHiWhite)
|
||||
c.Add(color.BgWhite)
|
||||
s.preGenerated.stateStr.unknown = c.Sprint(" ?? ")
|
||||
s.preGenerated.audioMon.off = c.Sprint(" OFF ")
|
||||
|
||||
c = color.New(color.FgHiWhite)
|
||||
c.Add(color.BgGreen)
|
||||
s.preGenerated.stateStr.rx = c.Sprint(" RX ")
|
||||
s.preGenerated.audioMon.on = c.Sprint(" ON ")
|
||||
|
||||
c = color.New(color.FgHiWhite, color.BlinkRapid)
|
||||
c.Add(color.BgRed)
|
||||
s.preGenerated.stateStr.tx = c.Sprint(" TX ")
|
||||
|
|
|
|||
Loading…
Reference in a new issue