(bcb06cc5c) Unstable v0.9.9.0

This commit is contained in:
Juan Pablo Arce
2020-03-27 15:22:59 -03:00
parent c81486a993
commit b143329701
326 changed files with 9692 additions and 4364 deletions
@@ -97,6 +97,32 @@ namespace Barotrauma.Sounds
if (position != null)
{
if (float.IsNaN(position.Value.X))
{
throw new Exception("Failed to set source's position: " + debugName + ", position.X is NaN");
}
if (float.IsNaN(position.Value.Y))
{
throw new Exception("Failed to set source's position: " + debugName + ", position.Y is NaN");
}
if (float.IsNaN(position.Value.Z))
{
throw new Exception("Failed to set source's position: " + debugName + ", position.Z is NaN");
}
if (float.IsInfinity(position.Value.X))
{
throw new Exception("Failed to set source's position: " + debugName + ", position.X is Infinity");
}
if (float.IsInfinity(position.Value.Y))
{
throw new Exception("Failed to set source's position: " + debugName + ", position.Y is Infinity");
}
if (float.IsInfinity(position.Value.Z))
{
throw new Exception("Failed to set source's position: " + debugName + ", position.Z is Infinity");
}
uint alSource = Sound.Owner.GetSourceFromIndex(Sound.SourcePoolIndex, ALSourceIndex);
Al.Sourcei(alSource, Al.SourceRelative, Al.False);
int alError = Al.GetError();
@@ -378,12 +404,12 @@ namespace Barotrauma.Sounds
uint alSource = Sound.Owner.GetSourceFromIndex(Sound.SourcePoolIndex, ALSourceIndex);
if (!Al.IsSource(alSource)) return false;
Al.GetSourcei(alSource, Al.SourceState, out state);
bool playing = state == Al.Playing;
int alError = Al.GetError();
if (alError != Al.NoError)
{
throw new Exception("Failed to determine playing state from source: " + debugName + ", " + Al.GetErrorString(alError));
}
bool playing = state == Al.Playing;
return playing;
}
}
@@ -615,7 +641,7 @@ namespace Barotrauma.Sounds
uint alSource = Sound.Owner.GetSourceFromIndex(Sound.SourcePoolIndex, ALSourceIndex);
int state;
Al.GetSourcei(Sound.Owner.GetSourceFromIndex(Sound.SourcePoolIndex, ALSourceIndex), Al.SourceState, out state);
Al.GetSourcei(alSource, Al.SourceState, out state);
bool playing = state == Al.Playing;
int alError = Al.GetError();
if (alError != Al.NoError)
@@ -630,7 +656,7 @@ namespace Barotrauma.Sounds
{
throw new Exception("Failed to determine processed buffers from streamed source: " + debugName + ", " + Al.GetErrorString(alError));
}
Al.SourceUnqueueBuffers(alSource, unqueuedBufferCount, unqueuedBuffers);
alError = Al.GetError();
if (alError != Al.NoError)
@@ -727,9 +753,20 @@ namespace Barotrauma.Sounds
streamAmplitude = streamBufferAmplitudes[queueStartIndex];
Al.GetSourcei(alSource, Al.SourceState, out state);
alError = Al.GetError();
if (alError != Al.NoError)
{
throw new Exception("Failed to retrieve stream source state: " + debugName + ", " + Al.GetErrorString(alError));
}
if (state != Al.Playing)
{
Al.SourcePlay(alSource);
alError = Al.GetError();
if (alError != Al.NoError)
{
throw new Exception("Failed to start stream playback: " + debugName + ", " + Al.GetErrorString(alError));
}
}
}
@@ -738,6 +775,10 @@ namespace Barotrauma.Sounds
streamAmplitude = 0.0f;
}
}
catch (Exception e)
{
DebugConsole.ThrowError($"An exception was thrown when updating a sound stream ({debugName})", e);
}
finally
{
Monitor.Exit(mutex);