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

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

Issue 11666005: Improves CoreAudioUtil::IsSupported by also loading Audioses.dll DLL (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/audio/win/core_audio_util_win.h" 5 #include "media/audio/win/core_audio_util_win.h"
6 6
7 #include <Audioclient.h> 7 #include <Audioclient.h>
8 #include <Functiondiscoverykeys_devpkey.h> 8 #include <Functiondiscoverykeys_devpkey.h>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 return CHANNEL_LAYOUT_7_1_WIDE; 59 return CHANNEL_LAYOUT_7_1_WIDE;
60 case KSAUDIO_SPEAKER_7POINT1_SURROUND: 60 case KSAUDIO_SPEAKER_7POINT1_SURROUND:
61 DVLOG(2) << "KSAUDIO_SPEAKER_7POINT1_SURROUND=>CHANNEL_LAYOUT_7_1"; 61 DVLOG(2) << "KSAUDIO_SPEAKER_7POINT1_SURROUND=>CHANNEL_LAYOUT_7_1";
62 return CHANNEL_LAYOUT_7_1; 62 return CHANNEL_LAYOUT_7_1;
63 default: 63 default:
64 DVLOG(2) << "Unsupported channel layout: " << config; 64 DVLOG(2) << "Unsupported channel layout: " << config;
65 return CHANNEL_LAYOUT_UNSUPPORTED; 65 return CHANNEL_LAYOUT_UNSUPPORTED;
66 } 66 }
67 } 67 }
68 68
69 bool LoadAudiosesDll() {
70 static const wchar_t* const kAudiosesDLL =
71 L"%WINDIR%\\system32\\audioses.dll";
72
73 wchar_t path[MAX_PATH] = {0};
74 ExpandEnvironmentStringsW(kAudiosesDLL, path, arraysize(path));
75 if (!LoadLibraryExW(path, NULL, LOAD_WITH_ALTERED_SEARCH_PATH))
tommi (sloooow) - chröme 2012/12/21 09:58:14 return LoadLibraryExW(path, NULL, LOAD_WITH_ALTERE
henrika (OOO until Aug 14) 2012/12/21 10:03:36 OK. I followed your example BTW ;-)
tommi (sloooow) - chröme 2012/12/21 10:29:18 Hah, well, you should have noticed that in the oth
76 return false;
77
78 return true;
79 }
80
69 // Scoped PROPVARIANT class for automatically freeing a COM PROPVARIANT 81 // Scoped PROPVARIANT class for automatically freeing a COM PROPVARIANT
70 // structure at the end of a scope. 82 // structure at the end of a scope.
71 class ScopedPropertyVariant { 83 class ScopedPropertyVariant {
72 public: 84 public:
73 ScopedPropertyVariant() { 85 ScopedPropertyVariant() {
74 PropVariantInit(&propvar_); 86 PropVariantInit(&propvar_);
75 } 87 }
76 ~ScopedPropertyVariant() { 88 ~ScopedPropertyVariant() {
77 PropVariantClear(&propvar_); 89 PropVariantClear(&propvar_);
78 } 90 }
(...skipping 17 matching lines...) Expand all
96 private: 108 private:
97 PROPVARIANT propvar_; 109 PROPVARIANT propvar_;
98 110
99 DISALLOW_COPY_AND_ASSIGN(ScopedPropertyVariant); 111 DISALLOW_COPY_AND_ASSIGN(ScopedPropertyVariant);
100 }; 112 };
101 113
102 bool CoreAudioUtil::IsSupported() { 114 bool CoreAudioUtil::IsSupported() {
103 // Microsoft does not plan to make the Core Audio APIs available for use 115 // Microsoft does not plan to make the Core Audio APIs available for use
104 // with earlier versions of Windows, including Microsoft Windows Server 2003, 116 // with earlier versions of Windows, including Microsoft Windows Server 2003,
105 // Windows XP, Windows Millennium Edition, Windows 2000, and Windows 98. 117 // Windows XP, Windows Millennium Edition, Windows 2000, and Windows 98.
106 return (base::win::GetVersion() >= base::win::VERSION_VISTA); 118 if (base::win::GetVersion() < base::win::VERSION_VISTA)
119 return false;
120
121 // The audio core APIs are implemented in the Mmdevapi.dll and Audioses.dll
122 // system components, both of which run in user mode.
tommi (sloooow) - chröme 2012/12/21 09:58:14 nit: dll's generally do run in usermode so you can
henrika (OOO until Aug 14) 2012/12/21 10:03:36 Got it. Copy paste from MSDN.
123 // Dependcy Walker shows that it is enough to verify possibility to load
tommi (sloooow) - chröme 2012/12/21 09:58:14 Dependency
henrika (OOO until Aug 14) 2012/12/21 10:03:36 Done.
124 // the Audioses DLL since it loads Mmdevapi.dll as well.
tommi (sloooow) - chröme 2012/12/21 09:58:14 s/it loads Mmdevapi.dll as well/it depends on Mmde
henrika (OOO until Aug 14) 2012/12/21 10:03:36 Thanks. Much better.
125 // See http://crbug.com/166397 why this extra step is required to guarantee
126 // Core Audio support.
127 static bool g_audioses_dll_available = LoadAudiosesDll();
128 return g_audioses_dll_available;
107 } 129 }
108 130
109 base::TimeDelta CoreAudioUtil::RefererenceTimeToTimeDelta(REFERENCE_TIME time) { 131 base::TimeDelta CoreAudioUtil::RefererenceTimeToTimeDelta(REFERENCE_TIME time) {
110 // Each unit of reference time is 100 nanoseconds <=> 0.1 microsecond. 132 // Each unit of reference time is 100 nanoseconds <=> 0.1 microsecond.
111 return base::TimeDelta::FromMicroseconds(0.1 * time + 0.5); 133 return base::TimeDelta::FromMicroseconds(0.1 * time + 0.5);
112 } 134 }
113 135
114 AUDCLNT_SHAREMODE CoreAudioUtil::GetShareMode() { 136 AUDCLNT_SHAREMODE CoreAudioUtil::GetShareMode() {
115 const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); 137 const CommandLine* cmd_line = CommandLine::ForCurrentProcess();
116 if (cmd_line->HasSwitch(switches::kEnableExclusiveAudio)) 138 if (cmd_line->HasSwitch(switches::kEnableExclusiveAudio))
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 HRESULT hr = client->GetService(__uuidof(IAudioCaptureClient), 593 HRESULT hr = client->GetService(__uuidof(IAudioCaptureClient),
572 audio_capture_client.ReceiveVoid()); 594 audio_capture_client.ReceiveVoid());
573 if (FAILED(hr)) { 595 if (FAILED(hr)) {
574 DVLOG(1) << "IAudioClient::GetService: " << std::hex << hr; 596 DVLOG(1) << "IAudioClient::GetService: " << std::hex << hr;
575 return ScopedComPtr<IAudioCaptureClient>(); 597 return ScopedComPtr<IAudioCaptureClient>();
576 } 598 }
577 return audio_capture_client; 599 return audio_capture_client;
578 } 600 }
579 601
580 } // namespace media 602 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698