Index: base/threading/platform_thread_linux.cc |
diff --git a/base/threading/platform_thread_linux.cc b/base/threading/platform_thread_linux.cc |
index 42e12c71a554920d94c23c503ff02c80bf8aaad4..6208131d735938844f31c9cb2679a70f59c0818f 100644 |
--- a/base/threading/platform_thread_linux.cc |
+++ b/base/threading/platform_thread_linux.cc |
@@ -76,6 +76,25 @@ void PlatformThread::SetName(const char* name) { |
void PlatformThread::SetThreadPriority(PlatformThreadHandle handle, |
ThreadPriority priority) { |
#ifndef OS_NACL |
+ if (priority == kThreadPriority_RealtimeAudio) { |
+ const int kRealTimePrio = 8; |
+ |
+ struct sched_param sched_param; |
+ memset(&sched_param, 0, sizeof(sched_param)); |
+ sched_param.sched_priority = kRealTimePrio; |
+ |
+ int res = pthread_setschedparam(pthread_self(), SCHED_RR, &sched_param); |
+ if (res == 0) |
+ // Got real time priority, no need to set nice level. |
+ return; |
piman
2013/05/28 21:58:56
nit: need braces if the clause takes multiple line
dgreid
2013/05/28 22:18:53
Done.
|
+ else |
+ LOG(INFO) << "Failed to set audio thread to real time."; |
+ |
+#if defined(OS_CHROMEOS) |
+ DCHECK_EQ(res, 0); // RT prio should always work on ChromeOS. |
piman
2013/05/28 21:58:56
This prevents debugging chromeos=1 builds on the d
dgreid
2013/05/28 22:18:53
Good point, switched this back to a return.
|
+#endif |
+ } |
+ |
// setpriority(2) will set a thread's priority if it is passed a tid as |
// the 'process identifier', not affecting the rest of the threads in the |
// process. Setting this priority will only succeed if the user has been |