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


C++ CPUThread::ExecAsCallback方法代码示例

本文整理汇总了C++中CPUThread::ExecAsCallback方法的典型用法代码示例。如果您正苦于以下问题:C++ CPUThread::ExecAsCallback方法的具体用法?C++ CPUThread::ExecAsCallback怎么用?C++ CPUThread::ExecAsCallback使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CPUThread的用法示例。


在下文中一共展示了CPUThread::ExecAsCallback方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: cellSurMixerCreate

int cellSurMixerCreate(vm::ptr<const CellSurMixerConfig> config)
{
	libmixer->Warning("cellSurMixerCreate(config_addr=0x%x)", config.addr());

	surMixer = *config;

	AudioPortConfig& port = m_config.m_ports[SUR_PORT];

	if (port.m_is_audio_port_opened)
	{
		return CELL_LIBMIXER_ERROR_FULL;
	}

	port.channel = 8;
	port.block = 16;
	port.attr = 0;
	port.level = 1.0f;

	libmixer->Warning("*** audio port opened(default)");

	port.m_is_audio_port_opened = true;
	port.tag = 0;
	m_config.m_port_in_use++;

	libmixer->Warning("*** surMixer created (ch1=%d, ch2=%d, ch6=%d, ch8=%d)",
		(u32)surMixer.chStrips1, (u32)surMixer.chStrips2, (u32)surMixer.chStrips6, (u32)surMixer.chStrips8);

	mixcount = 0;
	surMixerCb = 0;

	thread t("Surmixer Thread", []()
	{
		AudioPortConfig& port = m_config.m_ports[SUR_PORT];

		CPUThread* mixerCb = &Emu.GetCPU().AddThread(CPU_THREAD_PPU);

		mixerCb->SetName("Surmixer Callback");

		while (port.m_is_audio_port_opened)
		{
			if (Emu.IsStopped())
			{
				libmixer->Warning("Surmixer aborted");
				break;
			}

			if (mixcount > (port.tag + 0)) // adding positive value (1-15): preemptive buffer filling (hack)
			{
				std::this_thread::sleep_for(std::chrono::milliseconds(1));
				continue;
			}

			if (port.m_is_audio_port_started)
			{
				//u64 stamp0 = get_system_time();

				memset(mixdata, 0, sizeof(mixdata));
				if (surMixerCb) mixerCb->ExecAsCallback(surMixerCb, true, surMixerCbArg, mixcount, 256);

				//u64 stamp1 = get_system_time();

				{
					std::lock_guard<std::mutex> lock(mixer_mutex);

					for (auto& p : ssp) if (p.m_active && p.m_created)
					{
						auto v = vm::lptrl<s16>::make(p.m_addr); // 16-bit LE audio data
						float left = 0.0f;
						float right = 0.0f;
						float speed = fabs(p.m_speed);
						float fpos = 0.0f;
						for (int i = 0; i < 256; i++) if (p.m_active)
						{
							u32 pos = p.m_position;
							int pos_inc = 0;
							if (p.m_speed > 0.0f) // select direction
							{
								pos_inc = 1;
							}
							else if (p.m_speed < 0.0f)
							{
								pos_inc = -1;
							}
							int shift = i - (int)fpos; // change playback speed (simple and rough)
							if (shift > 0)
							{
								// slow playback
								pos_inc = 0; // duplicate one sample at this time
								fpos += 1.0f;
								fpos += speed;
							}
							else if (shift < 0)
							{
								// fast playback
								i--; // mix two sample into one at this time
								fpos -= 1.0f;
							}
							else
							{
								fpos += speed;
//.........这里部分代码省略.........
开发者ID:hminth,项目名称:rpcs3,代码行数:101,代码来源:libmixer.cpp


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