Build 0.20.7.0

This commit is contained in:
Markus Isberg
2022-11-18 18:13:38 +02:00
parent 8c8fd865c5
commit ecb6d40b4b
111 changed files with 1346 additions and 701 deletions
@@ -1,9 +1,7 @@
using System;
using Microsoft.Xna.Framework;
using OpenAL;
using Microsoft.Xna.Framework;
using System.Collections.Generic;
using System;
using System.Threading;
using System.Diagnostics;
namespace Barotrauma.Sounds
{
@@ -17,7 +15,7 @@ namespace Barotrauma.Sounds
public SoundSourcePool(int sourceCount = SoundManager.SOURCE_COUNT)
{
int alError = Al.NoError;
int alError;
ALSources = new uint[sourceCount];
for (int i = 0; i < sourceCount; i++)
@@ -83,7 +81,7 @@ namespace Barotrauma.Sounds
class SoundChannel : IDisposable
{
private const int STREAM_BUFFER_SIZE = 8820;
private short[] streamShortBuffer;
private readonly short[] streamShortBuffer;
private string debugName = "SoundChannel";
@@ -312,12 +310,12 @@ namespace Barotrauma.Sounds
if (ALSourceIndex < 0) { return; }
if (!IsPlaying) return;
if (!IsPlaying) { return; }
if (!IsStream)
{
uint alSource = Sound.Owner.GetSourceFromIndex(Sound.SourcePoolIndex, ALSourceIndex);
int playbackPos; Al.GetSourcei(alSource, Al.SampleOffset, out playbackPos);
Al.GetSourcei(alSource, Al.SampleOffset, out int playbackPos);
int alError = Al.GetError();
if (alError != Al.NoError)
{
@@ -379,7 +377,7 @@ namespace Barotrauma.Sounds
if (!IsStream)
{
int playbackPos; Al.GetSourcei(alSource, Al.SampleOffset, out playbackPos);
Al.GetSourcei(alSource, Al.SampleOffset, out int playbackPos);
int alError = Al.GetError();
if (alError != Al.NoError)
{
@@ -390,7 +388,7 @@ namespace Barotrauma.Sounds
}
else
{
float retVal = -1.0f;
float retVal;
Monitor.Enter(mutex);
retVal = streamAmplitude;
Monitor.Exit(mutex);
@@ -432,8 +430,8 @@ namespace Barotrauma.Sounds
private bool reachedEndSample;
private int queueStartIndex;
private readonly uint[] streamBuffers;
private uint[] unqueuedBuffers;
private float[] streamBufferAmplitudes;
private readonly uint[] unqueuedBuffers;
private readonly float[] streamBufferAmplitudes;
public int StreamSeekPos
{
@@ -448,18 +446,17 @@ namespace Barotrauma.Sounds
}
}
private object mutex;
private readonly object mutex;
public bool IsPlaying
{
get
{
if (ALSourceIndex < 0) return false;
if (IsStream && !reachedEndSample) return true;
int state;
if (ALSourceIndex < 0) { return false; }
if (IsStream && !reachedEndSample) { return true; }
uint alSource = Sound.Owner.GetSourceFromIndex(Sound.SourcePoolIndex, ALSourceIndex);
if (!Al.IsSource(alSource)) return false;
Al.GetSourcei(alSource, Al.SourceState, out state);
if (!Al.IsSource(alSource)) { return false; }
Al.GetSourcei(alSource, Al.SourceState, out int state);
int alError = Al.GetError();
if (alError != Al.NoError)
{
@@ -710,8 +707,7 @@ namespace Barotrauma.Sounds
{
uint alSource = Sound.Owner.GetSourceFromIndex(Sound.SourcePoolIndex, ALSourceIndex);
int state;
Al.GetSourcei(alSource, Al.SourceState, out state);
Al.GetSourcei(alSource, Al.SourceState, out int state);
bool playing = state == Al.Playing;
int alError = Al.GetError();
if (alError != Al.NoError)
@@ -719,8 +715,7 @@ namespace Barotrauma.Sounds
throw new Exception("Failed to determine playing state from streamed source: " + debugName + ", " + Al.GetErrorString(alError));
}
int unqueuedBufferCount;
Al.GetSourcei(alSource, Al.BuffersProcessed, out unqueuedBufferCount);
Al.GetSourcei(alSource, Al.BuffersProcessed, out int unqueuedBufferCount);
alError = Al.GetError();
if (alError != Al.NoError)
{