diff options
author | Eric Laurent <elaurent@google.com> | 2013-07-18 14:41:39 -0700 |
---|---|---|
committer | Eric Laurent <elaurent@google.com> | 2013-08-19 18:26:21 -0700 |
commit | dfb881f96af7898151940a4bbc52e45e6043d38b (patch) | |
tree | a6e62716270dcb7fb2a6a6afe44926e17dd6f69f /core/jni/android_media_AudioSystem.cpp | |
parent | 51d9652d45ec0a22b625a8529479ba61cdb55314 (diff) | |
download | frameworks_base-dfb881f96af7898151940a4bbc52e45e6043d38b.zip frameworks_base-dfb881f96af7898151940a4bbc52e45e6043d38b.tar.gz frameworks_base-dfb881f96af7898151940a4bbc52e45e6043d38b.tar.bz2 |
AudioSystem: new audioflinger restart detection
Add a specific method to AudioSystem for AudioService to poll
for AudioFlinger service restart instead of relying on current
callback mechanism which is flaky.
Bug: 9693068.
Change-Id: Id21d142a22b257205700201978cce1cb8b15180d
Diffstat (limited to 'core/jni/android_media_AudioSystem.cpp')
-rw-r--r-- | core/jni/android_media_AudioSystem.cpp | 35 |
1 files changed, 17 insertions, 18 deletions
diff --git a/core/jni/android_media_AudioSystem.cpp b/core/jni/android_media_AudioSystem.cpp index 2c1440f..7d99464 100644 --- a/core/jni/android_media_AudioSystem.cpp +++ b/core/jni/android_media_AudioSystem.cpp @@ -41,11 +41,15 @@ enum AudioError { static int check_AudioSystem_Command(status_t status) { - if (status == NO_ERROR) { + switch (status) { + case DEAD_OBJECT: + return kAudioStatusMediaServerDied; + case NO_ERROR: return kAudioStatusOk; - } else { - return kAudioStatusError; + default: + break; } + return kAudioStatusError; } static int @@ -122,21 +126,9 @@ android_media_AudioSystem_error_callback(status_t err) jclass clazz = env->FindClass(kClassPathName); - int error; - - switch (err) { - case DEAD_OBJECT: - error = kAudioStatusMediaServerDied; - break; - case NO_ERROR: - error = kAudioStatusOk; - break; - default: - error = kAudioStatusError; - break; - } - - env->CallStaticVoidMethod(clazz, env->GetStaticMethodID(clazz, "errorCallbackFromNative","(I)V"), error); + env->CallStaticVoidMethod(clazz, env->GetStaticMethodID(clazz, + "errorCallbackFromNative","(I)V"), + check_AudioSystem_Command(err)); } static int @@ -283,6 +275,12 @@ android_media_AudioSystem_setLowRamDevice(JNIEnv *env, jobject clazz, jboolean i return (jint) AudioSystem::setLowRamDevice((bool) isLowRamDevice); } +static int +android_media_AudioSystem_checkAudioFlinger(JNIEnv *env, jobject clazz) +{ + return check_AudioSystem_Command(AudioSystem::checkAudioFlinger()); +} + // ---------------------------------------------------------------------------- static JNINativeMethod gMethods[] = { @@ -310,6 +308,7 @@ static JNINativeMethod gMethods[] = { {"getPrimaryOutputFrameCount", "()I", (void *)android_media_AudioSystem_getPrimaryOutputFrameCount}, {"getOutputLatency", "(I)I", (void *)android_media_AudioSystem_getOutputLatency}, {"setLowRamDevice", "(Z)I", (void *)android_media_AudioSystem_setLowRamDevice}, + {"checkAudioFlinger", "()I", (void *)android_media_AudioSystem_checkAudioFlinger}, }; int register_android_media_AudioSystem(JNIEnv *env) |