| 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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 static std::string GetDeviceID(IMMDevice* device) { | 151 static std::string GetDeviceID(IMMDevice* device) { |
| 152 ScopedCoMem<WCHAR> device_id_com; | 152 ScopedCoMem<WCHAR> device_id_com; |
| 153 std::string device_id; | 153 std::string device_id; |
| 154 if (SUCCEEDED(device->GetId(&device_id_com))) | 154 if (SUCCEEDED(device->GetId(&device_id_com))) |
| 155 base::WideToUTF8(device_id_com, wcslen(device_id_com), &device_id); | 155 base::WideToUTF8(device_id_com, wcslen(device_id_com), &device_id); |
| 156 return device_id; | 156 return device_id; |
| 157 } | 157 } |
| 158 | 158 |
| 159 bool CoreAudioUtil::IsSupported() { | 159 bool CoreAudioUtil::IsSupported() { |
| 160 // It is possible to force usage of WaveXxx APIs by using a command line flag. | 160 // It is possible to force usage of WaveXxx APIs by using a command line flag. |
| 161 const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); | 161 const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); |
| 162 if (cmd_line->HasSwitch(switches::kForceWaveAudio)) { | 162 if (cmd_line->HasSwitch(switches::kForceWaveAudio)) { |
| 163 DVLOG(1) << "Forcing usage of Windows WaveXxx APIs"; | 163 DVLOG(1) << "Forcing usage of Windows WaveXxx APIs"; |
| 164 return false; | 164 return false; |
| 165 } | 165 } |
| 166 | 166 |
| 167 // Microsoft does not plan to make the Core Audio APIs available for use | 167 // Microsoft does not plan to make the Core Audio APIs available for use |
| 168 // with earlier versions of Windows, including Microsoft Windows Server 2003, | 168 // with earlier versions of Windows, including Microsoft Windows Server 2003, |
| 169 // Windows XP, Windows Millennium Edition, Windows 2000, and Windows 98. | 169 // Windows XP, Windows Millennium Edition, Windows 2000, and Windows 98. |
| 170 if (base::win::GetVersion() < base::win::VERSION_VISTA) | 170 if (base::win::GetVersion() < base::win::VERSION_VISTA) |
| 171 return false; | 171 return false; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 190 << GetCurrentThreadId(); | 190 << GetCurrentThreadId(); |
| 191 return g_can_create_device_enumerator; | 191 return g_can_create_device_enumerator; |
| 192 } | 192 } |
| 193 | 193 |
| 194 base::TimeDelta CoreAudioUtil::RefererenceTimeToTimeDelta(REFERENCE_TIME time) { | 194 base::TimeDelta CoreAudioUtil::RefererenceTimeToTimeDelta(REFERENCE_TIME time) { |
| 195 // Each unit of reference time is 100 nanoseconds <=> 0.1 microsecond. | 195 // Each unit of reference time is 100 nanoseconds <=> 0.1 microsecond. |
| 196 return base::TimeDelta::FromMicroseconds(0.1 * time + 0.5); | 196 return base::TimeDelta::FromMicroseconds(0.1 * time + 0.5); |
| 197 } | 197 } |
| 198 | 198 |
| 199 AUDCLNT_SHAREMODE CoreAudioUtil::GetShareMode() { | 199 AUDCLNT_SHAREMODE CoreAudioUtil::GetShareMode() { |
| 200 const CommandLine* cmd_line = CommandLine::ForCurrentProcess(); | 200 const base::CommandLine* cmd_line = base::CommandLine::ForCurrentProcess(); |
| 201 if (cmd_line->HasSwitch(switches::kEnableExclusiveAudio)) | 201 if (cmd_line->HasSwitch(switches::kEnableExclusiveAudio)) |
| 202 return AUDCLNT_SHAREMODE_EXCLUSIVE; | 202 return AUDCLNT_SHAREMODE_EXCLUSIVE; |
| 203 return AUDCLNT_SHAREMODE_SHARED; | 203 return AUDCLNT_SHAREMODE_SHARED; |
| 204 } | 204 } |
| 205 | 205 |
| 206 int CoreAudioUtil::NumberOfActiveDevices(EDataFlow data_flow) { | 206 int CoreAudioUtil::NumberOfActiveDevices(EDataFlow data_flow) { |
| 207 DCHECK(IsSupported()); | 207 DCHECK(IsSupported()); |
| 208 // Create the IMMDeviceEnumerator interface. | 208 // Create the IMMDeviceEnumerator interface. |
| 209 ScopedComPtr<IMMDeviceEnumerator> device_enumerator = | 209 ScopedComPtr<IMMDeviceEnumerator> device_enumerator = |
| 210 CreateDeviceEnumerator(); | 210 CreateDeviceEnumerator(); |
| (...skipping 637 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 848 return false; | 848 return false; |
| 849 | 849 |
| 850 // Using the AUDCLNT_BUFFERFLAGS_SILENT flag eliminates the need to | 850 // Using the AUDCLNT_BUFFERFLAGS_SILENT flag eliminates the need to |
| 851 // explicitly write silence data to the rendering buffer. | 851 // explicitly write silence data to the rendering buffer. |
| 852 DVLOG(2) << "filling up " << num_frames_to_fill << " frames with silence"; | 852 DVLOG(2) << "filling up " << num_frames_to_fill << " frames with silence"; |
| 853 return SUCCEEDED(render_client->ReleaseBuffer(num_frames_to_fill, | 853 return SUCCEEDED(render_client->ReleaseBuffer(num_frames_to_fill, |
| 854 AUDCLNT_BUFFERFLAGS_SILENT)); | 854 AUDCLNT_BUFFERFLAGS_SILENT)); |
| 855 } | 855 } |
| 856 | 856 |
| 857 } // namespace media | 857 } // namespace media |
| OLD | NEW |