diff options
author | Paul McLean <pmclean@google.com> | 2016-03-10 14:10:15 -0700 |
---|---|---|
committer | Paul McLean <pmclean@google.com> | 2016-03-14 12:20:48 -0600 |
commit | 15f1e492e8fe7e2b6665009b5facd2b42913ab0f (patch) | |
tree | fdc9fce07baca4e08028ff88f42ae898dd7636de | |
parent | 9f48e6a5f01aa87fab5c5cc867f8b078f96d1a45 (diff) | |
download | android_frameworks_wilhelm-15f1e492e8fe7e2b6665009b5facd2b42913ab0f.tar.gz android_frameworks_wilhelm-15f1e492e8fe7e2b6665009b5facd2b42913ab0f.tar.bz2 android_frameworks_wilhelm-15f1e492e8fe7e2b6665009b5facd2b42913ab0f.zip |
Native routing phase 4
Allow Acquire before Realize
Bug: 23899814
Change-Id: I27682ecb5259fc6ebbe3eca5c6aba5d956aa42bb
-rw-r--r-- | src/android/AudioPlayer_to_android.cpp | 21 | ||||
-rw-r--r-- | src/android/AudioRecorder_to_android.cpp | 21 | ||||
-rw-r--r-- | src/itf/IAndroidConfiguration.c | 26 |
3 files changed, 55 insertions, 13 deletions
diff --git a/src/android/AudioPlayer_to_android.cpp b/src/android/AudioPlayer_to_android.cpp index 2069a0b..685b54a 100644 --- a/src/android/AudioPlayer_to_android.cpp +++ b/src/android/AudioPlayer_to_android.cpp @@ -22,6 +22,8 @@ #include "android/include/AacBqToPcmCbRenderer.h" #include "android/channels.h" +#include <android_runtime/AndroidRuntime.h> + #include <fcntl.h> #include <sys/stat.h> @@ -1519,7 +1521,26 @@ SLresult android_audioPlayer_realize(CAudioPlayer *pAudioPlayer, SLboolean async // This use case does not have a separate "prepare" step pAudioPlayer->mAndroidObjState = ANDROID_READY; + + // If there is a JavaAudioRoutingProxy associated with this player, hook it up... + JNIEnv* j_env = NULL; + jclass clsAudioTrack = NULL; + jmethodID midRoutingProxy_connect = NULL; + if (pAudioPlayer->mAndroidConfiguration.mRoutingProxy != NULL && + (j_env = android::AndroidRuntime::getJNIEnv()) != NULL && + (clsAudioTrack = j_env->FindClass("android/media/AudioTrack")) != NULL && + (midRoutingProxy_connect = + j_env->GetMethodID(clsAudioTrack, "deferred_connect", "(J)V")) != NULL) { + j_env->ExceptionClear(); + j_env->CallVoidMethod(pAudioPlayer->mAndroidConfiguration.mRoutingProxy, + midRoutingProxy_connect, + pAudioPlayer->mAudioTrack.get()); + if (j_env->ExceptionCheck()) { + SL_LOGE("Java exception releasing recorder routing object."); + result = SL_RESULT_INTERNAL_ERROR; + } } + } break; //----------------------------------- diff --git a/src/android/AudioRecorder_to_android.cpp b/src/android/AudioRecorder_to_android.cpp index d2c63cd..bf6ecc4 100644 --- a/src/android/AudioRecorder_to_android.cpp +++ b/src/android/AudioRecorder_to_android.cpp @@ -23,6 +23,8 @@ #include <system/audio.h> #include <SLES/OpenSLES_Android.h> +#include <android_runtime/AndroidRuntime.h> + #define KEY_RECORDING_SOURCE_PARAMSIZE sizeof(SLuint32) #define KEY_RECORDING_PRESET_PARAMSIZE sizeof(SLuint32) @@ -481,6 +483,25 @@ SLresult android_audioRecorder_realize(CAudioRecorder* ar, SLboolean async) { ar->mAudioRecord.clear(); } + // If there is a JavaAudioRoutingProxy associated with this recorder, hook it up... + JNIEnv* j_env = NULL; + jclass clsAudioRecord = NULL; + jmethodID midRoutingProxy_connect = NULL; + if (ar->mAndroidConfiguration.mRoutingProxy != NULL && + (j_env = android::AndroidRuntime::getJNIEnv()) != NULL && + (clsAudioRecord = j_env->FindClass("android/media/AudioRecord")) != NULL && + (midRoutingProxy_connect = + j_env->GetMethodID(clsAudioRecord, "deferred_connect", "(J)V")) != NULL) { + j_env->ExceptionClear(); + j_env->CallVoidMethod(ar->mAndroidConfiguration.mRoutingProxy, + midRoutingProxy_connect, + ar->mAudioRecord.get()); + if (j_env->ExceptionCheck()) { + SL_LOGE("Java exception releasing recorder routing object."); + result = SL_RESULT_INTERNAL_ERROR; + } + } + return result; } diff --git a/src/itf/IAndroidConfiguration.c b/src/itf/IAndroidConfiguration.c index 9b2dd8e..bc0b666 100644 --- a/src/itf/IAndroidConfiguration.c +++ b/src/itf/IAndroidConfiguration.c @@ -115,19 +115,19 @@ static SLresult ValidatePlayerConfig(IAndroidConfiguration* iConfig) { switch (player->mAndroidObjType) { case AUDIOPLAYER_FROM_PCM_BUFFERQUEUE: - if (player->mObject.mState != SL_OBJECT_STATE_REALIZED) { - // Make sure the player has been realized. - result = SL_RESULT_PRECONDITIONS_VIOLATED; - SL_LOGE("Error creating routing object - Player not realized."); - } else { - android::AudioTrack* pAudioTrack = player->mAudioTrack.get(); - if (pAudioTrack == NULL) { - result = SL_RESULT_INTERNAL_ERROR; - SL_LOGE("Error creating routing object - Couldn't get AudioTrack."); - } else { - result = SL_RESULT_SUCCESS; - } - } +// if (player->mObject.mState != SL_OBJECT_STATE_REALIZED) { +// // Make sure the player has been realized. +// result = SL_RESULT_PRECONDITIONS_VIOLATED; +// SL_LOGE("Error creating routing object - Player not realized."); +// } else { +// android::AudioTrack* pAudioTrack = player->mAudioTrack.get(); +// if (pAudioTrack == NULL) { +// result = SL_RESULT_INTERNAL_ERROR; +// SL_LOGE("Error creating routing object - Couldn't get AudioTrack."); +// } else { + result = SL_RESULT_SUCCESS; +// } +// } break; default: |