本文整理汇总了C++中Functions::s_wait方法的典型用法代码示例。如果您正苦于以下问题:C++ Functions::s_wait方法的具体用法?C++ Functions::s_wait怎么用?C++ Functions::s_wait使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Functions
的用法示例。
在下文中一共展示了Functions::s_wait方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: run
//.........这里部分代码省略.........
delay /= playC.speed;
playC.frame_last_delay = delay;
playC.frame_last_pts = packet.ts;
if (playC.skipAudioFrame < 0.0)
playC.skipAudioFrame = 0.0;
const double true_delay = delay;
if (syncVtoA && playC.audio_current_pts > 0.0 && !oneFrame)
{
double sync_pts = playC.audio_current_pts;
if (sync_last_pts == sync_pts)
sync_pts += gettime() - sync_timer;
else
{
sync_last_pts = sync_pts;
sync_timer = gettime();
}
const double diff = packet.ts - (delay + sync_pts - playC.videoSync);
const double sync_threshold = qMax(delay, playC.audio_last_delay);
const double max_threshold = sync_threshold < 0.1 ? 0.125 : sync_threshold * 1.5;
const double fDiff = qAbs(diff);
if (fast && !skip && diff > -sync_threshold / 2.0)
fast = 0;
skip = false;
// qDebug() << "diff" << diff << "sync_threshold" << sync_threshold << "max_threshold" << max_threshold;
if (fDiff > sync_threshold && fDiff < max_threshold)
{
if (diff < 0.0) //obraz się spóźnia
{
delay -= sync_threshold / 10.0;
// qDebug() << "speed up" << diff << delay << sync_threshold;
}
else if (diff > 0.0) //obraz idzie za szybko
{
delay += sync_threshold / 10.0;
// qDebug() << "slow down" << diff << delay << sync_threshold;
}
}
else if (fDiff >= max_threshold)
{
if (diff < 0.0) //obraz się spóźnia
{
delay = 0.0;
if (fast > 3)
skip = true;
}
else if (diff > 0.0) //obraz idzie za szybko
{
if (diff <= 0.5)
delay *= 2.0;
else if (!playC.skipAudioFrame)
playC.skipAudioFrame = diff;
}
// qDebug() << "Skipping" << diff << skip << fast << delay;
}
}
else if (playC.audio_current_pts <= 0.0 || oneFrame)
{
skip = false;
fast = 0;
}
if (!frame.isEmpty())
{
if (frame_timer != -1.0)
{
const double delay_diff = gettime() - frame_timer;
if (syncVtoA && true_delay > 0.0 && delay_diff > true_delay)
++fast;
delay -= delay_diff;
while (delay > 0.0 && !playC.paused && !br && !br2)
{
const double sleepTime = qMin(delay, 0.1);
s_wait(sleepTime);
delay -= sleepTime;
}
}
if (!skip && canWrite)
{
oneFrame = canWrite = false;
VideoFrame::ref(frame);
emit write(frame);
}
frame_timer = gettime();
}
else if (frame_timer != -1.0)
frame_timer = gettime();
}
mutex.unlock();
}
VideoFrame::unref(frame);
}