30 lines
773 B
Go
30 lines
773 B
Go
package mpd
|
|
|
|
import "github.com/BeatGlow/beatglow/config"
|
|
|
|
// SetAudioSource configures FIFO output monitoring before Events is called.
|
|
func (p *Player) SetAudioSource(source config.Audio) {
|
|
p.audioSource = source
|
|
}
|
|
|
|
func (p *Player) checkFIFOOutput(conn *clientConn) {
|
|
lines, err := p.sendDataCommand(conn, "outputs")
|
|
if err == nil {
|
|
err = fifoOutputState(parseOutputs(lines), p.audioSource.Output)
|
|
}
|
|
state := "enabled"
|
|
if err != nil {
|
|
state = err.Error()
|
|
}
|
|
if state == p.fifoState {
|
|
return
|
|
}
|
|
p.fifoState = state
|
|
log := conn.log().WithField("fifo", p.audioSource.Path).WithField("output", p.audioSource.Output)
|
|
if err != nil {
|
|
log.WithError(err).Warn("FIFO audio source may not receive samples")
|
|
} else {
|
|
log.Info("MPD FIFO output is enabled")
|
|
}
|
|
}
|