Exemplo n.º 1
0
bool LLAudioSource::isDone() const
{
	static const F32 MAX_AGE = 60.f;
	static const F32 MAX_UNPLAYED_AGE = 15.f;
	static const F32 MAX_MUTED_AGE = 11.f;
	if(mCorrupted)
	{
		// If we decode bad data then just kill this source entirely.
		return true;
	}
	else if (isLoop())
	{
		// Looped sources never die on their own.
		return false;
	}
	else if (hasPendingPreloads())
	{
		// If there are pending preload requests then keep it alive.
		return false;
	}
	else if (mQueuedDatap)
	{
		// Don't kill this sound if we've got something queued up to play.
		return false;
	}
	else if(mPlayedOnce && (!mChannelp || !mChannelp->isPlaying()))
	{
		// This is a single-play source and it already did its thing.
		return true;
	}

	F32 elapsed = mAgeTimer.getElapsedTimeF32();

	if (!mChannelp)
	{
		LLAudioData* adp = mCurrentDatap;

		//Still decoding.
		if(adp && adp->isInPreload())
			return false;

		// We don't have a channel assigned, and it's been
		// over 15 seconds since we tried to play it.  Don't bother.
		return (elapsed > (mSourceMuted ? MAX_MUTED_AGE : MAX_UNPLAYED_AGE));
	}
	else if (mChannelp->isPlaying())
	{
		// Arbitarily cut off non-looped sounds when they're old.
		return elapsed > MAX_AGE;
	}
	else if(!isSyncSlave())
	{
		// The sound isn't playing back after 15 seconds, kill it.
		// This might happen if all channels are in use and this source is low-priority
		return elapsed > MAX_UNPLAYED_AGE;
	}

	return false;
}
Exemplo n.º 2
0
bool LLAudioSource::play(const LLUUID &audio_uuid)
{
	// Special abuse of play(); don't play a sound, but kill it.
	if (audio_uuid.isNull())
	{
		if (getChannel())
		{
			getChannel()->setSource(NULL);
			setChannel(NULL);
			if (!isMuted())
			{
				mCurrentDatap = NULL;
			}
		}
		return false;
	}

	// Reset our age timeout if someone attempts to play the source.
	mAgeTimer.reset();

	if (!gAudiop)
	{
		LL_WARNS("AudioEngine") << "LLAudioEngine instance doesn't exist!" << LL_ENDL;
		return false;
	}

	LLAudioData *adp = gAudiop->getAudioData(audio_uuid);
	addAudioData(adp);

	if (isMuted())
	{
		return false;
	}

	bool has_buffer = gAudiop->updateBufferForData(adp, audio_uuid);
	if (!has_buffer)
	{
		// Don't bother trying to set up a channel or anything, we don't have an audio buffer.
		return false;
	}

	if (!setupChannel())
	{
		return false;
	}

	if (isSyncSlave())
	{
		// A sync slave, it doesn't start playing until it's synced up with the master.
		// Flag this channel as waiting for sync, and return true.
		getChannel()->setWaiting(true);
		return true;
	}

	getChannel()->play();
	return true;
}
bool LLAudioSource::play(const LLUUID &audio_uuid)
{
	// Special abuse of play(); don't play a sound, but kill it.
	if (audio_uuid.isNull())
	{
		if (getChannel())
		{
			llassert(this == getChannel()->getSource());
			getChannel()->setSource(NULL);
			if (!isMuted())
			{
				mCurrentDatap = NULL;
			}
		}
		return false;
	}

	// <edit>
	if(mType != LLAudioEngine::AUDIO_TYPE_UI) //&& mSourceID.notNull())
		logSoundPlay(this, audio_uuid);
	// </edit>

	// Reset our age timeout if someone attempts to play the source.
	mAgeTimer.reset();

	LLAudioData *adp = gAudiop->getAudioData(audio_uuid);
	addAudioData(adp);

	if (isMuted())
	{
		return false;
	}

	bool has_buffer = gAudiop->updateBufferForData(adp, audio_uuid);
	if (!has_buffer)
	{
		// Don't bother trying to set up a channel or anything, we don't have an audio buffer.
		return false;
	}

	if (!setupChannel())
	{
		return false;
	}

	if (isSyncSlave())
	{
		// A sync slave, it doesn't start playing until it's synced up with the master.
		// Flag this channel as waiting for sync, and return true.
		getChannel()->setWaiting(true);
		return true;
	}

	getChannel()->play();
	return true;
}
Exemplo n.º 4
0
BOOL LLAudioSource::play(const LLUUID &audio_uuid)
{
	if (audio_uuid.isNull())
	{
		if (getChannel())
		{
			getChannel()->setSource(NULL);
			setChannel(NULL);
			addAudioData(NULL, TRUE);
		}
	}
	// Reset our age timeout if someone attempts to play the source.
	mAgeTimer.reset();

	LLAudioData *adp = gAudiop->getAudioData(audio_uuid);

	BOOL has_buffer = gAudiop->updateBufferForData(adp, audio_uuid);


	addAudioData(adp);

	if (!has_buffer)
	{
		// Don't bother trying to set up a channel or anything, we don't have an audio buffer.
		return FALSE;
	}

	if (!setupChannel())
	{
		return FALSE;
	}

	if (isSyncSlave())
	{
		// A sync slave, it doesn't start playing until it's synced up with the master.
		// Flag this channel as waiting for sync, and return true.
		getChannel()->setWaiting(TRUE);
		return TRUE;
	}

	getChannel()->play();
	return TRUE;
}
Exemplo n.º 5
0
bool LLAudioSource::play(const LLUUID &audio_uuid)
{
	// NaCl - Sound Explorer
	if(mType != LLAudioEngine::AUDIO_TYPE_UI) //&& mSourceID.notNull())
	{
		logSoundPlay(mLogID, this, mPositionGlobal, mType, audio_uuid, mOwnerID, mSourceID, mIsTrigger, mLoop);
	}
	// NaCl End
	// Special abuse of play(); don't play a sound, but kill it.
	if (audio_uuid.isNull())
	{
		if (getChannel())
		{
			// NaCl - Sound Explorer
			if(getChannel()->getSource())
			// NaCl End
			getChannel()->setSource(NULL);
			setChannel(NULL);
			if (!isMuted())
			{
				mCurrentDatap = NULL;
			}
		}
		return false;
	}

	// Reset our age timeout if someone attempts to play the source.
	mAgeTimer.reset();

	if (!gAudiop)
	{
		LL_WARNS("AudioEngine") << "LLAudioEngine instance doesn't exist!" << LL_ENDL;
		return false;
	}

	LLAudioData *adp = gAudiop->getAudioData(audio_uuid);
	if( !adp )
		return false;
	addAudioData(adp);

	if (isMuted())
	{
		return false;
	}

	bool has_buffer = gAudiop->updateBufferForData(adp, audio_uuid);
	if (!has_buffer)
	{
		// Don't bother trying to set up a channel or anything, we don't have an audio buffer.
		return false;
	}

	if (!setupChannel())
	{
		return false;
	}

	if (isSyncSlave())
	{
		// A sync slave, it doesn't start playing until it's synced up with the master.
		// Flag this channel as waiting for sync, and return true.
		getChannel()->setWaiting(true);
		return true;
	}

	getChannel()->play();
	return true;
}