func AddSource(in snd.Sound) error { switch in.Channels() { case 1: hwa.format = al.FormatMono16 case 2: hwa.format = al.FormatStereo16 default: return fmt.Errorf("snd/al: can't handle input with channels(%v)", in.Channels()) } hwa.in = in hwa.out = make([]byte, in.BufferLen()*2) s := al.GenSources(1) if code := al.Error(); code != 0 { return fmt.Errorf("snd/al: generate source failed [err=%v]", code) } hwa.source = s[0] hwa.buf.src = s[0] log.Println("snd/al: software latency", SoftLatency()) hwa.inputs = snd.GetInputs(in) return nil }
func Notify() { if hwa.in != nil { hwa.inputs = snd.GetInputs(hwa.in) } }