From 5ba3decc9436b6939546294e7ab91c319246b211 Mon Sep 17 00:00:00 2001 From: "henrika@webrtc.org" Date: Mon, 26 Nov 2012 09:12:02 +0000 Subject: [PATCH] Ensures that we can build using VS 2012 on Windows. See more details at https://code.google.com/p/webrtc/issues/detail?id=1146& TBR=Niklas BUG=1146 Review URL: https://webrtc-codereview.appspot.com/939028 git-svn-id: http://webrtc.googlecode.com/svn/trunk@3162 4adac7df-926f-26a2-2b94-8c16560cd09d --- .../modules/audio_coding/main/test/Channel.cc | 2 +- .../audio_device/win/audio_device_core_win.cc | 47 ++++++++++--------- .../video_capture/windows/device_info_ds.cc | 18 +++---- 3 files changed, 34 insertions(+), 33 deletions(-) diff --git a/webrtc/modules/audio_coding/main/test/Channel.cc b/webrtc/modules/audio_coding/main/test/Channel.cc index d7e387aca..55ffef532 100644 --- a/webrtc/modules/audio_coding/main/test/Channel.cc +++ b/webrtc/modules/audio_coding/main/test/Channel.cc @@ -160,7 +160,7 @@ Channel::CalcStatistics( _lastPayloadType = rtpInfo.header.payloadType; bool newPayload = true; - ACMTestPayloadStats* currentPayloadStr; + ACMTestPayloadStats* currentPayloadStr = NULL; for(n = 0; n < MAX_NUM_PAYLOADS; n++) { if(rtpInfo.header.payloadType == _payloadStats[n].payloadType) diff --git a/webrtc/modules/audio_device/win/audio_device_core_win.cc b/webrtc/modules/audio_device/win/audio_device_core_win.cc index 7428f0cd6..566cb69c1 100644 --- a/webrtc/modules/audio_device/win/audio_device_core_win.cc +++ b/webrtc/modules/audio_device/win/audio_device_core_win.cc @@ -244,7 +244,7 @@ bool AudioDeviceWindowsCore::CoreAudioIsSupported() // want to ensure that MTA is used and therefore return false here. return false; } - + // 3) Check if the MMDevice API is available. // // The Windows Multimedia Device (MMDevice) API enables audio clients to @@ -286,17 +286,17 @@ bool AudioDeviceWindowsCore::CoreAudioIsSupported() const DWORD dwFlags = FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS; const DWORD dwLangID = MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US); - + // Gets the system's human readable message string for this HRESULT. // All error message in English by default. - DWORD messageLength = ::FormatMessageW(dwFlags, + DWORD messageLength = ::FormatMessageW(dwFlags, 0, hr, dwLangID, - errorText, - MAXERRORLENGTH, + errorText, + MAXERRORLENGTH, NULL); - + assert(messageLength <= MAXERRORLENGTH); // Trims tailing white space (FormatMessage() leaves a trailing cr-lf.). @@ -3122,15 +3122,15 @@ WebRtc_Word32 AudioDeviceWindowsCore::StopPlayout() CriticalSectionScoped critScoped(&_critSect); WEBRTC_TRACE(kTraceInfo, kTraceAudioDevice, _id, "webrtc_core_audio_render_thread is now closed"); - - // to reset this event manually at each time we finish with it, + + // to reset this event manually at each time we finish with it, // in case that the render thread has exited before StopPlayout(), // this event might be caught by the new render thread within same VoE instance. - ResetEvent(_hShutdownRenderEvent); + ResetEvent(_hShutdownRenderEvent); SAFE_RELEASE(_ptrClientOut); SAFE_RELEASE(_ptrRenderClient); - + _playIsInitialized = false; _playing = false; @@ -3471,6 +3471,8 @@ DWORD AudioDeviceWindowsCore::DoRenderThread() _Lock(); + IAudioClock* clock = NULL; + // Get size of rendering buffer (length is expressed as the number of audio frames the buffer can hold). // This value is fixed during the rendering session. // @@ -3525,7 +3527,6 @@ DWORD AudioDeviceWindowsCore::DoRenderThread() _writtenSamples += bufferLength; - IAudioClock* clock = NULL; hr = _ptrClientOut->GetService(__uuidof(IAudioClock), (void**)&clock); if (FAILED(hr)) { WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, @@ -3614,7 +3615,7 @@ DWORD AudioDeviceWindowsCore::DoRenderThread() _ptrAudioBuffer->RequestPlayoutData(_playBlockSize); _Lock(); - if (nSamples == -1) + if (nSamples == -1) { _UnLock(); WEBRTC_TRACE(kTraceCritical, kTraceAudioDevice, _id, @@ -3629,7 +3630,7 @@ DWORD AudioDeviceWindowsCore::DoRenderThread() WEBRTC_TRACE(kTraceCritical, kTraceAudioDevice, _id, "output state has been modified during unlocked period"); goto Exit; } - if (nSamples != _playBlockSize) + if (nSamples != static_cast(_playBlockSize)) { WEBRTC_TRACE(kTraceWarning, kTraceAudioDevice, _id, "nSamples(%d) != _playBlockSize(%d)", nSamples, _playBlockSize); } @@ -3852,7 +3853,7 @@ DWORD AudioDeviceWindowsCore::DoCaptureThreadPollDMO() // TODO(andrew): verify that this is always satisfied. It might // be that ProcessOutput will try to return more than 10 ms if // we fail to call it frequently enough. - assert(kSamplesProduced == _recBlockSize); + assert(kSamplesProduced == static_cast(_recBlockSize)); assert(sizeof(BYTE) == sizeof(WebRtc_Word8)); _ptrAudioBuffer->SetRecordedBuffer( reinterpret_cast(data), @@ -4904,6 +4905,10 @@ WebRtc_Word32 AudioDeviceWindowsCore::_EnumerateEndpointDevicesAll(EDataFlow dat HRESULT hr = S_OK; IMMDeviceCollection *pCollection = NULL; + IMMDevice *pEndpoint = NULL; + IPropertyStore *pProps = NULL; + IAudioEndpointVolume* pEndpointVolume = NULL; + LPWSTR pwszID = NULL; // Generate a collection of audio endpoint devices in the system. // Get states for *all* endpoint devices. @@ -4917,11 +4922,7 @@ WebRtc_Word32 AudioDeviceWindowsCore::_EnumerateEndpointDevicesAll(EDataFlow dat // use the IMMDeviceCollection interface... - UINT count; - IMMDevice *pEndpoint = NULL; - IPropertyStore *pProps = NULL; - IAudioEndpointVolume* pEndpointVolume = NULL; - LPWSTR pwszID = NULL; + UINT count = 0; // Retrieve a count of the devices in the device collection. hr = pCollection->GetCount(&count); @@ -5083,15 +5084,15 @@ void AudioDeviceWindowsCore::_TraceCOMError(HRESULT hr) const const DWORD dwFlags = FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS; const DWORD dwLangID = MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US); - + // Gets the system's human readable message string for this HRESULT. // All error message in English by default. - DWORD messageLength = ::FormatMessageW(dwFlags, + DWORD messageLength = ::FormatMessageW(dwFlags, 0, hr, dwLangID, - errorText, - MAXERRORLENGTH, + errorText, + MAXERRORLENGTH, NULL); assert(messageLength <= MAXERRORLENGTH); diff --git a/webrtc/modules/video_capture/windows/device_info_ds.cc b/webrtc/modules/video_capture/windows/device_info_ds.cc index 5acd58ecb..b23d214e5 100644 --- a/webrtc/modules/video_capture/windows/device_info_ds.cc +++ b/webrtc/modules/video_capture/windows/device_info_ds.cc @@ -76,7 +76,7 @@ DeviceInfoDS::DeviceInfoDS(const WebRtc_Word32 id) the code for the object, other than to avoid calls to PeekMessage and SendMessage during processing that must not be interrupted by other method invocations or calls to other objects in the same apartment/thread.*/ - ///CoInitializeEx(NULL, COINIT_APARTMENTTHREADED ); //| COINIT_SPEED_OVER_MEMORY + ///CoInitializeEx(NULL, COINIT_APARTMENTTHREADED ); //| COINIT_SPEED_OVER_MEMORY HRESULT hr = CoInitializeEx(NULL, COINIT_MULTITHREADED); // Use COINIT_MULTITHREADED since Voice Engine uses COINIT_MULTITHREADED if (FAILED(hr)) { @@ -194,8 +194,8 @@ WebRtc_Word32 DeviceInfoDS::GetDeviceInfo( (_wcsnicmp(varName.bstrVal, (L"Google Camera Adapter"),21) != 0)) { - // Found a valid device - if (index == deviceNumber) // This is the device we are interested in. + // Found a valid device. + if (index == static_cast(deviceNumber)) { int convResult = 0; if (deviceNameLength > 0) @@ -336,7 +336,7 @@ IBaseFilter * DeviceInfoDS::GetDeviceFilter( (const char*) deviceUniqueIdUTF8, deviceUniqueIdUTF8Length) == 0) { - // We have found the requested device + // We have found the requested device deviceFound = true; hr = pM->BindToObject(0, 0, IID_IBaseFilter, (void**) &captureFilter); @@ -474,7 +474,7 @@ WebRtc_Word32 DeviceInfoDS::CreateCapabilityMap( } WebRtc_Word32 index = 0; // Index in created _capabilities map - // Check if the device support formattype == FORMAT_VideoInfo2 and FORMAT_VideoInfo. + // Check if the device support formattype == FORMAT_VideoInfo2 and FORMAT_VideoInfo. // Prefer FORMAT_VideoInfo since some cameras (ZureCam) has been seen having problem with MJPEG and FORMAT_VideoInfo2 // Interlace flag is only supported in FORMAT_VideoInfo2 bool supportFORMAT_VideoInfo2 = false; @@ -570,7 +570,7 @@ WebRtc_Word32 DeviceInfoDS::CreateCapabilityMap( if (hrVC == S_OK) { - LONGLONG *maxFps; // array + LONGLONG *maxFps; // array long listSize; SIZE size; size.cx = capability->width; @@ -578,7 +578,7 @@ WebRtc_Word32 DeviceInfoDS::CreateCapabilityMap( // GetMaxAvailableFrameRate doesn't return max frame rate always // eg: Logitech Notebook. This may be due to a bug in that API - // because GetFrameRateList array is reversed in the above camera. So + // because GetFrameRateList array is reversed in the above camera. So // a util method written. Can't assume the first value will return // the max fps. hrVC = videoControlConfig->GetFrameRateList(outputCapturePin, @@ -687,7 +687,7 @@ WebRtc_Word32 DeviceInfoDS::CreateCapabilityMap( RELEASE_AND_CLEAR(videoControlConfig); RELEASE_AND_CLEAR(outputCapturePin); RELEASE_AND_CLEAR(captureDevice); // Release the capture device - + // Store the new used device name _lastUsedDeviceNameLength = deviceUniqueIdUTF8Length; _lastUsedDeviceName = (char*) realloc(_lastUsedDeviceName, @@ -700,7 +700,7 @@ WebRtc_Word32 DeviceInfoDS::CreateCapabilityMap( return _captureCapabilities.Size(); } -/* Constructs a product ID from the Windows DevicePath. on a USB device the devicePath contains product id and vendor id. +/* Constructs a product ID from the Windows DevicePath. on a USB device the devicePath contains product id and vendor id. This seems to work for firewire as well /* Example of device path "\\?\usb#vid_0408&pid_2010&mi_00#7&258e7aaf&0&0000#{65e8773d-8f56-11d0-a3b9-00a0c9223196}\global"