Skip to content

Commit

Permalink
check AVFormatContext before read. exit extract thread before close
Browse files Browse the repository at this point in the history
  • Loading branch information
wang-bin committed Oct 28, 2014
1 parent 1ec7737 commit 6692def
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/AVDemuxer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 207,9 @@ MediaStatus AVDemuxer::mediaStatus() const

bool AVDemuxer::readFrame()
{
if (!format_context)
return false;

QMutexLocker lock(&mutex);
Q_UNUSED(lock);
AVPacket packet;
Expand Down
7 changes: 7 additions & 0 deletions src/VideoFrameExtractor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 26,11 @@ class ExtractThread : public QThread {
tasks.setCapacity(1); // avoid too frequent
}
~ExtractThread() {
waitStop();
}
void waitStop() {
if (!isRunning())
return;
scheduleStop();
wait();
}
Expand Down Expand Up @@ -99,6 104,8 @@ class VideoFrameExtractorPrivate : public DPtrPrivate<VideoFrameExtractor>
<< "FFmpeg";
}
~VideoFrameExtractorPrivate() {
// stop first before demuxer close to avoid running new seek task after demuxer is closed.
thread.waitStop();
demuxer.close();
}

Expand Down

0 comments on commit 6692def

Please sign in to comment.