Reset radio detector after Android capture queue discontinuities
This commit is contained in:
1 parent
051d453c2d
commit
2038e33d8d
3 files changed
+18
No files matched your search
@@ -292,6 +292,7 @@ object NativeLib {
|
||||
// dBFS, valid, RX-блокировка, вероятность речи 0..1, vadValid, усиление VAD в dB, компрессор VAD включён.
|
||||
fun radioInputStatus(): FloatArray = nativeRadioInputStatus()
|
||||
fun radioCaptureStop() { nativeRadioCaptureStop() }
|
||||
fun radioCaptureDiscontinuity(groupId: Long) { nativeRadioCaptureDiscontinuity(groupId) }
|
||||
fun radioTransmitting(): Boolean = nativeRadioTransmitting()
|
||||
fun radioAutoMode(): Int = nativeRadioAutoMode()
|
||||
fun radioTalkBegin(groupId: Long) { nativeRadioTalkBegin(groupId) }
|
||||
@@ -423,6 +424,7 @@ object NativeLib {
|
||||
private external fun nativeRadioConfigure(requestId: Long, settings: IntArray): Boolean
|
||||
private external fun nativeRadioInputStatus(): FloatArray
|
||||
private external fun nativeRadioCaptureStop()
|
||||
private external fun nativeRadioCaptureDiscontinuity(groupId: Long)
|
||||
private external fun nativeRadioTransmitting(): Boolean
|
||||
private external fun nativeRadioAutoMode(): Int
|
||||
private external fun nativeRadioTalkBegin(groupId: Long)
|
||||
|
||||
@@ -656,6 +656,8 @@ class RadioAudioEngine {
|
||||
}
|
||||
|
||||
private fun captureLoop(subscription: MicrophoneCapture.Subscription, group: Long, ch: Int) {
|
||||
var expected = -1L
|
||||
var discontinuity = false
|
||||
var frameN = 0L
|
||||
var reportedRequestNs = 0L
|
||||
var statsMs = SystemClock.elapsedRealtime()
|
||||
@@ -678,6 +680,14 @@ class RadioAudioEngine {
|
||||
continue
|
||||
}
|
||||
val captured = event as MicrophoneCapture.Frame
|
||||
val ageNs = System.nanoTime() - captured.createdNs
|
||||
if (ageNs > 100_000_000) {
|
||||
if (!discontinuity) LogManager.addLog("WARN", "radio", "stale capture group=$group ageMs=${ageNs / 1_000_000}")
|
||||
discontinuity = true
|
||||
continue
|
||||
}
|
||||
if (discontinuity || (expected >= 0 && captured.sequence != expected)) NativeLib.radioCaptureDiscontinuity(group)
|
||||
discontinuity = false; expected = captured.sequence + FRAME_SAMPLES
|
||||
val buf = captured.pcm
|
||||
maxReadNs = maxOf(maxReadNs, SystemClock.elapsedRealtimeNanos() - readStartedNs)
|
||||
val inputDb = rmsDb(buf)
|
||||
|
||||
Reference in new issue
Block a user