Skip to content

Commit

Permalink
do not notify EndOfMedia if stopped by user wang-bin#833
Browse files Browse the repository at this point in the history
  • Loading branch information
wang-bin committed Mar 5, 2017
1 parent cc56523 commit a56dd03
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 18 deletions.
18 changes: 9 additions & 9 deletions src/AVDemuxThread.cpp
Original file line number Diff line number Diff line change
@@ -1,6 1,6 @@
/******************************************************************************
QtAV: Multimedia framework based on Qt and FFmpeg
Copyright (C) 2012-2016 Wang Bin <[email protected]>
Copyright (C) 2012-2017 Wang Bin <[email protected]>
* This file is part of QtAV
Expand Down Expand Up @@ -513,11 513,6 @@ bool AVDemuxThread::waitForStarted(int msec)
return true;
}

void AVDemuxThread::eofDecoded()
{
Q_EMIT mediaStatusChanged(QtAV::EndOfMedia);
}

void AVDemuxThread::run()
{
m_buffering = false;
Expand Down Expand Up @@ -546,7 541,6 @@ void AVDemuxThread::run()
vqueue->setBlocking(true);
}
connect(thread, SIGNAL(seekFinished(qint64)), this, SIGNAL(seekFinished(qint64)), Qt::DirectConnection);
connect(thread, SIGNAL(eofDecoded()), this, SLOT(eofDecoded()));
seek_tasks.clear();
int was_end = 0;
if (ademuxer) {
Expand Down Expand Up @@ -585,7 579,6 @@ void AVDemuxThread::run()
if (m_buffering) {
m_buffering = false;
Q_EMIT mediaStatusChanged(QtAV::BufferedMedia);
Q_EMIT mediaStatusChanged(QtAV::EndOfMedia);
}
was_end = qMin(was_end 1, kMaxEof);
bool exit_thread = !user_paused;
Expand All @@ -607,6 600,10 @@ void AVDemuxThread::run()
msleep(100);
continue;
}
if (demuxer->mediaStatus() == StalledMedia) {
qDebug("stalled media. exiting demuxing thread");
break;
}
was_end = 0;
if (tryPause()) {
continue; //the queue is empty and will block
Expand Down Expand Up @@ -717,9 714,12 @@ void AVDemuxThread::run()
video_thread->pause(false);
video_thread->wait(500);
}
thread->disconnect(this, SIGNAL(eofDecoded()));
thread->disconnect(this, SIGNAL(seekFinished(qint64)));
qDebug("Demux thread stops running....");
if (demuxer->atEnd())
Q_EMIT mediaStatusChanged(QtAV::EndOfMedia);
else
Q_EMIT mediaStatusChanged(QtAV::StalledMedia);
}

bool AVDemuxThread::tryPause(unsigned long timeout)
Expand Down
3 changes: 1 addition & 2 deletions src/AVDemuxThread.h
Original file line number Diff line number Diff line change
@@ -1,6 1,6 @@
/******************************************************************************
QtAV: Multimedia framework based on Qt and FFmpeg
Copyright (C) 2012-2016 Wang Bin <[email protected]>
Copyright (C) 2012-2017 Wang Bin <[email protected]>
* This file is part of QtAV
Expand Down Expand Up @@ -71,7 71,6 @@ private slots:
void frameDeliveredOnStepForward();
void eofDecodedOnStepForward();
void onAVThreadQuit();
void eofDecoded();

protected:
virtual void run();
Expand Down
16 changes: 9 additions & 7 deletions src/AVDemuxer.cpp
Original file line number Diff line number Diff line change
@@ -1,6 1,6 @@
/******************************************************************************
QtAV: Multimedia framework based on Qt and FFmpeg
Copyright (C) 2012-2016 Wang Bin <[email protected]>
Copyright (C) 2012-2017 Wang Bin <[email protected]>
* This file is part of QtAV
Expand Down Expand Up @@ -435,18 435,20 @@ bool AVDemuxer::readFrame()
if (ret == AVERROR_EOF
|| avio_feof(d->format_ctx->pb)) {
if (!d->eof) {
if (getInterruptStatus()) { //eof error if interrupted!
if (getInterruptStatus()) {
AVError::ErrorCode ec(AVError::ReadError);
QString msg(tr("error reading stream data"));
handleError(ret, &ec, msg);
}
d->eof = true;
if (mediaStatus() != StalledMedia) {
d->eof = true;
#if 0 // EndOfMedia when demux thread finished
d->started = false;
setMediaStatus(EndOfMedia);
Q_EMIT finished();
d->started = false;
setMediaStatus(EndOfMedia);
Q_EMIT finished();
#endif
qDebug("End of file. erreof=%d feof=%d", ret == AVERROR_EOF, avio_feof(d->format_ctx->pb));
qDebug("End of file. erreof=%d feof=%d", ret == AVERROR_EOF, avio_feof(d->format_ctx->pb));
}
}
return false;
}
Expand Down

0 comments on commit a56dd03

Please sign in to comment.