Skip to content

Commit

Permalink
Merge pull request wang-bin#1167 from taniey/master
Browse files Browse the repository at this point in the history
BugFix:  fix the file maybe play error when play the top frames
  • Loading branch information
wang-bin authored Dec 29, 2018
2 parents 07277e5 + 26200c9 commit 17f2535
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
8 changes: 8 additions & 0 deletions src/AVPlayerPrivate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,10 @@ bool AVPlayer::Private::setupAudioThread(AVPlayer *player)
}
}
}

// we set the thre state before the thread start,
// as it maybe clear after by AVDemuxThread starting
athread->resetState();
athread->setDecoder(adec);
setAVOutput(ao, ao, athread);
updateBufferValue(athread->packetQueue());
Expand Down Expand Up @@ -605,6 +609,10 @@ bool AVPlayer::Private::setupVideoThread(AVPlayer *player)
}
QObject::connect(vthread, SIGNAL(finished()), player, SLOT(tryClearVideoRenderers()), Qt::DirectConnection);
}

// we set the thre state before the thread start
// as it maybe clear after by AVDemuxThread starting
vthread->resetState();
vthread->setDecoder(vdec);

vthread->setBrightness(brightness);
Expand Down
2 changes: 1 addition & 1 deletion src/AVThread.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ class AVThread : public QThread
qreal decodeFrameRate() const; //move to statistics?
void setDropFrameOnSeek(bool value);

void resetState();
public slots:
virtual void stop();
/*change pause state. the pause/continue action will do in the next loop*/
Expand All @@ -100,7 +101,6 @@ private Q_SLOTS:
void onFinished();
protected:
AVThread(AVThreadPrivate& d, QObject *parent = 0);
void resetState();
/*
* If the pause state is true setted by pause(true), then block the thread and wait for pause state changed, i.e. pause(false)
* and return true. Otherwise, return false immediatly.
Expand Down
2 changes: 1 addition & 1 deletion src/AudioThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ void AudioThread::run()
//No decoder or output. No audio output is ok, just display picture
if (!d.dec || !d.dec->isAvailable() || !d.outputSet)
return;
resetState();
// resetState(); // we can't reset the thread state from here
Q_ASSERT(d.clock != 0);
d.init();
Packet pkt;
Expand Down
4 changes: 2 additions & 2 deletions src/VideoThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ void VideoThread::run()
DPTR_D(VideoThread);
if (!d.dec || !d.dec->isAvailable() || !d.outputSet)
return;
resetState();
// resetState(); // we can't reset the thread state from here
if (d.capture->autoSave()) {
d.capture->setCaptureName(QFileInfo(d.statistics->url).completeBaseName());
}
Expand Down Expand Up @@ -320,7 +320,7 @@ void VideoThread::run()
if (!pkt.isValid()) {
// may be we should check other information. invalid packet can come from
wait_key_frame = true;
qDebug("Invalid packet! flush video codec context!!!!!!!!!! video packet queue size: %d", d.packets.size());
qDebug("Invalid packet! flush video codec context!!!!!!!!!! video packet queue size: %d", d.packets.size());
d.dec->flush(); //d.dec instead of dec because d.dec maybe changed in processNextTask() but dec is not
d.render_pts0 = pkt.pts;
sync_id = pkt.position;
Expand Down

0 comments on commit 17f2535

Please sign in to comment.