Use bounded AAudio write pacing in probe and trace audio controls
This commit is contained in:
1 parent
7a6ecf700c
commit
ede911e7e4
2 files changed
+3
-4
No files matched your search
@@ -273,6 +273,8 @@ object CallController : TelecomCallManager.Listener {
|
||||
}
|
||||
|
||||
private fun routeChanged(route: AudioRoute, headset: Boolean) {
|
||||
if (_route.value != route || _headset.value != headset) LogManager.addLog("INFO", "Call",
|
||||
"audio controls id=${_state.value?.callId} route=$route headset=$headset")
|
||||
_route.value = route
|
||||
_headset.value = headset
|
||||
if (route != AudioRoute.EARPIECE) videoSpeakerPending = false
|
||||
|
||||
@@ -102,12 +102,9 @@ extern "C" JNIEXPORT jboolean JNICALL Java_com_utun_audioprobe_ProbeActivity_ope
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jint JNICALL Java_com_utun_audioprobe_ProbeActivity_writeNative(JNIEnv* env, jclass, jshortArray input) {
|
||||
int64_t queued = AAudioStream_getFramesWritten(probe.stream) - AAudioStream_getFramesRead(probe.stream);
|
||||
int available = int(std::max<int64_t>(0, AAudioStream_getBufferSizeInFrames(probe.stream) - queued));
|
||||
if (!available) return AAudioStream_getState(probe.stream) == AAUDIO_STREAM_STATE_DISCONNECTED ? AAUDIO_ERROR_DISCONNECTED : 0;
|
||||
int16_t samples[960]{};
|
||||
env->GetShortArrayRegion(input, 0, 960, samples);
|
||||
return AAudioStream_write(probe.stream, samples, std::min(available, 960 / probe.channels), 0);
|
||||
return AAudioStream_write(probe.stream, samples, std::min(960 / probe.channels, AAudioStream_getFramesPerBurst(probe.stream)), 100000000);
|
||||
}
|
||||
|
||||
/* Timestamp опрашивается вне realtime callback. Java одинаково агрегирует AAudio и AudioTrack. */
|
||||
|
||||
Reference in new issue
Block a user