src/core/android/SDL_android.cpp
changeset 6864 97187387ad79
parent 6828 ac7f004fb63c
child 6885 700f1b25f77f
equal deleted inserted replaced
6863:73be5b6b2a86 6864:97187387ad79
   428     if (!env) {
   428     if (!env) {
   429         LOGE("callback_handler: failed to attach current thread");
   429         LOGE("callback_handler: failed to attach current thread");
   430     }
   430     }
   431     Android_JNI_SetupThread();
   431     Android_JNI_SetupThread();
   432 
   432 
   433     
       
   434     __android_log_print(ANDROID_LOG_VERBOSE, "SDL", "SDL audio: opening device");
   433     __android_log_print(ANDROID_LOG_VERBOSE, "SDL", "SDL audio: opening device");
   435     audioBuffer16Bit = is16Bit;
   434     audioBuffer16Bit = is16Bit;
   436     audioBufferStereo = channelCount > 1;
   435     audioBufferStereo = channelCount > 1;
   437 
   436 
   438     env->CallStaticObjectMethod(mActivityClass, midAudioInit, sampleRate, audioBuffer16Bit, audioBufferStereo, desiredBufferFrames);
   437     env->CallStaticVoidMethod(mActivityClass, midAudioInit, sampleRate, audioBuffer16Bit, audioBufferStereo, desiredBufferFrames);
   439 
   438 
   440     /* Allocating the audio buffer from the Java side and passing it as the return value for audioInit no longer works on
   439     /* Allocating the audio buffer from the Java side and passing it as the return value for audioInit no longer works on
   441      * Android >= 4.2 due to a "stale global reference" error. So now we allocate this buffer directly from this side. */
   440      * Android >= 4.2 due to a "stale global reference" error. So now we allocate this buffer directly from this side. */
   442     
   441     
   443     if (is16Bit) {
   442     if (is16Bit) {
   469         audioBufferFrames = env->GetArrayLength((jbyteArray)audioBuffer);
   468         audioBufferFrames = env->GetArrayLength((jbyteArray)audioBuffer);
   470     }
   469     }
   471     if (audioBufferStereo) {
   470     if (audioBufferStereo) {
   472         audioBufferFrames /= 2;
   471         audioBufferFrames /= 2;
   473     }
   472     }
   474  
   473 
   475     return audioBufferFrames;
   474     return audioBufferFrames;
   476 }
   475 }
   477 
   476 
   478 extern "C" void * Android_JNI_GetAudioBuffer()
   477 extern "C" void * Android_JNI_GetAudioBuffer()
   479 {
   478 {