Chromium Code Reviews
|
| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "base/logging.h" | |
| 6 #include "media/audio/win/avrt_wrapper_win.h" | |
| 7 | |
| 8 namespace { | |
| 9 // Function pointers | |
|
tommi
2011/10/18 14:14:10
don't indent this section
henrika (OOO until Aug 14)
2011/10/18 14:56:49
Done.
| |
| 10 typedef BOOL (WINAPI *AvRevertMmThreadCharacteristicsFn)(HANDLE); | |
| 11 typedef HANDLE (WINAPI *AvSetMmThreadCharacteristicsFn)(LPCSTR, LPDWORD); | |
| 12 typedef BOOL (WINAPI *AvSetMmThreadPriorityFn)(HANDLE, AVRT_PRIORITY); | |
| 13 | |
| 14 HMODULE g_avrt = NULL; | |
| 15 AvRevertMmThreadCharacteristicsFn g_revert_mm_thread_characteristics = NULL; | |
| 16 AvSetMmThreadCharacteristicsFn g_set_mm_thread_characteristics = NULL; | |
| 17 AvSetMmThreadPriorityFn g_set_mm_thread_priority = NULL; | |
| 18 } | |
| 19 | |
| 20 bool AvrtWrapper::Initialize() { | |
| 21 if (!g_set_mm_thread_priority) { | |
| 22 // The avrt.dll is available on Windows Vista and later. | |
| 23 char path[MAX_PATH] = {0}; | |
| 24 ExpandEnvironmentStringsA("%WINDIR%\\system32\\avrt.dll", path, | |
| 25 arraysize(path)); | |
| 26 g_avrt = LoadLibraryA(path); | |
| 27 g_revert_mm_thread_characteristics = | |
| 28 reinterpret_cast<AvRevertMmThreadCharacteristicsFn>( | |
| 29 GetProcAddress(g_avrt, "AvRevertMmThreadCharacteristics")); | |
| 30 g_set_mm_thread_characteristics = | |
| 31 reinterpret_cast<AvSetMmThreadCharacteristicsFn>( | |
| 32 GetProcAddress(g_avrt, "AvSetMmThreadCharacteristicsA")); | |
| 33 g_set_mm_thread_priority = reinterpret_cast<AvSetMmThreadPriorityFn>( | |
| 34 GetProcAddress(g_avrt, "AvSetMmThreadPriority")); | |
| 35 } | |
| 36 return (g_avrt && g_revert_mm_thread_characteristics && | |
| 37 g_set_mm_thread_characteristics && g_set_mm_thread_priority); | |
|
tommi
2011/10/18 14:14:10
only one space after g_set_mm_thread_characteristi
henrika (OOO until Aug 14)
2011/10/18 14:56:49
Done.
| |
| 38 } | |
| 39 | |
| 40 bool AvrtWrapper::AvRevertMmThreadCharacteristics(HANDLE avrt_handle) { | |
| 41 DCHECK(g_revert_mm_thread_characteristics); | |
| 42 return (g_revert_mm_thread_characteristics && | |
|
tommi
2011/10/18 14:14:10
nit: since you're using && you don't need the != F
henrika (OOO until Aug 14)
2011/10/18 14:56:49
LOL
| |
| 43 g_revert_mm_thread_characteristics(avrt_handle) != FALSE); | |
| 44 } | |
| 45 | |
| 46 HANDLE AvrtWrapper::AvSetMmThreadCharacteristics(const char* task_name, | |
| 47 DWORD* task_index) { | |
| 48 DCHECK(g_set_mm_thread_characteristics); | |
| 49 return (g_set_mm_thread_characteristics ? | |
| 50 g_set_mm_thread_characteristics(task_name, task_index) : NULL); | |
| 51 } | |
| 52 | |
| 53 bool AvrtWrapper::AvSetMmThreadPriority(HANDLE avrt_handle, | |
| 54 AVRT_PRIORITY priority) { | |
| 55 DCHECK(g_set_mm_thread_priority); | |
| 56 return (g_set_mm_thread_priority && | |
| 57 g_set_mm_thread_priority(avrt_handle, priority) != FALSE); | |
| 58 } | |
| OLD | NEW |