Fix action playback source clock using controlled video decode
This commit is contained in:
+3
-1
@@ -18,6 +18,7 @@ def avatarNatural = providers.gradleProperty('avatarNatural').orNull == 'true'
|
||||
def avatarUiCandidate = providers.gradleProperty('avatarUiCandidate').orNull == 'true'
|
||||
def avatarMouthCandidate = providers.gradleProperty('avatarMouthCandidate').orNull == 'true'
|
||||
def avatarActionCandidate = providers.gradleProperty('avatarActionCandidate').orNull == 'true'
|
||||
def avatarPlaybackClockFix = providers.gradleProperty('avatarPlaybackClockFix').orNull == 'true'
|
||||
def avatarPlaybackDiagnostic = providers.gradleProperty('avatarPlaybackDiagnostic').orNull == 'true'
|
||||
def avatarRuntimeFix = providers.gradleProperty('avatarRuntimeFix').orNull == 'true'
|
||||
def avatarFullActionCandidate = providers.gradleProperty('avatarFullActionCandidate').orNull == 'true'
|
||||
@@ -36,6 +37,7 @@ def emotionManifestSha = providers.gradleProperty('emotionManifestSha').orNull ?
|
||||
if (emotionManifestSha && !(emotionManifestSha ==~ /[0-9a-f]{64}/)) throw new GradleException('Emotion graph requires exact external manifest SHA')
|
||||
if (emotionManifestSha && (!avatarActionCandidate || !avatarMouthCandidate || !avatarNatural || actionVersionCode < 17)) throw new GradleException('Emotion candidate requires own-mouth runtime and a fresh code >=17')
|
||||
if (avatarFullActionCandidate && (!emotionManifestSha || !avatarActionCandidate || actionVersionCode < 18)) throw new GradleException('Full candidate requires pinned emotion/action graph and fresh code >=18')
|
||||
if (avatarPlaybackClockFix && (!avatarFullActionCandidate || actionVersionCode < 21 || emotionManifestSha != '987e125a7d7a2cde99121b5f5246c82f4dbe36c4899d3d49eaffd1a68bafb887')) throw new GradleException('Playback clock fix requires frozen full graph and fresh code >=21')
|
||||
if (avatarPlaybackDiagnostic && (!avatarFullActionCandidate || actionVersionCode < 20 || emotionManifestSha != '987e125a7d7a2cde99121b5f5246c82f4dbe36c4899d3d49eaffd1a68bafb887')) throw new GradleException('Playback diagnostic requires frozen full graph and fresh code >=20')
|
||||
if (avatarRuntimeFix && (!avatarFullActionCandidate || actionVersionCode < 19)) throw new GradleException('Runtime fix requires full pinned graph and fresh code >=19')
|
||||
if (avatarNatural && !(naturalManifestSha ==~ /[0-9a-f]{64}/)) {
|
||||
@@ -86,7 +88,7 @@ android {
|
||||
targetSdk 34
|
||||
testInstrumentationRunner 'com.gorios.lanvoice.AvatarCleanUiInstrumentation'
|
||||
versionCode avatarActionCandidate ? actionVersionCode : (avatarMouthCandidate ? 15 : (avatarUiCandidate ? 14 : (avatarNatural ? 13 : 12)))
|
||||
versionName = avatarPlaybackDiagnostic ? '0.7.2' : avatarRuntimeFix ? '0.7.1' : (avatarActionCandidate ? '0.7.0' : ((avatarUiCandidate || avatarMouthCandidate) ? '0.6.2' : '0.6.1'))
|
||||
versionName = avatarPlaybackClockFix ? '0.7.3' : avatarPlaybackDiagnostic ? '0.7.2' : avatarRuntimeFix ? '0.7.1' : (avatarActionCandidate ? '0.7.0' : ((avatarUiCandidate || avatarMouthCandidate) ? '0.6.2' : '0.6.1'))
|
||||
ndk { abiFilters 'arm64-v8a' }
|
||||
}
|
||||
compileOptions { sourceCompatibility JavaVersion.VERSION_17; targetCompatibility JavaVersion.VERSION_17 }
|
||||
|
||||
@@ -2,7 +2,8 @@ package com.gorios.lanvoice.avatar
|
||||
|
||||
data class ActionMedia(val path: String,val sha256: String,val root: String,val ptsUs: List<Long>,
|
||||
val durationUs: Long,val width: Int,val height: Int,val sourcePackage: String,val sourceFrame: Int,
|
||||
val returnPackage: String,val returnFrame: Int,val audioEndUs: Long)
|
||||
val returnPackage: String,val returnFrame: Int,val audioEndUs: Long,
|
||||
val fpsNumerator: Int=24,val fpsDenominator: Int=1)
|
||||
data class ActionAsset(val id: String, val durationMs: Long,val media: ActionMedia?=null)
|
||||
data class ReviewedActionPack(val manifestSha: String, val assets: List<ActionAsset>)
|
||||
data class ActionPlan(val id: String, val turn: Long, val packSha: String, val ttlMs: Long)
|
||||
|
||||
@@ -29,7 +29,7 @@ class ContinuousBodyRenderer(private val context: Context,private val pack: Cont
|
||||
private val output: Surface,private var width: Int,private var height: Int,
|
||||
private val presented: (ComposedBodyFrame,Long)->Unit,private val failure: (String)->Unit,
|
||||
private val automatic: Boolean=true,private val startFrame: Int=0,private val mayLoop: Boolean=true,
|
||||
private val mouthEnabled: Boolean=true,private val sharedMouth: ConversationMouthClock?=null,private val ended: ()->Unit={}) {
|
||||
private val mouthEnabled: Boolean=true,private val videoOnlyFromAv: Boolean=false,private val sharedMouth: ConversationMouthClock?=null,private val ended: ()->Unit={}) {
|
||||
private val alive=AtomicBoolean(true)
|
||||
private val releaseLock=Any()
|
||||
private val releaseCallbacks=mutableListOf<()->Unit>()
|
||||
@@ -141,10 +141,15 @@ class ContinuousBodyRenderer(private val context: Context,private val pack: Cont
|
||||
inputSurface=Surface(checkNotNull(inputTexture))
|
||||
val ex=MediaExtractor();extractor=ex
|
||||
context.assets.openFd(pack.root+pack.body.path).use { ex.setDataSource(it.fileDescriptor,it.startOffset,it.length) }
|
||||
check(ex.trackCount==1)
|
||||
val format=ex.getTrackFormat(0);check(format.getString(MediaFormat.KEY_MIME)=="video/avc")
|
||||
val track=if(videoOnlyFromAv) {
|
||||
check(!mouthEnabled && !mayLoop && ex.trackCount==2)
|
||||
val video=(0 until ex.trackCount).single { ex.getTrackFormat(it).getString(MediaFormat.KEY_MIME)=="video/avc" }
|
||||
check(ex.getTrackFormat(1-video).getString(MediaFormat.KEY_MIME)=="audio/mp4a-latm")
|
||||
video
|
||||
} else { check(ex.trackCount==1);0 }
|
||||
val format=ex.getTrackFormat(track);check(format.getString(MediaFormat.KEY_MIME)=="video/avc")
|
||||
check(format.getInteger(MediaFormat.KEY_WIDTH)==480 && format.getInteger(MediaFormat.KEY_HEIGHT)==848)
|
||||
ex.selectTrack(0);check(ex.sampleTime==0L)
|
||||
ex.selectTrack(track);check(ex.sampleTime==0L)
|
||||
codec=MediaCodec.createDecoderByType("video/avc").also { it.configure(format,checkNotNull(inputSurface),null,0);it.start() }
|
||||
progressMs=SystemClock.elapsedRealtime()
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.gorios.lanvoice.avatar
|
||||
import com.gorios.lanvoice.diag.DiagnosticLog
|
||||
import android.content.Context
|
||||
import android.graphics.BitmapFactory
|
||||
import android.graphics.Matrix
|
||||
import android.graphics.SurfaceTexture
|
||||
import android.media.MediaPlayer
|
||||
import android.os.Handler
|
||||
@@ -92,8 +91,7 @@ class EmotionActionAvatarView(context: Context,private val pack: AvatarPack,
|
||||
}
|
||||
private fun fitMovie() {
|
||||
val view=textures[3];if(view.width<=0 || view.height<=0) return
|
||||
val fit=fitVideo(view.width,view.height,480,848)
|
||||
view.setTransform(Matrix().apply { setScale(fit.scaleX,fit.scaleY,view.width/2f,view.height/2f) })
|
||||
movie?.resize(view.width,view.height)
|
||||
}
|
||||
private fun suspend() {
|
||||
main.removeCallbacks(summary)
|
||||
@@ -104,86 +102,109 @@ class EmotionActionAvatarView(context: Context,private val pack: AvatarPack,
|
||||
override fun onDetachedFromWindow() { dispose();super.onDetachedFromWindow() }
|
||||
}
|
||||
|
||||
/** Android's completion is combined with actual final TextureView PTS and release.
|
||||
* No timer substitutes for MediaPlayer.stop/release or idle presentation. */
|
||||
/** Video uses the existing controlled codec/compositor's decoded+latched source PTS.
|
||||
* MediaPlayer supplies audio only: its TextureView timestamp is a presentation clock,
|
||||
* not a source-frame index. Completion still requires final video, native audio end,
|
||||
* actual resource release and the driver's reviewed return A. */
|
||||
internal class AndroidMusicPort(private val context: Context,private val view: TextureView,private val diagnostic: (String)->Unit={}): MusicMediaPort {
|
||||
private val main=Handler(Looper.getMainLooper())
|
||||
private var player: MediaPlayer?=null
|
||||
private var surface: Surface?=null
|
||||
private var video: ContinuousBodyRenderer?=null
|
||||
private var epoch=0L
|
||||
private var media: ActionMedia?=null
|
||||
private var firstFrame: (()->Unit)?=null
|
||||
private var ready: (()->Unit)?=null
|
||||
private var ended: (()->Unit)?=null
|
||||
private var failed: (()->Unit)?=null
|
||||
private var lastPts=-1L
|
||||
private var lastIndex=-1
|
||||
private var playing=false
|
||||
private var audioReady=false
|
||||
private var readySent=false
|
||||
private var nativeEnded=false
|
||||
private var videoEnded=false
|
||||
private var startedMs=0L
|
||||
private var faulted=false
|
||||
private fun event(reason: String, timestampUs: Long?=null) {
|
||||
val position=try { player?.currentPosition ?: -1 } catch(_: Exception) { -1 }
|
||||
val message="event=$reason epoch=$epoch playing=$playing ended=$nativeEnded elapsed_ms=${SystemClock.elapsedRealtime()-startedMs} position_ms=$position pts_us=${timestampUs ?: lastPts} layer_alpha=${view.alpha}"
|
||||
val message="event=$reason epoch=$epoch playing=$playing ended=$nativeEnded video_ended=$videoEnded elapsed_ms=${SystemClock.elapsedRealtime()-startedMs} position_ms=$position pts_us=$lastPts frame=$lastIndex output_us=${timestampUs ?: -1} layer_alpha=${view.alpha}"
|
||||
diagnostic(message)
|
||||
DiagnosticLog.state("music_native", "$epoch/$reason",message)
|
||||
}
|
||||
private fun fault(reason: String,timestampUs: Long?=null) {
|
||||
private fun fault(reason: String) {
|
||||
if(faulted) return
|
||||
faulted=true;event(reason,timestampUs);failed?.invoke()
|
||||
faulted=true;event(reason);failed?.invoke()
|
||||
}
|
||||
private fun announceReady() {
|
||||
if(!faulted && audioReady && lastIndex==0 && !readySent) { readySent=true;event("prepared");ready?.invoke() }
|
||||
}
|
||||
override fun prepare(media: ActionMedia,ready: ()->Unit,firstFrame: ()->Unit,ended: ()->Unit,failed: ()->Unit) {
|
||||
check(player==null);val token=++epoch
|
||||
this.media=media;this.firstFrame=firstFrame;this.ended=ended;this.failed=failed;lastPts=-1;faulted=false;startedMs=SystemClock.elapsedRealtime();event("preparing")
|
||||
check(player==null && video==null);val token=++epoch
|
||||
this.media=media;this.ready=ready;this.firstFrame=firstFrame;this.ended=ended;this.failed=failed
|
||||
lastPts=-1;lastIndex=-1;faulted=false;audioReady=false;readySent=false;videoEnded=false;nativeEnded=false
|
||||
startedMs=SystemClock.elapsedRealtime();event("preparing")
|
||||
try {
|
||||
val s=Surface(checkNotNull(view.surfaceTexture));surface=s
|
||||
val current=MediaPlayer();player=current;current.setSurface(s);current.isLooping=false
|
||||
val body=ContinuousBodyAsset(media.path,media.sha256,media.width,media.height,media.ptsUs.size,
|
||||
media.durationUs,media.ptsUs,media.fpsNumerator,media.fpsDenominator)
|
||||
// Genuine body-only action: no registered mouth assets or conversation patch reuse.
|
||||
val pack=ContinuousAvatarPack(body,emptyList(),emptyMap(),media.root,media.sha256)
|
||||
video=ContinuousBodyRenderer(context,pack,Surface(checkNotNull(view.surfaceTexture)),view.width,view.height,
|
||||
{ value,_-> if(token==epoch && !faulted) {
|
||||
val key=value.key
|
||||
if(key.loopOrdinal!=0L || key.index!=lastIndex+1 || (media.ptsUs.getOrNull(key.index)?.let { kotlin.math.abs(it-key.ptsUs)<=2 }!=true) || value.selection.opacity!=0f) fault("video_frame_invalid")
|
||||
else {
|
||||
lastIndex=key.index;lastPts=key.ptsUs
|
||||
if(!playing) announceReady() else { if(key.index==media.ptsUs.lastIndex) event("final_codec_frame");video?.advance() }
|
||||
}
|
||||
} },{ _-> if(token==epoch) fault("video_decoder_or_gl") },automatic=false,mayLoop=false,
|
||||
mouthEnabled=false,videoOnlyFromAv=true,ended={ if(token==epoch && !faulted) {
|
||||
videoEnded=true;event("video_completed");finishIfReady()
|
||||
main.postDelayed({ if(token==epoch && videoEnded && !nativeEnded && playing) fault("audio_end_missing") },2_000)
|
||||
} })
|
||||
val current=MediaPlayer();player=current;current.setSurface(null);current.isLooping=false
|
||||
context.assets.openFd(media.root+media.path).use { current.setDataSource(it.fileDescriptor,it.startOffset,it.length) }
|
||||
current.setOnPreparedListener { if(token==epoch) {
|
||||
if(current.videoWidth!=media.width || current.videoHeight!=media.height) fault("dimensions_invalid") else { event("prepared");ready() }
|
||||
} }
|
||||
current.setOnCompletionListener { if(token==epoch && playing) {
|
||||
playing=false;nativeEnded=true;event("native_completed");finishIfReady()
|
||||
main.postDelayed({ if(token==epoch && nativeEnded) fault("native_ended_missing_final") },2_000) // Missing final-frame watchdog, no fabricated completion.
|
||||
current.setOnPreparedListener { if(token==epoch && !faulted) { audioReady=true;event("audio_prepared");announceReady() } }
|
||||
current.setOnCompletionListener { if(token==epoch && playing && !faulted) {
|
||||
if(SystemClock.elapsedRealtime()-startedMs+50 < media.audioEndUs/1000) fault("audio_duration_early")
|
||||
else { nativeEnded=true;event("native_completed");finishIfReady() }
|
||||
// Missing video progress retains the decoder's bounded watchdog, never fabricates an end.
|
||||
} }
|
||||
current.setOnInfoListener { _,what,_->
|
||||
if(token==epoch && what==MediaPlayer.MEDIA_INFO_VIDEO_RENDERING_START) event("native_rendering_start")
|
||||
true // Native info is not a latched frame or completion proof.
|
||||
false // Informational only; audio player owns no visible surface.
|
||||
}
|
||||
current.setOnErrorListener { _,_,_->if(token==epoch) fault("native_error");true }
|
||||
current.prepareAsync()
|
||||
} catch(_: Exception) { fault("prepare_failed") }
|
||||
}
|
||||
override fun start() { if(faulted) return;try { startedMs=SystemClock.elapsedRealtime();nativeEnded=false;playing=true;checkNotNull(player).start();event("started") } catch(_: Exception) { fault("start_failed") } }
|
||||
fun latched(timestampNs: Long) {
|
||||
if(faulted || (!playing && !nativeEnded)) return
|
||||
val pts=timestampNs/1000;val timeline=media?.ptsUs ?: return
|
||||
val found=timeline.binarySearch(pts)
|
||||
val candidate=if(found>=0) found else (-found-1).coerceAtMost(timeline.lastIndex)
|
||||
val index=listOf(candidate,(candidate-1).coerceAtLeast(0)).firstOrNull { kotlin.math.abs(timeline[it]-pts)<=2 }
|
||||
if(index==null) { fault("timestamp_not_indexed",pts);return }
|
||||
if(timeline[index]<lastPts) { fault("timestamp_regressed",pts);return }
|
||||
if(lastPts<0) {
|
||||
if(index!=0) { fault("first_frame_not_zero",pts);return }
|
||||
event("first_frame_latched",pts)
|
||||
firstFrame?.invoke();firstFrame=null
|
||||
}
|
||||
lastPts=timeline[index]
|
||||
finishIfReady()
|
||||
}
|
||||
private fun finishIfReady() {
|
||||
override fun start() {
|
||||
if(faulted) return
|
||||
try {
|
||||
check(readySent && lastIndex==0 && !playing)
|
||||
startedMs=SystemClock.elapsedRealtime();playing=true;checkNotNull(player).start();event("started")
|
||||
// Frame0 is already decoded, input-latched, composited and held on this action surface.
|
||||
event("first_codec_frame");firstFrame?.invoke();firstFrame=null;video?.advance()
|
||||
} catch(_: Exception) { fault("start_failed") }
|
||||
}
|
||||
/** EGL output presentation timestamps are diagnostic only. They cannot index source media.
|
||||
* Zero/old/epoch timestamps from SurfaceTexture updates never grant an entry or completion. */
|
||||
fun latched(timestampNs: Long) { if(playing && !faulted) event("output_texture_updated",timestampNs/1000) }
|
||||
fun resize(width: Int,height: Int) { video?.resize(width,height) }
|
||||
private fun finishIfReady() {
|
||||
val current=media ?: return
|
||||
if(nativeEnded && lastPts==current.ptsUs.last()) {
|
||||
nativeEnded=false
|
||||
if(!faulted && playing && nativeEnded && videoEnded && lastIndex==current.ptsUs.lastIndex && kotlin.math.abs(lastPts-current.ptsUs.last())<=2) {
|
||||
if(SystemClock.elapsedRealtime()-startedMs<(current.durationUs+999)/1000) fault("duration_early")
|
||||
else { event("validated_end");ended?.invoke() }
|
||||
else { playing=false;event("validated_end");ended?.invoke() }
|
||||
}
|
||||
}
|
||||
override fun close(released: ()->Unit) {
|
||||
event("closing");epoch++;playing=false;nativeEnded=false;firstFrame=null;ended=null
|
||||
val old=player
|
||||
try { try { old?.stop() } catch(_: Exception) { } // release also stops a prepared/error player.
|
||||
old?.release();player=null;surface?.release();surface=null;media=null
|
||||
event("released");main.post { released() }
|
||||
event("closing");epoch++;playing=false;nativeEnded=false;firstFrame=null;ready=null;ended=null
|
||||
val old=player;val oldVideo=video;video=null
|
||||
try {
|
||||
try { old?.stop() } catch(_: Exception) { } // release also stops a prepared/error player.
|
||||
old?.release();player=null;media=null;event("audio_released")
|
||||
val finish={ event("released");released() }
|
||||
oldVideo?.close(finish) ?: main.post(finish)
|
||||
} catch(_: Exception) { event("release_failed");val callback=failed;failed=null;callback?.invoke() } // No false release acknowledgement.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -159,7 +159,8 @@ object EmotionActionManifest {
|
||||
require(integer(action["sourcePtsUs"])==runtime.body.ptsUs[sourceFrame.toInt()] &&
|
||||
integer(action["returnPtsUs"])==runtime.body.ptsUs[returnFrame.toInt()])
|
||||
ActionAsset(action["id"] as String,(duration+999)/1000,ActionMedia(path(clip["path"]),hash(clip["sha256"]),pathRoot,
|
||||
pts,duration,480,848,fallback,sourceFrame.toInt(),fallback,returnFrame.toInt(),integer(action["audioEndUs"])))
|
||||
pts,duration,480,848,fallback,sourceFrame.toInt(),fallback,returnFrame.toInt(),integer(action["audioEndUs"]),
|
||||
boundedInt(clip["fpsNumerator"],120_000),boundedInt(clip["fpsDenominator"],10_000)))
|
||||
}
|
||||
ReviewedActionPack(actualSha,assets)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
# Android 0.7.3 action video clock repair
|
||||
|
||||
Baseline clean/pushed: `9cebf4f3d3013666aa438b92bf6b017234fc84aa`.
|
||||
This fixes a failure established by the user's new code20 report, not the earlier
|
||||
report-less code19 speculation. Existing white-outfit assets remain frozen.
|
||||
|
||||
## Device evidence and confirmed cause
|
||||
|
||||
One report was received2026-10-13 12:04:11.722 Asia/Shanghai, generated12:04:08.136,
|
||||
version0.7.2/code20/API31, mode`offline_preview`, exact index
|
||||
`987e125a7d7a2cde99121b5f5246c82f4dbe36c4899d3d49eaffd1a68bafb887`.
|
||||
Only version/mode/pin and fixed diagnostic enums/numbers were extracted. No user
|
||||
conversation, audio, pictures, face/landmark data, keys or raw report is archived.
|
||||
|
||||
- First local asset_01 attempt: native start12:03:48.475, output texture timestamp0
|
||||
accepted12:03:48.638, native rendering info12:03:48.642. At12:03:48.718, elapsed249ms,
|
||||
native position26ms, output timestamp47,741,893,941us was rejected as
|
||||
`timestamp_not_indexed`; displayed-layer alpha was1. Stop/release followed.
|
||||
- Second attempt: native start12:03:57.516, rendering info12:03:57.654, rejection
|
||||
12:03:57.674 atelapsed160ms with output timestamp47,742,026,182us. Then release.
|
||||
Layer alpha was0 because the timestamp had not been accepted as a first frame.
|
||||
- No native-error or user/background/new-turn cancellation initiated these two
|
||||
stops in the recorded sequence. This establishes the local-player failure; it
|
||||
does not establish a normal WS/model/plan episode on that phone.
|
||||
|
||||
Code20 `AndroidMusicPort.latched` divided the MediaPlayer/TextureView timestamp by
|
||||
1000 and demanded it match a0–10s source PTS within2us. TextureView's producer
|
||||
presentation timestamp is not a decoded source-frame identity. This phone's
|
||||
output value is outside the clip timeline, so the app itself killed playback.
|
||||
The earlier0 update also cannot prove an actual decoded sourceframe0. Precise
|
||||
vendor output-clock origin is not established and is not inferred from these
|
||||
numbers. The source video/asset bytes are valid and unchanged.
|
||||
|
||||
Offline mouth metadata did reach levels1–4 with opacity1. These are synthetic
|
||||
intent/draw callbacks, not evidence of normal AudioTrack mouth gating or human
|
||||
mouth visibility; mouth amplitude is not changed.
|
||||
|
||||
## Minimal repair and retained gates
|
||||
|
||||
`AndroidMusicPort` now reuses the existing `ContinuousBodyRenderer` for ACTION
|
||||
video. Its only new decoding option selects the single H264 video track from the
|
||||
reviewed H264+AAC container. Conversation/bridge track validation stays unchanged.
|
||||
The body-only ACTION renderer uploads one transparent texture, uses no registered
|
||||
mouth layers, preserves white Fit layout, and never loops. Manifest fpsN/fpsD are
|
||||
passed through, not inferred from an output-clock offset. No schema relaxation or
|
||||
neutral-mouth reuse is introduced.
|
||||
|
||||
The controlled decoder validates each output's real source PTS, latches its own
|
||||
input SurfaceTexture and composites/swaps the corresponding frame. Frame0 is
|
||||
prepared and held before ready/audio start; then the legal conversation source
|
||||
exit, ACTION ownership and first-frame reveal proceed. Output TextureView updates
|
||||
may be skipped, zero, stale or use another clock: they are sampled diagnostics,
|
||||
never source indices or completion proofs. No affine mapping from arbitrary
|
||||
output timestamps or MediaPlayer.currentPosition is used to choose frame/anchor.
|
||||
Actual bad codec PTS, a missing source entry/final frame, decode/GLES failure and
|
||||
native audio error remain failures. Existing source-codec rounding tolerance is
|
||||
retained. Layer/epoch ownership and all stale callback fences remain in force.
|
||||
|
||||
MediaPlayer has no video surface and supplies the original container's audio.
|
||||
It starts only after the real held sourceframe0 and native audio preparation.
|
||||
Completion needs the actual final source frame plus renderer end, native audio
|
||||
completion, minimum duration corroboration and actual audio+codec/GLES resource
|
||||
release. The driver then decodes/presents reviewed return neutralframe96/4s/A
|
||||
before emitting completed. Early native audio end fails (50ms bounded EOS rounding
|
||||
allowance, not a timer-generated completion); absent audio completion after video
|
||||
end fails after the bounded watchdog. Normal record-stop/after-once/new-turn,
|
||||
settings/background/disconnect cancellation remain the existing protocol.
|
||||
|
||||
This changes only Android playback. No gateway/provider/time/TTS/model update or
|
||||
restart, no asset import/generation and no paid/LLM/ASR/TTS inference call. The
|
||||
old pin and every3222 runtime file must match code20/19/18. New black-outfit assets
|
||||
are independent and are not read or imported. Owner batch cap is200 cumulative,
|
||||
not an additional200; existing recorded21 calls/known video$4.16 and unknown
|
||||
image/rate fees are unchanged by this work.
|
||||
|
||||
## Validation and limitations
|
||||
|
||||
Production adapter tests replay the exact two reported output timestamps, zero /
|
||||
nonzero first output, ignored native rendering info,1us source rounding, invalid
|
||||
source-codec timebase, missing source entry/final frame, actual audio end, cancel
|
||||
and late callbacks. Full241-frame cases use source decoder/renderer callbacks;
|
||||
output timestamps cannot manufacture frames or completion. Existing View ownership,
|
||||
legal routes, bridge TALK, idle rotation, capture-stop, after-once and stale-turn
|
||||
regressions remain required. All native codec/EGL/audio ports in host tests are
|
||||
doubles; current code21 Android/GPU/speaker/recording and listening are **not_run**.
|
||||
Instrumentation is compile-only. A/V synchronization of the newly separated
|
||||
native paths needs phone verification; video may hold its true last frame while
|
||||
waiting for real audio end or release. No perception or playback SLA is claimed.
|
||||
|
||||
Use existing settings→离线播放检查→舞蹈01/02 and explicit report after device
|
||||
verification. Normal WS action shares the same repaired adapter, but the report
|
||||
above is local/offline, so a normal-plan success is not claimed. Code20 diagnostic
|
||||
and previous rollback APKs remain intact. Release0.7.3/code21 must use the same
|
||||
certificate, arm64/min26/target34, frozen pin, occupied-version guards, exact
|
||||
packaged file bytes and verified HTTP APK/checksum bodies. Results follow after
|
||||
publication.
|
||||
|
||||
Prepublication checks completed: nine JVM/UI entry points;31 packaging tests
|
||||
(26 publisher tests plus5 repair/diagnostic tests);200 offline software GLES
|
||||
goldens over the five frozen bodies;97 gateway tests passed and one existing
|
||||
Silero artifact skip. Production Android callback doubles passed757 reported-clock
|
||||
assertions and103 native/offline assertions, with the existing1288 View/media,
|
||||
289 bridge TALK,27 idle and17 full-graph assertion groups retained. Android app
|
||||
and instrumentation APK compilation passed; instrumentation execution not_run.
|
||||
Gateway source stage was tests-only (`applied=false`), with no deployment/restart.
|
||||
@@ -97,6 +97,7 @@ fun main(args: Array<String>) {
|
||||
TestScheduler.reset();CodecFixture.reset();MediaPlayer.created.clear();CodecFixture.emitNativeSurface=true
|
||||
index.packages.values.forEach { CodecFixture.timelines[it.root+it.body.path]=it.body.ptsUs }
|
||||
index.edges.mapNotNull { it.mouthRuntime }.forEach { CodecFixture.timelines[it.root+it.body.path]=it.body.ptsUs }
|
||||
index.actionPack?.assets?.mapNotNull { it.media }?.forEach { CodecFixture.timelines[it.root+it.path]=it.ptsUs;CodecFixture.audioPaths.add(it.root+it.path) }
|
||||
val binding=AvatarMediaBinding();binding.beginTurn(7)
|
||||
val trace=mutableListOf<Pair<Long,VideoPresentation>>()
|
||||
val view=EmotionActionAvatarView(context,pack,binding) { trace.add(TestScheduler.now to it) }
|
||||
|
||||
@@ -297,7 +297,7 @@ def verify_runtime_fix_assets(built,pin):
|
||||
return len([p for p in paths(new) if p.startswith('assets/'+ASSET_ROOT)])
|
||||
|
||||
|
||||
def publish(report,output,requested,full=False,runtime_fix=False,playback_diagnostic=False):
|
||||
def publish(report,output,requested,full=False,runtime_fix=False,playback_diagnostic=False,playback_clock_fix=False):
|
||||
require(all(edge.get('nativeLoop') is True or 'mouthRuntimeManifest' in edge for edge in read_json(ROOT/'app/src/main/assets'/ASSET_ROOT/'manifest.json')['edges']),
|
||||
'live emotion release needs bridge-own TALK runtimes')
|
||||
tested_source(full);packaging_tests_current();require(file_sha(ROLLBACK)==ROLLBACK_SHA,'rollback drift')
|
||||
@@ -305,13 +305,14 @@ def publish(report,output,requested,full=False,runtime_fix=False,playback_diagno
|
||||
if requested is not None:
|
||||
require(requested>=version,'version code occupied');version=requested
|
||||
require(not full or version>=18,'full candidate needs code >=18')
|
||||
require(not playback_clock_fix or full and version>=21 and report['manifest_sha256']==RUNTIME_FIX_PIN,'playback clock fix release shape')
|
||||
require(not playback_diagnostic or full and version>=20 and report['manifest_sha256']==RUNTIME_FIX_PIN,'playback diagnostic release shape')
|
||||
require(not runtime_fix or full and version>=19 and report['manifest_sha256']==RUNTIME_FIX_PIN,'runtime fix release shape')
|
||||
subprocess.run([str(ROOT/'scripts/build.sh'),'assembleDebug','compileDebugAndroidTestKotlin','-PavatarActionCandidate=true',
|
||||
'-PavatarNatural=true','-PavatarMouthCandidate=true','-PnaturalManifestSha='+LEGACY_PIN,
|
||||
'-PemotionManifestSha='+report['manifest_sha256'],'-PactionVersionCode='+str(version),'-PavatarFullActionCandidate='+str(full).lower(),'-PavatarRuntimeFix='+str(runtime_fix).lower(),'-PavatarPlaybackDiagnostic='+str(playback_diagnostic).lower()],check=True,cwd=ROOT)
|
||||
'-PemotionManifestSha='+report['manifest_sha256'],'-PactionVersionCode='+str(version),'-PavatarFullActionCandidate='+str(full).lower(),'-PavatarRuntimeFix='+str(runtime_fix).lower(),'-PavatarPlaybackDiagnostic='+str(playback_diagnostic).lower(),'-PavatarPlaybackClockFix='+str(playback_clock_fix).lower()],check=True,cwd=ROOT)
|
||||
built=ROOT/'app/build/outputs/apk/debug/app-debug.apk';badge=badging(built)
|
||||
version_name='0.7.2' if playback_diagnostic else '0.7.1' if runtime_fix else ('0.7.0' if full else '0.7.0-emotion-dev')
|
||||
version_name='0.7.3' if playback_clock_fix else '0.7.2' if playback_diagnostic else '0.7.1' if runtime_fix else ('0.7.0' if full else '0.7.0-emotion-dev')
|
||||
for text in ("name='com.gorios.lanvoice'",f"versionCode='{version}'",f"versionName='{version_name}'","sdkVersion:'26'","targetSdkVersion:'34'"):
|
||||
require(text in badge,'APK metadata: '+text)
|
||||
require(re.search(r'^native-code: (.+)$',badge,re.M)[1].strip()=="'arm64-v8a'",'APK ABI')
|
||||
@@ -328,9 +329,9 @@ def publish(report,output,requested,full=False,runtime_fix=False,playback_diagno
|
||||
config=ROOT/'app/build/generated/source/buildConfig/debug/com/gorios/lanvoice/BuildConfig.java'
|
||||
require('EMOTION_MANIFEST_SHA = "'+report['manifest_sha256']+'"' in config.read_text(),'compiled index pin mismatch')
|
||||
require(version>=next_version((ROOT/'artifacts').glob('*.apk')),'version became occupied during build')
|
||||
if runtime_fix or playback_diagnostic: require(verify_runtime_fix_assets(built,report['manifest_sha256'])==len(report['files']),'runtime fix file count')
|
||||
stem='playback-diagnostic' if playback_diagnostic else 'runtime-fix' if runtime_fix else ('action-emotion' if full else 'emotion-candidate')
|
||||
release='v072' if playback_diagnostic else 'v071' if runtime_fix else 'v070'
|
||||
if runtime_fix or playback_diagnostic or playback_clock_fix: require(verify_runtime_fix_assets(built,report['manifest_sha256'])==len(report['files']),'runtime fix file count')
|
||||
stem='playback-clock-fix' if playback_clock_fix else 'playback-diagnostic' if playback_diagnostic else 'runtime-fix' if runtime_fix else ('action-emotion' if full else 'emotion-candidate')
|
||||
release='v073' if playback_clock_fix else 'v072' if playback_diagnostic else 'v071' if runtime_fix else 'v070'
|
||||
artifact=ROOT/f'artifacts/lan-voice-{release}-{stem}-code{version}-arm64-debug.apk'
|
||||
with artifact.open('xb') as f,built.open('rb') as source: shutil.copyfileobj(source,f)
|
||||
digest=file_sha(artifact);checksum=f'{digest} {artifact.name}\n'.encode()
|
||||
@@ -342,7 +343,7 @@ def publish(report,output,requested,full=False,runtime_fix=False,playback_diagno
|
||||
require(file_sha(ROLLBACK)==ROLLBACK_SHA,'rollback modified')
|
||||
delivery={'status':'full_action_emotion_candidate' if full else 'partial_emotion_candidate','version_name':version_name,'version_code':version,'url':url,'sha256':digest,
|
||||
'certificate_sha256':CERT,'manifest_sha256':report['manifest_sha256'],'dance_available':full,'action_count':report['action_count'],
|
||||
'http_bytes_verified':True,'device':'not_run','naturalness':'not_certified','paid_calls':0,'gateway_deployed':False,'runtime_fix':runtime_fix,'diagnostic_only':playback_diagnostic,'runtime_files_unchanged_from_code18':len(report['files']) if runtime_fix or playback_diagnostic else None}
|
||||
'http_bytes_verified':True,'device':'not_run','naturalness':'not_certified','paid_calls':0,'gateway_deployed':False,'runtime_fix':runtime_fix,'diagnostic_only':playback_diagnostic,'playback_clock_fix':playback_clock_fix,'runtime_files_unchanged_from_code18':len(report['files']) if runtime_fix or playback_diagnostic or playback_clock_fix else None}
|
||||
(output/'delivery.json').write_text(json.dumps(delivery,indent=2)+'\n')
|
||||
return delivery
|
||||
|
||||
@@ -360,8 +361,9 @@ def main():
|
||||
parser.add_argument('--version-code',type=int,help='Default max existing APK code+1, minimum17')
|
||||
parser.add_argument('--runtime-fix',action='store_true',help='0.7.1 Android-only repair; all avatar bytes must equal frozen code18')
|
||||
parser.add_argument('--playback-diagnostic',action='store_true',help='0.7.2 diagnostic-only Android build, frozen code18 avatar bytes')
|
||||
parser.add_argument('--playback-clock-fix',action='store_true',help='0.7.3 Android MediaPlayer-output clock fix; exact frozen avatar bytes')
|
||||
args=parser.parse_args();
|
||||
require(not (args.runtime_fix and args.playback_diagnostic),'choose one build purpose')
|
||||
require(sum((args.runtime_fix,args.playback_diagnostic,args.playback_clock_fix))<=1,'choose one build purpose')
|
||||
manifest=args.manifest.resolve(strict=True);output=args.output.resolve()
|
||||
require(not output.exists() and not output.is_relative_to(manifest.parent),'new evidence outside owner root required')
|
||||
if args.import_only or args.publish: require(args.pi_pin==args.sha256 and re.fullmatch('[0-9a-f]{64}',args.pi_pin or ''),'external Pi pin required')
|
||||
@@ -378,7 +380,7 @@ def main():
|
||||
require(not args.previous_pin and not args.backup,'previous import report required')
|
||||
import_files(manifest.parent,report['files'],target)
|
||||
(output/'import.json').write_text(json.dumps({'externally_pinned_sha256':args.pi_pin,'files':len(report['files']),'naturalness':'not_certified'})+'\n')
|
||||
result=publish(report,output,args.version_code,bool(report['action_count']),args.runtime_fix,args.playback_diagnostic) if args.publish else {k:v for k,v in report.items() if k!='files'}
|
||||
result=publish(report,output,args.version_code,bool(report['action_count']),args.runtime_fix,args.playback_diagnostic,args.playback_clock_fix) if args.publish else {k:v for k,v in report.items() if k!='files'}
|
||||
print(json.dumps(result,indent=2))
|
||||
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import android.media.MediaPlayer
|
||||
import android.view.TextureView
|
||||
|
||||
fun main() {
|
||||
reportedActionClockCheck()
|
||||
playbackDiagnosticCheck()
|
||||
boundedRuntimeDiagnosticCheck()
|
||||
dynamicBodyCheck()
|
||||
|
||||
@@ -11,23 +11,26 @@ object CodecFixture {
|
||||
var rendered=mutableListOf<Long>(); var onRender: ((Long) -> Unit)? = null
|
||||
var emitNativeSurface=false
|
||||
val timelines=mutableMapOf<String,List<Long>>()
|
||||
val audioPaths=mutableSetOf<String>()
|
||||
fun reset() {
|
||||
frames=20; fps=20; gop=4; firstPtsUs=0; timestampOffsetUs=0; outputEnabled=true; configureFails=false
|
||||
seeks.clear(); releases=0; flushes=0; rendered.clear(); onRender=null
|
||||
emitNativeSurface=false;timelines.clear()
|
||||
emitNativeSurface=false;timelines.clear();audioPaths.clear()
|
||||
}
|
||||
}
|
||||
class MediaFormat {
|
||||
class MediaFormat(private val mime: String="video/avc") {
|
||||
companion object { const val KEY_MIME="mime"; const val KEY_WIDTH="width"; const val KEY_HEIGHT="height" }
|
||||
fun getString(key: String): String? = "video/avc"
|
||||
fun getString(key: String): String? = mime
|
||||
fun getInteger(key: String): Int = if (key == KEY_WIDTH) 480 else 848
|
||||
}
|
||||
class MediaExtractor {
|
||||
val trackCount=1; private var frame=0
|
||||
private var av=false
|
||||
val trackCount get()=if(av) 2 else 1
|
||||
private var frame=0
|
||||
private var timeline: List<Long>?=null
|
||||
val sampleTime: Long get() = timeline?.getOrNull(frame) ?: if(frame >= (timeline?.size ?: CodecFixture.frames)) -1L else CodecFixture.firstPtsUs+frame*1_000_000L/CodecFixture.fps
|
||||
fun setDataSource(fd: java.io.FileDescriptor,offset: Long,length: Long) { timeline=CodecFixture.timelines[android.content.AssetFixture.paths[fd]] }
|
||||
fun getTrackFormat(index: Int) = MediaFormat()
|
||||
fun setDataSource(fd: java.io.FileDescriptor,offset: Long,length: Long) { val path=android.content.AssetFixture.paths[fd];timeline=CodecFixture.timelines[path];av=path in CodecFixture.audioPaths }
|
||||
fun getTrackFormat(index: Int) = MediaFormat(if(av && index==1) "audio/mp4a-latm" else "video/avc")
|
||||
fun selectTrack(index: Int) {}
|
||||
fun seekTo(time: Long,mode: Int) { CodecFixture.seeks += time; frame=(time*CodecFixture.fps/1_000_000).toInt()/CodecFixture.gop*CodecFixture.gop }
|
||||
fun readSampleData(buffer: ByteBuffer,offset: Int): Int = if (frame >= (timeline?.size ?: CodecFixture.frames)) -1 else 1
|
||||
|
||||
@@ -11,7 +11,8 @@ class MediaPlayer {
|
||||
var isLooping = false; val looping get() = isLooping
|
||||
var volume = 1f; var released = false; var started = false
|
||||
val videoWidth = 480; val videoHeight = 848
|
||||
fun setSurface(surface: Surface) {}
|
||||
var videoSurface: Surface? = null
|
||||
fun setSurface(surface: Surface?) { videoSurface=surface }
|
||||
fun setVolume(left: Float,right: Float) { volume = left }
|
||||
fun setDataSource(fd: java.io.FileDescriptor, offset: Long,length: Long) {}
|
||||
fun setOnPreparedListener(callback: (MediaPlayer)->Unit) { prepared = callback }
|
||||
|
||||
@@ -37,6 +37,7 @@ fun actualMediaViewCheck() {
|
||||
fun rig(index: EmotionActionIndex=mediaFixtureIndex()): Triple<EmotionActionAvatarView,AvatarMediaBinding,MutableList<VideoPresentation>> {
|
||||
index.packages.values.forEach { CodecFixture.timelines[it.root+it.body.path]=it.body.ptsUs }
|
||||
index.edges.filterNot { it.nativeLoop }.forEach { CodecFixture.timelines[(it.mouthRuntime?.root ?: index.root)+(it.mouthRuntime?.body?.path ?: it.clip.path)]=it.clip.ptsUs }
|
||||
index.actionPack?.assets?.mapNotNull { it.media }?.forEach { CodecFixture.timelines[it.root+it.path]=it.ptsUs;CodecFixture.audioPaths.add(it.root+it.path) }
|
||||
val binding=AvatarMediaBinding();binding.beginTurn(7)
|
||||
val reports=mutableListOf<VideoPresentation>()
|
||||
val view=EmotionActionAvatarView(android.content.Context(),AvatarPack(fallback="fixture.png",emotionAction=index),binding,reports::add)
|
||||
@@ -113,11 +114,11 @@ fun actualMediaViewCheck() {
|
||||
stopped!!(true);val movie=MediaPlayer.created.single()
|
||||
check(!movie.started);movie.prepared!!(movie)
|
||||
TestScheduler.until { movie.started }
|
||||
check(trace.last().clipId.startsWith("f96_") && trace.last().actual=="action");cases++
|
||||
check(trace.any { it.clipId.startsWith("f96_") && it.actual=="action" } && trace.last().actual=="action_first_frame");cases++
|
||||
val textures=actionView.children.filterIsInstance<TextureView>()
|
||||
fun latch(pts: Long) { val texture=checkNotNull(textures[3].surfaceTexture);texture.timestamp=pts*1000
|
||||
textures[3].surfaceTextureListener!!.onSurfaceTextureUpdated(texture) }
|
||||
check(textures[3].alpha==0f);latch(0);check(textures[3].alpha==1f);cases++
|
||||
check(textures[3].alpha==1f);latch(0);check(textures[3].alpha==1f);cases++
|
||||
when(mode) {
|
||||
"complete","late_final_frame" -> {
|
||||
index.actionPack!!.assets.first().media!!.ptsUs.drop(1).dropLast(if(mode=="late_final_frame") 1 else 0).forEach(::latch)
|
||||
@@ -145,7 +146,7 @@ fun actualMediaViewCheck() {
|
||||
val base=mediaFixtureIndex()
|
||||
val original=base.actionPack!!.assets.first()
|
||||
val media=original.media!!.copy(ptsUs=List(241) { it*1_000_000L/24 },durationUs=10_041_667,
|
||||
sourceFrame=0,returnFrame=96)
|
||||
sourceFrame=0,returnFrame=96,audioEndUs=10_000_000)
|
||||
val asset=original.copy(durationMs=10_042,media=media)
|
||||
val index=base.copy(actionPack=base.actionPack.copy(assets=listOf(asset,asset.copy(id="asset_02"))))
|
||||
val (v,b,trace)=rig(index)
|
||||
@@ -158,8 +159,8 @@ fun actualMediaViewCheck() {
|
||||
val textures=v.children.filterIsInstance<TextureView>()
|
||||
fun latch(pts: Long) { val t=textures[3].surfaceTexture!!;t.timestamp=pts*1000;textures[3].surfaceTextureListener!!.onSurfaceTextureUpdated(t) }
|
||||
val owner=driverField.get(v) as ConversationMediaDriver
|
||||
// Delayed first frame leaves the last valid body visible, with ACTION owning it.
|
||||
TestScheduler.advanceBy(80);check(owner.layerOwner==ConversationMediaDriver.LayerOwner.ACTION && textures[3].alpha==0f);cases++
|
||||
// First source frame was decoded+latched and held before native audio could start.
|
||||
TestScheduler.advanceBy(80);check(owner.layerOwner==ConversationMediaDriver.LayerOwner.ACTION && textures[3].alpha==1f);cases++
|
||||
latch(0);TestScheduler.advanceBy(21)
|
||||
check(textures[3].alpha==1f && textures.take(3).all { it.alpha==0f } && player.started);cases++
|
||||
prepared(player) // Duplicated ready cannot start/reclaim again.
|
||||
|
||||
@@ -8,30 +8,51 @@ import android.graphics.SurfaceTexture
|
||||
fun playbackDiagnosticCheck() {
|
||||
var assertions=0
|
||||
val asset=mediaFixtureIndex().actionPack!!.assets.first()
|
||||
for(reason in listOf("first_frame_not_zero","timestamp_not_indexed","timestamp_regressed","native_error","native_ended_missing_final","duration_early")) {
|
||||
TestScheduler.reset();MediaPlayer.created.clear()
|
||||
// Exact device report: compositor output clock jumped from0 to47,741,893,941us.
|
||||
// Reproduce the old failure independently, then pass that same output sequence
|
||||
// through the production adapter while source codec frames remain exact.
|
||||
val reported=listOf(0L,47_741_893_941_000L,47_742_026_182_000L)
|
||||
check(reported.drop(1).none { ts->asset.media!!.ptsUs.any { kotlin.math.abs(it-ts/1000)<=2 } });assertions++
|
||||
for(mode in listOf("report_clock","early_audio_end","native_error","wrong_codec_pts","missing_audio_end","cancel")) {
|
||||
TestScheduler.reset();android.media.CodecFixture.reset();MediaPlayer.created.clear()
|
||||
val media=asset.media!!
|
||||
android.media.CodecFixture.emitNativeSurface=true
|
||||
android.media.CodecFixture.timelines[media.root+media.path]=media.ptsUs
|
||||
android.media.CodecFixture.audioPaths.add(media.root+media.path)
|
||||
if(mode=="wrong_codec_pts") android.media.CodecFixture.timestampOffsetUs=10_000
|
||||
val view=TextureView(android.content.Context());val messages=mutableListOf<String>()
|
||||
val port=AndroidMusicPort(android.content.Context(),view,messages::add)
|
||||
var ready=false;var first=0;var ended=0;var failures=0
|
||||
port.prepare(asset.media!!,{ready=true},{first++},{ended++},{failures++})
|
||||
val native=MediaPlayer.created.last();native.prepared!!(native);check(ready);assertions++
|
||||
port.start();native.info!!(native,MediaPlayer.MEDIA_INFO_VIDEO_RENDERING_START,0)
|
||||
check(first==0 && ended==0);assertions++ // Info does not claim surface presentation.
|
||||
when(reason) {
|
||||
"first_frame_not_zero"->port.latched(asset.media.ptsUs[1]*1000)
|
||||
"timestamp_not_indexed"->port.latched(123456789)
|
||||
"timestamp_regressed"->{port.latched(0);port.latched(asset.media.ptsUs[1]*1000);port.latched(0)}
|
||||
"native_error"->native.error!!(native,1,2)
|
||||
"native_ended_missing_final"->{port.latched(0);native.completion!!(native);TestScheduler.advanceBy(2001)}
|
||||
"duration_early"->{port.latched(0);port.latched(asset.media.ptsUs.last()*1000);native.completion!!(native)}
|
||||
port.prepare(media,{ready=true},{first++},{ended++},{failures++})
|
||||
val native=MediaPlayer.created.last();native.prepared!!(native)
|
||||
TestScheduler.until { ready || failures>0 }
|
||||
if(mode=="wrong_codec_pts") {
|
||||
check(!ready && failures==1 && messages.any { "event=video_decoder_or_gl " in it });assertions++
|
||||
} else {
|
||||
check(ready && first==0 && native.videoSurface==null);assertions++
|
||||
native.info!!(native,MediaPlayer.MEDIA_INFO_VIDEO_RENDERING_START,0);check(first==0);assertions++
|
||||
port.start();check(first==1 && native.started);assertions++
|
||||
reported.forEach(port::latched)
|
||||
check(failures==0 && ended==0);assertions++
|
||||
when(mode) {
|
||||
"report_clock","early_audio_end" -> {
|
||||
if(mode=="early_audio_end") {
|
||||
native.completion!!(native);check(failures==1 && ended==0);assertions++
|
||||
} else {
|
||||
TestScheduler.advanceBy(1200);check(ended==0);assertions++
|
||||
native.completion!!(native)
|
||||
check(ended==1 && failures==0 && messages.any { "event=final_codec_frame " in it });assertions++
|
||||
}
|
||||
}
|
||||
"native_error" -> { native.error!!(native,1,2);check(failures==1 && ended==0);assertions++ }
|
||||
"missing_audio_end" -> { TestScheduler.advanceBy(3300);check(failures==1 && ended==0);assertions++ }
|
||||
}
|
||||
}
|
||||
check(failures==1 && ended==0 && messages.any { "event=$reason " in it });assertions++
|
||||
port.latched(123456789);port.latched(asset.media.ptsUs.last()*1000);TestScheduler.advanceBy(1001);native.completion!!(native)
|
||||
check(failures==1 && ended==0);assertions++ // No error flood.
|
||||
var release=0;port.close { release++ };TestScheduler.advanceBy(1)
|
||||
check(native.released && release==1 && messages.last().contains("event=released"));assertions++
|
||||
native.prepared!!(native);native.info!!(native,3,0);native.completion!!(native);native.error!!(native,1,2)
|
||||
check(failures==1 && ended==0);assertions++ // Old native callbacks fenced.
|
||||
val prior=ended;reported.forEach(port::latched);TestScheduler.advanceBy(100)
|
||||
check(ended==prior && release==1);assertions++
|
||||
}
|
||||
class Player: ActionPlayer {
|
||||
lateinit var end: (ActionEnd)->Unit;lateinit var failure: ()->Unit;lateinit var release: ()->Unit
|
||||
@@ -61,6 +82,7 @@ fun playbackDiagnosticCheck() {
|
||||
val index=mediaFixtureIndex()
|
||||
index.packages.values.forEach { android.media.CodecFixture.timelines[it.root+it.body.path]=it.body.ptsUs }
|
||||
index.edges.mapNotNull { it.mouthRuntime }.forEach { android.media.CodecFixture.timelines[it.root+it.body.path]=it.body.ptsUs }
|
||||
index.actionPack?.assets?.mapNotNull { it.media }?.forEach { android.media.CodecFixture.timelines[it.root+it.path]=it.ptsUs;android.media.CodecFixture.audioPaths.add(it.root+it.path) }
|
||||
val binding=AvatarMediaBinding();val view=EmotionActionAvatarView(android.content.Context(),AvatarPack(fallback="fixture.png",emotionAction=index),binding) {}
|
||||
view.render(true);TestScheduler.advanceBy(1)
|
||||
val local=OfflineDancePreview(index.actionPack,binding,{TestScheduler.now})
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
import com.gorios.lanvoice.avatar.*
|
||||
import android.os.TestScheduler
|
||||
import android.media.CodecFixture
|
||||
import android.media.MediaPlayer
|
||||
import android.view.TextureView
|
||||
|
||||
/** Fixed numeric metadata from code20 offline report, no user media or conversation. */
|
||||
fun reportedActionClockCheck() {
|
||||
var checks=0
|
||||
val base=mediaFixtureIndex().actionPack!!.assets.first().media!!
|
||||
val media=base.copy(ptsUs=List(241) { it*1_000_000L/24 },durationUs=10_041_667,audioEndUs=10_000_000)
|
||||
for(mode in listOf("report_first_zero","report_first_epoch","rounding_1us","invalid_codec_timebase","missing_source_zero","missing_source_final","cancel_late_callbacks")) {
|
||||
TestScheduler.reset();CodecFixture.reset();MediaPlayer.created.clear();CodecFixture.emitNativeSurface=true
|
||||
CodecFixture.audioPaths.add(media.root+media.path)
|
||||
CodecFixture.timelines[media.root+media.path]=when(mode) {
|
||||
"missing_source_zero"->media.ptsUs.drop(1)
|
||||
"missing_source_final"->media.ptsUs.dropLast(1)
|
||||
else->media.ptsUs
|
||||
}
|
||||
CodecFixture.timestampOffsetUs=when(mode) { "rounding_1us"->1;"invalid_codec_timebase"->47_741_893_941;else->0 }
|
||||
val output=TextureView(android.content.Context());val messages=mutableListOf<String>()
|
||||
val port=AndroidMusicPort(android.content.Context(),output,messages::add)
|
||||
var ready=false;var first=0;var end=0;var failures=0
|
||||
port.prepare(media,{ready=true},{first++},{end++},{failures++})
|
||||
val audio=MediaPlayer.created.single();audio.prepared!!(audio)
|
||||
port.latched(0);audio.info!!(audio,MediaPlayer.MEDIA_INFO_VIDEO_RENDERING_START,0)
|
||||
check(first==0 && end==0);checks++ // Neither output timestamp nor info grants source entry.
|
||||
TestScheduler.until { ready || failures>0 }
|
||||
if(mode in setOf("invalid_codec_timebase","missing_source_zero")) {
|
||||
check(!ready && failures==1 && end==0);checks++
|
||||
} else {
|
||||
check(ready && audio.videoSurface==null && first==0) { "mode=$mode ready=$ready failures=$failures" };checks++
|
||||
port.start();check(first==1);checks++
|
||||
if(mode=="cancel_late_callbacks") {
|
||||
val stale=audio.completion!!;var releases=0
|
||||
TestScheduler.advanceBy(249);port.latched(47_741_893_941_000)
|
||||
port.close { releases++ };TestScheduler.advanceBy(1)
|
||||
stale(audio);audio.error!!(audio,1,2);TestScheduler.advanceBy(11_000)
|
||||
check(releases==1 && end==0 && failures==0 && audio.released);checks++
|
||||
} else {
|
||||
repeat(241) { i->
|
||||
// An EGL output update can skip, use0, an epoch clock, ns, or a repeated value.
|
||||
// None may be relabelled as a source frame or satisfy completion.
|
||||
TestScheduler.advanceBy(42)
|
||||
port.latched(when {
|
||||
mode=="report_first_zero" && i==0->0
|
||||
i==0->47_742_026_182_000
|
||||
i%17==0->0
|
||||
i%13==0->41_666_000
|
||||
else->47_741_893_941_000+i*41_666_000L
|
||||
})
|
||||
if(mode!="missing_source_final") { check(failures==0 && end==0);checks++ }
|
||||
}
|
||||
if(mode=="missing_source_final") { check(failures==1 && end==0);checks++ }
|
||||
else {
|
||||
audio.currentPosition=10_042;audio.completion!!(audio)
|
||||
TestScheduler.until { end==1 || failures>0 }
|
||||
check(end==1 && failures==0 && messages.any { "event=final_codec_frame " in it && "frame=240 " in it && "pts_us=${10_000_000L+CodecFixture.timestampOffsetUs} " in it });checks++
|
||||
audio.completion!!(audio);check(end==1);checks++
|
||||
}
|
||||
}
|
||||
}
|
||||
var released=false;port.close { released=true };TestScheduler.advanceBy(1)
|
||||
check(released && audio.released);checks++
|
||||
}
|
||||
println("PASS: $checks production code20 report-clock replay/full241-source-frame/zero-epoch-output/1us-rounding/invalid-codec-timebase/missing-source-endpoint/native-end/cancel-release assertions; native Android/GPU not_run")
|
||||
}
|
||||
@@ -245,6 +245,17 @@ class PackageTests(unittest.TestCase):
|
||||
self.assertIn('-PavatarPlaybackDiagnostic=true',command)
|
||||
self.assertIn('-PactionVersionCode=20',command)
|
||||
|
||||
def test_clock_fix_requires_full_frozen_pin_and_fresh_version(self):
|
||||
with patch.object(pack,'tested_source'),patch.object(pack,'packaging_tests_current'),patch.object(pack,'read_json',return_value={'edges':[{'nativeLoop':True}]}),patch.object(pack,'next_version',return_value=21),patch.object(pack.subprocess,'run',side_effect=RuntimeError('build_sentinel')) as build:
|
||||
for full,pin,code in ((False,pack.RUNTIME_FIX_PIN,21),(True,'0'*64,21),(True,pack.RUNTIME_FIX_PIN,20)):
|
||||
with self.subTest(full=full,pin=pin,code=code),self.assertRaises(ValueError):
|
||||
pack.publish({'manifest_sha256':pin},self.base,code,full,False,False,True)
|
||||
build.assert_not_called()
|
||||
with self.assertRaisesRegex(RuntimeError,'build_sentinel'):
|
||||
pack.publish({'manifest_sha256':pack.RUNTIME_FIX_PIN},self.base,21,True,False,False,True)
|
||||
self.assertIn('-PavatarPlaybackClockFix=true',build.call_args.args[0])
|
||||
self.assertIn('-PactionVersionCode=21',build.call_args.args[0])
|
||||
|
||||
def test_cli_no_pin_no_import_no_output(self):
|
||||
self.manifest.write_text(json.dumps(self.index));out=self.base/'no-pin-output'
|
||||
result=subprocess.run([sys.executable,str(ROOT/'scripts/package-avatar-emotion.py'),
|
||||
|
||||
Reference in New Issue
Block a user