|
|
|
|
@ -118,12 +118,16 @@ int stream_playback_audio_feed(struct stream_playback_audio* a, int64_t pts, con
|
|
|
|
|
DEBUG_WARN(DEBUG_CATEGORY_STREAM, "playback audio late packet pts=%lld expected=%lld", (long long)pts, (long long)a->expectedPts); |
|
|
|
|
return 1; |
|
|
|
|
} |
|
|
|
|
int missing = a->expectedPts < 0 ? 0 : (int)((pts - a->expectedPts + 10000) / 20000); |
|
|
|
|
if (missing > 5) { |
|
|
|
|
DEBUG_WARN(DEBUG_CATEGORY_STREAM, "playback audio discontinuity pts=%lld expected=%lld missing=%d", |
|
|
|
|
(long long)pts, (long long)a->expectedPts, missing); return -2; |
|
|
|
|
int64_t difference = a->expectedPts < 0 ? 0 : pts - a->expectedPts; |
|
|
|
|
if (difference >= 110000) { |
|
|
|
|
DEBUG_WARN(DEBUG_CATEGORY_STREAM, "playback audio discontinuity pts=%lld expected=%lld gap_us=%lld", |
|
|
|
|
(long long)pts, (long long)a->expectedPts, (long long)difference); return -2; |
|
|
|
|
} |
|
|
|
|
int missing = a->expectedPts < 0 ? 0 : (int)((difference + 10000) / 20000); |
|
|
|
|
int64_t effectivePts = a->expectedPts < 0 ? pts : a->expectedPts + missing * 20000; |
|
|
|
|
if (effectivePts > INT64_MAX - 20000) { |
|
|
|
|
DEBUG_ERROR(DEBUG_CATEGORY_STREAM, "playback audio normalized PTS overflow pts=%lld", (long long)effectivePts); return -1; |
|
|
|
|
} |
|
|
|
|
for (int i = 0; i < missing; i++) if (feedPcm(a, a->expectedPts + i * 20000, nullptr, 0) < 0) return -1; |
|
|
|
|
if (feedPcm(a, effectivePts, packet, (int)length) < 0) return -1; |
|
|
|
|
a->expectedPts = effectivePts + 20000; |
|
|
|
|
|