|
|
|
|
@ -10,6 +10,7 @@
|
|
|
|
|
#include "../../../lib/audio_compressor.h" |
|
|
|
|
#include "../libutun_lite/stream_bridge.h" |
|
|
|
|
#include "../../../src/stream/stream_media.h" |
|
|
|
|
#include "../../../src/stream/stream_media_buffer.h" |
|
|
|
|
#include "../../../src/stream/stream_playback_clock.h" |
|
|
|
|
#include "../../../src/stream/stream_playback_audio.h" |
|
|
|
|
|
|
|
|
|
@ -88,6 +89,7 @@ struct android_stream_playback {
|
|
|
|
|
struct stream_playback_state state; |
|
|
|
|
struct stream_playback_audio *audio; |
|
|
|
|
int64_t position, time_us; |
|
|
|
|
int finished; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
JNIEXPORT jlong JNICALL Java_com_utun_chat_data_NativeLib_nativeStreamPlaybackCreate( |
|
|
|
|
@ -136,6 +138,7 @@ JNIEXPORT jlongArray JNICALL Java_com_utun_chat_data_NativeLib_nativeStreamPlayb
|
|
|
|
|
if (p->audio) { |
|
|
|
|
p->position = stream_playback_audio_position(p->audio, (uint64_t)played); |
|
|
|
|
pending = stream_playback_audio_pending_gain(p->audio, (uint64_t)played); |
|
|
|
|
if (!p->finished && stream_playback_audio_starved(p->audio, (uint64_t)played)) starved = JNI_TRUE; |
|
|
|
|
} else if (p->time_us >= 0 && !starved) { |
|
|
|
|
int64_t elapsed = now - p->time_us; |
|
|
|
|
if (elapsed < 0) { DEBUG_ERROR(DEBUG_CATEGORY_STREAM, "JNI playback wall clock regressed"); return NULL; } |
|
|
|
|
@ -157,7 +160,7 @@ JNIEXPORT jlongArray JNICALL Java_com_utun_chat_data_NativeLib_nativeStreamPlayb
|
|
|
|
|
|
|
|
|
|
JNIEXPORT void JNICALL Java_com_utun_chat_data_NativeLib_nativeStreamPlaybackFinish(JNIEnv *env, jobject obj, jlong handle) { |
|
|
|
|
(void)env; (void)obj; struct android_stream_playback *p = (struct android_stream_playback *)(intptr_t)handle; |
|
|
|
|
if (p) stream_playback_audio_finish(p->audio); |
|
|
|
|
if (p) { p->finished = 1; stream_playback_audio_finish(p->audio); } |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
JNIEXPORT jboolean JNICALL Java_com_utun_chat_data_NativeLib_nativeStreamPlaybackEmpty(JNIEnv *env, jobject obj, jlong handle) { |
|
|
|
|
|