Do not initialize speaker when streaming to fd
This commit is contained in:
parent
6c70ef3ffb
commit
df10c1312c
1 changed files with 9 additions and 7 deletions
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…
Reference in a new issue