Skip to content

Commit

Permalink
Properly ref-count the EndOfStream buffers.
Browse files Browse the repository at this point in the history
Also reverts most of the test change made in r105647.

BUG=99596
TEST=Valgrind on media_unittests.

Review URL: http://codereview.chromium.org/8319010

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@105890 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
ddorwin@chromium.org committed Oct 17, 2011
1 parent ac1cb15 commit 04a5ef8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
6 changes: 3 additions & 3 deletions media/filters/ffmpeg_demuxer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ void FFmpegDemuxerStream::Stop() {
buffer_queue_.clear();
for (ReadQueue::iterator it = read_queue_.begin();
it != read_queue_.end(); ++it) {
it->Run(new DataBuffer(0));
it->Run(scoped_refptr<Buffer>(new DataBuffer(0)));
}
read_queue_.clear();
stopped_ = true;
Expand All @@ -165,7 +165,7 @@ void FFmpegDemuxerStream::Read(const ReadCallback& read_callback) {
//
// TODO(scherkus): it would be cleaner if we replied with an error message.
if (stopped_) {
read_callback.Run(new DataBuffer(0));
read_callback.Run(scoped_refptr<Buffer>(new DataBuffer(0)));
return;
}

Expand Down Expand Up @@ -194,7 +194,7 @@ void FFmpegDemuxerStream::ReadTask(const ReadCallback& read_callback) {
//
// TODO(scherkus): it would be cleaner if we replied with an error message.
if (stopped_) {
read_callback.Run(new DataBuffer(0));
read_callback.Run(scoped_refptr<Buffer>(new DataBuffer(0)));
return;
}

Expand Down
10 changes: 2 additions & 8 deletions media/filters/ffmpeg_demuxer_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ MATCHER(IsEndOfStreamBuffer,
return arg->IsEndOfStream();
}

ACTION(DeleteArg0Buffer) {
scoped_refptr<Buffer> buffer(arg0);
}

// Fixture class to facilitate writing tests. Takes care of setting up the
// FFmpeg, pipeline and filter host mocks.
class FFmpegDemuxerTest : public testing::Test {
Expand Down Expand Up @@ -407,8 +403,7 @@ TEST_F(FFmpegDemuxerTest, Stop) {

// The callback should be immediately deleted. We'll use a checkpoint to
// verify that it has indeed been deleted.
EXPECT_CALL(*callback, Run(IsEndOfStreamBuffer()))
.WillOnce(DeleteArg0Buffer());
EXPECT_CALL(*callback, Run(IsEndOfStreamBuffer()));
EXPECT_CALL(*callback, OnDelete());
EXPECT_CALL(*this, CheckPoint(1));

Expand Down Expand Up @@ -447,8 +442,7 @@ TEST_F(FFmpegDemuxerTest, StreamReadAfterStopAndDemuxerDestruction) {

// The callback should be immediately deleted. We'll use a checkpoint to
// verify that it has indeed been deleted.
EXPECT_CALL(*callback, Run(IsEndOfStreamBuffer()))
.WillOnce(DeleteArg0Buffer());
EXPECT_CALL(*callback, Run(IsEndOfStreamBuffer()));
EXPECT_CALL(*callback, OnDelete());
EXPECT_CALL(*this, CheckPoint(1));

Expand Down

0 comments on commit 04a5ef8

Please sign in to comment.