Backported fix for a crash bug that could occur should a cached decoded sound file get corrupted or unreadable. Via Henri Beauchamp (Cool VL)

Sun, 18 Dec 2011 13:14:30 +0100

author
Ansariel
date
Sun, 18 Dec 2011 13:14:30 +0100
changeset 1606
3c98a3ae1707
parent 1605
9e24dabbfa7c
child 1607
bf6ce4770b56

Backported fix for a crash bug that could occur should a cached decoded sound file get corrupted or unreadable. Via Henri Beauchamp (Cool VL)

indra/llaudio/llaudioengine.cpp file | annotate | diff | revisions
indra/llaudio/llaudioengine.h file | annotate | diff | revisions
     1.1 --- a/indra/llaudio/llaudioengine.cpp	Sun Dec 18 13:13:42 2011 +0100
     1.2 +++ b/indra/llaudio/llaudioengine.cpp	Sun Dec 18 13:14:30 2011 +0100
     1.3 @@ -534,7 +534,7 @@
     1.4  	{
     1.5  		if (adp->hasDecodedData())
     1.6  		{
     1.7 -			adp->load();
     1.8 +			return adp->load() && adp->getBuffer();
     1.9  		}
    1.10  		else if (adp->hasLocalData())
    1.11  		{
    1.12 @@ -1329,6 +1329,7 @@
    1.13  	mSyncSlave(false),
    1.14  	mQueueSounds(false),
    1.15  	mPlayedOnce(false),
    1.16 +	mCorrupted(false),
    1.17  	mType(type),
    1.18  	// <edit>
    1.19  	mSourceID(source_id),
    1.20 @@ -1430,16 +1431,20 @@
    1.21  
    1.22  void LLAudioSource::update()
    1.23  {
    1.24 -	if (!getCurrentBuffer())
    1.25 +	if (!mCorrupted && !getCurrentBuffer())
    1.26  	{
    1.27  		if (getCurrentData())
    1.28  		{
    1.29 -			// Hack - try and load the sound.  Will do this as a callback
    1.30 +			// Hack - try and load the sound. Will do this as a callback
    1.31  			// on decode later.
    1.32 -			if (getCurrentData()->load())
    1.33 +			if (getCurrentData()->load() && getCurrentData()->getBuffer())
    1.34  			{
    1.35  				play(getCurrentData()->getID());
    1.36  			}			
    1.37 +			else
    1.38 +			{
    1.39 +				mCorrupted = true;
    1.40 +			}
    1.41  		}
    1.42  	}
    1.43  }
    1.44 @@ -1562,6 +1567,11 @@
    1.45  	const F32 MAX_UNPLAYED_AGE = 15.f;
    1.46  	const F32 MAX_MUTED_AGE = 11.f;
    1.47  
    1.48 +	if (mCorrupted)
    1.49 +	{
    1.50 +		return true;
    1.51 +	}
    1.52 +
    1.53  	if (isLoop())
    1.54  	{
    1.55  		// Looped sources never die on their own.
    1.56 @@ -1874,6 +1884,10 @@
    1.57  }
    1.58  
    1.59  
    1.60 +// Returns false only when the audio file is corrupted.
    1.61 +// You must test for the existence of the buffer (data->getBuffer())
    1.62 +// after calling load() to ensure that the data was actually loaded
    1.63 +// and is ready to be played.
    1.64  bool LLAudioData::load()
    1.65  {
    1.66  	// For now, just assume we're going to use one buffer per audiodata.
    1.67 @@ -1889,7 +1903,7 @@
    1.68  	{
    1.69  		// No free buffers, abort.
    1.70  		llinfos << "Not able to allocate a new audio buffer, aborting." << llendl;
    1.71 -		return false;
    1.72 +		return true;	// This is why you must test for mBufferp != NULL...
    1.73  	}
    1.74  
    1.75  	std::string uuid_str;
     2.1 --- a/indra/llaudio/llaudioengine.h	Sun Dec 18 13:13:42 2011 +0100
     2.2 +++ b/indra/llaudio/llaudioengine.h	Sun Dec 18 13:14:30 2011 +0100
     2.3 @@ -343,6 +343,7 @@
     2.4  	bool			mSyncSlave;
     2.5  	bool			mQueueSounds;
     2.6  	bool			mPlayedOnce;
     2.7 +	bool			mCorrupted;
     2.8  	S32             mType;
     2.9  	LLVector3d		mPositionGlobal;
    2.10  	LLVector3		mVelocity;

mercurial