Bind capture startup to the generation of its update request

This commit is contained in:
evgeny committed 2026-10-29 13:34:23 +01:00
1 parent 6bde320ce2
commit 29361aa800
1 file changed
+3 -3
@@ -440,7 +440,8 @@ class RadioAudioEngine {
if (captureSubscription != null && (captureRequestedMode != mode || (detectorFailed && !requestedTalk && !levelMonitoring))) stopCapture()
if (audioTrack == null) return
if (captureSubscription == null && nativeCaptureOwned) stopCapture()
if (captureSubscription == null && !startCapture(mode)) {
if (!active || generation != version || groupId != audioGroup) return
if (captureSubscription == null && !startCapture(mode, version)) {
if (generation == version) {
requestedTalk = false
_talkingFlow.value = nativeCaptureOwned && _transmittingGroup.value != null
@@ -467,13 +468,12 @@ class RadioAudioEngine {
}
/** Только io: сохранить подписку/native-владение до возможного эффекта API; при отказе выполнить rollback. */
private fun startCapture(mode: Int): Boolean {
private fun startCapture(mode: Int, version: Long): Boolean {
if (!MicrophonePermission.granted()) {
LogManager.addLog("WARN", "radio", "Auto/PTT capture blocked: RECORD_AUDIO not granted group=$audioGroup mode=$mode")
return false
}
val captureGroup = audioGroup
val version = generation
var operation = "subscribe"
try {
val subscription = MediaAudioController.subscribe("radio")