Use measured media tempo for sequential Android video playout

This commit is contained in:
evgeny committed 2026-10-19 17:25:16 +02:00
1 parent 4e9cce8a01
commit 0a2700a387
4 files changed
+61 -117

No files matched your search

@@ -17,7 +17,7 @@ internal object CallVideoNative {
external fun playoutReset(handle: Long)
/** >0: ждать микросекунды; 0: показать; <0: пропустить только показ. */
external fun playoutStep(handle: Long, pts: Long, received: Long, nextPts: Long, nextReceived: Long,
now: Long, valid: Boolean, audio: Long): Long
now: Long): Long
external fun requestKey(id: Long)
external fun range(id: Long, minimum: Int, maximum: Int): Boolean
external fun inspect(codec: Int, bytes: ByteArray): LongArray?
@@ -57,7 +57,7 @@ internal class CallVideoPlayer(private val id: Long, private val failure: (Strin
pending = null; displayed.value = null; CallVideoNative.requestKey(id)
LogManager.addLog("INFO", "call", "video output attached=${surface != null} call=$id")
}
// Два готовых output нужны для пропуска старого показа после паузы CPU, не для дополнительного запаса.
// Малый output lookahead; основной долг остаётся в encoded FIFO.
while (decoder != null && pictures.size < 2 && !endSeen) {
val out = decoder!!.dequeueOutputBuffer(info, 0)
if (out >= 0) {
@@ -82,7 +82,7 @@ internal class CallVideoPlayer(private val id: Long, private val failure: (Strin
val valid = NativeLib.callAudioClock(id, now / 1000, clock) && clock[5] != 0L
val first = pictures.peekFirst(); val nextPicture = if (pictures.size > 1) pictures.peekLast() else null
val decision = CallVideoNative.playoutStep(playout, first?.timing?.pts ?: -1, first?.timing?.received ?: 0,
nextPicture?.timing?.pts ?: -1, nextPicture?.timing?.received ?: 0, now / 1000, valid, clock[4])
nextPicture?.timing?.pts ?: -1, nextPicture?.timing?.received ?: 0, now / 1000)
if (decision > 0) wakeUs = now / 1000 + decision
else if (first != null) {
val render = decision == 0L