Add bounded native playback diagnostics and sensor-free dance inspection
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 avatarUiCandidate = providers.gradleProperty('avatarUiCandidate').orNull == 'true'
|
||||||
def avatarMouthCandidate = providers.gradleProperty('avatarMouthCandidate').orNull == 'true'
|
def avatarMouthCandidate = providers.gradleProperty('avatarMouthCandidate').orNull == 'true'
|
||||||
def avatarActionCandidate = providers.gradleProperty('avatarActionCandidate').orNull == 'true'
|
def avatarActionCandidate = providers.gradleProperty('avatarActionCandidate').orNull == 'true'
|
||||||
|
def avatarPlaybackDiagnostic = providers.gradleProperty('avatarPlaybackDiagnostic').orNull == 'true'
|
||||||
def avatarRuntimeFix = providers.gradleProperty('avatarRuntimeFix').orNull == 'true'
|
def avatarRuntimeFix = providers.gradleProperty('avatarRuntimeFix').orNull == 'true'
|
||||||
def avatarFullActionCandidate = providers.gradleProperty('avatarFullActionCandidate').orNull == 'true'
|
def avatarFullActionCandidate = providers.gradleProperty('avatarFullActionCandidate').orNull == 'true'
|
||||||
def actionVersionCode = (providers.gradleProperty('actionVersionCode').orNull ?: '16').toInteger()
|
def actionVersionCode = (providers.gradleProperty('actionVersionCode').orNull ?: '16').toInteger()
|
||||||
@@ -35,6 +36,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 && !(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 (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 (avatarFullActionCandidate && (!emotionManifestSha || !avatarActionCandidate || actionVersionCode < 18)) throw new GradleException('Full candidate requires pinned emotion/action graph and fresh code >=18')
|
||||||
|
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 (avatarRuntimeFix && (!avatarFullActionCandidate || actionVersionCode < 19)) throw new GradleException('Runtime fix requires full pinned graph and fresh code >=19')
|
||||||
if (avatarNatural && !(naturalManifestSha ==~ /[0-9a-f]{64}/)) {
|
if (avatarNatural && !(naturalManifestSha ==~ /[0-9a-f]{64}/)) {
|
||||||
throw new GradleException('Natural debug candidate requires exact runtime manifest SHA')
|
throw new GradleException('Natural debug candidate requires exact runtime manifest SHA')
|
||||||
@@ -84,7 +86,7 @@ android {
|
|||||||
targetSdk 34
|
targetSdk 34
|
||||||
testInstrumentationRunner 'com.gorios.lanvoice.AvatarCleanUiInstrumentation'
|
testInstrumentationRunner 'com.gorios.lanvoice.AvatarCleanUiInstrumentation'
|
||||||
versionCode avatarActionCandidate ? actionVersionCode : (avatarMouthCandidate ? 15 : (avatarUiCandidate ? 14 : (avatarNatural ? 13 : 12)))
|
versionCode avatarActionCandidate ? actionVersionCode : (avatarMouthCandidate ? 15 : (avatarUiCandidate ? 14 : (avatarNatural ? 13 : 12)))
|
||||||
versionName = avatarRuntimeFix ? '0.7.1' : (avatarActionCandidate ? '0.7.0' : ((avatarUiCandidate || avatarMouthCandidate) ? '0.6.2' : '0.6.1'))
|
versionName = avatarPlaybackDiagnostic ? '0.7.2' : avatarRuntimeFix ? '0.7.1' : (avatarActionCandidate ? '0.7.0' : ((avatarUiCandidate || avatarMouthCandidate) ? '0.6.2' : '0.6.1'))
|
||||||
ndk { abiFilters 'arm64-v8a' }
|
ndk { abiFilters 'arm64-v8a' }
|
||||||
}
|
}
|
||||||
compileOptions { sourceCompatibility JavaVersion.VERSION_17; targetCompatibility JavaVersion.VERSION_17 }
|
compileOptions { sourceCompatibility JavaVersion.VERSION_17; targetCompatibility JavaVersion.VERSION_17 }
|
||||||
|
|||||||
@@ -60,6 +60,7 @@ class MainActivity : ComponentActivity() {
|
|||||||
private lateinit var expressions: ExpressionController
|
private lateinit var expressions: ExpressionController
|
||||||
private var inForeground = false
|
private var inForeground = false
|
||||||
private var offlineAvatarPreview = false
|
private var offlineAvatarPreview = false
|
||||||
|
private var openingOffline = false
|
||||||
private val cameraPermission = registerForActivityResult(ActivityResultContracts.RequestPermission()) { granted ->
|
private val cameraPermission = registerForActivityResult(ActivityResultContracts.RequestPermission()) { granted ->
|
||||||
permissionResult(EntryPermission.CAMERA, granted)
|
permissionResult(EntryPermission.CAMERA, granted)
|
||||||
}
|
}
|
||||||
@@ -155,7 +156,7 @@ class MainActivity : ComponentActivity() {
|
|||||||
entry=AutoConversation(preferences().getBoolean("micAsked",false),preferences().getBoolean("camAsked",false),
|
entry=AutoConversation(preferences().getBoolean("micAsked",false),preferences().getBoolean("camAsked",false),
|
||||||
conversationEnabled=false,automaticPermissions=false)
|
conversationEnabled=false,automaticPermissions=false)
|
||||||
setContent { EngineeringPreviewScreen(avatarPack,micGranted,cameraGranted,micSettings,cameraSettings,
|
setContent { EngineeringPreviewScreen(avatarPack,micGranted,cameraGranted,micSettings,cameraSettings,
|
||||||
permissionPending,::authorizeMicrophone,::authorizeCamera) }
|
permissionPending,::authorizeMicrophone,::authorizeCamera,avatarMedia,::sendDiagnosticReport,reportSending,reportResult) }
|
||||||
return // No VoiceSession/audio focus/camera controller; manual permission consent only.
|
return // No VoiceSession/audio focus/camera controller; manual permission consent only.
|
||||||
}
|
}
|
||||||
audioOutput = AudioOutputGate(this) { session.outputUnavailable("播放被系统音频占用打断,请重新开始") }
|
audioOutput = AudioOutputGate(this) { session.outputUnavailable("播放被系统音频占用打断,请重新开始") }
|
||||||
@@ -202,6 +203,16 @@ class MainActivity : ComponentActivity() {
|
|||||||
micGranted,cameraGranted,permissionPending,::authorizeCamera,
|
micGranted,cameraGranted,permissionPending,::authorizeCamera,
|
||||||
onCancelAction = session::cancelAction,
|
onCancelAction = session::cancelAction,
|
||||||
mediaBinding = avatarMedia,
|
mediaBinding = avatarMedia,
|
||||||
|
onOfflinePreview = {
|
||||||
|
if(!openingOffline) {
|
||||||
|
openingOffline=true;closeCamera()
|
||||||
|
session.suspendForLocalPreview { safe ->
|
||||||
|
openingOffline=false
|
||||||
|
if(safe && inForeground && !isDestroyed) startActivity(android.content.Intent(this,MainActivity::class.java).putExtra(OfflineAvatarTrace.EXTRA,true))
|
||||||
|
else reportResult="录音停止未确认,暂不进入离线播放检查"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -224,8 +235,8 @@ class MainActivity : ComponentActivity() {
|
|||||||
cameraStatus = expressionState.status,
|
cameraStatus = expressionState.status,
|
||||||
cameraPermissionPending = entry.permissionPending == EntryPermission.CAMERA,
|
cameraPermissionPending = entry.permissionPending == EntryPermission.CAMERA,
|
||||||
faceSharing = shareFace,
|
faceSharing = shareFace,
|
||||||
cameraAnalysis = expressions.diagnosticsSnapshot(),
|
cameraAnalysis = if(offlineAvatarPreview) com.gorios.lanvoice.expression.CameraAnalysisSnapshot() else expressions.diagnosticsSnapshot(),
|
||||||
faceTransmission = session.faceDiagnosticsSnapshot(),
|
faceTransmission = if(offlineAvatarPreview) com.gorios.lanvoice.expression.FaceTransmissionSnapshot() else session.faceDiagnosticsSnapshot(),
|
||||||
rolePlaying = state.phase == VoicePhase.ANSWERING,
|
rolePlaying = state.phase == VoicePhase.ANSWERING,
|
||||||
role = state.replyEmotion.takeIf { it.turnId != null },
|
role = state.replyEmotion.takeIf { it.turnId != null },
|
||||||
previousRole = state.previousReplyEmotion,
|
previousRole = state.previousReplyEmotion,
|
||||||
|
|||||||
@@ -126,10 +126,18 @@ class VoiceSession(
|
|||||||
},
|
},
|
||||||
onActivity = { activity ->
|
onActivity = { activity ->
|
||||||
main.post {
|
main.post {
|
||||||
if (isActive() && !actions.active && playbackIsCurrent(activity.turnId, activity.generation) &&
|
val reason=when {
|
||||||
currentTurn == activity.turnId && blockedTurn != activity.turnId && emotionEndedTurn != activity.turnId) {
|
!isActive()->"inactive"
|
||||||
update(state.copy(playbackActivity = activity))
|
actions.active->"action_owner"
|
||||||
|
!playbackIsCurrent(activity.turnId,activity.generation)->"stale_generation"
|
||||||
|
currentTurn!=activity.turnId->"old_turn"
|
||||||
|
blockedTurn==activity.turnId->"blocked"
|
||||||
|
emotionEndedTurn==activity.turnId->"drained"
|
||||||
|
else->"accepted"
|
||||||
}
|
}
|
||||||
|
com.gorios.lanvoice.diag.DiagnosticLog.state("talk_gate","$reason/${activity.turnId}/${activity.generation}/${activity.audible}",
|
||||||
|
"reason=$reason turn=${activity.turnId} generation=${activity.generation} audible=${activity.audible} head=${activity.playedSamples} written=${activity.writtenSamples}")
|
||||||
|
if(reason=="accepted") update(state.copy(playbackActivity = activity))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
@@ -164,7 +172,7 @@ class VoiceSession(
|
|||||||
checkMainThread()
|
checkMainThread()
|
||||||
clearFaceContext()
|
clearFaceContext()
|
||||||
foreground = false
|
foreground = false
|
||||||
stopVoice(sendControls = keepConnectionForPermission)
|
stopVoice(sendControls = keepConnectionForPermission,cancelReason = "background")
|
||||||
backgroundTimeout?.let { main.removeCallbacks(it) }
|
backgroundTimeout?.let { main.removeCallbacks(it) }
|
||||||
backgroundTimeout = null
|
backgroundTimeout = null
|
||||||
DebugLogUpload.log("connect", "session background permission=$keepConnectionForPermission")
|
DebugLogUpload.log("connect", "session background permission=$keepConnectionForPermission")
|
||||||
@@ -184,6 +192,21 @@ class VoiceSession(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Explicit local inspection leaves voice first, then waits for real recorder cleanup.
|
||||||
|
* No microphone-safe flag is invented by the offline player. */
|
||||||
|
fun suspendForLocalPreview(confirmed: (Boolean)->Unit) {
|
||||||
|
checkMainThread();background()
|
||||||
|
val fence=captureEpoch;var acknowledged=false
|
||||||
|
capture.stopAndConfirm { stopped -> main.post {
|
||||||
|
if(!acknowledged) {
|
||||||
|
acknowledged=true
|
||||||
|
val safe=stopped && captureEpoch==fence && !foreground && !released
|
||||||
|
diagnostic("offline_capture state=${if(safe) "stop_confirmed" else "stop_unconfirmed"} epoch=$fence")
|
||||||
|
confirmed(safe)
|
||||||
|
}
|
||||||
|
} }
|
||||||
|
}
|
||||||
|
|
||||||
fun release() {
|
fun release() {
|
||||||
checkMainThread()
|
checkMainThread()
|
||||||
if (released) return
|
if (released) return
|
||||||
@@ -205,9 +228,9 @@ class VoiceSession(
|
|||||||
startCapture()
|
startCapture()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun stopVoice(sendControls: Boolean = true) {
|
fun stopVoice(sendControls: Boolean = true,cancelReason: String = "stop_voice") {
|
||||||
checkMainThread()
|
checkMainThread()
|
||||||
actions.cancel()
|
cancelActionFor(cancelReason)
|
||||||
resetReply("stop")
|
resetReply("stop")
|
||||||
val wasActive = state.voiceActive
|
val wasActive = state.voiceActive
|
||||||
stopCapture()
|
stopCapture()
|
||||||
@@ -261,7 +284,11 @@ class VoiceSession(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun cancelAction() { checkMainThread(); actions.cancel() }
|
private fun cancelActionFor(reason: String) {
|
||||||
|
if(actions.active) com.gorios.lanvoice.diag.DiagnosticLog.state("action_cancel","$reason/$currentTurn","reason=$reason turn=$currentTurn")
|
||||||
|
actions.cancel()
|
||||||
|
}
|
||||||
|
fun cancelAction() { checkMainThread(); cancelActionFor("settings_cancel") }
|
||||||
|
|
||||||
fun permissionDenied() {
|
fun permissionDenied() {
|
||||||
checkMainThread()
|
checkMainThread()
|
||||||
@@ -271,7 +298,7 @@ class VoiceSession(
|
|||||||
fun outputUnavailable(message: String) {
|
fun outputUnavailable(message: String) {
|
||||||
checkMainThread()
|
checkMainThread()
|
||||||
if (state.voiceActive) {
|
if (state.voiceActive) {
|
||||||
stopVoice()
|
stopVoice(cancelReason = "audio_focus_unavailable")
|
||||||
update(state.copy(guidance = message))
|
update(state.copy(guidance = message))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -334,7 +361,7 @@ class VoiceSession(
|
|||||||
private fun onConnection(connection: ConnectionStatus, reason: String) {
|
private fun onConnection(connection: ConnectionStatus, reason: String) {
|
||||||
diagnostic("connection ${state.connection.name} -> ${connection.name} reason=$reason", "connect")
|
diagnostic("connection ${state.connection.name} -> ${connection.name} reason=$reason", "connect")
|
||||||
if (connection != ConnectionStatus.CONNECTED) {
|
if (connection != ConnectionStatus.CONNECTED) {
|
||||||
actions.cancel()
|
cancelActionFor("disconnect")
|
||||||
onPrepareExpression(null)
|
onPrepareExpression(null)
|
||||||
resetReply("disconnect")
|
resetReply("disconnect")
|
||||||
faceSupported = false
|
faceSupported = false
|
||||||
@@ -417,7 +444,7 @@ class VoiceSession(
|
|||||||
}
|
}
|
||||||
if (event.kind == EventKind.ACTION) {
|
if (event.kind == EventKind.ACTION) {
|
||||||
if (!isActive() || !hasTurn || turn != currentTurn) { diagnostic("action_plan state=ignored_turn_or_inactive turn=$turn");return }
|
if (!isActive() || !hasTurn || turn != currentTurn) { diagnostic("action_plan state=ignored_turn_or_inactive turn=$turn");return }
|
||||||
if (event.type == "action.cancel") actions.cancel()
|
if (event.type == "action.cancel") cancelActionFor("server_cancel")
|
||||||
else if (event.type == "action.plan") {
|
else if (event.type == "action.plan") {
|
||||||
val id = event.payload.optString("action_id")
|
val id = event.payload.optString("action_id")
|
||||||
val ttl = (event.payload.opt("ttl_ms") as? Number)?.toLong() ?: 0L
|
val ttl = (event.payload.opt("ttl_ms") as? Number)?.toLong() ?: 0L
|
||||||
@@ -538,7 +565,7 @@ class VoiceSession(
|
|||||||
}
|
}
|
||||||
// IDs identify turns; do not assume the server allocates them in numeric order.
|
// IDs identify turns; do not assume the server allocates them in numeric order.
|
||||||
if (!hasTurn || id != currentTurn) {
|
if (!hasTurn || id != currentTurn) {
|
||||||
actions.cancel()
|
cancelActionFor("new_turn")
|
||||||
onPrepareExpression(null)
|
onPrepareExpression(null)
|
||||||
resetReply("new_turn")
|
resetReply("new_turn")
|
||||||
val resumeCapture = capturing
|
val resumeCapture = capturing
|
||||||
|
|||||||
@@ -1,13 +1,26 @@
|
|||||||
package com.gorios.lanvoice.avatar
|
package com.gorios.lanvoice.avatar
|
||||||
|
|
||||||
import com.gorios.lanvoice.dialogue.ReplyEmotion
|
import com.gorios.lanvoice.dialogue.ReplyEmotion
|
||||||
|
import com.gorios.lanvoice.diag.DiagnosticLog
|
||||||
|
|
||||||
/** One Activity-owned binding shared by VoiceSession and its persistent avatar view. */
|
/** One Activity-owned binding shared by VoiceSession and its persistent avatar view. */
|
||||||
class AvatarMediaBinding : ActionPlayer {
|
class AvatarMediaBinding : ActionPlayer {
|
||||||
val currentPackageId: String? get() = driver?.currentPackageId
|
val currentPackageId: String? get() = driver?.currentPackageId
|
||||||
val visualStatus: String get() = driver?.visualStatus ?: "renderer_unavailable"
|
val visualStatus: String get() = driver?.visualStatus ?: "renderer_unavailable"
|
||||||
val diagnosticState: String get() = driver?.diagnosticState ?: "owner=stopped renderer=unavailable"
|
val diagnosticState: String get() = (driver?.diagnosticState ?: "owner=stopped renderer=unavailable")+" $nativeMusic $mouthPresentation"
|
||||||
val selection: RoleVisualSelection? get() = driver?.selection
|
val selection: RoleVisualSelection? get() = driver?.selection
|
||||||
|
private var nativeMusic="music=unavailable"
|
||||||
|
private var visibleSlot: Int?=null
|
||||||
|
private val presentations=mutableMapOf<Int,String>()
|
||||||
|
private val mouthPresentation: String get() = visibleSlot?.let { presentations[it] } ?: "mouth=off"
|
||||||
|
fun visible(slot: Int?) { visibleSlot=slot }
|
||||||
|
fun musicDiagnostic(value: String) { nativeMusic=value }
|
||||||
|
fun presented(slot: Int,value: ComposedBodyFrame) {
|
||||||
|
val sample="slot=$slot mouth_phase=${value.mouth.phase} aperture=${value.mouth.alpha} level=${value.selection.levelIndex ?: -1} opacity=${value.selection.opacity} frame=${value.key.index} loop=${value.key.loopOrdinal} pts_us=${value.key.ptsUs} mouth_generation=${value.mouth.generation}"
|
||||||
|
// Frame/level changes are sampled, never the ring signature. Swap callback, not GPU visibility proof.
|
||||||
|
presentations[slot]=sample
|
||||||
|
if(visibleSlot==slot) DiagnosticLog.state("mouth_presented","$slot/${value.mouth.phase}/${value.mouth.generation}",sample)
|
||||||
|
}
|
||||||
private var driver: ConversationMediaDriver?=null
|
private var driver: ConversationMediaDriver?=null
|
||||||
private var prepared: ReplyEmotion?=null
|
private var prepared: ReplyEmotion?=null
|
||||||
private var reply: ReplyEmotion?=null
|
private var reply: ReplyEmotion?=null
|
||||||
|
|||||||
@@ -34,6 +34,8 @@ import com.gorios.lanvoice.expression.ExpressionStatus
|
|||||||
import com.gorios.lanvoice.expression.ExpressionUiState
|
import com.gorios.lanvoice.expression.ExpressionUiState
|
||||||
import com.gorios.lanvoice.BuildConfig
|
import com.gorios.lanvoice.BuildConfig
|
||||||
|
|
||||||
|
private val NoUiAction: ()->Unit = {}
|
||||||
|
|
||||||
/** The avatar always occupies the same composition slot. Opening/closing the sheet
|
/** The avatar always occupies the same composition slot. Opening/closing the sheet
|
||||||
* only changes chrome, never a lifecycle/voice/decoder key or renderer instance. */
|
* only changes chrome, never a lifecycle/voice/decoder key or renderer instance. */
|
||||||
@OptIn(ExperimentalMaterial3Api::class)
|
@OptIn(ExperimentalMaterial3Api::class)
|
||||||
@@ -79,6 +81,7 @@ fun CallScreen(state: VoiceUiState,entry: EntryPhase,permissionMessage: String?,
|
|||||||
micGranted: Boolean,cameraGranted: Boolean,permissionPending: EntryPermission?,onAuthorizeCamera: ()->Unit,
|
micGranted: Boolean,cameraGranted: Boolean,permissionPending: EntryPermission?,onAuthorizeCamera: ()->Unit,
|
||||||
onCancelAction: ()->Unit,
|
onCancelAction: ()->Unit,
|
||||||
mediaBinding: AvatarMediaBinding?=null,
|
mediaBinding: AvatarMediaBinding?=null,
|
||||||
|
onOfflinePreview: ()->Unit=NoUiAction,
|
||||||
) {
|
) {
|
||||||
val avatar=remember { AvatarController() }.select(state.voiceActive,state.replyEmotion,state.playbackActivity.takeUnless { state.actionActive })
|
val avatar=remember { AvatarController() }.select(state.voiceActive,state.replyEmotion,state.playbackActivity.takeUnless { state.actionActive })
|
||||||
val latestAvatar by rememberUpdatedState(avatar)
|
val latestAvatar by rememberUpdatedState(avatar)
|
||||||
@@ -133,6 +136,7 @@ fun CallScreen(state: VoiceUiState,entry: EntryPhase,permissionMessage: String?,
|
|||||||
Text("视觉选择:${mediaBinding?.selection?.let { "${it.visualEmotion.wire}/${it.visualIntensity}" } ?: "未选择"} · ${mediaBinding?.visualStatus ?: "旧中立素材"}",fontSize=12.sp)
|
Text("视觉选择:${mediaBinding?.selection?.let { "${it.visualEmotion.wire}/${it.visualIntensity}" } ?: "未选择"} · ${mediaBinding?.visualStatus ?: "旧中立素材"}",fontSize=12.sp)
|
||||||
if(pack?.emotionAction!=null) Text("整合候选 · 动态自然度、音乐听审及真机未测;表达可能等待 2–4 秒出口和约 1 秒过渡",fontSize=12.sp)
|
if(pack?.emotionAction!=null) Text("整合候选 · 动态自然度、音乐听审及真机未测;表达可能等待 2–4 秒出口和约 1 秒过渡",fontSize=12.sp)
|
||||||
Text("版本 ${com.gorios.lanvoice.BuildConfig.VERSION_NAME} · code ${com.gorios.lanvoice.BuildConfig.VERSION_CODE} · pin ${com.gorios.lanvoice.BuildConfig.EMOTION_MANIFEST_SHA.take(12)}",fontSize=12.sp)
|
Text("版本 ${com.gorios.lanvoice.BuildConfig.VERSION_NAME} · code ${com.gorios.lanvoice.BuildConfig.VERSION_CODE} · pin ${com.gorios.lanvoice.BuildConfig.EMOTION_MANIFEST_SHA.take(12)}",fontSize=12.sp)
|
||||||
|
if(BuildConfig.VERSION_NAME=="0.7.2") Text("播放诊断版:未确认手机根因;可离线检查两段原舞蹈并发送状态报告",fontSize=12.sp)
|
||||||
Text("素材准入:${pack?.emotionAdmission ?: "unavailable"} · ${mediaBinding?.diagnosticState ?: "legacy_neutral"}",fontSize=11.sp)
|
Text("素材准入:${pack?.emotionAdmission ?: "unavailable"} · ${mediaBinding?.diagnosticState ?: "legacy_neutral"}",fontSize=11.sp)
|
||||||
AvatarDiagnostics(pack,video)
|
AvatarDiagnostics(pack,video)
|
||||||
Text("AEC:${state.aec.name} · 效果待真机验证",fontSize=12.sp)
|
Text("AEC:${state.aec.name} · 效果待真机验证",fontSize=12.sp)
|
||||||
@@ -140,6 +144,7 @@ fun CallScreen(state: VoiceUiState,entry: EntryPhase,permissionMessage: String?,
|
|||||||
TextButton(onClick=onInterrupt,enabled=state.voiceActive && !state.actionActive) { Text("打断回答") }
|
TextButton(onClick=onInterrupt,enabled=state.voiceActive && !state.actionActive) { Text("打断回答") }
|
||||||
TextButton(onClick=onReport,enabled=!reportSending) { Text(if(reportSending) "发送中…" else "发送诊断报告") }
|
TextButton(onClick=onReport,enabled=!reportSending) { Text(if(reportSending) "发送中…" else "发送诊断报告") }
|
||||||
}
|
}
|
||||||
|
TextButton(onClick=onOfflinePreview) { Text("离线播放检查(停止当前会话)") }
|
||||||
reportResult?.let { Text(it,fontSize=12.sp) }
|
reportResult?.let { Text(it,fontSize=12.sp) }
|
||||||
Text(logs.takeLast(10).joinToString("\n"),fontSize=11.sp)
|
Text(logs.takeLast(10).joinToString("\n"),fontSize=11.sp)
|
||||||
})
|
})
|
||||||
@@ -174,25 +179,32 @@ private fun AvatarDiagnostics(pack: AvatarPack?,video: VideoPresentation) {
|
|||||||
/** Sensor-free synthetic intents, same real renderer and same clean home. */
|
/** Sensor-free synthetic intents, same real renderer and same clean home. */
|
||||||
@Composable
|
@Composable
|
||||||
fun EngineeringPreviewScreen(pack: AvatarPack?,micGranted: Boolean,cameraGranted: Boolean,micSettings: Boolean,cameraSettings: Boolean,
|
fun EngineeringPreviewScreen(pack: AvatarPack?,micGranted: Boolean,cameraGranted: Boolean,micSettings: Boolean,cameraSettings: Boolean,
|
||||||
permissionPending: EntryPermission?,onAuthorizeMic: ()->Unit,onAuthorizeCamera: ()->Unit) {
|
permissionPending: EntryPermission?,onAuthorizeMic: ()->Unit,onAuthorizeCamera: ()->Unit,
|
||||||
|
mediaBinding: AvatarMediaBinding?=null,onReport: ()->Unit=NoUiAction,reportSending: Boolean=false,reportResult: String?=null) {
|
||||||
val activity=LocalContext.current as ComponentActivity
|
val activity=LocalContext.current as ComponentActivity
|
||||||
var resumed by remember { mutableStateOf(activity.lifecycle.currentState.isAtLeast(Lifecycle.State.RESUMED)) }
|
var resumed by remember { mutableStateOf(activity.lifecycle.currentState.isAtLeast(Lifecycle.State.RESUMED)) }
|
||||||
var trace by remember { mutableStateOf(OfflineAvatarTrace.at(0)) }
|
var trace by remember { mutableStateOf(OfflineAvatarTrace.at(0)) }
|
||||||
var override by remember { mutableStateOf<AvatarMode?>(null) }
|
var override by remember { mutableStateOf<AvatarMode?>(null) }
|
||||||
var restart by remember { mutableStateOf(0L) }
|
var restart by remember { mutableStateOf(0L) }
|
||||||
var video by remember { mutableStateOf(VideoPresentation()) }
|
var video by remember { mutableStateOf(VideoPresentation()) }
|
||||||
val offlineBinding=remember(pack) { AvatarMediaBinding() }
|
val offlineBinding=mediaBinding ?: remember(pack) { AvatarMediaBinding() }
|
||||||
|
var danceActive by remember { mutableStateOf(false) }
|
||||||
|
var danceStatus by remember { mutableStateOf("idle") }
|
||||||
|
var nativeState by remember { mutableStateOf("renderer_unavailable") }
|
||||||
|
val dance=remember(pack,offlineBinding) { OfflineDancePreview(pack?.emotionAction?.actionPack,offlineBinding,
|
||||||
|
{ android.os.SystemClock.elapsedRealtime() }) { active,status -> danceActive=active;danceStatus=status } }
|
||||||
var emotionLabel by remember { mutableStateOf("") }
|
var emotionLabel by remember { mutableStateOf("") }
|
||||||
DisposableEffect(activity) {
|
DisposableEffect(activity) {
|
||||||
val observer=LifecycleEventObserver { _,event ->
|
val observer=LifecycleEventObserver { _,event ->
|
||||||
if(event==Lifecycle.Event.ON_RESUME) resumed=true
|
if(event==Lifecycle.Event.ON_RESUME) resumed=true
|
||||||
if(event==Lifecycle.Event.ON_PAUSE) resumed=false
|
if(event==Lifecycle.Event.ON_PAUSE) { resumed=false;dance.cancel("background") }
|
||||||
}
|
}
|
||||||
activity.lifecycle.addObserver(observer)
|
activity.lifecycle.addObserver(observer)
|
||||||
onDispose { activity.lifecycle.removeObserver(observer) }
|
onDispose { activity.lifecycle.removeObserver(observer);dance.cancel("disposed") }
|
||||||
}
|
}
|
||||||
LaunchedEffect(resumed,restart,override) {
|
LaunchedEffect(resumed) { while(resumed) { nativeState=offlineBinding.diagnosticState;delay(500) } }
|
||||||
if(resumed) {
|
LaunchedEffect(resumed,restart,override,danceActive) {
|
||||||
|
if(resumed && !danceActive) {
|
||||||
val start=android.os.SystemClock.elapsedRealtime()
|
val start=android.os.SystemClock.elapsedRealtime()
|
||||||
val emotionSequence=OfflineEmotionSequence(1000+restart)
|
val emotionSequence=OfflineEmotionSequence(1000+restart)
|
||||||
if(pack?.emotionAction!=null) offlineBinding.beginTurn(1000+restart)
|
if(pack?.emotionAction!=null) offlineBinding.beginTurn(1000+restart)
|
||||||
@@ -218,11 +230,22 @@ fun EngineeringPreviewScreen(pack: AvatarPack?,micGranted: Boolean,cameraGranted
|
|||||||
PermissionSettings(micGranted,cameraGranted,micSettings,cameraSettings,permissionPending,onAuthorizeMic,onAuthorizeCamera)
|
PermissionSettings(micGranted,cameraGranted,micSettings,cameraSettings,permissionPending,onAuthorizeMic,onAuthorizeCamera)
|
||||||
Text("合成意图:${override?.name ?: if(pack?.emotionAction!=null) emotionLabel else trace.label}",fontSize=12.sp)
|
Text("合成意图:${override?.name ?: if(pack?.emotionAction!=null) emotionLabel else trace.label}",fontSize=12.sp)
|
||||||
if(pack?.emotionAction!=null) Text("整合候选 · 动态自然度、音乐听审及真机未测;表达可能等待 2–4 秒出口和约 1 秒过渡",fontSize=12.sp)
|
if(pack?.emotionAction!=null) Text("整合候选 · 动态自然度、音乐听审及真机未测;表达可能等待 2–4 秒出口和约 1 秒过渡",fontSize=12.sp)
|
||||||
|
Text("版本 ${BuildConfig.VERSION_NAME} · code ${BuildConfig.VERSION_CODE} · pin ${BuildConfig.EMOTION_MANIFEST_SHA.take(12)}",fontSize=12.sp)
|
||||||
|
Text("离线媒体:$danceStatus · $nativeState",fontSize=11.sp)
|
||||||
AvatarDiagnostics(pack,video)
|
AvatarDiagnostics(pack,video)
|
||||||
|
if(pack?.emotionAction?.actionPack!=null) {
|
||||||
|
Row {
|
||||||
|
TextButton(onClick={offlineBinding.intent(null,false);dance.play("asset_01")},enabled=resumed && !danceActive) { Text("舞蹈 01") }
|
||||||
|
TextButton(onClick={offlineBinding.intent(null,false);dance.play("asset_02")},enabled=resumed && !danceActive) { Text("舞蹈 02") }
|
||||||
|
TextButton(onClick={dance.cancel()},enabled=danceActive) { Text("停止舞蹈") }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
TextButton(onClick=onReport,enabled=!reportSending) { Text(if(reportSending) "发送中…" else "发送诊断报告") }
|
||||||
|
reportResult?.let { Text(it,fontSize=12.sp) }
|
||||||
Row(horizontalArrangement=Arrangement.spacedBy(8.dp)) {
|
Row(horizontalArrangement=Arrangement.spacedBy(8.dp)) {
|
||||||
TextButton(onClick={override=AvatarMode.IDLE}) { Text("Idle") }
|
TextButton(onClick={override=AvatarMode.IDLE}) { Text("Idle") }
|
||||||
TextButton(onClick={override=AvatarMode.TALK}) { Text("Talk") }
|
TextButton(onClick={override=AvatarMode.TALK}) { Text("Talk") }
|
||||||
TextButton(onClick={override=AvatarMode.IDLE;restart++}) { Text("Abort") }
|
TextButton(onClick={dance.cancel();override=AvatarMode.IDLE;restart++}) { Text("Abort") }
|
||||||
TextButton(onClick={override=null;restart++}) { Text("Trace") }
|
TextButton(onClick={override=null;restart++}) { Text("Trace") }
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ class EmotionActionAvatarView(context: Context,private val pack: AvatarPack,
|
|||||||
if(!active || released || driver!=null || textures.any { !it.isAvailable }) return
|
if(!active || released || driver!=null || textures.any { !it.isAvailable }) return
|
||||||
val index=checkNotNull(pack.emotionAction)
|
val index=checkNotNull(pack.emotionAction)
|
||||||
val mouthClock=ConversationMouthClock()
|
val mouthClock=ConversationMouthClock()
|
||||||
val music=AndroidMusicPort(context,textures[3]);movie=music
|
val music=AndroidMusicPort(context,textures[3],binding::musicDiagnostic);movie=music
|
||||||
val current=ConversationMediaDriver(index,{ slot ->
|
val current=ConversationMediaDriver(index,{ slot ->
|
||||||
object: CompositeMediaPort {
|
object: CompositeMediaPort {
|
||||||
private var renderer: ContinuousBodyRenderer?=null
|
private var renderer: ContinuousBodyRenderer?=null
|
||||||
@@ -63,6 +63,7 @@ class EmotionActionAvatarView(context: Context,private val pack: AvatarPack,
|
|||||||
frame: (BodyFrameKey,Boolean)->Unit,ended: ()->Unit,failed: ()->Unit) {
|
frame: (BodyFrameKey,Boolean)->Unit,ended: ()->Unit,failed: ()->Unit) {
|
||||||
renderer=ContinuousBodyRenderer(context,pack,Surface(checkNotNull(textures[slot].surfaceTexture)),
|
renderer=ContinuousBodyRenderer(context,pack,Surface(checkNotNull(textures[slot].surfaceTexture)),
|
||||||
textures[slot].width,textures[slot].height,{ value,_->
|
textures[slot].width,textures[slot].height,{ value,_->
|
||||||
|
binding.presented(slot,value)
|
||||||
frame(value.key,value.mouth.phase=="idle" && value.selection.opacity==0f)
|
frame(value.key,value.mouth.phase=="idle" && value.selection.opacity==0f)
|
||||||
},{ reason->report(VideoPresentation(reason=reason));failed() },automatic=false,startFrame=entryFrame,mayLoop=loop,mouthEnabled=mouth,sharedMouth=mouthClock,ended=ended)
|
},{ reason->report(VideoPresentation(reason=reason));failed() },automatic=false,startFrame=entryFrame,mayLoop=loop,mouthEnabled=mouth,sharedMouth=mouthClock,ended=ended)
|
||||||
renderers[slot]=renderer
|
renderers[slot]=renderer
|
||||||
@@ -79,7 +80,7 @@ class EmotionActionAvatarView(context: Context,private val pack: AvatarPack,
|
|||||||
}
|
}
|
||||||
},music,{ slot ->
|
},music,{ slot ->
|
||||||
if(visibleLayer!=slot) {
|
if(visibleLayer!=slot) {
|
||||||
visibleLayer=slot
|
visibleLayer=slot;binding.visible(slot)
|
||||||
textures.forEachIndexed { i,v->v.alpha=if(i==slot) 1f else 0f };still.alpha=if(slot==null) 1f else 0f
|
textures.forEachIndexed { i,v->v.alpha=if(i==slot) 1f else 0f };still.alpha=if(slot==null) 1f else 0f
|
||||||
}
|
}
|
||||||
},{ phase,key ->
|
},{ phase,key ->
|
||||||
@@ -105,7 +106,7 @@ class EmotionActionAvatarView(context: Context,private val pack: AvatarPack,
|
|||||||
|
|
||||||
/** Android's completion is combined with actual final TextureView PTS and release.
|
/** Android's completion is combined with actual final TextureView PTS and release.
|
||||||
* No timer substitutes for MediaPlayer.stop/release or idle presentation. */
|
* No timer substitutes for MediaPlayer.stop/release or idle presentation. */
|
||||||
internal class AndroidMusicPort(private val context: Context,private val view: TextureView): MusicMediaPort {
|
internal class AndroidMusicPort(private val context: Context,private val view: TextureView,private val diagnostic: (String)->Unit={}): MusicMediaPort {
|
||||||
private val main=Handler(Looper.getMainLooper())
|
private val main=Handler(Looper.getMainLooper())
|
||||||
private var player: MediaPlayer?=null
|
private var player: MediaPlayer?=null
|
||||||
private var surface: Surface?=null
|
private var surface: Surface?=null
|
||||||
@@ -118,53 +119,71 @@ internal class AndroidMusicPort(private val context: Context,private val view: T
|
|||||||
private var playing=false
|
private var playing=false
|
||||||
private var nativeEnded=false
|
private var nativeEnded=false
|
||||||
private var startedMs=0L
|
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}"
|
||||||
|
diagnostic(message)
|
||||||
|
DiagnosticLog.state("music_native", "$epoch/$reason",message)
|
||||||
|
}
|
||||||
|
private fun fault(reason: String,timestampUs: Long?=null) {
|
||||||
|
if(faulted) return
|
||||||
|
faulted=true;event(reason,timestampUs);failed?.invoke()
|
||||||
|
}
|
||||||
override fun prepare(media: ActionMedia,ready: ()->Unit,firstFrame: ()->Unit,ended: ()->Unit,failed: ()->Unit) {
|
override fun prepare(media: ActionMedia,ready: ()->Unit,firstFrame: ()->Unit,ended: ()->Unit,failed: ()->Unit) {
|
||||||
check(player==null);val token=++epoch
|
check(player==null);val token=++epoch
|
||||||
this.media=media;this.firstFrame=firstFrame;this.ended=ended;this.failed=failed;lastPts=-1
|
this.media=media;this.firstFrame=firstFrame;this.ended=ended;this.failed=failed;lastPts=-1;faulted=false;startedMs=SystemClock.elapsedRealtime();event("preparing")
|
||||||
try {
|
try {
|
||||||
val s=Surface(checkNotNull(view.surfaceTexture));surface=s
|
val s=Surface(checkNotNull(view.surfaceTexture));surface=s
|
||||||
val current=MediaPlayer();player=current;current.setSurface(s);current.isLooping=false
|
val current=MediaPlayer();player=current;current.setSurface(s);current.isLooping=false
|
||||||
context.assets.openFd(media.root+media.path).use { current.setDataSource(it.fileDescriptor,it.startOffset,it.length) }
|
context.assets.openFd(media.root+media.path).use { current.setDataSource(it.fileDescriptor,it.startOffset,it.length) }
|
||||||
current.setOnPreparedListener { if(token==epoch) {
|
current.setOnPreparedListener { if(token==epoch) {
|
||||||
if(current.videoWidth!=media.width || current.videoHeight!=media.height) failed() else ready()
|
if(current.videoWidth!=media.width || current.videoHeight!=media.height) fault("dimensions_invalid") else { event("prepared");ready() }
|
||||||
} }
|
} }
|
||||||
current.setOnCompletionListener { if(token==epoch && playing) {
|
current.setOnCompletionListener { if(token==epoch && playing) {
|
||||||
playing=false;nativeEnded=true;finishIfReady()
|
playing=false;nativeEnded=true;event("native_completed");finishIfReady()
|
||||||
main.postDelayed({ if(token==epoch && nativeEnded) failed() },2_000) // Missing final-frame watchdog, no fabricated completion.
|
main.postDelayed({ if(token==epoch && nativeEnded) fault("native_ended_missing_final") },2_000) // Missing final-frame watchdog, no fabricated completion.
|
||||||
} }
|
} }
|
||||||
current.setOnErrorListener { _,_,_->if(token==epoch) failed();true }
|
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.
|
||||||
|
}
|
||||||
|
current.setOnErrorListener { _,_,_->if(token==epoch) fault("native_error");true }
|
||||||
current.prepareAsync()
|
current.prepareAsync()
|
||||||
} catch(_: Exception) { failed() }
|
} catch(_: Exception) { fault("prepare_failed") }
|
||||||
}
|
}
|
||||||
override fun start() { try { startedMs=SystemClock.elapsedRealtime();nativeEnded=false;playing=true;checkNotNull(player).start() } catch(_: Exception) { failed?.invoke() } }
|
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) {
|
fun latched(timestampNs: Long) {
|
||||||
if(!playing && !nativeEnded) return
|
if(faulted || (!playing && !nativeEnded)) return
|
||||||
val pts=timestampNs/1000;val timeline=media?.ptsUs ?: return
|
val pts=timestampNs/1000;val timeline=media?.ptsUs ?: return
|
||||||
val found=timeline.binarySearch(pts)
|
val found=timeline.binarySearch(pts)
|
||||||
val candidate=if(found>=0) found else (-found-1).coerceAtMost(timeline.lastIndex)
|
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 }
|
val index=listOf(candidate,(candidate-1).coerceAtLeast(0)).firstOrNull { kotlin.math.abs(timeline[it]-pts)<=2 }
|
||||||
if(index==null || timeline[index]<lastPts) { failed?.invoke();return }
|
if(index==null) { fault("timestamp_not_indexed",pts);return }
|
||||||
|
if(timeline[index]<lastPts) { fault("timestamp_regressed",pts);return }
|
||||||
if(lastPts<0) {
|
if(lastPts<0) {
|
||||||
if(index!=0) { failed?.invoke();return }
|
if(index!=0) { fault("first_frame_not_zero",pts);return }
|
||||||
|
event("first_frame_latched",pts)
|
||||||
firstFrame?.invoke();firstFrame=null
|
firstFrame?.invoke();firstFrame=null
|
||||||
}
|
}
|
||||||
lastPts=timeline[index]
|
lastPts=timeline[index]
|
||||||
finishIfReady()
|
finishIfReady()
|
||||||
}
|
}
|
||||||
private fun finishIfReady() {
|
private fun finishIfReady() {
|
||||||
|
if(faulted) return
|
||||||
val current=media ?: return
|
val current=media ?: return
|
||||||
if(nativeEnded && lastPts==current.ptsUs.last()) {
|
if(nativeEnded && lastPts==current.ptsUs.last()) {
|
||||||
nativeEnded=false
|
nativeEnded=false
|
||||||
if(SystemClock.elapsedRealtime()-startedMs<(current.durationUs+999)/1000) failed?.invoke()
|
if(SystemClock.elapsedRealtime()-startedMs<(current.durationUs+999)/1000) fault("duration_early")
|
||||||
else ended?.invoke()
|
else { event("validated_end");ended?.invoke() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
override fun close(released: ()->Unit) {
|
override fun close(released: ()->Unit) {
|
||||||
epoch++;playing=false;nativeEnded=false;firstFrame=null;ended=null
|
event("closing");epoch++;playing=false;nativeEnded=false;firstFrame=null;ended=null
|
||||||
val old=player
|
val old=player
|
||||||
try { try { old?.stop() } catch(_: Exception) { } // release also stops a prepared/error player.
|
try { try { old?.stop() } catch(_: Exception) { } // release also stops a prepared/error player.
|
||||||
old?.release();player=null;surface?.release();surface=null;media=null
|
old?.release();player=null;surface?.release();surface=null;media=null
|
||||||
main.post { released() }
|
event("released");main.post { released() }
|
||||||
} catch(_: Exception) { val callback=failed;failed=null;callback?.invoke() } // No false release acknowledgement.
|
} catch(_: Exception) { event("release_failed");val callback=failed;failed=null;callback?.invoke() } // No false release acknowledgement.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package com.gorios.lanvoice.avatar
|
||||||
|
|
||||||
|
import com.gorios.lanvoice.diag.DiagnosticLog
|
||||||
|
|
||||||
|
/** Explicit local media inspection, not a network action or a fabricated mic confirmation.
|
||||||
|
* Uses the same production player/return-A release fence. No capture, transport or after-reply. */
|
||||||
|
class OfflineDancePreview(private val pack: ReviewedActionPack?,private val player: ActionPlayer,
|
||||||
|
private val clock: ()->Long,private val changed: (Boolean,String)->Unit={_,_->}) {
|
||||||
|
private var epoch=0L
|
||||||
|
var active=false;private set
|
||||||
|
private var stopping=false
|
||||||
|
private fun state(value: String) { DiagnosticLog.state("offline_dance","$epoch/$value","event=$value epoch=$epoch active=$active");changed(active,value) }
|
||||||
|
fun play(id: String): Boolean {
|
||||||
|
if(active || stopping) return false
|
||||||
|
val asset=pack?.assets?.singleOrNull { it.id==id && it.id in setOf("asset_01","asset_02") && it.media!=null } ?: return false
|
||||||
|
val token=++epoch;val start=clock();active=true;state("requested_$id")
|
||||||
|
player.play(asset,{ end->
|
||||||
|
if(token!=epoch || !active || stopping) return@play
|
||||||
|
if(!end.videoEnded || !end.audioStopped || !end.idleRestored || clock()-start<asset.durationMs) cancel("invalid_end")
|
||||||
|
else { active=false;epoch++;state("completed") }
|
||||||
|
},{ if(token==epoch && active && !stopping) cancel("media_failed") })
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
fun cancel(reason: String="settings_cancel") {
|
||||||
|
if(!active || stopping) return
|
||||||
|
epoch++;stopping=true;state(reason)
|
||||||
|
player.stop { stopping=false;active=false;state("released") }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,94 @@
|
|||||||
|
# Android 0.7.2 playback diagnostic candidate
|
||||||
|
|
||||||
|
Baseline: clean/pushed `3458a9b03e636bdc910713c3832774b0322322aa`.
|
||||||
|
The user reports no visible dance and about one second of dance audio on code19.
|
||||||
|
This is **not a confirmed fix for that phone episode**. Code19's held-body layer
|
||||||
|
ownership and idle rotation repairs remain in place. Host presentation callbacks
|
||||||
|
are not evidence of Android GPU visibility or installed-phone playback.
|
||||||
|
|
||||||
|
## Current evidence
|
||||||
|
|
||||||
|
The last finite read-only query at 2026-10-13 11:36:47 Asia/Shanghai found zero
|
||||||
|
`/debug/report` entries. The latest remote debug-log timestamp remains11:12:13.668.
|
||||||
|
Earlier11:12:08 metadata contained the frozen pin's HELLO accepted, but has no
|
||||||
|
versionCode/episode binding. It cannot establish that the user's reported dance
|
||||||
|
received a plan or started. No user's conversation, recording, camera image or
|
||||||
|
landmarks were inspected. USB is unavailable; no installation was attempted.
|
||||||
|
|
||||||
|
Gateway0.8.0 remains healthy, Qwen3.8-27b/json_schema/AsiaShanghai. Canonical
|
||||||
|
`gateway.py`, `action_protocol.py` and `reviewed_action_packs.json` hashes match
|
||||||
|
previous checks. No deployment/restart or time/provider/TTS/model change.
|
||||||
|
|
||||||
|
## Diagnostic changes
|
||||||
|
|
||||||
|
- The real Android MediaPlayer/TextureView adapter now records fixed preparation,
|
||||||
|
start, native rendering-start, latched first-frame, native end, validated end,
|
||||||
|
close/release and failure enums with epoch, elapsed time, currentPosition,
|
||||||
|
actual texture PTS and alpha. Rendering-start info does not reveal the layer or
|
||||||
|
count as a surface frame. The existing exact-PTS/first-frame/final-frame/minimum
|
||||||
|
duration/release/return-A gates are preserved.
|
||||||
|
- The previously generic failure now distinguishes `first_frame_not_zero`,
|
||||||
|
`timestamp_not_indexed`, `timestamp_regressed`, `native_ended_missing_final`,
|
||||||
|
`duration_early`, dimensions/prepare/start/native/release failure. These branches
|
||||||
|
are reproducible with production adapter callbacks; none is yet tied to the
|
||||||
|
phone episode. TextureView can skip displayed frames or use a different clock;
|
||||||
|
device timestamps are needed before changing admission policy.
|
||||||
|
- Normal TTS activity logs accepted versus inactive/action-owner/stale-generation/
|
||||||
|
old-turn/blocked/drained, with actual AudioTrack head, written count and audible
|
||||||
|
flag. The compositor snapshot records the visible slot's body frame/PTS/loop,
|
||||||
|
mouth phase/aperture/selected level/opacity/generation after draw/swap. Hidden
|
||||||
|
prepared slots cannot masquerade as visible mouth presentation. Swap callback
|
||||||
|
evidence is still not a phone screenshot or perceptual measurement.
|
||||||
|
- Action cancellation records background, disconnect, server cancel, new turn,
|
||||||
|
audio-focus unavailable, settings cancel or stop-voice. Existing capture-stop,
|
||||||
|
media release, completion and after-reply semantics are unchanged.
|
||||||
|
- Settings offer **离线播放检查(停止当前会话)**. It stops voice/camera, waits for actual recorder cleanup confirmation, and opens
|
||||||
|
the existing sensor-free Activity branch. Settings there offer舞蹈01/02/停止舞蹈
|
||||||
|
and explicit发送诊断报告. These controls use the same actual production
|
||||||
|
binding/View/music player, legal approach and return A. Synthetic expression
|
||||||
|
intents pause during dance. Background/disposal cancels and fences callbacks.
|
||||||
|
No network action, fabricated recording confirmation, microphone/camera capture,
|
||||||
|
after-reply, or LLM call occurs. A requested local dance is not proof it played;
|
||||||
|
the settings status/explicit report exposes actual player/layer failures.
|
||||||
|
|
||||||
|
All added diagnostics use fixed enums/ids/numbers, a500-entry bounded ring, state
|
||||||
|
changes and10s summaries; no frame-level ring writes, raw PCM/chat/model text or
|
||||||
|
secrets. Reports include app versionCode, mode, frozen pin/admission, current
|
||||||
|
owner, native playback and visible mouth state. Offline report submission uses
|
||||||
|
empty camera/face diagnostic snapshots and never accesses uninitialized sensor
|
||||||
|
or voice controllers. Main screen remains avatar plus gear.
|
||||||
|
|
||||||
|
## Frozen assets and release boundaries
|
||||||
|
|
||||||
|
Index pin: `987e125a7d7a2cde99121b5f5246c82f4dbe36c4899d3d49eaffd1a68bafb887`.
|
||||||
|
All3222 runtime references and every packaged avatar byte must equal code18 and
|
||||||
|
code19. Existing white-clothed identity, five bodies, eight own-mouth bridges,
|
||||||
|
thirteen edges, two real music dances and mouth gap1.1 source pixels are unchanged.
|
||||||
|
No new visual imports or asset generation. Owner ledger remains21 submitted,
|
||||||
|
known video$4.16, image/rate fees unknown; this step0 paid/AI/inference calls.
|
||||||
|
Code19/18/17/16 rollback artifacts remain intact.
|
||||||
|
|
||||||
|
Build purpose is explicit `-PavatarPlaybackDiagnostic=true`, frozen full graph,
|
||||||
|
code>=20, version0.7.2. Publisher `--playback-diagnostic` verifies exact media bytes,
|
||||||
|
external pin, reviewed action registry, arm64/min26/target34, same debug certificate,
|
||||||
|
compiled pin, occupied-version prevention and downloaded HTTP bytes. It does not
|
||||||
|
rewrite asset admission to naturalness-approved.
|
||||||
|
|
||||||
|
## Validation
|
||||||
|
|
||||||
|
Production adapter/offline controller tests cover exact failure enums, native-info
|
||||||
|
without latch, single failure/release, stale callbacks, early end rejection,
|
||||||
|
cancel/background and both local assets through the actual View/binding/renderer/
|
||||||
|
player callbacks (100 assertions). Existing action record-stop, held-body layer
|
||||||
|
ownership, return A, after-once, idle/new-turn and bridge-own mouth suites remain
|
||||||
|
required. Full JVM/UI, packaging, five-body software GLES, gateway archive-stage
|
||||||
|
and exact APK loader/callback results are recorded below after publication.
|
||||||
|
Instrumentation compiles only. Real-device codec/GPU/surface, AudioRecord stop,
|
||||||
|
AudioTrack audibility, music listening, naturalness and perceptual latency are
|
||||||
|
**not_run**. No new inference probe or device installation.
|
||||||
|
|
||||||
|
The shortest next observation is settings→离线播放检查→舞蹈01 or02; close the sheet
|
||||||
|
to view the actor, reopen settings and explicitly send the diagnostic. This
|
||||||
|
separates native-media visibility from normal HELLO/plan/drain/capture-stop gates.
|
||||||
|
For the normal conversation issue, a report from that mode is needed as well;
|
||||||
|
no attribution from another device/turn or old version is made.
|
||||||
@@ -50,7 +50,7 @@ for name in ('CallScreen','EngineeringPreviewScreen'):
|
|||||||
for expected in ('正在连接','重试连接','permissionMessage','onAuthorizeMic','onMute','onCamera','ExpressionControls','请求表达','onReport'):
|
for expected in ('正在连接','重试连接','permissionMessage','onAuthorizeMic','onMute','onCamera','ExpressionControls','请求表达','onReport'):
|
||||||
assert expected in text(settings)
|
assert expected in text(settings)
|
||||||
else:
|
else:
|
||||||
for expected in ('离线 avatar','Idle','Talk','Abort','Trace'):
|
for expected in ('离线 avatar','Idle','Talk','Abort','Trace','舞蹈 01','舞蹈 02','停止舞蹈','onReport'):
|
||||||
assert expected in text(settings)
|
assert expected in text(settings)
|
||||||
for name in ('AvatarPortrait','ContinuousPortrait'):
|
for name in ('AvatarPortrait','ContinuousPortrait'):
|
||||||
fn=text(block('fun '+name))
|
fn=text(block('fun '+name))
|
||||||
@@ -71,6 +71,9 @@ assert 'actionPlayer = avatarMedia' in activity and 'onPrepareExpression = avata
|
|||||||
assert 'avatarMedia.beginTurn(it.turnId)' in activity and 'mediaBinding = avatarMedia' in activity
|
assert 'avatarMedia.beginTurn(it.turnId)' in activity and 'mediaBinding = avatarMedia' in activity
|
||||||
assert 'pack?.emotionAction!=null && mediaBinding!=null' in source
|
assert 'pack?.emotionAction!=null && mediaBinding!=null' in source
|
||||||
assert 'remember(pack,mediaBinding) { EmotionActionAvatarView' in source
|
assert 'remember(pack,mediaBinding) { EmotionActionAvatarView' in source
|
||||||
|
assert 'onOfflinePreview' in text(block('},settings=',block('fun CallScreen')))
|
||||||
|
assert 'danceActive' in text(block('fun EngineeringPreviewScreen'))
|
||||||
|
assert 'else expressions.diagnosticsSnapshot()' in activity and 'else session.faceDiagnosticsSnapshot()' in activity
|
||||||
assert 'EMOTION_MANIFEST_SHA' in (ROOT/'app/src/main/java/com/gorios/lanvoice/avatar/AvatarPack.kt').read_text()
|
assert 'EMOTION_MANIFEST_SHA' in (ROOT/'app/src/main/java/com/gorios/lanvoice/avatar/AvatarPack.kt').read_text()
|
||||||
permissions=text(block('fun PermissionSettings'))
|
permissions=text(block('fun PermissionSettings'))
|
||||||
for label in ('已授权','未授权','申请麦克风权限','申请摄像头权限','系统权限设置'):
|
for label in ('已授权','未授权','申请麦克风权限','申请摄像头权限','系统权限设置'):
|
||||||
|
|||||||
@@ -25,9 +25,9 @@ compiler = ':'.join([jar('org.jetbrains.kotlin','kotlin-compiler-embeddable','2.
|
|||||||
cp = ':'.join([stdlib, jar('com.squareup.okhttp3','okhttp','4.12.0'), jar('com.squareup.okio','okio-jvm','3.6.0')])
|
cp = ':'.join([stdlib, jar('com.squareup.okhttp3','okhttp','4.12.0'), jar('com.squareup.okio','okio-jvm','3.6.0')])
|
||||||
source = ROOT/'app/src/main/java/com/gorios/lanvoice'
|
source = ROOT/'app/src/main/java/com/gorios/lanvoice'
|
||||||
suites = [
|
suites = [
|
||||||
('session','ConnectionCheckKt', [source/'audio/PlaybackActivity.kt', source/'audio/VoiceSession.kt', source/'avatar/ActionController.kt', source/'dialogue/ReplyEmotion.kt', source/'net/DialogueClient.kt', source/'expression/FaceCueRules.kt', source/'expression/ExpressionRules.kt', source/'expression/FaceDiagnostics.kt']),
|
('session','ConnectionCheckKt', [source/'diag/DiagnosticLog.kt',source/'audio/PlaybackActivity.kt', source/'audio/VoiceSession.kt', source/'avatar/ActionController.kt', source/'dialogue/ReplyEmotion.kt', source/'net/DialogueClient.kt', source/'expression/FaceCueRules.kt', source/'expression/ExpressionRules.kt', source/'expression/FaceDiagnostics.kt']),
|
||||||
('playback','PlaybackCheckKt', [source/'audio/AudioPlayback.kt', source/'audio/PlaybackActivity.kt']),
|
('playback','PlaybackCheckKt', [source/'audio/AudioPlayback.kt', source/'audio/PlaybackActivity.kt']),
|
||||||
('avatar','AvatarCheckKt', [source/'diag/DiagnosticLog.kt',source/'avatar/ConversationMediaDriver.kt',source/'avatar/AvatarMediaBinding.kt',source/'avatar/EmotionActionAvatarView.kt',source/'avatar/ContinuousAvatarView.kt',source/'avatar/ConversationPackagePlanner.kt', source/'avatar/EmotionActionManifest.kt', source/'avatar/ActionController.kt', source/'avatar/RoleVisualSelection.kt', source/'avatar/ContinuousAvatarManifest.kt', source/'avatar/ContinuousMouth.kt', source/'avatar/ContinuousFramePresenter.kt', source/'avatar/ContinuousBodyRenderer.kt', source/'avatar/EngineeringGraphAdmission.kt', source/'avatar/OfflineAvatarTrace.kt', source/'avatar/NeutralGraphContract.kt', source/'avatar/SafeVideoDriver.kt', source/'avatar/CodecAnchorVideoPort.kt', source/'avatar/AutoConversation.kt', source/'avatar/SafeAvatarGraph.kt', source/'avatar/SafeTransitionPlanner.kt', source/'avatar/SafeAvatarManifest.kt', source/'avatar/TransitionDiagnostics.kt', source/'avatar/AvatarController.kt', source/'avatar/CallIntent.kt', source/'avatar/AvatarVideoView.kt', source/'audio/PlaybackActivity.kt', source/'dialogue/ReplyEmotion.kt']),
|
('avatar','AvatarCheckKt', [source/'diag/DiagnosticLog.kt',source/'avatar/ConversationMediaDriver.kt',source/'avatar/AvatarMediaBinding.kt',source/'avatar/OfflineDancePreview.kt',source/'avatar/EmotionActionAvatarView.kt',source/'avatar/ContinuousAvatarView.kt',source/'avatar/ConversationPackagePlanner.kt', source/'avatar/EmotionActionManifest.kt', source/'avatar/ActionController.kt', source/'avatar/RoleVisualSelection.kt', source/'avatar/ContinuousAvatarManifest.kt', source/'avatar/ContinuousMouth.kt', source/'avatar/ContinuousFramePresenter.kt', source/'avatar/ContinuousBodyRenderer.kt', source/'avatar/EngineeringGraphAdmission.kt', source/'avatar/OfflineAvatarTrace.kt', source/'avatar/NeutralGraphContract.kt', source/'avatar/SafeVideoDriver.kt', source/'avatar/CodecAnchorVideoPort.kt', source/'avatar/AutoConversation.kt', source/'avatar/SafeAvatarGraph.kt', source/'avatar/SafeTransitionPlanner.kt', source/'avatar/SafeAvatarManifest.kt', source/'avatar/TransitionDiagnostics.kt', source/'avatar/AvatarController.kt', source/'avatar/CallIntent.kt', source/'avatar/AvatarVideoView.kt', source/'audio/PlaybackActivity.kt', source/'dialogue/ReplyEmotion.kt']),
|
||||||
('capture','CaptureCheckKt', [source/'audio/AudioCapture.kt']),
|
('capture','CaptureCheckKt', [source/'audio/AudioCapture.kt']),
|
||||||
('protocol','ProtocolCheckKt', [source/'avatar/ActionController.kt', source/'net/DialogueProtocol.kt', source/'dialogue/ReplyEmotion.kt', source/'expression/FaceCueRules.kt', source/'expression/ExpressionRules.kt']),
|
('protocol','ProtocolCheckKt', [source/'avatar/ActionController.kt', source/'net/DialogueProtocol.kt', source/'dialogue/ReplyEmotion.kt', source/'expression/FaceCueRules.kt', source/'expression/ExpressionRules.kt']),
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -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)])
|
return len([p for p in paths(new) if p.startswith('assets/'+ASSET_ROOT)])
|
||||||
|
|
||||||
|
|
||||||
def publish(report,output,requested,full=False,runtime_fix=False):
|
def publish(report,output,requested,full=False,runtime_fix=False,playback_diagnostic=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']),
|
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')
|
'live emotion release needs bridge-own TALK runtimes')
|
||||||
tested_source(full);packaging_tests_current();require(file_sha(ROLLBACK)==ROLLBACK_SHA,'rollback drift')
|
tested_source(full);packaging_tests_current();require(file_sha(ROLLBACK)==ROLLBACK_SHA,'rollback drift')
|
||||||
@@ -305,12 +305,13 @@ def publish(report,output,requested,full=False,runtime_fix=False):
|
|||||||
if requested is not None:
|
if requested is not None:
|
||||||
require(requested>=version,'version code occupied');version=requested
|
require(requested>=version,'version code occupied');version=requested
|
||||||
require(not full or version>=18,'full candidate needs code >=18')
|
require(not full or version>=18,'full candidate needs code >=18')
|
||||||
|
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')
|
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',
|
subprocess.run([str(ROOT/'scripts/build.sh'),'assembleDebug','compileDebugAndroidTestKotlin','-PavatarActionCandidate=true',
|
||||||
'-PavatarNatural=true','-PavatarMouthCandidate=true','-PnaturalManifestSha='+LEGACY_PIN,
|
'-PavatarNatural=true','-PavatarMouthCandidate=true','-PnaturalManifestSha='+LEGACY_PIN,
|
||||||
'-PemotionManifestSha='+report['manifest_sha256'],'-PactionVersionCode='+str(version),'-PavatarFullActionCandidate='+str(full).lower(),'-PavatarRuntimeFix='+str(runtime_fix).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()],check=True,cwd=ROOT)
|
||||||
built=ROOT/'app/build/outputs/apk/debug/app-debug.apk';badge=badging(built)
|
built=ROOT/'app/build/outputs/apk/debug/app-debug.apk';badge=badging(built)
|
||||||
version_name='0.7.1' if runtime_fix else ('0.7.0' if full else '0.7.0-emotion-dev')
|
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')
|
||||||
for text in ("name='com.gorios.lanvoice'",f"versionCode='{version}'",f"versionName='{version_name}'","sdkVersion:'26'","targetSdkVersion:'34'"):
|
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(text in badge,'APK metadata: '+text)
|
||||||
require(re.search(r'^native-code: (.+)$',badge,re.M)[1].strip()=="'arm64-v8a'",'APK ABI')
|
require(re.search(r'^native-code: (.+)$',badge,re.M)[1].strip()=="'arm64-v8a'",'APK ABI')
|
||||||
@@ -327,9 +328,9 @@ def publish(report,output,requested,full=False,runtime_fix=False):
|
|||||||
config=ROOT/'app/build/generated/source/buildConfig/debug/com/gorios/lanvoice/BuildConfig.java'
|
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('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')
|
require(version>=next_version((ROOT/'artifacts').glob('*.apk')),'version became occupied during build')
|
||||||
if runtime_fix: require(verify_runtime_fix_assets(built,report['manifest_sha256'])==len(report['files']),'runtime fix file count')
|
if runtime_fix or playback_diagnostic: require(verify_runtime_fix_assets(built,report['manifest_sha256'])==len(report['files']),'runtime fix file count')
|
||||||
stem='runtime-fix' if runtime_fix else ('action-emotion' if full else 'emotion-candidate')
|
stem='playback-diagnostic' if playback_diagnostic else 'runtime-fix' if runtime_fix else ('action-emotion' if full else 'emotion-candidate')
|
||||||
release='v071' if runtime_fix else 'v070'
|
release='v072' if playback_diagnostic else 'v071' if runtime_fix else 'v070'
|
||||||
artifact=ROOT/f'artifacts/lan-voice-{release}-{stem}-code{version}-arm64-debug.apk'
|
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)
|
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()
|
digest=file_sha(artifact);checksum=f'{digest} {artifact.name}\n'.encode()
|
||||||
@@ -341,7 +342,7 @@ def publish(report,output,requested,full=False,runtime_fix=False):
|
|||||||
require(file_sha(ROLLBACK)==ROLLBACK_SHA,'rollback modified')
|
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,
|
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'],
|
'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,'runtime_files_unchanged_from_code18':len(report['files']) if runtime_fix 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,'runtime_files_unchanged_from_code18':len(report['files']) if runtime_fix or playback_diagnostic else None}
|
||||||
(output/'delivery.json').write_text(json.dumps(delivery,indent=2)+'\n')
|
(output/'delivery.json').write_text(json.dumps(delivery,indent=2)+'\n')
|
||||||
return delivery
|
return delivery
|
||||||
|
|
||||||
@@ -358,7 +359,10 @@ def main():
|
|||||||
parser.add_argument('--action-registry',type=Path,help='Reviewed public gateway registry required for full dance release')
|
parser.add_argument('--action-registry',type=Path,help='Reviewed public gateway registry required for full dance release')
|
||||||
parser.add_argument('--version-code',type=int,help='Default max existing APK code+1, minimum17')
|
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('--runtime-fix',action='store_true',help='0.7.1 Android-only repair; all avatar bytes must equal frozen code18')
|
||||||
args=parser.parse_args();manifest=args.manifest.resolve(strict=True);output=args.output.resolve()
|
parser.add_argument('--playback-diagnostic',action='store_true',help='0.7.2 diagnostic-only Android build, frozen code18 avatar bytes')
|
||||||
|
args=parser.parse_args();
|
||||||
|
require(not (args.runtime_fix and args.playback_diagnostic),'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')
|
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')
|
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')
|
||||||
if args.import_only or args.publish:
|
if args.import_only or args.publish:
|
||||||
@@ -374,7 +378,7 @@ def main():
|
|||||||
require(not args.previous_pin and not args.backup,'previous import report required')
|
require(not args.previous_pin and not args.backup,'previous import report required')
|
||||||
import_files(manifest.parent,report['files'],target)
|
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')
|
(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) 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) if args.publish else {k:v for k,v in report.items() if k!='files'}
|
||||||
print(json.dumps(result,indent=2))
|
print(json.dumps(result,indent=2))
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import android.media.MediaPlayer
|
|||||||
import android.view.TextureView
|
import android.view.TextureView
|
||||||
|
|
||||||
fun main() {
|
fun main() {
|
||||||
|
playbackDiagnosticCheck()
|
||||||
boundedRuntimeDiagnosticCheck()
|
boundedRuntimeDiagnosticCheck()
|
||||||
dynamicBodyCheck()
|
dynamicBodyCheck()
|
||||||
actionCheck()
|
actionCheck()
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ class MediaPlayer {
|
|||||||
var info: ((MediaPlayer,Int,Int)->Boolean)? = null
|
var info: ((MediaPlayer,Int,Int)->Boolean)? = null
|
||||||
var error: ((MediaPlayer,Int,Int)->Boolean)? = null
|
var error: ((MediaPlayer,Int,Int)->Boolean)? = null
|
||||||
var completion: ((MediaPlayer)->Unit)? = null
|
var completion: ((MediaPlayer)->Unit)? = null
|
||||||
|
var currentPosition = 0
|
||||||
var isLooping = false; val looping get() = isLooping
|
var isLooping = false; val looping get() = isLooping
|
||||||
var volume = 1f; var released = false; var started = false
|
var volume = 1f; var released = false; var started = false
|
||||||
val videoWidth = 480; val videoHeight = 848
|
val videoWidth = 480; val videoHeight = 848
|
||||||
|
|||||||
@@ -0,0 +1,88 @@
|
|||||||
|
import com.gorios.lanvoice.avatar.*
|
||||||
|
import com.gorios.lanvoice.diag.DiagnosticLog
|
||||||
|
import android.os.TestScheduler
|
||||||
|
import android.media.MediaPlayer
|
||||||
|
import android.view.TextureView
|
||||||
|
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()
|
||||||
|
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)}
|
||||||
|
}
|
||||||
|
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.
|
||||||
|
}
|
||||||
|
class Player: ActionPlayer {
|
||||||
|
lateinit var end: (ActionEnd)->Unit;lateinit var failure: ()->Unit;lateinit var release: ()->Unit
|
||||||
|
val ids=mutableListOf<String>()
|
||||||
|
override fun play(asset: ActionAsset,finished: (ActionEnd)->Unit,failed: ()->Unit) {ids.add(asset.id);end=finished;failure=failed}
|
||||||
|
override fun stop(released: ()->Unit) {release=released}
|
||||||
|
}
|
||||||
|
val p=Player();var now=0L;val events=mutableListOf<Pair<Boolean,String>>()
|
||||||
|
val demo=OfflineDancePreview(mediaFixtureIndex().actionPack,p,{now}) {a,s->events.add(a to s)}
|
||||||
|
check(!demo.play("unknown") && p.ids.isEmpty());assertions++
|
||||||
|
check(demo.play("asset_01") && !demo.play("asset_02"));assertions++
|
||||||
|
val old=p.end;old(ActionEnd(true,true,true)) // Early end is failure, never completion.
|
||||||
|
check(demo.active && events.none { it.second=="completed" });assertions++
|
||||||
|
p.release();check(!demo.active);assertions++
|
||||||
|
check(demo.play("asset_02"));assertions++
|
||||||
|
old(ActionEnd(true,true,true));check(demo.active);assertions++
|
||||||
|
now=1001;p.end(ActionEnd(true,true,true));check(!demo.active && events.last().second=="completed");assertions++
|
||||||
|
check(demo.play("asset_01"));assertions++
|
||||||
|
val stale=p.failure;demo.cancel("background");demo.cancel();check(!demo.play("asset_02"));assertions++
|
||||||
|
p.release();stale();check(!demo.active && events.last().second=="released");assertions++
|
||||||
|
check(demo.play("asset_02"));assertions++
|
||||||
|
p.failure();p.release();check(!demo.active && p.ids==listOf("asset_01","asset_02","asset_01","asset_02"));assertions++
|
||||||
|
// Local controls exercise the actual persistent View + renderer + native music callbacks.
|
||||||
|
for(id in listOf("asset_01","asset_02")) {
|
||||||
|
TestScheduler.reset();android.media.CodecFixture.reset();MediaPlayer.created.clear()
|
||||||
|
android.media.CodecFixture.emitNativeSurface=true
|
||||||
|
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 }
|
||||||
|
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})
|
||||||
|
check(local.play(id));assertions++
|
||||||
|
TestScheduler.until { MediaPlayer.created.isNotEmpty() }
|
||||||
|
val native=MediaPlayer.created.last();native.prepared!!(native)
|
||||||
|
TestScheduler.until { native.started }
|
||||||
|
val texture=(view.javaClass.getDeclaredField("textures").apply { isAccessible=true }.get(view) as List<TextureView>).last()
|
||||||
|
val start=TestScheduler.now
|
||||||
|
val media=index.actionPack!!.assets.single { it.id==id }.media!!
|
||||||
|
for(pts in media.ptsUs) {
|
||||||
|
TestScheduler.advanceBy((start+pts/1000-TestScheduler.now).coerceAtLeast(0))
|
||||||
|
texture.surfaceTexture.timestamp=pts*1000
|
||||||
|
texture.surfaceTextureListener!!.onSurfaceTextureUpdated(texture.surfaceTexture)
|
||||||
|
TestScheduler.advanceBy(1)
|
||||||
|
check(texture.alpha==1f && local.active);assertions++
|
||||||
|
}
|
||||||
|
TestScheduler.advanceBy((start+1000-TestScheduler.now).coerceAtLeast(0))
|
||||||
|
native.completion!!(native)
|
||||||
|
TestScheduler.until { !local.active }
|
||||||
|
check(native.released && texture.alpha==0f && binding.diagnosticState.contains("event=released"));assertions++
|
||||||
|
view.dispose();TestScheduler.advanceBy(50)
|
||||||
|
}
|
||||||
|
println("PASS: $assertions production native failure reasons/info-vs-latched/stale-callback/release and sensor-free offline dance lifecycle assertions; strict media gate retained, native Android/GPU not_run")
|
||||||
|
}
|
||||||
@@ -232,6 +232,19 @@ class PackageTests(unittest.TestCase):
|
|||||||
with self.subTest(kind=kind),self.assertRaises(ValueError):
|
with self.subTest(kind=kind),self.assertRaises(ValueError):
|
||||||
pack.verify_runtime_fix_assets(new,'0'*64 if kind=='pin' else pin)
|
pack.verify_runtime_fix_assets(new,'0'*64 if kind=='pin' else pin)
|
||||||
|
|
||||||
|
def test_diagnostic_requires_frozen_full_pack_and_fresh_version(self):
|
||||||
|
report={'manifest_sha256':pack.RUNTIME_FIX_PIN}
|
||||||
|
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=20),patch.object(pack.subprocess,'run',side_effect=RuntimeError('build_sentinel')) as build:
|
||||||
|
for full,pin,code in ((False,pack.RUNTIME_FIX_PIN,20),(True,'0'*64,20),(True,pack.RUNTIME_FIX_PIN,19)):
|
||||||
|
with self.subTest(full=full,pin=pin,code=code),self.assertRaises(ValueError):
|
||||||
|
pack.publish({'manifest_sha256':pin},self.base,code,full,False,True)
|
||||||
|
build.assert_not_called()
|
||||||
|
with self.assertRaisesRegex(RuntimeError,'build_sentinel'):
|
||||||
|
pack.publish(report,self.base,20,True,False,True)
|
||||||
|
command=build.call_args.args[0]
|
||||||
|
self.assertIn('-PavatarPlaybackDiagnostic=true',command)
|
||||||
|
self.assertIn('-PactionVersionCode=20',command)
|
||||||
|
|
||||||
def test_cli_no_pin_no_import_no_output(self):
|
def test_cli_no_pin_no_import_no_output(self):
|
||||||
self.manifest.write_text(json.dumps(self.index));out=self.base/'no-pin-output'
|
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'),
|
result=subprocess.run([sys.executable,str(ROOT/'scripts/package-avatar-emotion.py'),
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import com.gorios.lanvoice.avatar.*
|
|||||||
import com.gorios.lanvoice.net.*
|
import com.gorios.lanvoice.net.*
|
||||||
|
|
||||||
fun checkActionSession() {
|
fun checkActionSession() {
|
||||||
|
checkLocalPreviewCaptureFence()
|
||||||
checkActionFollowupSession()
|
checkActionFollowupSession()
|
||||||
val sha="a".repeat(64);val states=mutableListOf<VoiceUiState>()
|
val sha="a".repeat(64);val states=mutableListOf<VoiceUiState>()
|
||||||
val prepared=mutableListOf<com.gorios.lanvoice.dialogue.ReplyEmotion?>()
|
val prepared=mutableListOf<com.gorios.lanvoice.dialogue.ReplyEmotion?>()
|
||||||
@@ -102,3 +103,21 @@ fun checkActionFollowupSession() {
|
|||||||
session.release();AudioPlayback.activityFence=null
|
session.release();AudioPlayback.activityFence=null
|
||||||
println("PASS: client normal action completion/new server speech turn accepted, future after emotion hidden, retired pre audio/emotion/drain rejected, independent after drain and duplicate completion fence; deterministic doubles only")
|
println("PASS: client normal action completion/new server speech turn accepted, future after emotion hidden, retired pre audio/emotion/drain rejected, independent after drain and duplicate completion fence; deterministic doubles only")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun checkLocalPreviewCaptureFence() {
|
||||||
|
AudioCapture.confirmStopsAutomatically=false
|
||||||
|
val s=VoiceSession("localhost",5011,{})
|
||||||
|
val results=mutableListOf<Boolean>()
|
||||||
|
s.suspendForLocalPreview(results::add);Handler.drain()
|
||||||
|
check(results.isEmpty())
|
||||||
|
AudioCapture.lastStopped!!(false);Handler.drain();check(results==listOf(false))
|
||||||
|
AudioCapture.lastStopped!!(true);Handler.drain();check(results==listOf(false))
|
||||||
|
s.suspendForLocalPreview(results::add);AudioCapture.lastStopped!!(true);Handler.drain()
|
||||||
|
check(results==listOf(false,true))
|
||||||
|
s.suspendForLocalPreview(results::add);s.foreground(connectAutomatically=false)
|
||||||
|
AudioCapture.lastStopped!!(true);Handler.drain();check(results.last()==false)
|
||||||
|
s.suspendForLocalPreview(results::add);val stale=AudioCapture.lastStopped!!;s.release()
|
||||||
|
stale(true);Handler.drain();check(results.last()==false)
|
||||||
|
AudioCapture.confirmStopsAutomatically=true
|
||||||
|
println("PASS:6 production local-preview capture cleanup/unconfirmed/duplicate/foreground/release callback fences; AudioRecord double, device not_run")
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user