OLD | NEW |
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 Loading... |
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 return (LoadLibraryExW(path, NULL, LOAD_WITH_ALTERED_SEARCH_PATH) != NULL); |
| 76 } |
| 77 |
69 // Scoped PROPVARIANT class for automatically freeing a COM PROPVARIANT | 78 // Scoped PROPVARIANT class for automatically freeing a COM PROPVARIANT |
70 // structure at the end of a scope. | 79 // structure at the end of a scope. |
71 class ScopedPropertyVariant { | 80 class ScopedPropertyVariant { |
72 public: | 81 public: |
73 ScopedPropertyVariant() { | 82 ScopedPropertyVariant() { |
74 PropVariantInit(&propvar_); | 83 PropVariantInit(&propvar_); |
75 } | 84 } |
76 ~ScopedPropertyVariant() { | 85 ~ScopedPropertyVariant() { |
77 PropVariantClear(&propvar_); | 86 PropVariantClear(&propvar_); |
78 } | 87 } |
(...skipping 17 matching lines...) Expand all Loading... |
96 private: | 105 private: |
97 PROPVARIANT propvar_; | 106 PROPVARIANT propvar_; |
98 | 107 |
99 DISALLOW_COPY_AND_ASSIGN(ScopedPropertyVariant); | 108 DISALLOW_COPY_AND_ASSIGN(ScopedPropertyVariant); |
100 }; | 109 }; |
101 | 110 |
102 bool CoreAudioUtil::IsSupported() { | 111 bool CoreAudioUtil::IsSupported() { |
103 // Microsoft does not plan to make the Core Audio APIs available for use | 112 // Microsoft does not plan to make the Core Audio APIs available for use |
104 // with earlier versions of Windows, including Microsoft Windows Server 2003, | 113 // with earlier versions of Windows, including Microsoft Windows Server 2003, |
105 // Windows XP, Windows Millennium Edition, Windows 2000, and Windows 98. | 114 // Windows XP, Windows Millennium Edition, Windows 2000, and Windows 98. |
106 return (base::win::GetVersion() >= base::win::VERSION_VISTA); | 115 if (base::win::GetVersion() < base::win::VERSION_VISTA) |
| 116 return false; |
| 117 |
| 118 // The audio core APIs are implemented in the Mmdevapi.dll and Audioses.dll |
| 119 // system components. |
| 120 // Dependency Walker shows that it is enough to verify possibility to load |
| 121 // the Audioses DLL since it depends on Mmdevapi.dll. |
| 122 // See http://crbug.com/166397 why this extra step is required to guarantee |
| 123 // Core Audio support. |
| 124 static bool g_audioses_dll_available = LoadAudiosesDll(); |
| 125 return g_audioses_dll_available; |
107 } | 126 } |
108 | 127 |
109 base::TimeDelta CoreAudioUtil::RefererenceTimeToTimeDelta(REFERENCE_TIME time) { | 128 base::TimeDelta CoreAudioUtil::RefererenceTimeToTimeDelta(REFERENCE_TIME time) { |
110 // Each unit of reference time is 100 nanoseconds <=> 0.1 microsecond. | 129 // Each unit of reference time is 100 nanoseconds <=> 0.1 microsecond. |
111 return base::TimeDelta::FromMicroseconds(0.1 * time + 0.5); | 130 return base::TimeDelta::FromMicroseconds(0.1 * time + 0.5); |
112 } | 131 } |
113 | 132 |
114 AUDCLNT_SHAREMODE CoreAudioUtil::GetShareMode() { | 133 AUDCLNT_SHAREMODE CoreAudioUtil::GetShareMode() { |
115 const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); | 134 const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); |
116 if (cmd_line->HasSwitch(switches::kEnableExclusiveAudio)) | 135 if (cmd_line->HasSwitch(switches::kEnableExclusiveAudio)) |
(...skipping 454 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
571 HRESULT hr = client->GetService(__uuidof(IAudioCaptureClient), | 590 HRESULT hr = client->GetService(__uuidof(IAudioCaptureClient), |
572 audio_capture_client.ReceiveVoid()); | 591 audio_capture_client.ReceiveVoid()); |
573 if (FAILED(hr)) { | 592 if (FAILED(hr)) { |
574 DVLOG(1) << "IAudioClient::GetService: " << std::hex << hr; | 593 DVLOG(1) << "IAudioClient::GetService: " << std::hex << hr; |
575 return ScopedComPtr<IAudioCaptureClient>(); | 594 return ScopedComPtr<IAudioCaptureClient>(); |
576 } | 595 } |
577 return audio_capture_client; | 596 return audio_capture_client; |
578 } | 597 } |
579 | 598 |
580 } // namespace media | 599 } // namespace media |
OLD | NEW |