// Stream.Read reads data from the stream, // blocking until it has filled the provided slice. func (s *Stream) Read(data []byte) (int, error) { var err C.int written := C.pa_simple_read( s.simple, unsafe.Pointer(&data[0]), C.size_t(len(data)), &err, ) if err == C.PA_OK { return int(written), nil } return int(written), errorFromCode(err) }
// Read reads data from server. func (r *Reader) Read(data []byte) error { cdata := (*reflect.SliceHeader)(unsafe.Pointer(&data)) C.pa_simple_read( r.Conn.simple, unsafe.Pointer(cdata.Data), C.size_t(len(data)), &r.Conn.err.no, ) if r.Conn.err.no != C.int(0) { return r.Conn.err } return nil }