OSDN Git Service

stagefright-plugins: Seek to beginning of file on seek error
authorSteve Kondik <steve@cyngn.com>
Mon, 21 Dec 2015 11:44:06 +0000 (06:44 -0500)
committerSteve Kondik <steve@cyngn.com>
Mon, 21 Dec 2015 11:44:06 +0000 (06:44 -0500)
 * Prevent a deadlock on seek error

Change-Id: Ic7dfe1849298f6166154c319e618048720d1ea61

extractor/FFmpegExtractor.cpp

index 04b5140..f966b4d 100644 (file)
@@ -1147,15 +1147,15 @@ void FFmpegExtractor::readerEntry() {
             ret = avformat_seek_file(mFormatCtx, -1, mSeekMin, mSeekPos, mSeekMax, 0);
             if (ret < 0) {
                 ALOGE("%s: error while seeking", mFormatCtx->filename);
-            } else {
-                if (mAudioStreamIdx >= 0) {
-                    packet_queue_flush(&mAudioQ);
-                    packet_queue_put(&mAudioQ, &mAudioQ.flush_pkt);
-                }
-                if (mVideoStreamIdx >= 0) {
-                    packet_queue_flush(&mVideoQ);
-                    packet_queue_put(&mVideoQ, &mVideoQ.flush_pkt);
-                }
+                avformat_seek_file(mFormatCtx, -1, 0, 0, 0, 0);
+            }
+            if (mAudioStreamIdx >= 0) {
+                packet_queue_flush(&mAudioQ);
+                packet_queue_put(&mAudioQ, &mAudioQ.flush_pkt);
+            }
+            if (mVideoStreamIdx >= 0) {
+                packet_queue_flush(&mVideoQ);
+                packet_queue_put(&mVideoQ, &mVideoQ.flush_pkt);
             }
             mSeekIdx = -1;
             eof = false;