diff --git a/app/build.gradle b/app/build.gradle index 484ccdf..82023a4 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -45,8 +45,8 @@ android { applicationId 'com.gorios.lanvoice' minSdk 26 targetSdk 34 - versionCode 5 - versionName '0.3.1' + versionCode 6 + versionName '0.3.3' ndk { abiFilters 'arm64-v8a' } } compileOptions { sourceCompatibility JavaVersion.VERSION_17; targetCompatibility JavaVersion.VERSION_17 } diff --git a/app/src/main/java/com/gorios/lanvoice/audio/VoiceSession.kt b/app/src/main/java/com/gorios/lanvoice/audio/VoiceSession.kt index cd4da8c..35a8b65 100644 --- a/app/src/main/java/com/gorios/lanvoice/audio/VoiceSession.kt +++ b/app/src/main/java/com/gorios/lanvoice/audio/VoiceSession.kt @@ -222,6 +222,9 @@ class VoiceSession( diagnostic("ABORT ignored active=false blockedTurn=$blockedTurn") return } + // An ABORT can announce the replacement turn. Remember the interrupted + // turn before acceptTurn updates currentTurn and retires the old one. + val oldTurn = if (hasTurn) currentTurn else null if (turn != null && !acceptTurn(turn)) return val action = event.payload.optString("state", "").ifBlank { event.type.substringAfter('.', "") } when (event.kind) { @@ -260,8 +263,8 @@ class VoiceSession( // listen_start aborts the previous reply while announcing the NEW turn. // The server's following LISTEN start and TTS belong to that new turn. val listenReset = event.payload.optString("reason") == "listen_start" - blockedTurn = if (listenReset) null else currentTurn - diagnostic("ABORT blockedTurn=$blockedTurn active=${isActive()} listenReset=$listenReset") + blockedTurn = if (listenReset) null else oldTurn + diagnostic("ABORT blockedTurn=$blockedTurn active=${isActive()} listenReset=$listenReset oldTurn=$oldTurn currentTurn=$currentTurn") playback.interrupt() if (isActive()) { update(state.copy(phase = VoicePhase.LISTENING))