Support bridge-owned TALK layers and recover free P4a candidate

This commit is contained in:
zenord
2026-10-13 04:35:33 +08:00
parent fcc55b8370
commit a53600db92
22 changed files with 18696 additions and 43 deletions
+31 -2
View File
@@ -15,7 +15,8 @@ fun mediaFixtureIndex(): EmotionActionIndex {
val bridges=packs.map { (id,p)->ConversationEdge("$id-loop",id,id,p.body.frameCount-1,0,p.body,true) }+
listOf("happy","sad").flatMap { id->listOf("neutral" to id,id to "neutral").map { (from,to)->
ConversationEdge("$from-$to",from,to,packs.getValue(from).body.frameCount-1,0,
ContinuousBodyAsset("clips/$from-$to.mp4","f".repeat(64),480,848,3,125000,List(3) { it*1_000_000L/24 }))
ContinuousBodyAsset("clips/$from-$to.mp4","f".repeat(64),480,848,3,125000,List(3) { it*1_000_000L/24 }),
mouthRuntime=dynamicPack(3,24,"f".repeat(64)).copy(root="bridge-$from-$to/"))
} }
val musicPts=List(24) { it*1_000_000L/24 }
val actions=ReviewedActionPack("a".repeat(64),listOf("asset_01","asset_02").map {
@@ -35,7 +36,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[index.root+it.clip.path]=it.clip.ptsUs }
index.edges.filterNot { it.nativeLoop }.forEach { CodecFixture.timelines[(it.mouthRuntime?.root ?: index.root)+(it.mouthRuntime?.body?.path ?: it.clip.path)]=it.clip.ptsUs }
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)
@@ -49,6 +50,15 @@ fun actualMediaViewCheck() {
binding.prepare(mediaReply(RoleEmotion.HAPPY,seq=1));TestScheduler.advanceBy(200)
check(reports.none { it.actual=="body_happy" });cases++ // Header preloads hidden, never shows.
binding.intent(mediaReply(RoleEmotion.HAPPY,intensity=2),true)
TestScheduler.until { reports.last().actual=="bridge" || reports.last().actual=="media_failed" }
check(reports.last().actual=="bridge")
val actualRenderers=view.javaClass.getDeclaredField("renderers").apply { isAccessible=true }.get(view) as Array<*>
val bridgeRenderer=actualRenderers.filterNotNull().first { value ->
value.javaClass.getDeclaredField("pack").apply { isAccessible=true }.get(value).let { (it as ContinuousAvatarPack).root=="bridge-neutral-happy/" }
}
check(bridgeRenderer.javaClass.getDeclaredField("mouthEnabled").apply { isAccessible=true }.getBoolean(bridgeRenderer));cases++
check(bridgeRenderer.javaClass.getDeclaredField("sharedMouth").apply { isAccessible=true }.get(bridgeRenderer)!=null);cases++
check(binding.currentPackageId==null && binding.visualStatus=="bridge_own_mouth");cases++
TestScheduler.until { reports.any { it.actual=="body_happy" } || reports.any { it.actual=="media_failed" } }
check(reports.none { it.actual=="media_failed" }) { reports.takeLast(6).toString() }
val selected=(driver as ConversationMediaDriver).selection
@@ -128,6 +138,25 @@ fun actualMediaViewCheck() {
check(statuses.size==before);cases++
actionView.dispose();TestScheduler.advanceBy(100)
}
// Real renderer path over a25-frame own-mouth bridge, no loop or endpoint patches.
reset()
val ownBridge=dynamicPack(25,24,"f".repeat(64)).copy(root="bridge25/")
CodecFixture.timelines[ownBridge.root+ownBridge.body.path]=ownBridge.body.ptsUs
val clock=ConversationMouthClock();val prior=Any()
clock.intent(prior,ownBridge.curves,true,1,1,0);clock.sample(prior,0)
TestScheduler.advanceBy(600);val priorPhase=clock.sample(prior,600).phase
val composed=mutableListOf<ComposedBodyFrame>();var ended=false;val failures=mutableListOf<String>()
val renderer=ContinuousBodyRenderer(android.content.Context(),ownBridge,android.view.Surface(android.graphics.SurfaceTexture(5)),480,848,
{ frame,_->composed.add(frame) },failures::add,mayLoop=false,sharedMouth=clock,ended={ended=true})
renderer.intent(true,1,2)
TestScheduler.until { ended || failures.isNotEmpty() }
check(failures.isEmpty() && ended && composed.map { it.key.index }==(0..24).toList());cases++
check(composed.first().mouth.phase==priorPhase && composed.none { it.mouth.phase=="opening" });cases++
check(composed.all { it.patch===ownBridge.patches[it.key.index] && it.key.loopOrdinal==0L &&
it.selection.textureSlot/5==it.key.index });cases++
check(composed.any { it.selection.opacity==1f } && GLFixture.rendered.any { it.second==1f });cases++
renderer.close();TestScheduler.advanceBy(50)
check(GLFixture.deleted>=126 && CodecFixture.releases==1);cases++
CodecFixture.reset();MediaPlayer.created.clear()
println("PASS: $cases actual EmotionActionAvatarView/binding/held GLES renderer/MediaPlayer callback cases: hidden header/final mismatch, final slight,97→49→121 and24→30fps/native loops, real bridge frames/latest turn, settings continuity, mic-confirm/cancel-pending/failure gate, safe exit/music first+last PTS/native end/release/idle-A, completion order, cancel/error/background/stale callbacks; deterministic Android doubles, device/naturalness not_run")
}