diff --git a/device/alsa/alsa.go b/device/alsa/alsa.go index 970a325f..eadf7bd3 100644 --- a/device/alsa/alsa.go +++ b/device/alsa/alsa.go @@ -116,11 +116,11 @@ func (d *ALSA) Name() string { return "ALSA" } -// Set will take a Config struct, check the validity of the relevant fields +// Setup will take a Config struct, check the validity of the relevant fields // and then performs any configuration necessary. If fields are not valid, // an error is added to the multiError and a default value is used. // It then initialises the ALSA device which can then be started, read from, and stopped. -func (d *ALSA) Set(c config.Config) error { +func (d *ALSA) Setup(c config.Config) error { var errs device.MultiError if c.SampleRate <= 0 { errs = append(errs, errInvalidSampleRate) @@ -185,6 +185,14 @@ func (d *ALSA) Set(c config.Config) error { return nil } +// Set exists to satisfy the implementation of the Device interface that revid uses. +// Everything that would usually be in Set is in the Setup function. +// This is because an ALSA device is different to other devices in that it +// outputs binary non-packetised data and it requires a different configuration procedure. +func (d *ALSA) Set(c config.Config) error { + return nil +} + // Start will start recording audio and writing to the ringbuffer. // Once an ALSA device has been stopped it cannot be started again. This is likely to change in future. func (d *ALSA) Start() error { diff --git a/revid/audio_linux.go b/revid/audio_linux.go index 4c128922..d3d08a58 100644 --- a/revid/audio_linux.go +++ b/revid/audio_linux.go @@ -41,7 +41,7 @@ func (r *Revid) setupAudio() error { // Configure ALSA device. r.cfg.Logger.Log(logger.Debug, "configuring input device") - err := r.input.Set(r.cfg) + err := d.Setup(r.cfg) if err != nil { r.cfg.Logger.Log(logger.Warning, "errors from configuring input device", "errors", err) } diff --git a/revid/revid.go b/revid/revid.go index 75d06e76..d0d981b4 100644 --- a/revid/revid.go +++ b/revid/revid.go @@ -392,12 +392,6 @@ func (r *Revid) setupPipeline(mtsEnc func(dst io.WriteCloser, rate float64) (io. } } - // input.Set does not need to be called for InputAudio since it is called - // in setupAudio above, so we can return here. - if r.cfg.Input == config.InputAudio { - return nil - } - // Configure the input device. We know that defaults are set, so no need to // return error, but we should log. r.cfg.Logger.Log(logger.Debug, "configuring input device")