From 4c96601aed3ac07a34de4c15f139ad96ee86f441 Mon Sep 17 00:00:00 2001 From: "pbos@webrtc.org" Date: Wed, 21 Aug 2013 12:07:37 +0000 Subject: [PATCH] Make FrameGeneratorCapturer own frame_generator. Fixes memleaks where test::FrameGenerator::Create() was used to create frame_generator, but it was never freed. Since the frame generator shouldn't be used concurrently it's easiest if FrameGeneratorCapturer take ownership of the instance. BUG= R=stefan@webrtc.org Review URL: https://webrtc-codereview.appspot.com/2047005 git-svn-id: http://webrtc.googlecode.com/svn/trunk@4580 4adac7df-926f-26a2-2b94-8c16560cd09d --- .../test/common/frame_generator_capturer.h | 4 +++- webrtc/video_engine/test/full_stack.cc | 17 +++++++---------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/webrtc/video_engine/test/common/frame_generator_capturer.h b/webrtc/video_engine/test/common/frame_generator_capturer.h index 40ad47e4e2..3c2ec2393a 100644 --- a/webrtc/video_engine/test/common/frame_generator_capturer.h +++ b/webrtc/video_engine/test/common/frame_generator_capturer.h @@ -26,6 +26,8 @@ class FrameGenerator; class FrameGeneratorCapturer : public VideoCapturer { public: + // The FrameGeneratorCapturer takes ownership of the FrameGenerator, which + // will be freed when the FrameGeneratorCapturer is deleted. static FrameGeneratorCapturer* Create(newapi::VideoSendStreamInput* input, FrameGenerator* frame_generator, int target_fps); @@ -47,7 +49,7 @@ class FrameGeneratorCapturer : public VideoCapturer { scoped_ptr tick_; scoped_ptr lock_; scoped_ptr thread_; - FrameGenerator* frame_generator_; + scoped_ptr frame_generator_; int target_fps_; }; diff --git a/webrtc/video_engine/test/full_stack.cc b/webrtc/video_engine/test/full_stack.cc index ba830c390c..382e89aaf0 100644 --- a/webrtc/video_engine/test/full_stack.cc +++ b/webrtc/video_engine/test/full_stack.cc @@ -304,18 +304,15 @@ TEST_P(FullStackTest, NoPacketLoss) { Clock* test_clock = Clock::GetRealTimeClock(); - scoped_ptr file_frame_generator( - test::YuvFileFrameGenerator::Create( - test::ResourcePath(params.clip.name, "yuv").c_str(), - params.clip.width, - params.clip.height, - test_clock)); - ASSERT_TRUE(file_frame_generator.get() != NULL); - scoped_ptr file_capturer( test::FrameGeneratorCapturer::Create( - &analyzer, file_frame_generator.get(), params.clip.fps)); - ASSERT_TRUE(file_capturer.get() != NULL); + &analyzer, + test::YuvFileFrameGenerator::Create( + test::ResourcePath(params.clip.name, "yuv").c_str(), + params.clip.width, + params.clip.height, + test_clock), + params.clip.fps)); newapi::VideoReceiveStream::Config receive_config = call->GetDefaultReceiveConfig();