OSDN Git Service

stagefright-plugins: call packet_queue_init earier
authorKeith Mok <kmok@cyngn.com>
Mon, 20 Jun 2016 17:19:56 +0000 (10:19 -0700)
committerKeith Mok <kmok@cyngn.com>
Mon, 20 Jun 2016 17:19:56 +0000 (10:19 -0700)
On FFmpegExtractor destructor it always call
packet_queue_destroy. However packet_queue_init
may not be called if there is an error inside
initStreams. Causing packet_queue_destroy trying
to free some random data in mVideoQ and mAudioQ and
leading to crash.

OPO-775

Change-Id: Idded5f886a680f135d6e004977c85135e40d02f1

extractor/FFmpegExtractor.cpp

index 1a27f68..9692cb5 100644 (file)
@@ -122,6 +122,9 @@ FFmpegExtractor::FFmpegExtractor(const sp<DataSource> &source, const sp<AMessage
 
     fetchStuffsFromSniffedMeta(meta);
 
+    packet_queue_init(&mVideoQ);
+    packet_queue_init(&mAudioQ);
+
     int err = initStreams();
     if (err < 0) {
         ALOGE("failed to init ffmpeg");
@@ -1023,9 +1026,6 @@ int FFmpegExtractor::initStreams()
             hours, mins, secs, (100 * us) / AV_TIME_BASE);
     }
 
-    packet_queue_init(&mVideoQ);
-    packet_queue_init(&mAudioQ);
-
     if (st_index[AVMEDIA_TYPE_AUDIO] >= 0) {
         audio_ret = stream_component_open(st_index[AVMEDIA_TYPE_AUDIO]);
         if (audio_ret >= 0)