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

Side by Side Diff: media/audio/win/avrt_wrapper_win.cc

Issue 8283032: Low-latency AudioInputStream implementation based on WASAPI for Windows. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Fixes in AVRT wrapper based on review by tommi Created 9 years, 2 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 | Annotate | Revision Log
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(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"
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.
7
8 namespace {
9 // Function pointers
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 } // namespace
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);
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.
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);
38 }
39
40 bool AvrtWrapper::AvRevertMmThreadCharacteristics(HANDLE avrt_handle) {
41 DCHECK(g_revert_mm_thread_characteristics);
42 return (g_revert_mm_thread_characteristics &&
43 g_revert_mm_thread_characteristics(avrt_handle));
44 }
45
46 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
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));
58 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698