diff --git a/codec/codecutil/list.go b/codec/codecutil/list.go index ecba3659..c270eb6b 100644 --- a/codec/codecutil/list.go +++ b/codec/codecutil/list.go @@ -24,8 +24,6 @@ LICENSE package codecutil -import "fmt" - // numCodecs is the number of entries in the list of codecs. const numCodecs = 5 @@ -39,10 +37,7 @@ const ( MJPEG ) -// Validate recieves an int representing a codec and checks if it is valid. -func Validate(codec uint8) error { - if codec < 0 || codec >= numCodecs { - return fmt.Errorf("invalid codec") - } - return nil +// IsValid recieves an int representing a codec and checks if it is valid. +func IsValid(codec uint8) bool { + return 0 <= codec && codec < numCodecs } diff --git a/container/mts/encoder_test.go b/container/mts/encoder_test.go index 4443e8e8..1a1d20d7 100644 --- a/container/mts/encoder_test.go +++ b/container/mts/encoder_test.go @@ -197,7 +197,7 @@ func TestEncodePcm(t *testing.T) { for i+PacketSize <= len(clip) { // Check MTS packet - if !(pkt.PID() == AudioPid) { + if pkt.PID() != AudioPid { i += PacketSize if i+PacketSize <= len(clip) { copy(pkt[:], clip[i:i+PacketSize]) diff --git a/input/audio/audio.go b/input/audio/audio.go index 745b71fe..0f03a20e 100644 --- a/input/audio/audio.go +++ b/input/audio/audio.go @@ -94,7 +94,10 @@ type OpenError error // NewDevice initializes and returns an Device which can be started, read from, and stopped. func NewDevice(cfg *Config, l Logger) (*Device, error) { - validate(cfg) + err := validate(cfg) + if err != nil { + return nil, err + } d := &Device{ Config: cfg, @@ -102,7 +105,7 @@ func NewDevice(cfg *Config, l Logger) (*Device, error) { } // Open the requested audio device. - err := d.open() + err = d.open() if err != nil { d.l.Log(logger.Error, pkg+"failed to open device") return nil, err