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_MULTITHREADED); | 181 hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); |
182 if (SUCCEEDED(hr)) { | 182 if (SUCCEEDED(hr)) { |
183 hr = device_enumerator.CreateInstance(__uuidof(MMDeviceEnumerator), | 183 hr = device_enumerator.CreateInstance(__uuidof(MMDeviceEnumerator), NULL, |
184 NULL, CLSCTX_INPROC_SERVER); | 184 CLSCTX_INPROC_SERVER); |
| 185 } else { |
| 186 LOG(ERROR) << "CoCreateInstance still failed! " << std::hex << hr; |
185 } | 187 } |
186 } | 188 } |
187 return device_enumerator; | 189 return device_enumerator; |
188 } | 190 } |
189 | 191 |
190 static bool IsSupportedInternal() { | 192 static bool IsSupportedInternal() { |
191 // It is possible to force usage of WaveXxx APIs by using a command line flag. | 193 // It is possible to force usage of WaveXxx APIs by using a command line flag. |
192 const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); | 194 const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); |
193 if (cmd_line->HasSwitch(switches::kForceWaveAudio)) { | 195 if (cmd_line->HasSwitch(switches::kForceWaveAudio)) { |
194 DVLOG(1) << "Forcing usage of Windows WaveXxx APIs"; | 196 DVLOG(1) << "Forcing usage of Windows WaveXxx APIs"; |
(...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
863 return false; | 865 return false; |
864 | 866 |
865 // Using the AUDCLNT_BUFFERFLAGS_SILENT flag eliminates the need to | 867 // Using the AUDCLNT_BUFFERFLAGS_SILENT flag eliminates the need to |
866 // explicitly write silence data to the rendering buffer. | 868 // explicitly write silence data to the rendering buffer. |
867 DVLOG(2) << "filling up " << num_frames_to_fill << " frames with silence"; | 869 DVLOG(2) << "filling up " << num_frames_to_fill << " frames with silence"; |
868 return SUCCEEDED(render_client->ReleaseBuffer(num_frames_to_fill, | 870 return SUCCEEDED(render_client->ReleaseBuffer(num_frames_to_fill, |
869 AUDCLNT_BUFFERFLAGS_SILENT)); | 871 AUDCLNT_BUFFERFLAGS_SILENT)); |
870 } | 872 } |
871 | 873 |
872 } // namespace media | 874 } // namespace media |
OLD | NEW |