diff --git a/webrtc/video_engine/test/auto_test/primitives/general_primitives.cc b/webrtc/video_engine/test/auto_test/primitives/general_primitives.cc index 86d4b648a..fda0abdf3 100644 --- a/webrtc/video_engine/test/auto_test/primitives/general_primitives.cc +++ b/webrtc/video_engine/test/auto_test/primitives/general_primitives.cc @@ -36,17 +36,19 @@ void FindCaptureDeviceOnSystem(webrtc::ViECapture* capture, *device_video = webrtc::VideoCaptureFactory::Create(4571, unique_id); EXPECT_TRUE(*device_video != NULL); - (*device_video)->AddRef(); + if (*device_video) { + (*device_video)->AddRef(); - int error = capture->AllocateCaptureDevice(**device_video, *device_id); - if (error == 0) { - ViETest::Log("Using capture device: %s, captureId: %d.", - device_name, *device_id); - capture_device_set = true; - break; - } else { - (*device_video)->Release(); - (*device_video) = NULL; + int error = capture->AllocateCaptureDevice(**device_video, *device_id); + if (error == 0) { + ViETest::Log("Using capture device: %s, captureId: %d.", + device_name, *device_id); + capture_device_set = true; + break; + } else { + (*device_video)->Release(); + (*device_video) = NULL; + } } } delete dev_info; diff --git a/webrtc/video_engine/test/auto_test/source/vie_autotest_base.cc b/webrtc/video_engine/test/auto_test/source/vie_autotest_base.cc index 5f0ef7cff..4a7437a96 100644 --- a/webrtc/video_engine/test/auto_test/source/vie_autotest_base.cc +++ b/webrtc/video_engine/test/auto_test/source/vie_autotest_base.cc @@ -28,7 +28,7 @@ void ViEAutoTest::ViEBaseStandardTest() { int video_channel = -1; EXPECT_EQ(0, interfaces.base->CreateChannel(video_channel)); - webrtc::VideoCaptureModule* video_capture_module(NULL); + webrtc::VideoCaptureModule* video_capture_module = NULL; const unsigned int kMaxDeviceNameLength = 128; char device_name[kMaxDeviceNameLength]; memset(device_name, 0, kMaxDeviceNameLength); @@ -44,6 +44,10 @@ void ViEAutoTest::ViEBaseStandardTest() { &capture_id, &video_capture_module); + EXPECT_TRUE(video_capture_module); + if (!video_capture_module) + return; + EXPECT_EQ(0, capture_interface->ConnectCaptureDevice(capture_id, video_channel)); EXPECT_EQ(0, capture_interface->StartCapture(capture_id)); diff --git a/webrtc/video_engine/test/auto_test/source/vie_autotest_capture.cc b/webrtc/video_engine/test/auto_test/source/vie_autotest_capture.cc index bec665767..d44f6b916 100644 --- a/webrtc/video_engine/test/auto_test/source/vie_autotest_capture.cc +++ b/webrtc/video_engine/test/auto_test/source/vie_autotest_capture.cc @@ -121,10 +121,10 @@ void ViEAutoTest::ViECaptureStandardTest() { ASSERT_GT(number_of_capture_devices, 0) << "This test requires a capture device (i.e. a webcam)"; - int capture_device_id[10]; - memset(capture_device_id, 0, sizeof(capture_device_id)); - webrtc::VideoCaptureModule* vcpms[10]; - memset(vcpms, 0, sizeof(vcpms)); +#if !defined(WEBRTC_MAC) + int capture_device_id[10] = {0}; + webrtc::VideoCaptureModule* vcpms[10] = {0}; +#endif // Check capabilities for (int device_index = 0; device_index < number_of_capture_devices; @@ -179,6 +179,9 @@ void ViEAutoTest::ViECaptureStandardTest() { webrtc::VideoCaptureModule* vcpm = webrtc::VideoCaptureFactory::Create(device_index, device_unique_name); EXPECT_TRUE(vcpm != NULL); + if (!vcpm) + continue; + vcpm->AddRef(); vcpms[device_index] = vcpm; @@ -249,7 +252,8 @@ void ViEAutoTest::ViECaptureStandardTest() { EXPECT_EQ(0, video_engine.capture->ReleaseCaptureDevice( capture_device_id[device_index])); #endif // !WEBRTC_ANDROID - vcpms[device_index]->Release(); + if (vcpms[device_index]) + vcpms[device_index]->Release(); } #endif // !WEBRTC_MAC } diff --git a/webrtc/video_engine/test/libvietest/testbed/tb_capture_device.cc b/webrtc/video_engine/test/libvietest/testbed/tb_capture_device.cc index 684bff978..61b356563 100644 --- a/webrtc/video_engine/test/libvietest/testbed/tb_capture_device.cc +++ b/webrtc/video_engine/test/libvietest/testbed/tb_capture_device.cc @@ -66,7 +66,8 @@ TbCaptureDevice::~TbCaptureDevice(void) { EXPECT_EQ(0, ViE.capture->StopCapture(captureId)); EXPECT_EQ(0, ViE.capture->ReleaseCaptureDevice(captureId)); - vcpm_->Release(); + if (vcpm_) + vcpm_->Release(); } void TbCaptureDevice::ConnectTo(int videoChannel)