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


C++ Memory::GetSize方法代码示例

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


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

示例1: Update

bool StreamedInstance::Update()
{
	if (mState != State::Playing) return false;

	int queued;
	alGetSourcei(mSource, AL_BUFFERS_QUEUED, &queued);
	ASSERT(alGetError() == 0, "AL error occured");

	if (queued)
	{
		int processed;
		alGetSourcei(mSource, AL_BUFFERS_PROCESSED, &processed);
		ASSERT(alGetError() == 0, "AL error occured");

		while (processed--)
		{
			uint processedBuffer;
			alSourceUnqueueBuffers(mSource, 1, &processedBuffer);
			ASSERT(alGetError() == 0, "AL error occured");

			if (((StreamedSound*)mSound)->GetAudioData()->IsEOF() && mRepeat)
			{
				((StreamedSound*)mSound)->GetAudioData()->Reset();
			}

			if (!((StreamedSound*)mSound)->GetAudioData()->IsEOF())
			{
				Memory dataOut;
				ALenum format = (((StreamedSound*)mSound)->GetAudioData()->GetChannels() == 1) ? AL_FORMAT_MONO16 : AL_FORMAT_STEREO16;	

				((StreamedSound*)mSound)->GetAudioData()->Decode(dataOut);

				alBufferData(processedBuffer, format, dataOut.GetBuffer(), dataOut.GetSize(), ((StreamedSound*)mSound)->GetAudioData()->GetRate());
				ASSERT(alGetError() == 0, "AL error occured");

				alSourceQueueBuffers(mSource, 1, &processedBuffer);
				ASSERT(alGetError() == 0, "AL error occured");
			}
		}

		int streamState;
		alGetSourcei(mSource, AL_SOURCE_STATE, &streamState);

		if (streamState == AL_STOPPED)
		{
			alSourcePlay(mSource);
		}

		return true;
	}
	else
	{
		// Load the buffers with initial data in case the sound is to be played again.
		Init();
		mState = State::Stopped;
		mActiveInstancesEntry = NULL;
		return false;
	}
}
开发者ID:saggita,项目名称:r5ge,代码行数:59,代码来源:StreamedInstance.cpp

示例2: Init

void StreamedInstance::Init()
{
	Memory dataOut;
	ALenum format = (((StreamedSound*)mSound)->GetAudioData()->GetChannels() == 1) ? AL_FORMAT_MONO16 : AL_FORMAT_STEREO16;	

	alSourcei(mSource, AL_BUFFER, 0);
	ASSERT(alGetError() == 0, "AL error occured");

	((StreamedSound*)mSound)->GetAudioData()->Reset();
	((StreamedSound*)mSound)->GetAudioData()->Decode(dataOut);

	alBufferData(mBuffers[0], format, dataOut.GetBuffer(), dataOut.GetSize(), ((StreamedSound*)mSound)->GetAudioData()->GetRate());
	ASSERT(alGetError() == 0, "AL error occured");

	((StreamedSound*)mSound)->GetAudioData()->Decode(dataOut);

	alBufferData(mBuffers[1], format, dataOut.GetBuffer(), dataOut.GetSize(), ((StreamedSound*)mSound)->GetAudioData()->GetRate());
	ASSERT(alGetError() == 0, "AL error occured");

	alSourceQueueBuffers(mSource, 2, mBuffers);
	ASSERT(alGetError() == 0, "AL error occured");
}
开发者ID:saggita,项目名称:r5ge,代码行数:22,代码来源:StreamedInstance.cpp


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