Merged master into looper-systemd

This commit is contained in:
Saxon Milton 2020-12-19 03:16:22 +00:00
commit e56b6507f7
12 changed files with 27 additions and 27 deletions

View File

@ -3,7 +3,7 @@ jobs:
build: build:
docker: docker:
# CircleCI Go images available at: https://hub.docker.com/r/circleci/golang/ # CircleCI Go images available at: https://hub.docker.com/r/circleci/golang/
- image: circleci/golang:1.13 - image: circleci/golang:1.15.2
environment: environment:
GO111MODULE: "on" GO111MODULE: "on"

View File

@ -127,12 +127,12 @@ func TestIsRunning(t *testing.T) {
InputCodec: codecutil.ADPCM, InputCodec: codecutil.ADPCM,
}) })
if err != nil { if err != nil {
t.Skipf("could not set device: %w", err) t.Skipf("could not set device: %v", err)
} }
err = d.Start() err = d.Start()
if err != nil { if err != nil {
t.Fatalf("could not start device %w", err) t.Fatalf("could not start device %v", err)
} }
time.Sleep(dur) time.Sleep(dur)

View File

@ -41,12 +41,12 @@ func TestIsRunning(t *testing.T) {
InputPath: path, InputPath: path,
}) })
if err != nil { if err != nil {
t.Skipf("could not set device: %w", err) t.Skipf("could not set device: %v", err)
} }
err = d.Start() err = d.Start()
if err != nil { if err != nil {
t.Fatalf("could not start device %w", err) t.Fatalf("could not start device %v", err)
} }
time.Sleep(dur) time.Sleep(dur)

View File

@ -153,13 +153,13 @@ func TestCodecOut(t *testing.T) {
}, },
{ {
s: settings{ch: 1}, s: settings{ch: 1},
c: Codec(500), c: Codec("500"),
want: settings{ch: 1}, want: settings{ch: 1},
err: true, err: true,
}, },
{ {
s: settings{ch: 2}, s: settings{ch: 2},
c: Codec(500), c: Codec("500"),
want: settings{ch: 2}, want: settings{ch: 2},
err: true, err: true,
}, },

View File

@ -47,12 +47,12 @@ func TestIsRunning(t *testing.T) {
CameraIP: ip, CameraIP: ip,
}) })
if err != nil { if err != nil {
t.Skipf("could not set device: %w", err) t.Skipf("could not set device: %v", err)
} }
err = d.Start() err = d.Start()
if err != nil { if err != nil {
t.Fatalf("could not start device %w", err) t.Fatalf("could not start device %v", err)
} }
time.Sleep(dur) time.Sleep(dur)

View File

@ -45,12 +45,12 @@ func TestIsRunning(t *testing.T) {
InputCodec: codecutil.H264, InputCodec: codecutil.H264,
}) })
if err != nil { if err != nil {
t.Skipf("could not set device: %w", err) t.Skipf("could not set device: %v", err)
} }
err = d.Start() err = d.Start()
if err != nil { if err != nil {
t.Fatalf("could not start device %w", err) t.Fatalf("could not start device %v", err)
} }
time.Sleep(dur) time.Sleep(dur)

View File

@ -45,12 +45,12 @@ func TestIsRunning(t *testing.T) {
InputCodec: codecutil.H264, InputCodec: codecutil.H264,
}) })
if err != nil { if err != nil {
t.Skipf("could not set device: %w", err) t.Skipf("could not set device: %v", err)
} }
err = d.Start() err = d.Start()
if err != nil { if err != nil {
t.Fatalf("could not start device %w", err) t.Fatalf("could not start device %v", err)
} }
time.Sleep(dur) time.Sleep(dur)

View File

