Do not initialize speaker when streaming to fd

This commit is contained in:
Trevor Slocum 2020-01-23 09:44:04 -08:00
parent 6c70ef3ffb
commit df10c1312c

View file

@ -111,14 +111,16 @@ func play(audioFile *audioFile) {
}
}
if audioFile.Format.SampleRate != playingSampleRate {
err := speaker.Init(audioFile.Format.SampleRate, audioFile.Format.SampleRate.N(bufferSize))
if err != nil {
log.Fatalf("failed to initialize audio device: %s", err)
if streamFdInt == -1 {
if audioFile.Format.SampleRate != playingSampleRate {
err := speaker.Init(audioFile.Format.SampleRate, audioFile.Format.SampleRate.N(bufferSize))
if err != nil {
log.Fatalf("failed to initialize audio device: %s", err)
}
playingSampleRate = audioFile.Format.SampleRate
} else {
speaker.Clear()
}
playingSampleRate = audioFile.Format.SampleRate
} else {
speaker.Clear()
}
streamer := beep.Seq(audioFile.Streamer, beep.Callback(func() {