mirror of
https://github.com/pion/webrtc.git
synced 2025-10-07 08:01:27 +08:00
Avoid leaking tickers
In Go 1.22 and earlier, a ticker needs to be explicitly stopped when it's no longer useful in order to avoid a resource leak. In Go 1.23 and later, an orphaned ticker will eventually be garbage collected, but it's still more thrifty to stop it early.
This commit is contained in:

committed by
Sean DuBois

parent
cbbb1c29e5
commit
f29ef99b22
@@ -223,6 +223,7 @@ func fourCCToTrack(fourCC string) *webrtc.TrackLocalStaticSample {
|
||||
// Write a file to Track
|
||||
func writeFileToTrack(ivf *ivfreader.IVFReader, header *ivfreader.IVFFileHeader, track *webrtc.TrackLocalStaticSample) {
|
||||
ticker := time.NewTicker(time.Millisecond * time.Duration((float32(header.TimebaseNumerator)/float32(header.TimebaseDenominator))*1000))
|
||||
defer ticker.Stop()
|
||||
for ; true; <-ticker.C {
|
||||
frame, _, err := ivf.ParseNextFrame()
|
||||
if errors.Is(err, io.EOF) {
|
||||
|
Reference in New Issue
Block a user