@ -129,16 +129,16 @@ func main() {
case *configPtr != "": // Decode JSON file to map. case *configPtr != "": // Decode JSON file to map.
err = json.Unmarshal([]byte(*configPtr), &cfg) err = json.Unmarshal([]byte(*configPtr), &cfg)
if err != nil { if err != nil {
panic(fmt.Sprintf("could not decode JSON config: %w", err)) panic(fmt.Sprintf("could not decode JSON config: %v", err))
} }
case *configFilePtr != "": // Decode JSON string to map from command line flag. case *configFilePtr != "": // Decode JSON string to map from command line flag.
f, err := os.Open(*configFilePtr) f, err := os.Open(*configFilePtr)
if err != nil { if err != nil {
panic(fmt.Sprintf("could not open config file: %w", err)) panic(fmt.Sprintf("could not open config file: %v", err))
} }
err = json.NewDecoder(f).Decode(&cfg) err = json.NewDecoder(f).Decode(&cfg)
if err != nil { if err != nil {
panic(fmt.Sprintf("could not decode JSON config: %w", err)) panic(fmt.Sprintf("could not decode JSON config: %v", err))
} }
default: // No config information has been provided; give empty map to force defaults. default: // No config information has been provided; give empty map to force defaults.
cfg = map[string]string{} cfg = map[string]string{}
@ -167,19 +167,19 @@ func main() {
rv, err := revid.New(config.Config{Logger: log}, ns) rv, err := revid.New(config.Config{Logger: log}, ns)
if err != nil { if err != nil {
panic(fmt.Sprintf("could not create revid: %w", err)) panic(fmt.Sprintf("could not create revid: %v", err))
} }
// Configure revid with configuration map obtained through flags or file. // Configure revid with configuration map obtained through flags or file.
// If config is empty, defaults will be adopted by revid. // If config is empty, defaults will be adopted by revid.
err = rv.Update(cfg) err = rv.Update(cfg)
if err != nil { if err != nil {
panic(fmt.Sprintf("could not update revid config: %w", err)) panic(fmt.Sprintf("could not update revid config: %v", err))
} }
err = rv.Start() err = rv.Start()
if err != nil { if err != nil {
panic(fmt.Sprintf("could not start revid: %w", err)) panic(fmt.Sprintf("could not start revid: %v", err))
} }
// Run indefinitely. // Run indefinitely.

View File

@ -81,7 +81,7 @@ type Object struct {
// Number, string types use String and arrays and objects use // Number, string types use String and arrays and objects use
// Object. The Name is optional. // Object. The Name is optional.
type Property struct { type Property struct {
Type uint8 Type uint8
Name string Name string
Number float64 Number float64

View File

@ -50,7 +50,7 @@ func NewClient(addr string) (c *Client, local, remote *net.TCPAddr, err error) {
c = &Client{addr: addr} c = &Client{addr: addr}
c.url, err = url.Parse(addr) c.url, err = url.Parse(addr)
if err != nil { if err != nil {
return nil, nil,nil, err return nil, nil, nil, err
} }
c.conn, err = net.Dial("tcp", c.url.Host) c.conn, err = net.Dial("tcp", c.url.Host)
if err != nil { if err != nil {

View File

@ -69,7 +69,7 @@ func (r *Revid) reset(c config.Config) error {
r.cfg.Logger.Log(logger.Debug, "setting config") r.cfg.Logger.Log(logger.Debug, "setting config")
err := r.setConfig(c) err := r.setConfig(c)
if err != nil { if err != nil {
return fmt.Errorf("could not set config: %w",err) return fmt.Errorf("could not set config: %w", err)
} }
r.cfg.Logger.Log(logger.Info, "config set") r.cfg.Logger.Log(logger.Info, "config set")
@ -95,7 +95,7 @@ func (r *Revid) reset(c config.Config) error {
encOptions = append(encOptions, mts.TimeBasedPSI(time.Duration(r.cfg.PSITime)*time.Second)) encOptions = append(encOptions, mts.TimeBasedPSI(time.Duration(r.cfg.PSITime)*time.Second))
r.cfg.CBR = true r.cfg.CBR = true
case codecutil.PCM, codecutil.ADPCM: case codecutil.PCM, codecutil.ADPCM:
return nil, errors.New(fmt.Sprintf("invalid input codec: %v for input: %v",r.cfg.InputCodec,r.cfg.Input)) return nil, errors.New(fmt.Sprintf("invalid input codec: %v for input: %v", r.cfg.InputCodec, r.cfg.Input))
default: default:
panic("unknown input codec") panic("unknown input codec")
} }
@ -117,7 +117,7 @@ func (r *Revid) reset(c config.Config) error {
r.cfg.Logger.Log(logger.Info, "finished setting pipeline") r.cfg.Logger.Log(logger.Info, "finished setting pipeline")
if err != nil { if err != nil {
return fmt.Errorf("could not set up pipeline: %w",err) return fmt.Errorf("could not set up pipeline: %w", err)
} }
return nil return nil
@ -282,7 +282,7 @@ func (r *Revid) setupPipeline(mtsEnc func(dst io.WriteCloser, rate float64) (io.
err = r.setupAudio() err = r.setupAudio()
} }
if err != nil { if err != nil {
return fmt.Errorf("could not set lexer: %w",err) return fmt.Errorf("could not set lexer: %w", err)
} }
// Configure the input device. We know that defaults are set, so no need to // Configure the input device. We know that defaults are set, so no need to