From 048b0373429fd077b51e2ca72f2c3f5b491c8a9f Mon Sep 17 00:00:00 2001 From: "phoglund@webrtc.org" Date: Tue, 6 Dec 2011 10:42:05 +0000 Subject: [PATCH] Fixed vie_auto_test shutdown race conditions. Fixed a race condition crash in vie_auto_test shutdown. Certain tests did not clean up the voice engine properly which caused crashes during certain uncommon timing conditions. BUG= TEST= Review URL: http://webrtc-codereview.appspot.com/307001 git-svn-id: http://webrtc.googlecode.com/svn/trunk@1109 4adac7df-926f-26a2-2b94-8c16560cd09d --- src/video_engine/test/auto_test/source/vie_autotest_base.cc | 4 ++++ src/video_engine/test/auto_test/source/vie_autotest_file.cc | 6 ++++++ src/video_engine/vie_base_impl.h | 3 ++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/video_engine/test/auto_test/source/vie_autotest_base.cc b/src/video_engine/test/auto_test/source/vie_autotest_base.cc index 4e12c99d4..d2a29b251 100644 --- a/src/video_engine/test/auto_test/source/vie_autotest_base.cc +++ b/src/video_engine/test/auto_test/source/vie_autotest_base.cc @@ -189,7 +189,11 @@ void ViEAutoTest::ViEBaseAPITest() { "Should fail: disconnecting bogus channel"; EXPECT_EQ(0, ptrViEBase->DisconnectAudioChannel(videoChannel)); + + // Clean up voice engine EXPECT_EQ(0, ptrViEBase->SetVoiceEngine(NULL)); + EXPECT_EQ(0, ptrVoEBase->Release()); + EXPECT_TRUE(webrtc::VoiceEngine::Delete(ptrVoE)); webrtc::ViEBase* ptrViEBase2 = webrtc::ViEBase::GetInterface(ptrViE); EXPECT_TRUE(NULL != ptrViEBase2); diff --git a/src/video_engine/test/auto_test/source/vie_autotest_file.cc b/src/video_engine/test/auto_test/source/vie_autotest_file.cc index afb73685f..4e87554d7 100644 --- a/src/video_engine/test/auto_test/source/vie_autotest_file.cc +++ b/src/video_engine/test/auto_test/source/vie_autotest_file.cc @@ -463,6 +463,12 @@ void ViEAutoTest::ViEFileStandardTest() // Testing finished. Tear down Video Engine //*************************************************************** + EXPECT_EQ(0, ptrViEBase->DisconnectAudioChannel(videoChannel)); + EXPECT_EQ(0, ptrViEBase->SetVoiceEngine(NULL)); + EXPECT_EQ(0, ptrVEBase->DeleteChannel(audioChannel)); + EXPECT_EQ(0, ptrVEBase->Release()); + EXPECT_EQ(0, ptrVECodec->Release()); + EXPECT_TRUE(webrtc::VoiceEngine::Delete(ptrVEEngine)); EXPECT_EQ(0, ptrViEBase->StopReceive(videoChannel)); EXPECT_EQ(0, ptrViEBase->StopSend(videoChannel)); diff --git a/src/video_engine/vie_base_impl.h b/src/video_engine/vie_base_impl.h index f6a30fb04..a96140513 100644 --- a/src/video_engine/vie_base_impl.h +++ b/src/video_engine/vie_base_impl.h @@ -31,7 +31,8 @@ class ViEBaseImpl // Initializes VideoEngine and must be called before any other API is called. virtual int Init(); - // Connects ViE to a VoE instance. + // Connects ViE to a VoE instance. Pass in NULL to forget about a previously + // set voice engine and release all resources we allocated from it. virtual int SetVoiceEngine(VoiceEngine* voice_engine); // Creates a new ViE channel.