// Poll reports whether there is input available in the stream. func (s *Stream) Poll() (bool, error) { poll := C.Pm_Poll(unsafe.Pointer(s.pmStream)) if poll < 0 { return false, convertToError(C.PmError(poll)) } return poll > 0, nil }
func (s SystemPort) poll() (bool, error) { if s.IsInputPort == true { return false, errors.New("Can't poll from an input port, " + "only output ports.") } if s.stream == nil { return false, errors.New("No input stream set on this SystemPort.") } if s.IsOpen() == false { return false, errors.New("SystemPort is not open.") } dataAvailable, err := C.Pm_Poll(s.stream) if err != nil { return false, err // Tried to read data, failed. } if dataAvailable > 0 { return true, nil // Data available. } return false, nil // No data available. }