Skip to content

Commit

Permalink
speed up seeking
Browse files Browse the repository at this point in the history
  • Loading branch information
wang-bin committed Nov 24, 2014
1 parent 31152cc commit b8121a0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
10 changes: 5 additions & 5 deletions src/AudioThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,11 @@ void AudioThread::run()
*/
qreal a_v = pkt.pts - d.clock->videoPts();

//qDebug("skip audio decode at %f/%f v=%f a-v=%f", pkt.pts, d.render_pts0, d.clock->videoPts(), a_v);
//qDebug("skip audio decode at %f/%f v=%f a-v=%fms", pkt.pts, d.render_pts0, d.clock->videoPts(), a_v*1000.0);
if (a_v > 0)
msleep(qMin((ulong)300, ulong(a_v*1000.0)));
else
msleep(2);
msleep(qMin((ulong)20, ulong(a_v*1000.0)));
//else
// msleep(1);
pkt = Packet(); //mark invalid to take next
continue;
}
Expand Down Expand Up @@ -194,7 +194,7 @@ void AudioThread::run()
if (dt > 0.618 || dt < 0) {
dt = 0;
}
//qDebug("sleep %f", dt);
//qDebug("a sleep %f", dt);
//TODO: avoid acummulative error. External clock?
msleep((unsigned long)(dt*1000.0));
pkt = Packet();
Expand Down
4 changes: 3 additions & 1 deletion src/VideoThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ void VideoThread::run()
}
}
//audio packet not cleaned up?
if (d.delay < 3 && qFuzzyIsNull(d.render_pts0)) {
if (d.delay < 1.0 && qFuzzyIsNull(d.render_pts0)) {
while (d.delay > kSyncThreshold) { //Slow down
//d.delay_cond.wait(&d.mutex, d.delay*1000); //replay may fail. why?
//qDebug("~~~~~wating for %f msecs", d.delay*1000);
Expand All @@ -245,6 +245,8 @@ void VideoThread::run()
d.delay = 0;
else
d.delay -= kSyncThreshold;
d.delay = qMax(0.0, qMin(d.delay, pts - d.clock->value()));
processNextTask();
}
if (d.delay > 0)
usleep(d.delay * 1000000UL);
Expand Down

0 comments on commit b8121a0

Please sign in to comment.