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 включён.
|
// dBFS, valid, RX-блокировка, вероятность речи 0..1, vadValid, усиление VAD в dB, компрессор VAD включён.
|
||||||
fun radioInputStatus(): FloatArray = nativeRadioInputStatus()
|
fun radioInputStatus(): FloatArray = nativeRadioInputStatus()
|
||||||
fun radioCaptureStop() { nativeRadioCaptureStop() }
|
fun radioCaptureStop() { nativeRadioCaptureStop() }
|
||||||
|
fun radioCaptureDiscontinuity(groupId: Long) { nativeRadioCaptureDiscontinuity(groupId) }
|
||||||
fun radioTransmitting(): Boolean = nativeRadioTransmitting()
|
fun radioTransmitting(): Boolean = nativeRadioTransmitting()
|
||||||
fun radioAutoMode(): Int = nativeRadioAutoMode()
|
fun radioAutoMode(): Int = nativeRadioAutoMode()
|
||||||
fun radioTalkBegin(groupId: Long) { nativeRadioTalkBegin(groupId) }
|
fun radioTalkBegin(groupId: Long) { nativeRadioTalkBegin(groupId) }
|
||||||
@@ -423,6 +424,7 @@ object NativeLib {
|
|||||||
private external fun nativeRadioConfigure(requestId: Long, settings: IntArray): Boolean
|
private external fun nativeRadioConfigure(requestId: Long, settings: IntArray): Boolean
|
||||||
private external fun nativeRadioInputStatus(): FloatArray
|
private external fun nativeRadioInputStatus(): FloatArray
|
||||||
private external fun nativeRadioCaptureStop()
|
private external fun nativeRadioCaptureStop()
|
||||||
|
private external fun nativeRadioCaptureDiscontinuity(groupId: Long)
|
||||||
private external fun nativeRadioTransmitting(): Boolean
|
private external fun nativeRadioTransmitting(): Boolean
|
||||||
private external fun nativeRadioAutoMode(): Int
|
private external fun nativeRadioAutoMode(): Int
|
||||||
private external fun nativeRadioTalkBegin(groupId: Long)
|
private external fun nativeRadioTalkBegin(groupId: Long)
|
||||||
|
|||||||
@@ -656,6 +656,8 @@ class RadioAudioEngine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun captureLoop(subscription: MicrophoneCapture.Subscription, group: Long, ch: Int) {
|
private fun captureLoop(subscription: MicrophoneCapture.Subscription, group: Long, ch: Int) {
|
||||||
|
var expected = -1L
|
||||||
|
var discontinuity = false
|
||||||
var frameN = 0L
|
var frameN = 0L
|
||||||
var reportedRequestNs = 0L
|
var reportedRequestNs = 0L
|
||||||
var statsMs = SystemClock.elapsedRealtime()
|
var statsMs = SystemClock.elapsedRealtime()
|
||||||
@@ -678,6 +680,14 @@ class RadioAudioEngine {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
val captured = event as MicrophoneCapture.Frame
|
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
|
val buf = captured.pcm
|
||||||
maxReadNs = maxOf(maxReadNs, SystemClock.elapsedRealtimeNanos() - readStartedNs)
|
maxReadNs = maxOf(maxReadNs, SystemClock.elapsedRealtimeNanos() - readStartedNs)
|
||||||
val inputDb = rmsDb(buf)
|
val inputDb = rmsDb(buf)
|
||||||
|
|||||||
@@ -2882,6 +2882,12 @@ JNIEXPORT void JNICALL Java_com_utun_chat_data_NativeLib_nativeRadioCaptureStop(
|
|||||||
radio_audio_capture_stop();
|
radio_audio_capture_stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JNIEXPORT void JNICALL Java_com_utun_chat_data_NativeLib_nativeRadioCaptureDiscontinuity(
|
||||||
|
JNIEnv* env, jobject thiz, jlong groupId) {
|
||||||
|
(void)env; (void)thiz;
|
||||||
|
radio_audio_capture_discontinuity((uint64_t)groupId);
|
||||||
|
}
|
||||||
|
|
||||||
JNIEXPORT jboolean JNICALL Java_com_utun_chat_data_NativeLib_nativeRadioAudioFeed(
|
JNIEXPORT jboolean JNICALL Java_com_utun_chat_data_NativeLib_nativeRadioAudioFeed(
|
||||||
JNIEnv* env, jobject thiz, jlong groupId, jshortArray samples) {
|
JNIEnv* env, jobject thiz, jlong groupId, jshortArray samples) {
|
||||||
(void)thiz;
|
(void)thiz;
|
||||||
|
|||||||
Reference in new issue
Block a user