mirror of https://github.com/encounter/SDL.git
Android: Audio thread is already setup for the JVM
In 'src/thread/pthread/SDL_systhread.c' RunThread() calls first 'Android_JNI_SetupThread()'
This commit is contained in:
parent
9d82f4e985
commit
3cfd907df7
|
@ -1223,11 +1223,6 @@ int Android_JNI_OpenAudioDevice(int iscapture, SDL_AudioSpec *spec)
|
||||||
|
|
||||||
JNIEnv *env = Android_JNI_GetEnv();
|
JNIEnv *env = Android_JNI_GetEnv();
|
||||||
|
|
||||||
if (!env) {
|
|
||||||
LOGE("callback_handler: failed to attach current thread");
|
|
||||||
}
|
|
||||||
Android_JNI_SetupThread();
|
|
||||||
|
|
||||||
switch (spec->format) {
|
switch (spec->format) {
|
||||||
case AUDIO_U8:
|
case AUDIO_U8:
|
||||||
audioformat = ENCODING_PCM_8BIT;
|
audioformat = ENCODING_PCM_8BIT;
|
||||||
|
@ -1386,20 +1381,20 @@ void * Android_JNI_GetAudioBuffer(void)
|
||||||
|
|
||||||
void Android_JNI_WriteAudioBuffer(void)
|
void Android_JNI_WriteAudioBuffer(void)
|
||||||
{
|
{
|
||||||
JNIEnv *mAudioEnv = Android_JNI_GetEnv();
|
JNIEnv *env = Android_JNI_GetEnv();
|
||||||
|
|
||||||
switch (audioBufferFormat) {
|
switch (audioBufferFormat) {
|
||||||
case ENCODING_PCM_8BIT:
|
case ENCODING_PCM_8BIT:
|
||||||
(*mAudioEnv)->ReleaseByteArrayElements(mAudioEnv, (jbyteArray)audioBuffer, (jbyte *)audioBufferPinned, JNI_COMMIT);
|
(*env)->ReleaseByteArrayElements(env, (jbyteArray)audioBuffer, (jbyte *)audioBufferPinned, JNI_COMMIT);
|
||||||
(*mAudioEnv)->CallStaticVoidMethod(mAudioEnv, mAudioManagerClass, midAudioWriteByteBuffer, (jbyteArray)audioBuffer);
|
(*env)->CallStaticVoidMethod(env, mAudioManagerClass, midAudioWriteByteBuffer, (jbyteArray)audioBuffer);
|
||||||
break;
|
break;
|
||||||
case ENCODING_PCM_16BIT:
|
case ENCODING_PCM_16BIT:
|
||||||
(*mAudioEnv)->ReleaseShortArrayElements(mAudioEnv, (jshortArray)audioBuffer, (jshort *)audioBufferPinned, JNI_COMMIT);
|
(*env)->ReleaseShortArrayElements(env, (jshortArray)audioBuffer, (jshort *)audioBufferPinned, JNI_COMMIT);
|
||||||
(*mAudioEnv)->CallStaticVoidMethod(mAudioEnv, mAudioManagerClass, midAudioWriteShortBuffer, (jshortArray)audioBuffer);
|
(*env)->CallStaticVoidMethod(env, mAudioManagerClass, midAudioWriteShortBuffer, (jshortArray)audioBuffer);
|
||||||
break;
|
break;
|
||||||
case ENCODING_PCM_FLOAT:
|
case ENCODING_PCM_FLOAT:
|
||||||
(*mAudioEnv)->ReleaseFloatArrayElements(mAudioEnv, (jfloatArray)audioBuffer, (jfloat *)audioBufferPinned, JNI_COMMIT);
|
(*env)->ReleaseFloatArrayElements(env, (jfloatArray)audioBuffer, (jfloat *)audioBufferPinned, JNI_COMMIT);
|
||||||
(*mAudioEnv)->CallStaticVoidMethod(mAudioEnv, mAudioManagerClass, midAudioWriteFloatBuffer, (jfloatArray)audioBuffer);
|
(*env)->CallStaticVoidMethod(env, mAudioManagerClass, midAudioWriteFloatBuffer, (jfloatArray)audioBuffer);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
__android_log_print(ANDROID_LOG_WARN, "SDL", "SDL audio: unhandled audio buffer format");
|
__android_log_print(ANDROID_LOG_WARN, "SDL", "SDL audio: unhandled audio buffer format");
|
||||||
|
|
Loading…
Reference in New Issue