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

Side by Side 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: refactor code Created 7 years, 11 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/threading/platform_thread.h" 5 #include "base/threading/platform_thread.h"
6 6
7 #include <errno.h> 7 #include <errno.h>
8 #include <sched.h> 8 #include <sched.h>
9 9
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
(...skipping 12 matching lines...) Expand all
23 #if defined(OS_LINUX) 23 #if defined(OS_LINUX)
24 #include <sys/prctl.h> 24 #include <sys/prctl.h>
25 #include <sys/resource.h> 25 #include <sys/resource.h>
26 #include <sys/syscall.h> 26 #include <sys/syscall.h>
27 #include <sys/time.h> 27 #include <sys/time.h>
28 #include <unistd.h> 28 #include <unistd.h>
29 #endif 29 #endif
30 30
31 #if defined(OS_ANDROID) 31 #if defined(OS_ANDROID)
32 #include "base/android/jni_android.h" 32 #include "base/android/jni_android.h"
33 #include "jni/ThreadUtils_jni.h"
33 #endif 34 #endif
34 35
35 // TODO(bbudge) Use time.h when NaCl toolchain supports _POSIX_TIMERS 36 // TODO(bbudge) Use time.h when NaCl toolchain supports _POSIX_TIMERS
36 #if defined(OS_NACL) 37 #if defined(OS_NACL)
37 #include <sys/nacl_syscalls.h> 38 #include <sys/nacl_syscalls.h>
38 #endif 39 #endif
39 40
40 namespace base { 41 namespace base {
41 42
42 #if defined(OS_MACOSX) 43 #if defined(OS_MACOSX)
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 268
268 // static 269 // static
269 void PlatformThread::Join(PlatformThreadHandle thread_handle) { 270 void PlatformThread::Join(PlatformThreadHandle thread_handle) {
270 // Joining another thread may block the current thread for a long time, since 271 // Joining another thread may block the current thread for a long time, since
271 // the thread referred to by |thread_handle| may still be running long-lived / 272 // the thread referred to by |thread_handle| may still be running long-lived /
272 // blocking tasks. 273 // blocking tasks.
273 base::ThreadRestrictions::AssertIOAllowed(); 274 base::ThreadRestrictions::AssertIOAllowed();
274 pthread_join(thread_handle, NULL); 275 pthread_join(thread_handle, NULL);
275 } 276 }
276 277
277 #if !defined(OS_MACOSX) 278 #if !defined(OS_MACOSX) && !defined(OS_ANDROID)
278 // Mac OS X uses lower-level mach APIs. 279 // Mac OS X uses lower-level mach APIs and Android uses Java APIs.
279
280 // static 280 // static
281 void PlatformThread::SetThreadPriority(PlatformThreadHandle, ThreadPriority) { 281 void PlatformThread::SetThreadPriority(PlatformThreadHandle, ThreadPriority) {
282 // TODO(crogers): Implement, see http://crbug.com/116172 282 // TODO(crogers): Implement, see http://crbug.com/116172
283 } 283 }
284 #endif 284 #endif
285 285
286 #if defined(OS_ANDROID)
287 bool RegisterThreadUtils(JNIEnv* env) {
288 return RegisterNativesImpl(env);
bulach 2013/01/09 12:57:58 nit: unindent -2
Wei James(wistoch) 2013/01/10 08:30:05 fixed. thanks
289 }
290
291 void PlatformThread::SetThreadPriority(PlatformThreadHandle,
292 ThreadPriority priority) {
293 // Use Android SDK API to set priority for real time audio thread and it will
294 // set the thread to corresponding cgroups.
bulach 2013/01/09 12:57:58 this comment is a bit spurious, since it's just ma
Wei James(wistoch) 2013/01/10 08:30:05 removed, thanks
295 if (priority == kThreadPriority_RealtimeAudio) {
296 JNIEnv* env = base::android::AttachCurrentThread();
297 Java_ThreadUtils_setAudioThreadPriority(env, PlatformThread::CurrentId());
bulach 2013/01/09 12:57:58 nit: as above, maybe rename to ..._setThreadPriori
Wei James(wistoch) 2013/01/10 08:30:05 fixed. thanks
298 } else {
299 NOTREACHED() << "Unknown thread priority.";
300 }
301 }
302 #endif
bulach 2013/01/09 12:57:58 nit: // defined(OS_ANDROID)
Wei James(wistoch) 2013/01/10 08:30:05 fixed. thanks
303
286 } // namespace base 304 } // namespace base
OLDNEW
« base/threading/platform_thread.h ('K') | « base/threading/platform_thread.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698