Proper bugfix for corrupted sound crashes under OpenAL from Henri Beauchamp (Cool VL)

Tue, 27 Dec 2011 12:34:44 +0100

author
Ansariel
date
Tue, 27 Dec 2011 12:34:44 +0100
changeset 1609
0a3680990a34
parent 1608
d95fae20e46b
child 1610
324c1cacc296

Proper bugfix for corrupted sound crashes under OpenAL from Henri Beauchamp (Cool VL)

indra/llaudio/llaudioengine.cpp file | annotate | diff | revisions
indra/llaudio/llaudioengine.h file | annotate | diff | revisions
indra/llaudio/llaudioengine_openal.cpp file | annotate | diff | revisions
     1.1 --- a/indra/llaudio/llaudioengine.cpp	Sun Dec 18 13:22:35 2011 +0100
     1.2 +++ b/indra/llaudio/llaudioengine.cpp	Tue Dec 27 12:34:44 2011 +0100
     1.3 @@ -534,7 +534,7 @@
     1.4  	{
     1.5  		if (adp->hasDecodedData())
     1.6  		{
     1.7 -			return adp->load() && adp->getBuffer();
     1.8 +			return adp->load();
     1.9  		}
    1.10  		else if (adp->hasLocalData())
    1.11  		{
    1.12 @@ -1329,7 +1329,6 @@
    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 @@ -1431,20 +1430,16 @@
    1.21  
    1.22  void LLAudioSource::update()
    1.23  {
    1.24 -	if (!mCorrupted && !getCurrentBuffer())
    1.25 +	if (!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  			// on decode later.
    1.31 -			if (getCurrentData()->load() && getCurrentData()->getBuffer())
    1.32 +			if (getCurrentData()->load())
    1.33  			{
    1.34  				play(getCurrentData()->getID());
    1.35  			}			
    1.36 -			else
    1.37 -			{
    1.38 -				mCorrupted = true;
    1.39 -			}
    1.40  		}
    1.41  	}
    1.42  }
    1.43 @@ -1567,11 +1562,6 @@
    1.44  	const F32 MAX_UNPLAYED_AGE = 15.f;
    1.45  	const F32 MAX_MUTED_AGE = 11.f;
    1.46  
    1.47 -	if (mCorrupted)
    1.48 -	{
    1.49 -		return true;
    1.50 -	}
    1.51 -
    1.52  	if (isLoop())
    1.53  	{
    1.54  		// Looped sources never die on their own.
    1.55 @@ -1884,10 +1874,6 @@
    1.56  }
    1.57  
    1.58  
    1.59 -// Returns false only when the audio file is corrupted.
    1.60 -// You must test for the existence of the buffer (data->getBuffer())
    1.61 -// after calling load() to ensure that the data was actually loaded
    1.62 -// and is ready to be played.
    1.63  bool LLAudioData::load()
    1.64  {
    1.65  	// For now, just assume we're going to use one buffer per audiodata.
    1.66 @@ -1903,7 +1889,7 @@
    1.67  	{
    1.68  		// No free buffers, abort.
    1.69  		llinfos << "Not able to allocate a new audio buffer, aborting." << llendl;
    1.70 -		return true;	// This is why you must test for mBufferp != NULL...
    1.71 +		return false;
    1.72  	}
    1.73  
    1.74  	std::string uuid_str;
     2.1 --- a/indra/llaudio/llaudioengine.h	Sun Dec 18 13:22:35 2011 +0100
     2.2 +++ b/indra/llaudio/llaudioengine.h	Tue Dec 27 12:34:44 2011 +0100
     2.3 @@ -343,7 +343,6 @@
     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;
     3.1 --- a/indra/llaudio/llaudioengine_openal.cpp	Sun Dec 18 13:22:35 2011 +0100
     3.2 +++ b/indra/llaudio/llaudioengine_openal.cpp	Tue Dec 27 12:34:44 2011 +0100
     3.3 @@ -341,6 +341,12 @@
     3.4  
     3.5  bool LLAudioBufferOpenAL::loadWAV(const std::string& filename)
     3.6  {
     3.7 +	if (filename.empty())
     3.8 +	{
     3.9 +		// invalid filename, abort.
    3.10 +		return false;
    3.11 +	}
    3.12 +
    3.13  	cleanup();
    3.14  	mALBuffer = alutCreateBufferFromFile(filename.c_str());
    3.15  	if(mALBuffer == AL_NONE)
    3.16 @@ -352,6 +358,12 @@
    3.17  				"LLAudioBufferOpenAL::loadWAV() Error loading "
    3.18  				<< filename
    3.19  				<< " " << alutGetErrorString(error) << llendl;
    3.20 +			//
    3.21 +			// If we EVER want to load wav files provided by end users, we need
    3.22 +			// to rethink this!
    3.23 +			//
    3.24 +			// file is probably corrupt - remove it.
    3.25 +			LLFile::remove(filename);
    3.26  		}
    3.27  		else
    3.28  		{

mercurial