jint EXPORT_ME Java_com_jeyries_quake2_Quake2_Quake2PaintAudio( JNIEnv* env, jobject thiz, jobject buf ) { extern int paint_audio (void *unused, void * stream, int len); void *stream; int len; stream = (*env)->GetDirectBufferAddress( env, buf); len = (*env)->GetDirectBufferCapacity( env, buf); //__android_log_print(ANDROID_LOG_DEBUG, "quake2-jni.c", "paint_audio %p %d\n", stream, len ); return paint_audio ( NULL, stream, len ); }
void write_audio(int len) { static void *buf = NULL; int chunk = (the_shm.samplebits * the_shm.samples) >> 3; if(!snd_inited) return; if(!buf) buf = malloc(chunk); while(len) { if(chunk > len) chunk = len; paint_audio(NULL, (Uint8 *)buf, chunk); len -= chunk; } }