Do not post close callback in ops queue if not started. (#649)
* Do not post close callback in ops queue if not started. Ops queue is started in `Bind()`. If `Close()` is called when bind did not happen (because the underlying peer connection closed before bind), the close callback does not run. Check if ops queue is running before posting close callback into the queue. Not pretty, but covers this case. Need to think about it more. * correct check
This commit is contained in:
+17
-9
@@ -595,17 +595,25 @@ func (d *DownTrack) CloseWithFlush(flush bool) {
|
||||
d.rtpStats.Stop()
|
||||
d.logger.Debugw("rtp stats", "stats", d.rtpStats.ToString())
|
||||
|
||||
if d.onMaxLayerChanged != nil && d.kind == webrtc.RTPCodecTypeVideo {
|
||||
d.callbacksQueue.Enqueue(func() {
|
||||
d.onMaxLayerChanged(d, InvalidLayerSpatial)
|
||||
})
|
||||
}
|
||||
if d.callbacksQueue.IsStarted() {
|
||||
if d.kind == webrtc.RTPCodecTypeVideo {
|
||||
d.callbacksQueue.Enqueue(func() {
|
||||
if d.onMaxLayerChanged != nil {
|
||||
d.onMaxLayerChanged(d, InvalidLayerSpatial)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
if d.onCloseHandler != nil {
|
||||
d.callbacksQueue.Enqueue(d.onCloseHandler)
|
||||
}
|
||||
if d.onCloseHandler != nil {
|
||||
d.callbacksQueue.Enqueue(d.onCloseHandler)
|
||||
}
|
||||
|
||||
d.callbacksQueue.Stop()
|
||||
d.callbacksQueue.Stop()
|
||||
} else {
|
||||
if d.onCloseHandler != nil {
|
||||
d.onCloseHandler()
|
||||
}
|
||||
}
|
||||
d.stopKeyFrameRequester()
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user