From ed32f84f01476cdcbde9b3f70c56998cb76d34fc Mon Sep 17 00:00:00 2001 From: Alan Noble Date: Mon, 28 May 2018 15:36:28 +0930 Subject: [PATCH] Make wantPeriodSize a power of two to make BCM2835 happy. --- cmd/beep/main.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmd/beep/main.go b/cmd/beep/main.go index e80ec10..47ded64 100644 --- a/cmd/beep/main.go +++ b/cmd/beep/main.go @@ -87,7 +87,8 @@ func beepDevice(device *alsa.Device) error { // We adjust the buffer so it's of minimal size (period * 2) since it appear ALSA won't // start playback until the buffer has been filled to a certain degree and the automatic // buffer size can be quite large. - wantPeriodSize := 44100 / 20 + // Some devices only accept even periods while others want powers of 2. + wantPeriodSize := 2048 // 46ms @ 44100Hz periodSize, err := device.NegotiatePeriodSize(wantPeriodSize) if err != nil {