Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1889)

Unified Diff: base/threading/platform_thread_posix.cc

Issue 11729002: Set Realtime Audio Thread priority on Android (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/threading/platform_thread.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/threading/platform_thread_posix.cc
diff --git a/base/threading/platform_thread_posix.cc b/base/threading/platform_thread_posix.cc
index 444edc58a6268649115f2f1583bc7b56374d961d..e5b77981f64a54a479fd2a30ef4f256d84c84f57 100644
--- a/base/threading/platform_thread_posix.cc
+++ b/base/threading/platform_thread_posix.cc
@@ -30,6 +30,7 @@
#if defined(OS_ANDROID)
#include "base/android/jni_android.h"
+#include "jni/ThreadUtils_jni.h"
#endif
// TODO(bbudge) Use time.h when NaCl toolchain supports _POSIX_TIMERS
@@ -274,13 +275,33 @@ void PlatformThread::Join(PlatformThreadHandle thread_handle) {
pthread_join(thread_handle, NULL);
}
-#if !defined(OS_MACOSX)
-// Mac OS X uses lower-level mach APIs.
-
+#if !defined(OS_MACOSX) && !defined(OS_ANDROID)
+// Mac OS X uses lower-level mach APIs and Android uses Java APIs.
// static
void PlatformThread::SetThreadPriority(PlatformThreadHandle, ThreadPriority) {
// TODO(crogers): Implement, see http://crbug.com/116172
}
#endif
+#if defined(OS_ANDROID)
+bool RegisterThreadUtils(JNIEnv* env) {
+ return RegisterNativesImpl(env);
+}
+
+void PlatformThread::SetThreadPriority(PlatformThreadHandle,
+ ThreadPriority priority) {
+ // Use Android SDK API to set priority for real time audio thread and it will
+ // set the thread to corresponding cgroups.
+ if (priority == kThreadPriority_RealtimeAudio) {
+ JNIEnv* env = base::android::AttachCurrentThread();
+ // Keep consistent with android.os.Process.THREAD_PRIORITY_AUDIO.
+ const int kThreadPriorityAudio = -16;
qinmin 2013/01/07 19:16:34 There is no need to define this variable here and
Wei James(wistoch) 2013/01/08 02:42:37 fixed. thanks
+ Java_ThreadUtils_setThreadPriority(env, PlatformThread::CurrentId(),
+ kThreadPriorityAudio);
+ } else {
+ NOTREACHED() << "Unknown thread priority.";
+ }
+}
+#endif
+
} // namespace base
« no previous file with comments | « base/threading/platform_thread.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698