mirror of https://bitbucket.org/ausocean/av.git
Merged in fix-loop-mode-pause (pull request #402)
revid: add stop signal channel to allow pause in loop mode Approved-by: Trek Hopton <trek.hopton@gmail.com>
This commit is contained in:
commit
f359d9ce79
|
@ -116,6 +116,9 @@ type Revid struct {
|
|||
|
||||
// bitrate is used for bitrate calculations.
|
||||
bitrate bitrate.Calculator
|
||||
|
||||
// stop used used to signal stopping when looping an input.
|
||||
stop chan struct{}
|
||||
}
|
||||
|
||||
// New returns a pointer to a new Revid with the desired configuration, and/or
|
||||
|
@ -440,6 +443,8 @@ func (r *Revid) Start() error {
|
|||
r.mu.Lock()
|
||||
defer r.mu.Unlock()
|
||||
|
||||
r.stop = make(chan struct{})
|
||||
|
||||
r.cfg.Logger.Log(logger.Debug, "resetting revid")
|
||||
err := r.reset(r.cfg)
|
||||
if err != nil {
|
||||
|
@ -475,6 +480,8 @@ func (r *Revid) Stop() {
|
|||
r.mu.Lock()
|
||||
defer r.mu.Unlock()
|
||||
|
||||
close(r.stop)
|
||||
|
||||
r.cfg.Logger.Log(logger.Debug, "stopping input")
|
||||
err := r.input.Stop()
|
||||
if err != nil {
|
||||
|
@ -904,5 +911,12 @@ func (r *Revid) processFrom(in device.AVDevice, delay time.Duration) {
|
|||
} else {
|
||||
r.cfg.Logger.Log(logger.Info, "input stopped")
|
||||
}
|
||||
|
||||
// If we're looping and we get a stop signal we return.
|
||||
select {
|
||||
case <-r.stop:
|
||||
return
|
||||
default:
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue