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

Unified 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: Added MMCSS support (loads avrt.dll) 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/audio/win/avrt_wrapper_win.h ('k') | media/media.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
+
+namespace {
+ // 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.
+ 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;
+}
+
+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);
+ 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);
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.
+}
+
+bool AvrtWrapper::AvRevertMmThreadCharacteristics(HANDLE avrt_handle) {
+ DCHECK(g_revert_mm_thread_characteristics);
+ 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
+ g_revert_mm_thread_characteristics(avrt_handle) != FALSE);
+}
+
+HANDLE AvrtWrapper::AvSetMmThreadCharacteristics(const char* task_name,
+ 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) != FALSE);
+}
Property changes on: media\audio\win\avrt_wrapper_win.cc
___________________________________________________________________
Added: svn:eol-style
+ LF
« no previous file with comments | « media/audio/win/avrt_wrapper_win.h ('k') | media/media.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698