Skip to content

Commit

Permalink
[HLS] Fix current_segment_ being set
Browse files Browse the repository at this point in the history
As with the PTS offset issue, `nextSegment` has been deleted by way of refreshing the tree. Since this becomes the new `current_segment_` we run into trouble. Affected live streams.
  • Loading branch information
glennguy committed Jul 27, 2021
1 parent 46e9f78 commit eee35e0
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/common/AdaptiveStream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -538,6 +538,12 @@ bool AdaptiveStream::ensureSegment()
absolutePTSOffset_ = (current_rep_->segments_[0]->startPTS_ * current_rep_->timescale_ext_) /
current_rep_->timescale_int_;

current_rep_->current_segment_ = nextSegment;
ResetSegment(nextSegment);

if (observer_ && nextSegment != &current_rep_->initialization_ && ~nextSegment->startPTS_)
observer_->OnSegmentChanged(this);

uint32_t nextsegmentPosold = current_rep_->get_segment_pos(nextSegment);
uint32_t nextsegno = current_rep_->getSegmentNumber(nextSegment);
AdaptiveTree::Representation* newRep;
Expand All @@ -559,8 +565,7 @@ bool AdaptiveStream::ensureSegment()
if (tree_.SecondsSinceRepUpdate(newRep) > 1)
{
tree_.prepareRepresentation(
current_period_, current_adp_, newRep,
false);
current_period_, current_adp_, newRep, tree_.has_timeshift_buffer_);
}

uint32_t nextsegmentPos = nextsegno - newRep->startNumber_;
Expand All @@ -583,12 +588,6 @@ bool AdaptiveStream::ensureSegment()
break;
}

current_rep_->current_segment_ = nextSegment;
ResetSegment(nextSegment);

if (observer_ && nextSegment != &current_rep_->initialization_ && ~nextSegment->startPTS_)
observer_->OnSegmentChanged(this);

thread_data_->signal_dl_.notify_one();
// Make sure that we have at least one segment filling
// Otherwise we lead into a deadlock because first condition is false.
Expand Down

0 comments on commit eee35e0

Please sign in to comment.