// (RFC 8216 4.3.3.1) and we get closer to the target by doing so.
// Note that in particular, this means we'll always extend
// as long as we don't exceed the target duration.
- double current_duration = fragments[fragments.size() - 1].pts;
+ double current_duration = pts_double - fragments[fragments.size() - 1].pts;
double candidate_duration = pts_double - fragments[fragments.size() - 2].pts;
if (lrintf(candidate_duration) <= hls_frag_duration &&
fabs(candidate_duration - hls_frag_duration) < fabs(current_duration - hls_frag_duration)) {