当前位置: 首页>>代码示例>>C++>>正文


C++ Functions::s_wait方法代码示例

本文整理汇总了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);
}
开发者ID:mitya57,项目名称:QMPlay2,代码行数:101,代码来源:VideoThr.cpp


注:本文中的Functions::s_wait方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。