alsa, revid: reverted changes to revid and changed how ALSA implements Device

This commit is contained in:
Trek H 2020-08-13 15:28:59 +09:30
parent 53a55cc477
commit c394dc9d89
3 changed files with 11 additions and 9 deletions

View File

@ -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 {

View File

@ -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)
}

View File

@ -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")