|
|
|
|
@ -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. */ |
|
|
|
|
|