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 <devicetopology.h> | 8 #include <devicetopology.h> |
9 #include <functiondiscoverykeys_devpkey.h> | 9 #include <functiondiscoverykeys_devpkey.h> |
10 | 10 |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 static ScopedComPtr<IMMDeviceEnumerator> CreateDeviceEnumeratorInternal() { | 171 static ScopedComPtr<IMMDeviceEnumerator> CreateDeviceEnumeratorInternal() { |
172 ScopedComPtr<IMMDeviceEnumerator> device_enumerator; | 172 ScopedComPtr<IMMDeviceEnumerator> device_enumerator; |
173 HRESULT hr = device_enumerator.CreateInstance(__uuidof(MMDeviceEnumerator), | 173 HRESULT hr = device_enumerator.CreateInstance(__uuidof(MMDeviceEnumerator), |
174 NULL, CLSCTX_INPROC_SERVER); | 174 NULL, CLSCTX_INPROC_SERVER); |
175 if (hr == CO_E_NOTINITIALIZED) { | 175 if (hr == CO_E_NOTINITIALIZED) { |
176 LOG(ERROR) << "CoCreateInstance fails with CO_E_NOTINITIALIZED"; | 176 LOG(ERROR) << "CoCreateInstance fails with CO_E_NOTINITIALIZED"; |
177 // We have seen crashes which indicates that this method can in fact | 177 // We have seen crashes which indicates that this method can in fact |
178 // fail with CO_E_NOTINITIALIZED in combination with certain 3rd party | 178 // fail with CO_E_NOTINITIALIZED in combination with certain 3rd party |
179 // modules. Calling CoInitializeEx is an attempt to resolve the reported | 179 // modules. Calling CoInitializeEx is an attempt to resolve the reported |
180 // issues. See http://crbug.com/378465 for details. | 180 // issues. See http://crbug.com/378465 for details. |
181 hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); | 181 hr = CoInitializeEx(NULL, COINIT_MULTITHREADED); |
182 if (SUCCEEDED(hr)) { | 182 if (SUCCEEDED(hr)) { |
183 hr = device_enumerator.CreateInstance(__uuidof(MMDeviceEnumerator), NULL, | 183 hr = device_enumerator.CreateInstance(__uuidof(MMDeviceEnumerator), |
184 CLSCTX_INPROC_SERVER); | 184 NULL, CLSCTX_INPROC_SERVER); |
185 } else { | |
186 LOG(ERROR) << "CoCreateInstance still failed! " << std::hex << hr; | |
187 } | 185 } |
188 } | 186 } |
189 return device_enumerator; | 187 return device_enumerator; |
190 } | 188 } |
191 | 189 |
192 static bool IsSupportedInternal() { | 190 static bool IsSupportedInternal() { |
193 // It is possible to force usage of WaveXxx APIs by using a command line flag. | 191 // It is possible to force usage of WaveXxx APIs by using a command line flag. |
194 const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); | 192 const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); |
195 if (cmd_line->HasSwitch(switches::kForceWaveAudio)) { | 193 if (cmd_line->HasSwitch(switches::kForceWaveAudio)) { |
196 DVLOG(1) << "Forcing usage of Windows WaveXxx APIs"; | 194 DVLOG(1) << "Forcing usage of Windows WaveXxx APIs"; |
(...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
865 return false; | 863 return false; |
866 | 864 |
867 // Using the AUDCLNT_BUFFERFLAGS_SILENT flag eliminates the need to | 865 // Using the AUDCLNT_BUFFERFLAGS_SILENT flag eliminates the need to |
868 // explicitly write silence data to the rendering buffer. | 866 // explicitly write silence data to the rendering buffer. |
869 DVLOG(2) << "filling up " << num_frames_to_fill << " frames with silence"; | 867 DVLOG(2) << "filling up " << num_frames_to_fill << " frames with silence"; |
870 return SUCCEEDED(render_client->ReleaseBuffer(num_frames_to_fill, | 868 return SUCCEEDED(render_client->ReleaseBuffer(num_frames_to_fill, |
871 AUDCLNT_BUFFERFLAGS_SILENT)); | 869 AUDCLNT_BUFFERFLAGS_SILENT)); |
872 } | 870 } |
873 | 871 |
874 } // namespace media | 872 } // namespace media |
OLD | NEW |