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

Unified Diff: media/filters/ffmpeg_glue_unittest.cc

Issue 2497603003: Roll src/third_party/ffmpeg/ 3c7a09882..cdf4accee (3188 commits). (Closed)
Patch Set: Rebase (liberato@'s pipeline_integration_test_base conflicted; using liberato@'s now here) 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
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..624a6c0a2a6def22ebfd82fc4d6f0d6b30432018 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,25 @@ 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_|.
+ std::unique_ptr<AVCodecContext, ScopedPtrAVFreeContext> context(
+ avcodec_alloc_context3(NULL));
+
// 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));
+ ASSERT_LE(0,
+ avcodec_parameters_to_context(
+ context.get(), glue_->format_context()->streams[1]->codecpar));
+ ASSERT_EQ(0, avcodec_open2(context.get(),
+ avcodec_find_decoder(context->codec_id), NULL));
}
} // namespace media

Powered by Google App Engine
This is Rietveld 408576698