Set layer state to stopped on pause. (#818)

* Set layer state to `stopped` on pause.

Previously, on pause, the worker was let run and declare
layer gone 1/2 a second (or whatever the stream tracker window
is set for) later.

But, when rapidly changing mute/unmute, the following cuold happen
and layer changes may be missed
- Available layers - 0, 1, 2
- Mute
- Before layer gone detected, unumute. Because of this layer gone
  is not reported and available layers stay at 0, 1, 2.
- Stream tracker is reset on unmute to enable quick detection of layer
  start.
- If all layers start back up, no issues.
- But, if the layers do not start back up, there is no layer start
  firing and the available layers are still 0, 1, 2 which is incorrect.

* exempt handling when paused
This commit is contained in:
Raja Subramanian
2022-07-07 22:52:45 +05:30
committed by GitHub
parent 177061712c
commit 8315a547a8
2 changed files with 23 additions and 7 deletions
+10 -1
View File
@@ -165,13 +165,22 @@ func (s *StreamTracker) resetLocked() {
func (s *StreamTracker) SetPaused(paused bool) {
s.lock.Lock()
defer s.lock.Unlock()
s.paused = paused
status := s.status
changed := false
if !paused {
s.resetLocked()
} else {
// bump generation to trigger exit of current worker
s.generation.Inc()
status, changed = s.maybeSetStatus(StreamStatusStopped)
}
s.lock.Unlock()
s.maybeNotifyStatus(status, changed)
}
// Observe a packet that's received