diff --git a/modules/audio_device/android/audio_manager.cc b/modules/audio_device/android/audio_manager.cc index 63020bb7ec..98a2afd20c 100644 --- a/modules/audio_device/android/audio_manager.cc +++ b/modules/audio_device/android/audio_manager.cc @@ -236,6 +236,7 @@ int AudioManager::GetDelayEstimateInMilliseconds() const { return delay_estimate_in_milliseconds_; } +JNI_FUNCTION_ALIGN void JNICALL AudioManager::CacheAudioParameters(JNIEnv* env, jobject obj, jint sample_rate, diff --git a/modules/audio_device/android/audio_record_jni.cc b/modules/audio_device/android/audio_record_jni.cc index 7e4654ecdd..02d74486e0 100644 --- a/modules/audio_device/android/audio_record_jni.cc +++ b/modules/audio_device/android/audio_record_jni.cc @@ -229,6 +229,7 @@ int32_t AudioRecordJni::EnableBuiltInNS(bool enable) { return j_audio_record_->EnableBuiltInNS(enable) ? 0 : -1; } +JNI_FUNCTION_ALIGN void JNICALL AudioRecordJni::CacheDirectBufferAddress(JNIEnv* env, jobject obj, jobject byte_buffer, @@ -249,6 +250,7 @@ void AudioRecordJni::OnCacheDirectBufferAddress(JNIEnv* env, direct_buffer_capacity_in_bytes_ = static_cast(capacity); } +JNI_FUNCTION_ALIGN void JNICALL AudioRecordJni::DataIsRecorded(JNIEnv* env, jobject obj, jint length, diff --git a/modules/audio_device/android/audio_track_jni.cc b/modules/audio_device/android/audio_track_jni.cc index 4469450a9a..f8f254a883 100644 --- a/modules/audio_device/android/audio_track_jni.cc +++ b/modules/audio_device/android/audio_track_jni.cc @@ -204,6 +204,7 @@ void AudioTrackJni::AttachAudioBuffer(AudioDeviceBuffer* audioBuffer) { audio_device_buffer_->SetPlayoutChannels(channels); } +JNI_FUNCTION_ALIGN void JNICALL AudioTrackJni::CacheDirectBufferAddress(JNIEnv* env, jobject obj, jobject byte_buffer, @@ -227,6 +228,7 @@ void AudioTrackJni::OnCacheDirectBufferAddress(JNIEnv* env, RTC_LOG(INFO) << "frames_per_buffer: " << frames_per_buffer_; } +JNI_FUNCTION_ALIGN void JNICALL AudioTrackJni::GetPlayoutData(JNIEnv* env, jobject obj, jint length, diff --git a/modules/utility/include/helpers_android.h b/modules/utility/include/helpers_android.h index 2ee577ceea..808b347ee7 100644 --- a/modules/utility/include/helpers_android.h +++ b/modules/utility/include/helpers_android.h @@ -20,6 +20,15 @@ RTC_CHECK(!jni->ExceptionCheck()) \ << (jni->ExceptionDescribe(), jni->ExceptionClear(), "") +#if defined(WEBRTC_ARCH_X86) +// Dalvik JIT generated code doesn't guarantee 16-byte stack alignment on +// x86 - use force_align_arg_pointer to realign the stack at the JNI +// boundary. bugs.webrtc.org/9050 +#define JNI_FUNCTION_ALIGN __attribute__((force_align_arg_pointer)) +#else +#define JNI_FUNCTION_ALIGN +#endif + namespace webrtc { // Return a |JNIEnv*| usable on this thread or NULL if this thread is detached.