Index: media/audio/win/avrt_wrapper_win.cc |
=================================================================== |
--- media/audio/win/avrt_wrapper_win.cc (revision 0) |
+++ media/audio/win/avrt_wrapper_win.cc (revision 0) |
@@ -0,0 +1,58 @@ |
+// Copyright (c) 2011 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "base/logging.h" |
+#include "media/audio/win/avrt_wrapper_win.h" |
scherkus (not reviewing)
2011/10/18 21:12:30
this should go first
henrika (OOO until Aug 14)
2011/10/19 15:42:43
Done.
|
+ |
+namespace { |
+// Function pointers |
+typedef BOOL (WINAPI *AvRevertMmThreadCharacteristicsFn)(HANDLE); |
+typedef HANDLE (WINAPI *AvSetMmThreadCharacteristicsFn)(LPCSTR, LPDWORD); |
+typedef BOOL (WINAPI *AvSetMmThreadPriorityFn)(HANDLE, AVRT_PRIORITY); |
+ |
+HMODULE g_avrt = NULL; |
+AvRevertMmThreadCharacteristicsFn g_revert_mm_thread_characteristics = NULL; |
+AvSetMmThreadCharacteristicsFn g_set_mm_thread_characteristics = NULL; |
+AvSetMmThreadPriorityFn g_set_mm_thread_priority = NULL; |
+} // namespace |
+ |
+bool AvrtWrapper::Initialize() { |
+ if (!g_set_mm_thread_priority) { |
+ // The avrt.dll is available on Windows Vista and later. |
+ char path[MAX_PATH] = {0}; |
+ ExpandEnvironmentStringsA("%WINDIR%\\system32\\avrt.dll", path, |
+ arraysize(path)); |
+ g_avrt = LoadLibraryA(path); |
scherkus (not reviewing)
2011/10/18 21:12:30
you may want to use the following instead:
::LoadL
henrika (OOO until Aug 14)
2011/10/19 15:42:43
Done.
|
+ g_revert_mm_thread_characteristics = |
+ reinterpret_cast<AvRevertMmThreadCharacteristicsFn>( |
+ GetProcAddress(g_avrt, "AvRevertMmThreadCharacteristics")); |
+ g_set_mm_thread_characteristics = |
+ reinterpret_cast<AvSetMmThreadCharacteristicsFn>( |
+ GetProcAddress(g_avrt, "AvSetMmThreadCharacteristicsA")); |
+ g_set_mm_thread_priority = reinterpret_cast<AvSetMmThreadPriorityFn>( |
+ GetProcAddress(g_avrt, "AvSetMmThreadPriority")); |
+ } |
+ return (g_avrt && g_revert_mm_thread_characteristics && |
+ g_set_mm_thread_characteristics && g_set_mm_thread_priority); |
+} |
+ |
+bool AvrtWrapper::AvRevertMmThreadCharacteristics(HANDLE avrt_handle) { |
+ DCHECK(g_revert_mm_thread_characteristics); |
+ return (g_revert_mm_thread_characteristics && |
+ g_revert_mm_thread_characteristics(avrt_handle)); |
+} |
+ |
+HANDLE AvrtWrapper::AvSetMmThreadCharacteristics(const char* task_name, |
scherkus (not reviewing)
2011/10/18 21:12:30
should also be unicode
henrika (OOO until Aug 14)
2011/10/19 15:42:43
I would say "could be unicode" but OK ;-)
Changed
|
+ DWORD* task_index) { |
+ DCHECK(g_set_mm_thread_characteristics); |
+ return (g_set_mm_thread_characteristics ? |
+ g_set_mm_thread_characteristics(task_name, task_index) : NULL); |
+} |
+ |
+bool AvrtWrapper::AvSetMmThreadPriority(HANDLE avrt_handle, |
+ AVRT_PRIORITY priority) { |
+ DCHECK(g_set_mm_thread_priority); |
+ return (g_set_mm_thread_priority && |
+ g_set_mm_thread_priority(avrt_handle, priority)); |
+} |
Property changes on: media\audio\win\avrt_wrapper_win.cc |
___________________________________________________________________ |
Added: svn:eol-style |
+ LF |