Fix how we were using TbInterfaces and disallow operator=() and the copy constructor.
The reason is that this will cause a crash: TbInterfaces foo = TbInterfaces("blah"); It relies on the generated copy constructor (or assignment operator), which copies the pointer values from a temporary object. After |foo| in this case has been initialized with values from the temporary object, the temp goes out of scope and is deleted. The result is that |foo| has been initialized with pointers do a deleted object. Also fixing expectations for the return value of VoE Release() calls after I checked in my change that makes the VoiceEngine per-object ref counted and not per-interface. Review URL: https://webrtc-codereview.appspot.com/509005 git-svn-id: http://webrtc.googlecode.com/svn/trunk@2128 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
@ -215,7 +215,9 @@ void ViEAutoTest::ViEBaseAPITest() {
|
||||
// Clean up voice engine
|
||||
EXPECT_EQ(0, ptrVieNetwork->Release());
|
||||
EXPECT_EQ(0, ptrViEBase->SetVoiceEngine(NULL));
|
||||
EXPECT_EQ(0, ptrVoEBase->Release());
|
||||
// VoiceEngine reference counting is per object, not per interface, so
|
||||
// Release should return != 0.
|
||||
EXPECT_NE(0, ptrVoEBase->Release());
|
||||
EXPECT_TRUE(webrtc::VoiceEngine::Delete(ptrVoE));
|
||||
|
||||
webrtc::ViEBase* ptrViEBase2 = webrtc::ViEBase::GetInterface(ptrViE);
|
||||
|
@ -109,7 +109,7 @@ public:
|
||||
};
|
||||
|
||||
void ViEAutoTest::ViECodecStandardTest() {
|
||||
TbInterfaces interfaces = TbInterfaces("ViECodecStandardTest");
|
||||
TbInterfaces interfaces("ViECodecStandardTest");
|
||||
|
||||
TbCaptureDevice capture_device = TbCaptureDevice(interfaces);
|
||||
int capture_id = capture_device.captureId;
|
||||
@ -273,7 +273,7 @@ void ViEAutoTest::ViECodecExtendedTest() {
|
||||
ViECodecStandardTest();
|
||||
ViECodecExternalCodecTest();
|
||||
|
||||
TbInterfaces interfaces = TbInterfaces("ViECodecExtendedTest");
|
||||
TbInterfaces interfaces("ViECodecExtendedTest");
|
||||
webrtc::ViEBase* base = interfaces.base;
|
||||
webrtc::ViECapture* capture = interfaces.capture;
|
||||
webrtc::ViERender* render = interfaces.render;
|
||||
|
@ -39,7 +39,7 @@ void ViEAutoTest::ViEFileStandardTest()
|
||||
{
|
||||
ViETest::Log("Starting a loopback call...");
|
||||
|
||||
TbInterfaces interfaces = TbInterfaces("ViEFileStandardTest");
|
||||
TbInterfaces interfaces("ViEFileStandardTest");
|
||||
|
||||
webrtc::VideoEngine* ptrViE = interfaces.video_engine;
|
||||
webrtc::ViEBase* ptrViEBase = interfaces.base;
|
||||
@ -464,8 +464,9 @@ void ViEAutoTest::ViEFileStandardTest()
|
||||
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());
|
||||
// VoE reference counting is per-object, so we use EXPECT_NE
|
||||
EXPECT_NE(0, ptrVEBase->Release());
|
||||
EXPECT_NE(0, ptrVECodec->Release());
|
||||
EXPECT_TRUE(webrtc::VoiceEngine::Delete(ptrVEEngine));
|
||||
|
||||
EXPECT_EQ(0, ptrViEBase->StopReceive(videoChannel));
|
||||
|
@ -87,7 +87,7 @@ bool ViEFileBasedComparisonTests::TestCodecs(
|
||||
ViEToFileRenderer* local_file_renderer,
|
||||
ViEToFileRenderer* remote_file_renderer) {
|
||||
|
||||
TbInterfaces interfaces = TbInterfaces("TestCodecs");
|
||||
TbInterfaces interfaces("TestCodecs");
|
||||
|
||||
ViEFakeCamera fake_camera(interfaces.capture);
|
||||
if (!fake_camera.StartCameraInNewThread(i420_video_file, width, height)) {
|
||||
@ -127,7 +127,7 @@ void ViEFileBasedComparisonTests::TestFullStack(
|
||||
ViEToFileRenderer* local_file_renderer,
|
||||
ViEToFileRenderer* remote_file_renderer,
|
||||
FrameDropDetector* frame_drop_detector) {
|
||||
TbInterfaces interfaces = TbInterfaces("TestFullStack");
|
||||
TbInterfaces interfaces("TestFullStack");
|
||||
|
||||
// Setup camera capturing from file.
|
||||
ViEFakeCamera fake_camera(interfaces.capture);
|
||||
|
@ -13,6 +13,7 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "constructor_magic.h"
|
||||
#include "common_types.h"
|
||||
#include "video_engine/include/vie_base.h"
|
||||
#include "video_engine/include/vie_capture.h"
|
||||
@ -31,7 +32,7 @@ class TbInterfaces
|
||||
{
|
||||
public:
|
||||
// Sets up all interfaces and creates a trace file
|
||||
TbInterfaces(std::string test_name);
|
||||
TbInterfaces(const std::string& test_name);
|
||||
~TbInterfaces(void);
|
||||
|
||||
webrtc::VideoEngine* video_engine;
|
||||
@ -47,6 +48,9 @@ public:
|
||||
int LastError() {
|
||||
return base->LastError();
|
||||
}
|
||||
|
||||
private:
|
||||
DISALLOW_COPY_AND_ASSIGN(TbInterfaces);
|
||||
};
|
||||
|
||||
#endif // WEBRTC_VIDEO_ENGINE_MAIN_TEST_AUTOTEST_INTERFACE_TB_INTERFACES_H_
|
||||
|
@ -13,7 +13,17 @@
|
||||
#include "gtest/gtest.h"
|
||||
#include "testsupport/fileutils.h"
|
||||
|
||||
TbInterfaces::TbInterfaces(std::string test_name) {
|
||||
TbInterfaces::TbInterfaces(const std::string& test_name) :
|
||||
video_engine(NULL),
|
||||
base(NULL),
|
||||
capture(NULL),
|
||||
render(NULL),
|
||||
rtp_rtcp(NULL),
|
||||
codec(NULL),
|
||||
network(NULL),
|
||||
image_process(NULL),
|
||||
encryption(NULL)
|
||||
{
|
||||
std::string complete_path =
|
||||
webrtc::test::OutputPath() + test_name + "_trace.txt";
|
||||
|
||||
@ -53,15 +63,23 @@ TbInterfaces::TbInterfaces(std::string test_name) {
|
||||
TbInterfaces::~TbInterfaces(void)
|
||||
{
|
||||
EXPECT_EQ(0, encryption->Release());
|
||||
encryption = NULL;
|
||||
EXPECT_EQ(0, image_process->Release());
|
||||
image_process = NULL;
|
||||
EXPECT_EQ(0, codec->Release());
|
||||
codec = NULL;
|
||||
EXPECT_EQ(0, capture->Release());
|
||||
capture = NULL;
|
||||
EXPECT_EQ(0, render->Release());
|
||||
render = NULL;
|
||||
EXPECT_EQ(0, rtp_rtcp->Release());
|
||||
rtp_rtcp = NULL;
|
||||
EXPECT_EQ(0, network->Release());
|
||||
network = NULL;
|
||||
EXPECT_EQ(0, base->Release());
|
||||
base = NULL;
|
||||
EXPECT_TRUE(webrtc::VideoEngine::Delete(video_engine)) <<
|
||||
"Since we have released all interfaces at this point, deletion "
|
||||
"should be successful.";
|
||||
|
||||
video_engine = NULL;
|
||||
}
|
||||
|
Reference in New Issue
Block a user