Skip to content

Commit

Permalink
workaround: emit positionChanged after stepForward
Browse files Browse the repository at this point in the history
  • Loading branch information
wang-bin committed Feb 3, 2016
1 parent f672d2d commit d08961b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
11 changes: 2 additions & 9 deletions src/AVDemuxThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,10 187,6 @@ void AVDemuxThread::stepBackward()
};

pause(true);
// set clock first
if (clock_type < 0)
clock_type = (int)video_thread->clock()->isClockAuto() 2*(int)video_thread->clock()->clockType();
video_thread->clock()->setClockType(AVClock::VideoClock);
t->packetQueue()->clear(); // will put new packets before task run
t->packetQueue();
Packet pkt;
Expand Down Expand Up @@ -431,11 427,6 @@ void AVDemuxThread::seekOnPauseFinished()
if (audio_thread)
audio_thread->pause(true);
}
if (clock_type >= 0) {
thread->clock()->setClockAuto(clock_type & 1);
thread->clock()->setClockType(AVClock::ClockType(clock_type/2));
clock_type = -1;
}
}

void AVDemuxThread::frameDeliveredOnStepForward()
Expand All @@ -460,6 451,7 @@ void AVDemuxThread::frameDeliveredOnStepForward()
thread->clock()->setClockType(AVClock::ClockType(clock_type/2));
clock_type = -1;
}
Q_EMIT stepFinished();
}

void AVDemuxThread::eofDecodedOnStepForward()
Expand All @@ -477,6 469,7 @@ void AVDemuxThread::eofDecodedOnStepForward()
thread->clock()->setClockType(AVClock::ClockType(clock_type/2));
clock_type = -1;
}
Q_EMIT stepFinished();
}

void AVDemuxThread::onAVThreadQuit()
Expand Down
1 change: 1 addition & 0 deletions src/AVDemuxThread.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 63,7 @@ class AVDemuxThread : public QThread
void mediaStatusChanged(QtAV::MediaStatus);
void bufferProgressChanged(qreal);
void seekFinished(qint64 timestamp);
void stepFinished();
void internalSubtitlePacketRead(int index, const QtAV::Packet& packet);
private slots:
void seekOnPauseFinished();
Expand Down
8 changes: 6 additions & 2 deletions src/AVPlayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -931,6 931,7 @@ qreal AVPlayer::positionF() const

qint64 AVPlayer::position() const
{
// TODO: videoTime()?
const qint64 pts = d->clock->value()*1000.0;
if (relativeTimeMode())
return pts - absoluteMediaStartPosition();
Expand Down Expand Up @@ -1443,7 1444,10 @@ void AVPlayer::onSeekFinished(qint64 value)
d->seeking = false;
Q_EMIT seekFinished(value);
//d->clock->updateValue(value/1000.0);
Q_EMIT positionChanged(value);
if (relativeTimeMode())
Q_EMIT positionChanged(value - absoluteMediaStartPosition());
else
Q_EMIT positionChanged(value);
}

void AVPlayer::tryClearVideoRenderers()
Expand Down Expand Up @@ -1513,7 1517,7 @@ void AVPlayer::timerEvent(QTimerEvent *te)
if (te->timerId() == d->timer_id) {
// killTimer() should be in the same thread as object. kill here?
if (isPaused()) {
return;
//return; //ensure positionChanged emitted for stepForward()
}
// active only when playing
const qint64 t = position();
Expand Down

0 comments on commit d08961b

Please sign in to comment.