(f0d812055) v0.9.9.0
This commit is contained in:
@@ -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();
|
||||
@@ -179,7 +205,7 @@ namespace Barotrauma.Sounds
|
||||
get { return gain; }
|
||||
set
|
||||
{
|
||||
gain = Math.Max(Math.Min(value, 1.0f), 0.0f);
|
||||
gain = Math.Clamp(value, 0.0f, 1.0f);
|
||||
|
||||
if (ALSourceIndex < 0) { return; }
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user