| Index: media/filters/ffmpeg_glue_unittest.cc
|
| diff --git a/media/filters/ffmpeg_glue_unittest.cc b/media/filters/ffmpeg_glue_unittest.cc
|
| index de123ec2727be5819dee186fcfb505d6a741d589..5781bf3e2afb0d20c8c0530c09ba2dde24eb1d2a 100644
|
| --- a/media/filters/ffmpeg_glue_unittest.cc
|
| +++ b/media/filters/ffmpeg_glue_unittest.cc
|
| @@ -13,6 +13,7 @@
|
| #include "media/base/mock_filters.h"
|
| #include "media/base/test_data_util.h"
|
| #include "media/ffmpeg/ffmpeg_common.h"
|
| +#include "media/ffmpeg/ffmpeg_deleters.h"
|
| #include "media/filters/in_memory_url_protocol.h"
|
| #include "testing/gtest/include/gtest/gtest.h"
|
|
|
| @@ -234,17 +235,22 @@ TEST_F(FFmpegGlueDestructionTest, WithOpenWithStreams) {
|
| }
|
|
|
| // Ensure destruction release the appropriate resources when OpenContext() is
|
| -// called and streams have been opened.
|
| +// called and streams have been opened. This now requires user of FFmpegGlue to
|
| +// ensure any allocated AVCodecContext is closed prior to ~FFmpegGlue().
|
| TEST_F(FFmpegGlueDestructionTest, WithOpenWithOpenStreams) {
|
| Initialize("bear-320x240.webm");
|
| ASSERT_TRUE(glue_->OpenContext());
|
| ASSERT_GT(glue_->format_context()->nb_streams, 0u);
|
|
|
| + // Use ScopedPtrAVFreeContext to ensure |context| is closed, and use scoping
|
| + // and ordering to ensure |context| is destructed before |glue_|.
|
| // Pick the audio stream (1) so this works when the ffmpeg video decoders are
|
| // disabled.
|
| - AVCodecContext* context = glue_->format_context()->streams[1]->codec;
|
| - ASSERT_EQ(0, avcodec_open2(
|
| - context, avcodec_find_decoder(context->codec_id), NULL));
|
| + std::unique_ptr<AVCodecContext, ScopedPtrAVFreeContext> context(
|
| + AVStreamToAVCodecContext(glue_->format_context()->streams[1]));
|
| + ASSERT_NE(nullptr, context.get());
|
| + ASSERT_EQ(0, avcodec_open2(context.get(),
|
| + avcodec_find_decoder(context->codec_id), nullptr));
|
| }
|
|
|
| } // namespace media
|
|
|