Remove ops queue from stream tracker. (#652)
It is not needed as the callback happens in a goroutine. Also, had missed included bitrate availability change in the queue which was inconsistent.
This commit is contained in:
@@ -6,7 +6,6 @@ import (
|
|||||||
|
|
||||||
"go.uber.org/atomic"
|
"go.uber.org/atomic"
|
||||||
|
|
||||||
"github.com/livekit/livekit-server/pkg/utils"
|
|
||||||
"github.com/livekit/protocol/logger"
|
"github.com/livekit/protocol/logger"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -72,16 +71,13 @@ type StreamTracker struct {
|
|||||||
bytesForBitrate [4]int64
|
bytesForBitrate [4]int64
|
||||||
bitrate [4]int64
|
bitrate [4]int64
|
||||||
|
|
||||||
callbacksQueue *utils.OpsQueue
|
|
||||||
|
|
||||||
isStopped bool
|
isStopped bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewStreamTracker(params StreamTrackerParams) *StreamTracker {
|
func NewStreamTracker(params StreamTrackerParams) *StreamTracker {
|
||||||
s := &StreamTracker{
|
s := &StreamTracker{
|
||||||
params: params,
|
params: params,
|
||||||
status: StreamStatusStopped,
|
status: StreamStatusStopped,
|
||||||
callbacksQueue: utils.NewOpsQueue(params.Logger, "streamtracker", 50),
|
|
||||||
}
|
}
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
@@ -113,9 +109,7 @@ func (s *StreamTracker) maybeSetStatus(status StreamStatus) (StreamStatus, bool)
|
|||||||
|
|
||||||
func (s *StreamTracker) maybeNotifyStatus(status StreamStatus, changed bool) {
|
func (s *StreamTracker) maybeNotifyStatus(status StreamStatus, changed bool) {
|
||||||
if changed && s.onStatusChanged != nil {
|
if changed && s.onStatusChanged != nil {
|
||||||
s.callbacksQueue.Enqueue(func() {
|
s.onStatusChanged(status)
|
||||||
s.onStatusChanged(status)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -130,7 +124,6 @@ func (s *StreamTracker) init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *StreamTracker) Start() {
|
func (s *StreamTracker) Start() {
|
||||||
s.callbacksQueue.Start()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *StreamTracker) Stop() {
|
func (s *StreamTracker) Stop() {
|
||||||
@@ -142,8 +135,6 @@ func (s *StreamTracker) Stop() {
|
|||||||
}
|
}
|
||||||
s.isStopped = true
|
s.isStopped = true
|
||||||
|
|
||||||
s.callbacksQueue.Stop()
|
|
||||||
|
|
||||||
// bump generation to trigger exit of worker
|
// bump generation to trigger exit of worker
|
||||||
s.generation.Inc()
|
s.generation.Inc()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user