From ccf3bd3ca48377b2808edd2ec6b86e2ab4e85910 Mon Sep 17 00:00:00 2001 From: wang-bin Date: Wed, 3 Feb 2016 19:23:51 +0800 Subject: [PATCH] pause avthread after seek finished --- src/AudioThread.cpp | 15 ++++++++------- src/VideoThread.cpp | 12 +++++++----- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/AudioThread.cpp b/src/AudioThread.cpp index fe88e793..f07b35db 100644 --- a/src/AudioThread.cpp +++ b/src/AudioThread.cpp @@ -87,13 +87,14 @@ void AudioThread::run() int sync_id = 0; while (!d.stop) { processNextTask(); - //TODO: why put it at the end of loop then playNextFrame() not work? - if (tryPause()) { //DO NOT continue, or playNextFrame() will fail - if (d.stop) - break; //the queue is empty and may block. should setBlocking(false) wake up cond empty? - } else { - if (isPaused()) - continue; + if (d.render_pts0 < 0) { // no pause when seeking + if (tryPause()) { //DO NOT continue, or stepForward() will fail + if (d.stop) + break; //the queue is empty and may block. should setBlocking(false) wake up cond empty? + } else { + if (isPaused()) + continue; + } } if (d.seek_requested) { d.seek_requested = false; diff --git a/src/VideoThread.cpp b/src/VideoThread.cpp index 6eee15ed..84bc48d3 100644 --- a/src/VideoThread.cpp +++ b/src/VideoThread.cpp @@ -295,11 +295,13 @@ void VideoThread::run() processNextTask(); //TODO: why put it at the end of loop then stepForward() not work? //processNextTask tryPause(timeout) and and continue outter loop - if (tryPause()) { //DO NOT continue, or stepForward() will fail + if (d.render_pts0 < 0) { // no pause when seeking + if (tryPause()) { //DO NOT continue, or stepForward() will fail - } else { - if (isPaused()) - continue; //timeout. process pending tasks + } else { + if (isPaused()) + continue; //timeout. process pending tasks + } } if (d.seek_requested) { d.seek_requested = false; @@ -344,7 +346,7 @@ void VideoThread::run() continue; } } - if (pkt.pts <= 0) { + if (pkt.pts <= 0 && !pkt.isEOF() && pkt.data.size() > 0) { nb_no_pts++; } else { nb_no_pts = 0;