Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(880)

Unified Diff: media/filters/ffmpeg_glue_unittest.cc

Issue 2534193003: To M56: Roll src/third_party/ffmpeg/ 3c7a09882..cdf4accee (3188 commits). (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/filters/ffmpeg_glue.cc ('k') | media/filters/ffmpeg_h264_to_annex_b_bitstream_converter.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « media/filters/ffmpeg_glue.cc ('k') | media/filters/ffmpeg_h264_to_annex_b_bitstream_converter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698