Skip to content

Commit

Permalink
fix deadlock (#369)
Browse files Browse the repository at this point in the history
  • Loading branch information
frostbyte73 authored Dec 14, 2023
1 parent 602e75b commit 54bbfd6
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pkg/synchronizer/track.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ func (t *TrackSynchronizer) getElapsed(ts int64) time.Duration {
}

func (t *TrackSynchronizer) resetRTP(pkt *rtp.Packet) (int64, time.Duration) {
frames := int64(time.Since(t.lastPacket) / t.GetFrameDuration())
frames := int64(time.Since(t.lastPacket) / t.getFrameDuration())
duration := t.getFrameDurationRTP() * frames
ts := t.lastTS + duration
pts := t.lastPTS + t.rtpConverter.toDuration(duration)
Expand Down Expand Up @@ -259,6 +259,10 @@ func (t *TrackSynchronizer) GetFrameDuration() time.Duration {
t.Lock()
defer t.Unlock()

return t.getFrameDuration()
}

func (t *TrackSynchronizer) getFrameDuration() time.Duration {
switch t.track.Kind() {
case webrtc.RTPCodecTypeAudio:
// round opus packets to 2.5ms
Expand Down

0 comments on commit 54bbfd6

Please sign in to comment.