Browse Source

Do not initialize speaker when streaming to fd

master
Trevor Slocum 3 years ago
parent
commit
df10c1312c
  1. 16
      audio.go

16
audio.go

@ -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() {

Loading…
Cancel
Save