audio-netsender: fixed type and netsender errors

This commit is contained in:
Trek H 2019-09-14 19:24:47 +09:30
parent 3bd3e52371
commit 83a425ce2b
1 changed files with 6 additions and 6 deletions

View File

@ -386,7 +386,7 @@ func (ac *audioClient) output() {
reported := time.Now() // When we last did so. reported := time.Now() // When we last did so.
for { for {
var rc int var rc bool
start := time.Now() start := time.Now()
audio := false audio := false
var pins []netsender.Pin var pins []netsender.Pin
@ -447,8 +447,8 @@ func (ac *audioClient) output() {
reported = start reported = start
report = false report = false
} }
if rc == netsender.ResponseUpdate { if rc {
_, err = ac.ns.Config() err = ac.ns.Config()
if err != nil { if err != nil {
log.Log(logger.Warning, "netsender.Config failed", "error", err.Error()) log.Log(logger.Warning, "netsender.Config failed", "error", err.Error())
goto sleep goto sleep
@ -529,7 +529,7 @@ func (ac *audioClient) formatBuffer() alsa.Buffer {
// Convert channels. // Convert channels.
if ac.ab.Format.Channels == 2 && wantChannels == 1 { if ac.ab.Format.Channels == 2 && wantChannels == 1 {
if formatted.Data, err = pcm.StereoToMono(ac.ab); err != nil { if formatted, err = pcm.StereoToMono(ac.ab); err != nil {
log.Log(logger.Warning, "channel conversion failed, audio has remained stereo", "error", err.Error()) log.Log(logger.Warning, "channel conversion failed, audio has remained stereo", "error", err.Error())
} else { } else {
formatted.Format.Channels = 1 formatted.Format.Channels = 1
@ -542,9 +542,9 @@ func (ac *audioClient) formatBuffer() alsa.Buffer {
// Convert rate. // Convert rate.
if bufCopied { if bufCopied {
formatted.Data, err = pcm.Resample(formatted, wantRate) formatted, err = pcm.Resample(formatted, wantRate)
} else { } else {
formatted.Data, err = pcm.Resample(ac.ab, wantRate) formatted, err = pcm.Resample(ac.ab, wantRate)
} }
if err != nil { if err != nil {
log.Log(logger.Warning, "rate conversion failed, audio has remained original rate", "error", err.Error()) log.Log(logger.Warning, "rate conversion failed, audio has remained original rate", "error", err.Error())