/// Stop playing
void CStreamSource::stop()
{
	CAutoMutex<CMutex> autoMutex(m_BufferMutex);
	
	// nldebug("CStreamSource %p : stop", (CAudioMixerUser::IMixerEvent*)this);
	// nlassert(_Playing);
	
	if (!_Playing)
		return;
	
	if (hasPhysicalSource())
		releasePhysicalSource();
	
	CSourceCommon::stop();

	m_FreeBuffers = 3;
	m_NextBuffer = 0;
	
	if (_Spawn)
	{
		if (_SpawnEndCb != NULL)
			_SpawnEndCb(this, _CbUserParam);
		delete this;
	}
}
Пример #2
0
/// Stop playing
void CSimpleSource::stop()
{
	// nldebug("CSimpleSource %p : stop", (CAudioMixerUser::IMixerEvent*)this);
	// nlassert(_Playing);

	if (_WaitingForPlay)
	{
		nlassert(!_Playing); // cannot already be playing if waiting for play
		CAudioMixerUser *mixer = CAudioMixerUser::instance();
		mixer->removeSourceWaitingForPlay(this);
	}

	if (!_Playing)
		return;

	if (hasPhysicalSource())
	{
		releasePhysicalSource();
	}
	else if (_PlayMuted)
	{
		CAudioMixerUser *mixer = CAudioMixerUser::instance();
		// clear the registered event because of a stop before normal end of play
		mixer->decPlayingSourceMuted();
		mixer->removeEvents(this);
	}
	
	CSourceCommon::stop();

	if (_Spawn)
	{
		if (_SpawnEndCb != NULL)
		{
			_SpawnEndCb(this, _CbUserParam);
		}

		delete this;
	}
}