// PCMBuffer populates the passed PCM buffer
175097
func (d *Decoder) PCMBuffer(buf *audio.PCMBuffer) error {
	if buf == nil {
		return nil
	}

	if !d.pcmDataAccessed {
		if d.Debug {
			fmt.Println("forwarding to PCM Data")
		}
		err := d.FwdToPCM()
		if err != nil {
			return d.err
		}
	}

	// TODO: avoid a potentially unecessary allocation
	format := &audio.Format{
		NumChannels: int(d.NumChans),
		SampleRate:  int(d.SampleRate),
		BitDepth:    int(d.BitDepth),
		Endianness:  binary.LittleEndian,
	}

	decodeF, err := sampleDecodeFunc(int(d.BitDepth))
	if err != nil {
		return fmt.Errorf("could not get sample decode func %v", err)
	}

	// Note that we populate the buffer even if the
	// size of the buffer doesn't fit an even number of frames.
	if d.Debug {
		fmt.Println("populating %d samples", len(buf.Ints))
	}
	for i := 0; i < len(buf.Ints); i++ {
		buf.Ints[i], err = decodeF(d.r)
		if err != nil {
			break
		}
	}
	if err == io.EOF {
		err = nil
	}
	buf.Format = format
	if buf.DataType != audio.Integer {
		buf.DataType = audio.Integer
	}

	return err
}
1150490
func (key *Key) GetPubKeyBlob() (pubkey []byte, err error) {
	var dataLen C.UINT32
	var cData *C.BYTE
	err = tspiError(C.Tspi_GetAttribData((C.TSS_HOBJECT)(key.handle), C.TSS_TSPATTRIB_KEY_BLOB, C.TSS_TSPATTRIB_KEYBLOB_PUBLIC_KEY, &dataLen, &cData))
	data := C.GoBytes(unsafe.Pointer(cData), (C.int)(dataLen))
	C.Tspi_Context_FreeMemory(key.context, cData)
	return data, err
}
766679
func (soc *Socket) SetVmciBufferMinSize(value uint64) error {
	if minor < 2 {
		return ErrorNotImplemented42
	}
	return soc.setUInt64(C.ZMQ_VMCI_BUFFER_MIN_SIZE, value)
}
1166893
func (connection *Connection) getInjectBuf(reply bool) InjectBuf {
	if reply {
		return connection.ReplyBuf
	}
	return connection.OrigBuf
}
342558
func NewPixbufFromData(pbd PixbufData) *Pixbuf {
	gpixbuf := C.gdk_pixbuf_new_from_data(
		C.to_gucharptr(unsafe.Pointer(&pbd.Data[0])),
		C.GdkColorspace(pbd.Colorspace),
		gbool(pbd.HasAlpha),
		C.int(pbd.BitsPerSample),
		C.int(pbd.Width),
		C.int(pbd.Height),
		C.int(pbd.RowStride),
		nil, nil)
	return &Pixbuf{
		GdkPixbuf: &GdkPixbuf{gpixbuf},
		GObject:   glib.ObjectFromNative(unsafe.Pointer(gpixbuf)),
	}
}
939136
func (soc *Socket) SetVmciBufferSize(value uint64) error {
	if minor < 2 {
		return ErrorNotImplemented42
	}
	return soc.setUInt64(C.ZMQ_VMCI_BUFFER_SIZE, value)
}
703020
func copyBuf(w io.Writer, r io.Reader) (int64, error) {
	buf := buffer32KPool.Get().([]byte)
	written, err := io.CopyBuffer(w, r, buf)
	buffer32KPool.Put(buf)
	return written, err
}
1064423
func (b *PCMBuffer) AsFloatBuffer() *FloatBuffer {
	newB := &FloatBuffer{}
	newB.Data = b.AsF64()
	if b.Format != nil {
		newB.Format = &Format{
			NumChannels: b.Format.NumChannels,
			SampleRate:  b.Format.SampleRate,
		}
	}
	return newB
}
1036047
func newReadBuffer(path string, num int32, c *Client) *Buffer {
	buffers.RLock()
	// return the existing buffer if there is one
	if existing, exists := buffers.m[path]; exists {
		buffers.RUnlock()
		return existing
	}
	buffers.RUnlock()

	// make a new one
	b := &Buffer{Num: num, client: c}

	// add it to the global map
	buffers.Lock()
	buffers.m[path] = b
	buffers.Unlock()

	return b
}
747229
func GnuplotText(buf *audio.PCMBuffer, path string) error {
	if buf == nil || buf.Format == nil {
		return audio.ErrInvalidBuffer
	}
	out, err := os.Create(path)
	if err != nil {
		return err
	}
	defer out.Close()
	if _, err = out.WriteString("#"); err != nil {
		return err
	}
	for i := 0; i < buf.Format.NumChannels; i++ {
		if _, err = out.WriteString(fmt.Sprintf("%d\t", i+1)); err != nil {
			return err
		}
	}
	if _, err = out.WriteString("\n"); err != nil {
		return err
	}

	buf.SwitchPrimaryType(audio.Float)
	for i := 0; i < buf.Size(); i++ {
		for j := 0; j < buf.Format.NumChannels; j++ {
			out.WriteString(fmt.Sprintf("%f\t", buf.Floats[i*buf.Format.NumChannels+j]))
		}
		out.WriteString("\n")
	}
	return err
}
195439
func (c *conn) SetReadBuffer(bytes int) error {
	return os.NewSyscallError("setsockopt", c.s.SetSockoptInt(
		unix.SOL_SOCKET,
		unix.SO_RCVBUF,
		bytes,
	))
}
1286407
func (b *PCMBuffer) AsInt16s() (out []int16) {
	if b == nil {
		return nil
	}
	switch b.DataType {
	case Integer, Float:
		out = make([]int16, len(b.Ints))
		for i := 0; i < len(b.Ints); i++ {
			out[i] = int16(b.Ints[i])
		}
	case Byte:
		// if the format isn't defined, we can't read the byte data
		if b.Format == nil || b.Format.Endianness == nil || b.Format.BitDepth == 0 {
			return out
		}
		bytesPerSample := int((b.Format.BitDepth-1)/8 + 1)
		buf := bytes.NewBuffer(b.Bytes)
		out := make([]int16, len(b.Bytes)/bytesPerSample)
		binary.Read(buf, b.Format.Endianness, &out)
	}
	return out
}
1229818
func (cvt *AudioCVT) AllocBuf(size uintptr) {
	cvt.Buf = C.malloc(C.size_t(size))
}
1345966
func (s *Stack) GetTCPProbe() TCPProbeFunc {
	s.mu.Lock()
	p := s.tcpProbeFunc
	s.mu.Unlock()
	return p
}
678348
func NewBufReaderWithDrainbufAndBuffer(r io.Reader, drainBuffer []byte, buffer *bytes.Buffer) io.ReadCloser {
	reader := &bufReader{
		buf:      buffer,
		drainBuf: drainBuffer,
		reader:   r,
	}
	reader.wait.L = &reader.Mutex
	go reader.drain()
	return reader
}
1246720
func (bf *BufferFactory) ReturnBuffer(buf *bytes.Buffer) {
	bf.Return(buf.Bytes())
}
1128147
func (obj *Doc) ClearUndoBuffer(ctx context.Context) error {
	err := obj.rpc(ctx, "ClearUndoBuffer", nil)
	return err 
}