OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 2219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2230 | 2230 |
2231 // Set wave format | 2231 // Set wave format |
2232 Wfx.wFormatTag = WAVE_FORMAT_PCM; | 2232 Wfx.wFormatTag = WAVE_FORMAT_PCM; |
2233 Wfx.wBitsPerSample = 16; | 2233 Wfx.wBitsPerSample = 16; |
2234 Wfx.cbSize = 0; | 2234 Wfx.cbSize = 0; |
2235 | 2235 |
2236 const int freqs[] = {48000, 44100, 16000, 96000, 32000, 8000}; | 2236 const int freqs[] = {48000, 44100, 16000, 96000, 32000, 8000}; |
2237 hr = S_FALSE; | 2237 hr = S_FALSE; |
2238 | 2238 |
2239 // Iterate over frequencies and channels, in order of priority | 2239 // Iterate over frequencies and channels, in order of priority |
2240 for (int freq = 0; freq < sizeof(freqs)/sizeof(freqs[0]); freq++) | 2240 for (unsigned int freq = 0; freq < sizeof(freqs)/sizeof(freqs[0]); freq++) |
2241 { | 2241 { |
2242 for (int chan = 0; chan < sizeof(_playChannelsPrioList)/sizeof(_playChan
nelsPrioList[0]); chan++) | 2242 for (unsigned int chan = 0; chan < sizeof(_playChannelsPrioList)/sizeof(
_playChannelsPrioList[0]); chan++) |
2243 { | 2243 { |
2244 Wfx.nChannels = _playChannelsPrioList[chan]; | 2244 Wfx.nChannels = _playChannelsPrioList[chan]; |
2245 Wfx.nSamplesPerSec = freqs[freq]; | 2245 Wfx.nSamplesPerSec = freqs[freq]; |
2246 Wfx.nBlockAlign = Wfx.nChannels * Wfx.wBitsPerSample / 8; | 2246 Wfx.nBlockAlign = Wfx.nChannels * Wfx.wBitsPerSample / 8; |
2247 Wfx.nAvgBytesPerSec = Wfx.nSamplesPerSec * Wfx.nBlockAlign; | 2247 Wfx.nAvgBytesPerSec = Wfx.nSamplesPerSec * Wfx.nBlockAlign; |
2248 // If the method succeeds and the audio endpoint device supports the
specified stream format, | 2248 // If the method succeeds and the audio endpoint device supports the
specified stream format, |
2249 // it returns S_OK. If the method succeeds and provides a closest ma
tch to the specified format, | 2249 // it returns S_OK. If the method succeeds and provides a closest ma
tch to the specified format, |
2250 // it returns S_FALSE. | 2250 // it returns S_FALSE. |
2251 hr = _ptrClientOut->IsFormatSupported( | 2251 hr = _ptrClientOut->IsFormatSupported( |
2252 AUDCLNT_SHAREMODE_SHARED, | 2252 AUDCLNT_SHAREMODE_SHARED, |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2567 | 2567 |
2568 // Set wave format | 2568 // Set wave format |
2569 Wfx.wFormatTag = WAVE_FORMAT_PCM; | 2569 Wfx.wFormatTag = WAVE_FORMAT_PCM; |
2570 Wfx.wBitsPerSample = 16; | 2570 Wfx.wBitsPerSample = 16; |
2571 Wfx.cbSize = 0; | 2571 Wfx.cbSize = 0; |
2572 | 2572 |
2573 const int freqs[6] = {48000, 44100, 16000, 96000, 32000, 8000}; | 2573 const int freqs[6] = {48000, 44100, 16000, 96000, 32000, 8000}; |
2574 hr = S_FALSE; | 2574 hr = S_FALSE; |
2575 | 2575 |
2576 // Iterate over frequencies and channels, in order of priority | 2576 // Iterate over frequencies and channels, in order of priority |
2577 for (int freq = 0; freq < sizeof(freqs)/sizeof(freqs[0]); freq++) | 2577 for (unsigned int freq = 0; freq < sizeof(freqs)/sizeof(freqs[0]); freq++) |
2578 { | 2578 { |
2579 for (int chan = 0; chan < sizeof(_recChannelsPrioList)/sizeof(_recChanne
lsPrioList[0]); chan++) | 2579 for (unsigned int chan = 0; chan < sizeof(_recChannelsPrioList)/sizeof(_
recChannelsPrioList[0]); chan++) |
2580 { | 2580 { |
2581 Wfx.nChannels = _recChannelsPrioList[chan]; | 2581 Wfx.nChannels = _recChannelsPrioList[chan]; |
2582 Wfx.nSamplesPerSec = freqs[freq]; | 2582 Wfx.nSamplesPerSec = freqs[freq]; |
2583 Wfx.nBlockAlign = Wfx.nChannels * Wfx.wBitsPerSample / 8; | 2583 Wfx.nBlockAlign = Wfx.nChannels * Wfx.wBitsPerSample / 8; |
2584 Wfx.nAvgBytesPerSec = Wfx.nSamplesPerSec * Wfx.nBlockAlign; | 2584 Wfx.nAvgBytesPerSec = Wfx.nSamplesPerSec * Wfx.nBlockAlign; |
2585 // If the method succeeds and the audio endpoint device supports the
specified stream format, | 2585 // If the method succeeds and the audio endpoint device supports the
specified stream format, |
2586 // it returns S_OK. If the method succeeds and provides a closest ma
tch to the specified format, | 2586 // it returns S_OK. If the method succeeds and provides a closest ma
tch to the specified format, |
2587 // it returns S_FALSE. | 2587 // it returns S_FALSE. |
2588 hr = _ptrClientIn->IsFormatSupported( | 2588 hr = _ptrClientIn->IsFormatSupported( |
2589 AUDCLNT_SHAREMODE_SHARED, | 2589 AUDCLNT_SHAREMODE_SHARED, |
(...skipping 2481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5071 | 5071 |
5072 // ---------------------------------------------------------------------------- | 5072 // ---------------------------------------------------------------------------- |
5073 // WideToUTF8 | 5073 // WideToUTF8 |
5074 // ---------------------------------------------------------------------------- | 5074 // ---------------------------------------------------------------------------- |
5075 | 5075 |
5076 char* AudioDeviceWindowsCore::WideToUTF8(const TCHAR* src) const { | 5076 char* AudioDeviceWindowsCore::WideToUTF8(const TCHAR* src) const { |
5077 #ifdef UNICODE | 5077 #ifdef UNICODE |
5078 const size_t kStrLen = sizeof(_str); | 5078 const size_t kStrLen = sizeof(_str); |
5079 memset(_str, 0, kStrLen); | 5079 memset(_str, 0, kStrLen); |
5080 // Get required size (in bytes) to be able to complete the conversion. | 5080 // Get required size (in bytes) to be able to complete the conversion. |
5081 int required_size = WideCharToMultiByte(CP_UTF8, 0, src, -1, _str, 0, 0, 0); | 5081 unsigned int required_size = (unsigned int)WideCharToMultiByte(CP_UTF8, 0, s
rc, -1, _str, 0, 0, 0); |
5082 if (required_size <= kStrLen) | 5082 if (required_size <= kStrLen) |
5083 { | 5083 { |
5084 // Process the entire input string, including the terminating null char. | 5084 // Process the entire input string, including the terminating null char. |
5085 if (WideCharToMultiByte(CP_UTF8, 0, src, -1, _str, kStrLen, 0, 0) == 0) | 5085 if (WideCharToMultiByte(CP_UTF8, 0, src, -1, _str, kStrLen, 0, 0) == 0) |
5086 memset(_str, 0, kStrLen); | 5086 memset(_str, 0, kStrLen); |
5087 } | 5087 } |
5088 return _str; | 5088 return _str; |
5089 #else | 5089 #else |
5090 return const_cast<char*>(src); | 5090 return const_cast<char*>(src); |
5091 #endif | 5091 #endif |
5092 } | 5092 } |
5093 | 5093 |
5094 | 5094 |
5095 bool AudioDeviceWindowsCore::KeyPressed() const{ | 5095 bool AudioDeviceWindowsCore::KeyPressed() const{ |
5096 | 5096 |
5097 int key_down = 0; | 5097 int key_down = 0; |
5098 for (int key = VK_SPACE; key < VK_NUMLOCK; key++) { | 5098 for (int key = VK_SPACE; key < VK_NUMLOCK; key++) { |
5099 short res = GetAsyncKeyState(key); | 5099 short res = GetAsyncKeyState(key); |
5100 key_down |= res & 0x1; // Get the LSB | 5100 key_down |= res & 0x1; // Get the LSB |
5101 } | 5101 } |
5102 return (key_down > 0); | 5102 return (key_down > 0); |
5103 } | 5103 } |
5104 } // namespace webrtc | 5104 } // namespace webrtc |
5105 | 5105 |
5106 #endif // WEBRTC_WINDOWS_CORE_AUDIO_BUILD | 5106 #endif // WEBRTC_WINDOWS_CORE_AUDIO_BUILD |
OLD | NEW |