(6eee2e437) Replaced OpenTK + replaced reference OpenAL implementation with soft_oal
This commit is contained in:
committed by
Joonas Rikkonen
parent
babc87903b
commit
9364b3839a
@@ -202,6 +202,8 @@
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Source\Screens\SubEditorScreen.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Source\Serialization\SerializableEntityEditor.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Source\Sounds\OggSound.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Source\Sounds\OpenAL\Al.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Source\Sounds\OpenAL\Alc.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Source\Sounds\Sound.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Source\Sounds\SoundChannel.cs" />
|
||||
<Compile Include="$(MSBuildThisFileDirectory)Source\Sounds\SoundFilters.cs" />
|
||||
|
||||
@@ -118,9 +118,6 @@
|
||||
<Content Include="MonoGame.Framework.dll.config">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="OpenTK.dll.config">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Shaders\solidcolor_opengl.fx" />
|
||||
<Content Include="SharpFont.dll.config">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
@@ -350,7 +347,7 @@
|
||||
<Import Project="ClientCode.projitems" Label="Shared" />
|
||||
<Import Project="..\BarotraumaShared\SharedCode.projitems" Label="Shared" />
|
||||
<Import Project="..\BarotraumaShared\SharedContent.projitems" Label="Shared" />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="..\..\Libraries\NuGet\GameAnalytics.Mono.SDK.2.1.6\build\net45\GameAnalytics.Mono.SDK.targets" Condition="Exists('..\..\Libraries\NuGet\GameAnalytics.Mono.SDK.2.1.6\build\net45\GameAnalytics.Mono.SDK.targets')" />
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
<PropertyGroup>
|
||||
@@ -368,8 +365,9 @@
|
||||
<Target Name="AfterBuild">
|
||||
<!-- Write version number to a "Version.txt" file in the output folder -->
|
||||
<GetAssemblyIdentity AssemblyFiles="$(TargetPath)">
|
||||
<Output TaskParameter="Assemblies" ItemName="CurrentAssembly" />
|
||||
<Output TaskParameter="Assemblies" ItemName="CurrentAssembly" />
|
||||
</GetAssemblyIdentity>
|
||||
<Exec Command="echo v%(CurrentAssembly.Version) > $(TargetDir)Version.txt"></Exec>
|
||||
<Exec Command="echo v%(CurrentAssembly.Version) > $(TargetDir)Version.txt">
|
||||
</Exec>
|
||||
</Target>
|
||||
</Project>
|
||||
@@ -117,9 +117,6 @@
|
||||
<Content Include="MonoGame.Framework.dll.config">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="OpenTK.dll.config">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="Shaders\solidcolor_opengl.fx" />
|
||||
<Content Include="SharpFont.dll.config">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
<configuration>
|
||||
<dllmap os="linux" dll="opengl32.dll" target="libGL.so.1"/>
|
||||
<dllmap os="linux" dll="glu32.dll" target="libGLU.so.1"/>
|
||||
<dllmap os="linux" dll="openal32.dll" target="libopenal.so.1"/>
|
||||
<dllmap os="linux" dll="alut.dll" target="libalut.so.0"/>
|
||||
<dllmap os="linux" dll="opencl.dll" target="libOpenCL.so"/>
|
||||
<dllmap os="linux" dll="libX11" target="libX11.so.6"/>
|
||||
<dllmap os="linux" dll="libXi" target="libXi.so.6"/>
|
||||
<!-- <dllmap os="linux" dll="SDL2.dll" target="libSDL2-2.0.so.0"/> -->
|
||||
<dllmap os="osx" dll="opengl32.dll" target="/System/Library/Frameworks/OpenGL.framework/OpenGL"/>
|
||||
<dllmap os="osx" dll="openal32.dll" target="/System/Library/Frameworks/OpenAL.framework/OpenAL" />
|
||||
<dllmap os="osx" dll="alut.dll" target="/System/Library/Frameworks/OpenAL.framework/OpenAL" />
|
||||
<dllmap os="osx" dll="libGLES.dll" target="/System/Library/Frameworks/OpenGLES.framework/OpenGLES" />
|
||||
<dllmap os="osx" dll="libGLESv1_CM.dll" target="/System/Library/Frameworks/OpenGLES.framework/OpenGLES" />
|
||||
<dllmap os="osx" dll="libGLESv2.dll" target="/System/Library/Frameworks/OpenGLES.framework/OpenGLES" />
|
||||
<dllmap os="osx" dll="opencl.dll" target="/System/Library/Frameworks/OpenCL.framework/OpenCL"/>
|
||||
<dllmap os="osx" dll="SDL2.dll" target="libSDL2.dylib"/>
|
||||
<!-- XQuartz compatibility (X11 on Mac) -->
|
||||
<dllmap os="osx" dll="libGL.so.1" target="/usr/X11/lib/libGL.dylib"/>
|
||||
<dllmap os="osx" dll="libX11" target="/usr/X11/lib/libX11.dylib"/>
|
||||
<dllmap os="osx" dll="libXcursor.so.1" target="/usr/X11/lib/libXcursor.dylib"/>
|
||||
<dllmap os="osx" dll="libXi" target="/usr/X11/lib/libXi.dylib"/>
|
||||
<dllmap os="osx" dll="libXinerama" target="/usr/X11/lib/libXinerama.dylib"/>
|
||||
<dllmap os="osx" dll="libXrandr.so.2" target="/usr/X11/lib/libXrandr.dylib"/>
|
||||
</configuration>
|
||||
@@ -3,7 +3,7 @@ using Barotrauma.Networking;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Microsoft.Xna.Framework.Input;
|
||||
using OpenTK.Audio.OpenAL;
|
||||
using OpenAL;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
@@ -465,7 +465,7 @@ namespace Barotrauma
|
||||
|
||||
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.05f), audioSliders.RectTransform), TextManager.Get("VoiceChat"));
|
||||
|
||||
IList<string> deviceNames = Alc.GetString((IntPtr)null, AlcGetStringList.CaptureDeviceSpecifier);
|
||||
IList<string> deviceNames = Alc.GetStringList((IntPtr)null, Alc.CaptureDeviceSpecifier);
|
||||
foreach (string name in deviceNames)
|
||||
{
|
||||
DebugConsole.NewMessage(name + " " + name.Length.ToString(), Color.Lime);
|
||||
@@ -484,10 +484,10 @@ namespace Barotrauma
|
||||
|
||||
if (string.IsNullOrWhiteSpace(VoiceCaptureDevice)) VoiceCaptureDevice = deviceNames[0];
|
||||
#if (!OSX)
|
||||
var deviceList = new GUIDropDown(new RectTransform(new Vector2(1.0f, 0.05f), audioSliders.RectTransform), TextManager.EnsureUTF8(VoiceCaptureDevice), deviceNames.Count);
|
||||
var deviceList = new GUIDropDown(new RectTransform(new Vector2(1.0f, 0.05f), audioSliders.RectTransform), VoiceCaptureDevice, deviceNames.Count);
|
||||
foreach (string name in deviceNames)
|
||||
{
|
||||
deviceList.AddItem(TextManager.EnsureUTF8(name), name);
|
||||
deviceList.AddItem(name, name);
|
||||
}
|
||||
deviceList.OnSelected = (GUIComponent selected, object obj) =>
|
||||
{
|
||||
@@ -499,7 +499,7 @@ namespace Barotrauma
|
||||
};
|
||||
#else
|
||||
var suavemente = new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.05f), audioSliders.RectTransform),
|
||||
TextManager.AddPunctuation(':', TextManager.Get("CurrentDevice"), TextManager.EnsureUTF8(VoiceCaptureDevice)))
|
||||
TextManager.AddPunctuation(':', TextManager.Get("CurrentDevice"), VoiceCaptureDevice))
|
||||
{
|
||||
ToolTip = TextManager.Get("CurrentDeviceToolTip.OSX"),
|
||||
TextAlignment = Alignment.CenterX
|
||||
@@ -514,7 +514,7 @@ namespace Barotrauma
|
||||
if (VoiceCaptureDevice == deviceNames[0]) return true;
|
||||
|
||||
VoipCapture.ChangeCaptureDevice(deviceNames[0]);
|
||||
suavemente.Text = TextManager.AddPunctuation(':', TextManager.Get("CurrentDevice"), TextManager.EnsureUTF8(VoiceCaptureDevice));
|
||||
suavemente.Text = TextManager.AddPunctuation(':', TextManager.Get("CurrentDevice"), VoiceCaptureDevice);
|
||||
suavemente.Flash(Color.Blue);
|
||||
|
||||
return true;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using Lidgren.Network;
|
||||
using Microsoft.Xna.Framework;
|
||||
using OpenTK.Audio.OpenAL;
|
||||
using OpenAL;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
@@ -69,7 +69,7 @@ namespace Barotrauma.Networking
|
||||
VoipConfig.SetupEncoding();
|
||||
|
||||
//set up capture device
|
||||
captureDevice = Alc.CaptureOpenDevice(deviceName, VoipConfig.FREQUENCY, ALFormat.Mono16, VoipConfig.BUFFER_SIZE * 5);
|
||||
captureDevice = Alc.CaptureOpenDevice(deviceName, VoipConfig.FREQUENCY, Al.FormatMono16, VoipConfig.BUFFER_SIZE * 5);
|
||||
|
||||
if (captureDevice == IntPtr.Zero)
|
||||
{
|
||||
@@ -88,20 +88,20 @@ namespace Barotrauma.Networking
|
||||
return;
|
||||
}
|
||||
|
||||
ALError alError = AL.GetError();
|
||||
AlcError alcError = Alc.GetError(captureDevice);
|
||||
if (alcError != AlcError.NoError)
|
||||
int alError = Al.GetError();
|
||||
int alcError = Alc.GetError(captureDevice);
|
||||
if (alcError != Alc.NoError)
|
||||
{
|
||||
throw new Exception("Failed to open capture device: " + alcError.ToString() + " (ALC)");
|
||||
}
|
||||
if (alError != ALError.NoError)
|
||||
if (alError != Al.NoError)
|
||||
{
|
||||
throw new Exception("Failed to open capture device: " + alError.ToString() + " (AL)");
|
||||
}
|
||||
|
||||
Alc.CaptureStart(captureDevice);
|
||||
alcError = Alc.GetError(captureDevice);
|
||||
if (alcError != AlcError.NoError)
|
||||
if (alcError != Alc.NoError)
|
||||
{
|
||||
throw new Exception("Failed to start capturing: " + alcError.ToString());
|
||||
}
|
||||
@@ -132,11 +132,11 @@ namespace Barotrauma.Networking
|
||||
short[] uncompressedBuffer = new short[VoipConfig.BUFFER_SIZE];
|
||||
while (capturing)
|
||||
{
|
||||
AlcError alcError;
|
||||
Alc.GetInteger(captureDevice, AlcGetInteger.CaptureSamples, 1, out int sampleCount);
|
||||
int alcError;
|
||||
Alc.GetInteger(captureDevice, Alc.EnumCaptureSamples, out int sampleCount);
|
||||
|
||||
alcError = Alc.GetError(captureDevice);
|
||||
if (alcError != AlcError.NoError)
|
||||
if (alcError != Alc.NoError)
|
||||
{
|
||||
throw new Exception("Failed to determine sample count: " + alcError.ToString());
|
||||
}
|
||||
@@ -160,7 +160,7 @@ namespace Barotrauma.Networking
|
||||
}
|
||||
|
||||
alcError = Alc.GetError(captureDevice);
|
||||
if (alcError != AlcError.NoError)
|
||||
if (alcError != Alc.NoError)
|
||||
{
|
||||
throw new Exception("Failed to capture samples: " + alcError.ToString());
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using System;
|
||||
using OpenTK.Audio.OpenAL;
|
||||
using OpenAL;
|
||||
using NVorbis;
|
||||
using System.Collections.Generic;
|
||||
|
||||
@@ -21,7 +21,7 @@ namespace Barotrauma.Sounds
|
||||
|
||||
reader = new VorbisReader(filename);
|
||||
|
||||
ALFormat = reader.Channels == 1 ? ALFormat.Mono16 : ALFormat.Stereo16;
|
||||
ALFormat = reader.Channels == 1 ? Al.FormatMono16 : Al.FormatStereo16;
|
||||
SampleRate = reader.SampleRate;
|
||||
|
||||
if (!stream)
|
||||
@@ -35,26 +35,26 @@ namespace Barotrauma.Sounds
|
||||
|
||||
CastBuffer(floatBuffer, shortBuffer, readSamples);
|
||||
|
||||
AL.BufferData((int)ALBuffer, ALFormat, shortBuffer,
|
||||
Al.BufferData(ALBuffer, ALFormat, shortBuffer,
|
||||
readSamples * sizeof(short), SampleRate);
|
||||
|
||||
ALError alError = AL.GetError();
|
||||
if (alError != ALError.NoError)
|
||||
int alError = Al.GetError();
|
||||
if (alError != Al.NoError)
|
||||
{
|
||||
throw new Exception("Failed to set buffer data for non-streamed audio! "+AL.GetErrorString(alError));
|
||||
throw new Exception("Failed to set buffer data for non-streamed audio! "+Al.GetErrorString(alError));
|
||||
}
|
||||
|
||||
MuffleBuffer(floatBuffer, SampleRate, reader.Channels);
|
||||
|
||||
CastBuffer(floatBuffer, shortBuffer, readSamples);
|
||||
|
||||
AL.BufferData((int)ALMuffledBuffer, ALFormat, shortBuffer,
|
||||
Al.BufferData(ALMuffledBuffer, ALFormat, shortBuffer,
|
||||
readSamples * sizeof(short), SampleRate);
|
||||
|
||||
alError = AL.GetError();
|
||||
if (alError != ALError.NoError)
|
||||
alError = Al.GetError();
|
||||
if (alError != Al.NoError)
|
||||
{
|
||||
throw new Exception("Failed to set buffer data for non-streamed audio! " + AL.GetErrorString(alError));
|
||||
throw new Exception("Failed to set buffer data for non-streamed audio! " + Al.GetErrorString(alError));
|
||||
}
|
||||
|
||||
reader.Dispose();
|
||||
@@ -98,4 +98,4 @@ namespace Barotrauma.Sounds
|
||||
base.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
467
Barotrauma/BarotraumaClient/Source/Sounds/OpenAL/Al.cs
Normal file
467
Barotrauma/BarotraumaClient/Source/Sounds/OpenAL/Al.cs
Normal file
@@ -0,0 +1,467 @@
|
||||
/***
|
||||
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2018 Nathan Glover
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
****************
|
||||
|
||||
Further modified for use in Barotrauma.
|
||||
Original source code at https://github.com/NathanielGlover/OpenAL.NETCore/
|
||||
|
||||
***/
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace OpenAL
|
||||
{
|
||||
public class Al
|
||||
{
|
||||
#if OSX
|
||||
public const string OpenAlDll = "/System/Library/Frameworks/OpenAL.framework/OpenAL";
|
||||
#elif LINUX
|
||||
public const string OpenAlDll = "libopenal.so.1";
|
||||
#elif WINDOWS
|
||||
#if X86
|
||||
public const string OpenAlDll = "soft_oal_x86.dll";
|
||||
#elif X64
|
||||
public const string OpenAlDll = "soft_oal_x64.dll";
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#region Enum
|
||||
|
||||
public const int None = 0;
|
||||
public const int False = 0;
|
||||
public const int True = 1;
|
||||
public const int SourceRelative = 0x202;
|
||||
public const int ConeInnerAngle = 0x1001;
|
||||
public const int ConeOuterAngle = 0x1002;
|
||||
public const int Pitch = 0x1003;
|
||||
public const int Position = 0x1004;
|
||||
public const int Direction = 0x1005;
|
||||
public const int Velocity = 0x1006;
|
||||
public const int Looping = 0x1007;
|
||||
public const int Buffer = 0x1009;
|
||||
public const int Gain = 0x100A;
|
||||
public const int MinGain = 0x100D;
|
||||
public const int MaxGain = 0x100E;
|
||||
public const int Orientation = 0x100F;
|
||||
public const int SourceState = 0x1010;
|
||||
public const int Initial = 0x1011;
|
||||
public const int Playing = 0x1012;
|
||||
public const int Paused = 0x1013;
|
||||
public const int Stopped = 0x1014;
|
||||
public const int BuffersQueued = 0x1015;
|
||||
public const int BuffersProcessed = 0x1016;
|
||||
public const int SecOffset = 0x1024;
|
||||
public const int SampleOffset = 0x1025;
|
||||
public const int ByteOffset = 0x1026;
|
||||
public const int SourceType = 0x1027;
|
||||
public const int Static = 0x1028;
|
||||
public const int Streaming = 0x1029;
|
||||
public const int Undetermined = 0x1030;
|
||||
public const int FormatMono8 = 0x1100;
|
||||
public const int FormatMono16 = 0x1101;
|
||||
public const int FormatStereo8 = 0x1102;
|
||||
public const int FormatStereo16 = 0x1103;
|
||||
public const int ReferenceDistance = 0x1020;
|
||||
public const int RolloffFactor = 0x1021;
|
||||
public const int ConeOuterGain = 0x1022;
|
||||
public const int MaxDistance = 0x1023;
|
||||
public const int Frequency = 0x2001;
|
||||
public const int Bits = 0x2002;
|
||||
public const int Channels = 0x2003;
|
||||
public const int Size = 0x2004;
|
||||
public const int Unused = 0x2010;
|
||||
public const int Pending = 0x2011;
|
||||
public const int Processed = 0x2012;
|
||||
public const int NoError = False;
|
||||
public const int InvalidName = 0xA001;
|
||||
public const int InvalidEnum = 0xA002;
|
||||
public const int InvalidValue = 0xA003;
|
||||
public const int InvalidOperation = 0xA004;
|
||||
public const int OutOfMemory = 0xA005;
|
||||
public const int Vendor = 0xB001;
|
||||
public const int Version = 0xB002;
|
||||
public const int Renderer = 0xB003;
|
||||
public const int Extensions = 0xB004;
|
||||
public const int EnumDopplerFactor = 0xC000;
|
||||
public const int EnumDopplerVelocity = 0xC001;
|
||||
public const int EnumSpeedOfSound = 0xC003;
|
||||
public const int EnumDistanceModel = 0xD000;
|
||||
public const int InverseDistance = 0xD001;
|
||||
public const int InverseDistanceClamped = 0xD002;
|
||||
public const int LinearDistance = 0xD003;
|
||||
public const int LinearDistanceClamped = 0xD004;
|
||||
public const int ExponentDistance = 0xD005;
|
||||
public const int ExponentDistanceClamped = 0xD006;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Functions
|
||||
|
||||
[DllImport(OpenAlDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "alEnable")]
|
||||
public static extern void Enable(int capability);
|
||||
|
||||
[DllImport(OpenAlDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "alDisable")]
|
||||
public static extern void Disable(int capability);
|
||||
|
||||
[DllImport(OpenAlDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "alIsEnabled")]
|
||||
public static extern bool IsEnabled(int capability);
|
||||
|
||||
[DllImport(OpenAlDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "alGetString")]
|
||||
private static extern IntPtr _GetString(int param);
|
||||
|
||||
public static string GetString(int param) => Marshal.PtrToStringAnsi(_GetString(param));
|
||||
|
||||
[DllImport(OpenAlDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "alGetBooleanv")]
|
||||
public static extern void GetBooleanv(int param, out bool data);
|
||||
|
||||
[DllImport(OpenAlDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "alGetIntegerv")]
|
||||
public static extern void GetIntegerv(int param, out int data);
|
||||
|
||||
[DllImport(OpenAlDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "alGetFloatv")]
|
||||
public static extern void GetFloatv(int param, out float data);
|
||||
|
||||
[DllImport(OpenAlDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "alGetDoublev")]
|
||||
public static extern void GetDoublev(int param, out double data);
|
||||
|
||||
[DllImport(OpenAlDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "alGetBoolean")]
|
||||
public static extern bool GetBoolean(int param);
|
||||
|
||||
[DllImport(OpenAlDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "alGetInteger")]
|
||||
public static extern int GetInteger(int param);
|
||||
|
||||
[DllImport(OpenAlDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "alGetFloat")]
|
||||
public static extern float GetFloat(int param);
|
||||
|
||||
[DllImport(OpenAlDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "alGetDouble")]
|
||||
public static extern double GetDouble(int param);
|
||||
|
||||
[DllImport(OpenAlDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "alGetError")]
|
||||
public static extern int GetError();
|
||||
|
||||
public static string GetErrorString(int error)
|
||||
{
|
||||
switch (error)
|
||||
{
|
||||
case NoError:
|
||||
return "No error";
|
||||
case InvalidName:
|
||||
return "Invalid name";
|
||||
case InvalidEnum:
|
||||
return "Invalid enum";
|
||||
case InvalidValue:
|
||||
return "Invalid value";
|
||||
case InvalidOperation:
|
||||
return "Invalid operation";
|
||||
case OutOfMemory:
|
||||
return "Out of memory";
|
||||
default:
|
||||
return "Unknown error";
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport(OpenAlDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "alIsExtensionPresent")]
|
||||
public static extern bool IsExtensionPresent(string extname);
|
||||
|
||||
[DllImport(OpenAlDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "alGetProcAddress")]
|
||||
public static extern IntPtr GetProcAddress(string fname);
|
||||
|
||||
[DllImport(OpenAlDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "alGetEnumValue")]
|
||||
public static extern int GetEnumValue(string ename);
|
||||
|
||||
[DllImport(OpenAlDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "alListenerf")]
|
||||
public static extern void Listenerf(int param, float value);
|
||||
|
||||
[DllImport(OpenAlDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "alListener3f")]
|
||||
public static extern void Listener3f(int param, float value1, float value2, float value3);
|
||||
|
||||
[DllImport(OpenAlDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "alListenerfv")]
|
||||
public static extern void Listenerfv(int param, float[] values);
|
||||
|
||||
[DllImport(OpenAlDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "alGetListenerf")]
|
||||
public static extern void GetListenerf(int param, out float value);
|
||||
|
||||
[DllImport(OpenAlDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "alGetListener3f")]
|
||||
public static extern void GetListener3f(int param, out float value1, out float value2, out float value3);
|
||||
|
||||
[DllImport(OpenAlDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "alGetListenerfv")]
|
||||
private static extern void _GetListenerfv(int param, IntPtr values);
|
||||
|
||||
public static void GetListenerfv(int param, out float[] values)
|
||||
{
|
||||
int len;
|
||||
switch(param)
|
||||
{
|
||||
case Gain:
|
||||
len = 1;
|
||||
break;
|
||||
case Position:
|
||||
case Velocity:
|
||||
len = 3;
|
||||
break;
|
||||
case Orientation:
|
||||
len = 6;
|
||||
break;
|
||||
default:
|
||||
len = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
values = new float[len];
|
||||
|
||||
GCHandle arrayHandle = GCHandle.Alloc(values, GCHandleType.Pinned);
|
||||
_GetListenerfv(param, arrayHandle.AddrOfPinnedObject());
|
||||
arrayHandle.Free();
|
||||
}
|
||||
|
||||
[DllImport(OpenAlDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "alGenSources")]
|
||||
private static extern void _GenSources(int n, IntPtr sources);
|
||||
|
||||
public static void GenSources(int n, out uint[] sources)
|
||||
{
|
||||
sources = new uint[n];
|
||||
|
||||
GCHandle arrayHandle = GCHandle.Alloc(sources, GCHandleType.Pinned);
|
||||
_GenSources(n, arrayHandle.AddrOfPinnedObject());
|
||||
arrayHandle.Free();
|
||||
}
|
||||
|
||||
public static void GenSource(out uint source)
|
||||
{
|
||||
GenSources(1, out var sources);
|
||||
source = sources[0];
|
||||
}
|
||||
|
||||
[DllImport(OpenAlDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "alDeleteSources")]
|
||||
public static extern void DeleteSources(int n, uint[] sources);
|
||||
|
||||
public static void DeleteSource(uint source) => DeleteSources(1, new[] {source});
|
||||
|
||||
[DllImport(OpenAlDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "alIsSource")]
|
||||
public static extern bool IsSource(uint sid);
|
||||
|
||||
[DllImport(OpenAlDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "alSourcef")]
|
||||
public static extern void Sourcef(uint sid, int param, float value);
|
||||
|
||||
[DllImport(OpenAlDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "alSource3f")]
|
||||
public static extern void Source3f(uint sid, int param, float value1, float value2, float value3);
|
||||
|
||||
[DllImport(OpenAlDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "alSourcefv")]
|
||||
public static extern void Sourcefv(uint sid, int param, float[] values);
|
||||
|
||||
[DllImport(OpenAlDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "alSourcei")]
|
||||
public static extern void Sourcei(uint sid, int param, int value);
|
||||
|
||||
[DllImport(OpenAlDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "alSource3i")]
|
||||
public static extern void Source3i(uint sid, int param, int value1, int value2, int value3);
|
||||
|
||||
[DllImport(OpenAlDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "alSourceiv")]
|
||||
public static extern void Sourceiv(uint sid, int param, int[] values);
|
||||
|
||||
[DllImport(OpenAlDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "alGetSourcef")]
|
||||
public static extern void GetSourcef(uint sid, int param, out float value);
|
||||
|
||||
[DllImport(OpenAlDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "alGetSource3f")]
|
||||
public static extern void GetSource3f(uint sid, int param, out float value1, out float value2, out float value3);
|
||||
|
||||
[DllImport(OpenAlDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "alGetSourcefv")]
|
||||
private static extern void _GetSourcefv(uint sid, int param, IntPtr values);
|
||||
|
||||
public static void GetSourcefv(uint sid, int param, out float[] values)
|
||||
{
|
||||
int len;
|
||||
switch(param)
|
||||
{
|
||||
case Pitch:
|
||||
case Gain:
|
||||
case MaxDistance:
|
||||
case RolloffFactor:
|
||||
case ReferenceDistance:
|
||||
case MinGain:
|
||||
case MaxGain:
|
||||
case ConeOuterGain:
|
||||
case ConeInnerAngle:
|
||||
case ConeOuterAngle:
|
||||
case SecOffset:
|
||||
case SampleOffset:
|
||||
case ByteOffset:
|
||||
len = 1;
|
||||
break;
|
||||
case Position:
|
||||
case Velocity:
|
||||
case Direction:
|
||||
len = 3;
|
||||
break;
|
||||
default:
|
||||
len = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
values = new float[len];
|
||||
|
||||
GCHandle arrayHandle = GCHandle.Alloc(values, GCHandleType.Pinned);
|
||||
_GetSourcefv(sid, param, arrayHandle.AddrOfPinnedObject());
|
||||
arrayHandle.Free();
|
||||
}
|
||||
|
||||
[DllImport(OpenAlDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "alGetSourcei")]
|
||||
public static extern void GetSourcei(uint sid, int param, out int value);
|
||||
|
||||
[DllImport(OpenAlDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "alGetSource3i")]
|
||||
public static extern void GetSource3i(uint sid, int param, out int value1, out int value2, out int value3);
|
||||
|
||||
[DllImport(OpenAlDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "alGetSourceiv")]
|
||||
private static extern void _GetSourceiv(uint sid, int param, IntPtr values);
|
||||
|
||||
public static void GetSourceiv(uint sid, int param, out int[] values)
|
||||
{
|
||||
int len;
|
||||
switch(param)
|
||||
{
|
||||
case MaxDistance:
|
||||
case RolloffFactor:
|
||||
case ReferenceDistance:
|
||||
case ConeInnerAngle:
|
||||
case ConeOuterAngle:
|
||||
case SourceRelative:
|
||||
case SourceType:
|
||||
case Looping:
|
||||
case Buffer:
|
||||
case SourceState:
|
||||
case BuffersQueued:
|
||||
case BuffersProcessed:
|
||||
case SecOffset:
|
||||
case SampleOffset:
|
||||
case ByteOffset:
|
||||
len = 1;
|
||||
break;
|
||||
case Direction:
|
||||
len = 3;
|
||||
break;
|
||||
default:
|
||||
len = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
values = new int[len];
|
||||
|
||||
GCHandle arrayHandle = GCHandle.Alloc(values, GCHandleType.Pinned);
|
||||
_GetSourceiv(sid, param, arrayHandle.AddrOfPinnedObject());
|
||||
arrayHandle.Free();
|
||||
}
|
||||
|
||||
[DllImport(OpenAlDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "alSourcePlayv")]
|
||||
public static extern void SourcePlayv(int ns, uint[] sids);
|
||||
|
||||
[DllImport(OpenAlDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "alSourceStopv")]
|
||||
public static extern void SourceStopv(int ns, uint[] sids);
|
||||
|
||||
[DllImport(OpenAlDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "alSourceRewindv")]
|
||||
public static extern void SourceRewindv(int ns, uint[] sids);
|
||||
|
||||
[DllImport(OpenAlDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "alSourcePausev")]
|
||||
public static extern void SourcePausev(int ns, uint[] sids);
|
||||
|
||||
[DllImport(OpenAlDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "alSourcePlay")]
|
||||
public static extern void SourcePlay(uint sid);
|
||||
|
||||
[DllImport(OpenAlDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "alSourceStop")]
|
||||
public static extern void SourceStop(uint sid);
|
||||
|
||||
[DllImport(OpenAlDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "alSourceRewind")]
|
||||
public static extern void SourceRewind(uint sid);
|
||||
|
||||
[DllImport(OpenAlDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "alSourcePause")]
|
||||
public static extern void SourcePause(uint sid);
|
||||
|
||||
[DllImport(OpenAlDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "alSourceQueueBuffers")]
|
||||
public static extern void SourceQueueBuffers(uint sid, int numEntries, uint[] bids);
|
||||
|
||||
public static void SourceQueueBuffer(uint sid, uint bid)
|
||||
{
|
||||
uint[] bids = new uint[1]; bids[0] = bid;
|
||||
SourceQueueBuffers(sid, 1, bids);
|
||||
}
|
||||
|
||||
[DllImport(OpenAlDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "alSourceUnqueueBuffers")]
|
||||
public static extern void SourceUnqueueBuffers(uint sid, int numEntries, uint[] bids);
|
||||
|
||||
[DllImport(OpenAlDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "alGenBuffers")]
|
||||
private static extern void _GenBuffers(int n, IntPtr buffers);
|
||||
|
||||
public static void GenBuffers(int n, out uint[] buffers)
|
||||
{
|
||||
buffers = new uint[n];
|
||||
|
||||
GCHandle arrayHandle = GCHandle.Alloc(buffers, GCHandleType.Pinned);
|
||||
_GenBuffers(n, arrayHandle.AddrOfPinnedObject());
|
||||
arrayHandle.Free();
|
||||
}
|
||||
|
||||
public static void GenBuffer(out uint buffer)
|
||||
{
|
||||
GenBuffers(1, out var buffers);
|
||||
buffer = buffers[0];
|
||||
}
|
||||
|
||||
[DllImport(OpenAlDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "alDeleteBuffers")]
|
||||
public static extern void DeleteBuffers(int n, uint[] buffers);
|
||||
|
||||
public static void DeleteBuffer(uint buffer) => DeleteBuffers(1, new[] {buffer});
|
||||
|
||||
[DllImport(OpenAlDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "alIsBuffer")]
|
||||
public static extern bool IsBuffer(uint bid);
|
||||
|
||||
[DllImport(OpenAlDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "alBufferData")]
|
||||
public static extern void BufferData(uint bid, int format, IntPtr data, int size, int freq);
|
||||
|
||||
public static void BufferData<T>(uint bid, int format, T[] data, int len, int freq)
|
||||
{
|
||||
GCHandle handle = GCHandle.Alloc(data, GCHandleType.Pinned);
|
||||
BufferData(bid, format, handle.AddrOfPinnedObject(), len, freq);
|
||||
handle.Free();
|
||||
}
|
||||
|
||||
[DllImport(OpenAlDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "alBufferi")]
|
||||
public static extern void Bufferi(uint bid, int param, int value);
|
||||
|
||||
[DllImport(OpenAlDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "alGetBufferi")]
|
||||
public static extern void GetBufferi(uint bid, int param, out int value);
|
||||
|
||||
[DllImport(OpenAlDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "alDopplerFactor")]
|
||||
public static extern void DopplerFactor(float value);
|
||||
|
||||
[DllImport(OpenAlDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "alDopplerVelocity")]
|
||||
public static extern void DopplerVelocity(float value);
|
||||
|
||||
[DllImport(OpenAlDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "alSpeedOfSound")]
|
||||
public static extern void SpeedOfSound(float value);
|
||||
|
||||
[DllImport(OpenAlDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "alDistanceModel")]
|
||||
public static extern void DistanceModel(int distanceModel);
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
220
Barotrauma/BarotraumaClient/Source/Sounds/OpenAL/Alc.cs
Normal file
220
Barotrauma/BarotraumaClient/Source/Sounds/OpenAL/Alc.cs
Normal file
@@ -0,0 +1,220 @@
|
||||
/***
|
||||
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2018 Nathan Glover
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
****************
|
||||
|
||||
Further modified for use in Barotrauma.
|
||||
Original source code at https://github.com/NathanielGlover/OpenAL.NETCore/
|
||||
|
||||
***/
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenAL
|
||||
{
|
||||
public class Alc
|
||||
{
|
||||
#if OSX
|
||||
public const string OpenAlDll = "/System/Library/Frameworks/OpenAL.framework/OpenAL";
|
||||
#elif LINUX
|
||||
public const string OpenAlDll = "libopenal.so.1";
|
||||
#elif WINDOWS
|
||||
#if X86
|
||||
public const string OpenAlDll = "soft_oal_x86.dll";
|
||||
#elif X64
|
||||
public const string OpenAlDll = "soft_oal_x64.dll";
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#region Enum
|
||||
|
||||
public const int False = 0;
|
||||
public const int True = 1;
|
||||
public const int Frequency = 0x1007;
|
||||
public const int Refresh = 0x1008;
|
||||
public const int Sync = 0x1009;
|
||||
public const int MonoSources = 0x1010;
|
||||
public const int StereoSources = 0x1011;
|
||||
public const int NoError = False;
|
||||
public const int InvalidDevice = 0xA001;
|
||||
public const int InvalidContext = 0xA002;
|
||||
public const int InvalidEnum = 0xA003;
|
||||
public const int InvalidValue = 0xA004;
|
||||
public const int OutOfMemory = 0xA005;
|
||||
public const int DefaultDeviceSpecifier = 0x1004;
|
||||
public const int DeviceSpecifier = 0x1005;
|
||||
public const int Extensions = 0x1006;
|
||||
public const int MajorVersion = 0x1000;
|
||||
public const int MinorVersion = 0x1001;
|
||||
public const int AttributesSize = 0x1002;
|
||||
public const int AllAttributes = 0x1003;
|
||||
public const int DefaultAllDevicesSpecifier = 0x1012;
|
||||
public const int AllDevicesSpecifier = 0x1013;
|
||||
public const int CaptureDeviceSpecifier = 0x310;
|
||||
public const int CaptureDefaultDeviceSpecifier = 0x311;
|
||||
public const int EnumCaptureSamples = 0x312;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Context Management Functions
|
||||
|
||||
[DllImport(OpenAlDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "alcCreateContext")]
|
||||
private static extern IntPtr _CreateContext(IntPtr device, IntPtr attrlist);
|
||||
|
||||
public static IntPtr CreateContext(IntPtr device, int[] attrList)
|
||||
{
|
||||
GCHandle handle = GCHandle.Alloc(attrList, GCHandleType.Pinned);
|
||||
IntPtr retVal = _CreateContext(device, handle.AddrOfPinnedObject());
|
||||
handle.Free();
|
||||
return retVal;
|
||||
}
|
||||
|
||||
[DllImport(OpenAlDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "alcMakeContextCurrent")]
|
||||
public static extern bool MakeContextCurrent(IntPtr context);
|
||||
|
||||
[DllImport(OpenAlDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "alcProcessContext")]
|
||||
public static extern void ProcessContext(IntPtr context);
|
||||
|
||||
[DllImport(OpenAlDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "alcSuspendContext")]
|
||||
public static extern void SuspendContext(IntPtr context);
|
||||
|
||||
[DllImport(OpenAlDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "alcDestroyContext")]
|
||||
public static extern void DestroyContext(IntPtr context);
|
||||
|
||||
[DllImport(OpenAlDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "alcGetCurrentContext")]
|
||||
public static extern IntPtr GetCurrentContext();
|
||||
|
||||
[DllImport(OpenAlDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "alcGetContextsDevice")]
|
||||
public static extern IntPtr GetContextsDevice(IntPtr context);
|
||||
|
||||
[DllImport(OpenAlDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "alcOpenDevice")]
|
||||
public static extern IntPtr OpenDevice(string deviceName);
|
||||
|
||||
[DllImport(OpenAlDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "alcCloseDevice")]
|
||||
public static extern bool CloseDevice(IntPtr device);
|
||||
|
||||
[DllImport(OpenAlDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "alcGetError")]
|
||||
public static extern int GetError(IntPtr device);
|
||||
|
||||
[DllImport(OpenAlDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "alcIsExtensionPresent")]
|
||||
public static extern bool IsExtensionPresent(IntPtr device, string extname);
|
||||
|
||||
[DllImport(OpenAlDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "alcGetProcAddress")]
|
||||
public static extern IntPtr GetProcAddress(IntPtr device, string funcname);
|
||||
|
||||
[DllImport(OpenAlDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "alcGetEnumValue")]
|
||||
public static extern int GetEnumValue(IntPtr device, string enumname);
|
||||
|
||||
#endregion
|
||||
|
||||
#region Query Functions
|
||||
|
||||
[DllImport(OpenAlDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "alcGetString")]
|
||||
private static extern IntPtr _GetString(IntPtr device, int param);
|
||||
|
||||
public static string GetString(IntPtr device, int param)
|
||||
{
|
||||
IntPtr strPtr = _GetString(device, param);
|
||||
int strLen = 0;
|
||||
while (Marshal.ReadByte(strPtr,strLen)!='\0') { strLen++; }
|
||||
byte[] bytes = new byte[strLen];
|
||||
Marshal.Copy(strPtr, bytes, 0, strLen);
|
||||
return Encoding.UTF8.GetString(bytes);
|
||||
}
|
||||
|
||||
public static IList<string> GetStringList(IntPtr device, int param)
|
||||
{
|
||||
List<string> retVal = new List<string>();
|
||||
IntPtr strPtr = _GetString(device, param);
|
||||
int strStart = 0;
|
||||
int strEnd = 0;
|
||||
byte currChar = Marshal.ReadByte(strPtr, strEnd);
|
||||
if (currChar == '\0') { return retVal; }
|
||||
byte prevChar = 255;
|
||||
while (true) {
|
||||
strEnd++;
|
||||
prevChar = currChar;
|
||||
currChar = Marshal.ReadByte(strPtr, strEnd);
|
||||
|
||||
if (currChar == '\0')
|
||||
{
|
||||
if (prevChar == '\0')
|
||||
{
|
||||
break;
|
||||
}
|
||||
byte[] bytes = new byte[strEnd-strStart];
|
||||
Marshal.Copy(strPtr+strStart, bytes, 0, strEnd - strStart);
|
||||
retVal.Add(Encoding.UTF8.GetString(bytes));
|
||||
strStart = strEnd+1;
|
||||
}
|
||||
}
|
||||
return retVal;
|
||||
}
|
||||
|
||||
[DllImport(OpenAlDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "alcGetIntegerv")]
|
||||
public static extern void GetIntegerv(IntPtr device, int param, int size, IntPtr data);
|
||||
|
||||
public static void GetInteger(IntPtr device, int param, out int data)
|
||||
{
|
||||
int[] dataArr = new int[1];
|
||||
GCHandle handle = GCHandle.Alloc(dataArr,GCHandleType.Pinned);
|
||||
GetIntegerv(device, param, 1, handle.AddrOfPinnedObject());
|
||||
handle.Free();
|
||||
data = dataArr[0];
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Capture Functions
|
||||
|
||||
[DllImport(OpenAlDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "alcCaptureOpenDevice")]
|
||||
private static extern IntPtr CaptureOpenDevice(IntPtr devicename, uint frequency, int format, int buffersize);
|
||||
|
||||
public static IntPtr CaptureOpenDevice(string devicename, uint frequency, int format, int buffersize)
|
||||
{
|
||||
byte[] devicenameBytes = Encoding.UTF8.GetBytes(devicename);
|
||||
GCHandle devicenameHandle = GCHandle.Alloc(devicenameBytes, GCHandleType.Pinned);
|
||||
IntPtr retVal = CaptureOpenDevice(devicenameHandle.AddrOfPinnedObject(), frequency, format, buffersize);
|
||||
devicenameHandle.Free();
|
||||
return retVal;
|
||||
}
|
||||
|
||||
[DllImport(OpenAlDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "alcCaptureCloseDevice")]
|
||||
public static extern bool CaptureCloseDevice(IntPtr device);
|
||||
|
||||
[DllImport(OpenAlDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "alcCaptureStart")]
|
||||
public static extern void CaptureStart(IntPtr device);
|
||||
|
||||
[DllImport(OpenAlDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "alcCaptureStop")]
|
||||
public static extern void CaptureStop(IntPtr device);
|
||||
|
||||
[DllImport(OpenAlDll, CallingConvention = CallingConvention.Cdecl, EntryPoint = "alcCaptureSamples")]
|
||||
public static extern void CaptureSamples(IntPtr device, IntPtr buffer, int samples);
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
using System;
|
||||
using OpenTK.Audio.OpenAL;
|
||||
using OpenAL;
|
||||
using Microsoft.Xna.Framework;
|
||||
using System.IO;
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace Barotrauma.Sounds
|
||||
get { return !Stream ? alMuffledBuffer : 0; }
|
||||
}
|
||||
|
||||
public ALFormat ALFormat
|
||||
public int ALFormat
|
||||
{
|
||||
get;
|
||||
protected set;
|
||||
@@ -91,26 +91,26 @@ namespace Barotrauma.Sounds
|
||||
|
||||
if (!stream)
|
||||
{
|
||||
AL.GenBuffer(out alBuffer);
|
||||
ALError alError = AL.GetError();
|
||||
if (alError != ALError.NoError)
|
||||
Al.GenBuffer(out alBuffer);
|
||||
int alError = Al.GetError();
|
||||
if (alError != Al.NoError)
|
||||
{
|
||||
throw new Exception("Failed to create OpenAL buffer for non-streamed sound: " + AL.GetErrorString(alError));
|
||||
throw new Exception("Failed to create OpenAL buffer for non-streamed sound: " + Al.GetErrorString(alError));
|
||||
}
|
||||
|
||||
if (!AL.IsBuffer(alBuffer))
|
||||
if (!Al.IsBuffer(alBuffer))
|
||||
{
|
||||
throw new Exception("Generated OpenAL buffer is invalid!");
|
||||
}
|
||||
|
||||
AL.GenBuffer(out alMuffledBuffer);
|
||||
alError = AL.GetError();
|
||||
if (alError != ALError.NoError)
|
||||
Al.GenBuffer(out alMuffledBuffer);
|
||||
alError = Al.GetError();
|
||||
if (alError != Al.NoError)
|
||||
{
|
||||
throw new Exception("Failed to create OpenAL buffer for non-streamed sound: " + AL.GetErrorString(alError));
|
||||
throw new Exception("Failed to create OpenAL buffer for non-streamed sound: " + Al.GetErrorString(alError));
|
||||
}
|
||||
|
||||
if (!AL.IsBuffer(alMuffledBuffer))
|
||||
if (!Al.IsBuffer(alMuffledBuffer))
|
||||
{
|
||||
throw new Exception("Generated OpenAL buffer is invalid!");
|
||||
}
|
||||
@@ -186,32 +186,32 @@ namespace Barotrauma.Sounds
|
||||
Owner.KillChannels(this);
|
||||
if (alBuffer != 0)
|
||||
{
|
||||
if (!AL.IsBuffer(alBuffer))
|
||||
if (!Al.IsBuffer(alBuffer))
|
||||
{
|
||||
throw new Exception("Buffer to delete is invalid!");
|
||||
}
|
||||
|
||||
AL.DeleteBuffer(ref alBuffer); alBuffer = 0;
|
||||
Al.DeleteBuffer(alBuffer); alBuffer = 0;
|
||||
|
||||
ALError alError = AL.GetError();
|
||||
if (alError != ALError.NoError)
|
||||
int alError = Al.GetError();
|
||||
if (alError != Al.NoError)
|
||||
{
|
||||
throw new Exception("Failed to delete OpenAL buffer for non-streamed sound: " + AL.GetErrorString(alError));
|
||||
throw new Exception("Failed to delete OpenAL buffer for non-streamed sound: " + Al.GetErrorString(alError));
|
||||
}
|
||||
}
|
||||
if (alMuffledBuffer != 0)
|
||||
{
|
||||
if (!AL.IsBuffer(alMuffledBuffer))
|
||||
if (!Al.IsBuffer(alMuffledBuffer))
|
||||
{
|
||||
throw new Exception("Buffer to delete is invalid!");
|
||||
}
|
||||
|
||||
AL.DeleteBuffer(ref alMuffledBuffer); alMuffledBuffer = 0;
|
||||
Al.DeleteBuffer(alMuffledBuffer); alMuffledBuffer = 0;
|
||||
|
||||
ALError alError = AL.GetError();
|
||||
if (alError != ALError.NoError)
|
||||
int alError = Al.GetError();
|
||||
if (alError != Al.NoError)
|
||||
{
|
||||
throw new Exception("Failed to delete OpenAL buffer for non-streamed sound: " + AL.GetErrorString(alError));
|
||||
throw new Exception("Failed to delete OpenAL buffer for non-streamed sound: " + Al.GetErrorString(alError));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
using System;
|
||||
using OpenTK.Audio.OpenAL;
|
||||
using OpenAL;
|
||||
using Microsoft.Xna.Framework;
|
||||
using System.Collections.Generic;
|
||||
|
||||
@@ -15,49 +15,49 @@ namespace Barotrauma.Sounds
|
||||
|
||||
public SoundSourcePool(int sourceCount = SoundManager.SOURCE_COUNT)
|
||||
{
|
||||
ALError alError = ALError.NoError;
|
||||
int alError = Al.NoError;
|
||||
|
||||
ALSources = new uint[sourceCount];
|
||||
for (int i = 0; i < sourceCount; i++)
|
||||
{
|
||||
AL.GenSource(out ALSources[i]);
|
||||
alError = AL.GetError();
|
||||
if (alError != ALError.NoError)
|
||||
Al.GenSource(out ALSources[i]);
|
||||
alError = Al.GetError();
|
||||
if (alError != Al.NoError)
|
||||
{
|
||||
throw new Exception("Error generating alSource[" + i.ToString() + "]: " + AL.GetErrorString(alError));
|
||||
throw new Exception("Error generating alSource[" + i.ToString() + "]: " + Al.GetErrorString(alError));
|
||||
}
|
||||
|
||||
if (!AL.IsSource(ALSources[i]))
|
||||
if (!Al.IsSource(ALSources[i]))
|
||||
{
|
||||
throw new Exception("Generated alSource[" + i.ToString() + "] is invalid!");
|
||||
}
|
||||
|
||||
AL.SourceStop(ALSources[i]);
|
||||
alError = AL.GetError();
|
||||
if (alError != ALError.NoError)
|
||||
Al.SourceStop(ALSources[i]);
|
||||
alError = Al.GetError();
|
||||
if (alError != Al.NoError)
|
||||
{
|
||||
throw new Exception("Error stopping newly generated alSource[" + i.ToString() + "]: " + AL.GetErrorString(alError));
|
||||
throw new Exception("Error stopping newly generated alSource[" + i.ToString() + "]: " + Al.GetErrorString(alError));
|
||||
}
|
||||
|
||||
AL.Source(ALSources[i], ALSourcef.MinGain, 0.0f);
|
||||
alError = AL.GetError();
|
||||
if (alError != ALError.NoError)
|
||||
Al.Sourcef(ALSources[i], Al.MinGain, 0.0f);
|
||||
alError = Al.GetError();
|
||||
if (alError != Al.NoError)
|
||||
{
|
||||
throw new Exception("Error setting min gain: " + AL.GetErrorString(alError));
|
||||
throw new Exception("Error setting min gain: " + Al.GetErrorString(alError));
|
||||
}
|
||||
|
||||
AL.Source(ALSources[i], ALSourcef.MaxGain, 1.0f);
|
||||
alError = AL.GetError();
|
||||
if (alError != ALError.NoError)
|
||||
Al.Sourcef(ALSources[i], Al.MaxGain, 1.0f);
|
||||
alError = Al.GetError();
|
||||
if (alError != Al.NoError)
|
||||
{
|
||||
throw new Exception("Error setting max gain: " + AL.GetErrorString(alError));
|
||||
throw new Exception("Error setting max gain: " + Al.GetErrorString(alError));
|
||||
}
|
||||
|
||||
AL.Source(ALSources[i], ALSourcef.RolloffFactor, 1.0f);
|
||||
alError = AL.GetError();
|
||||
if (alError != ALError.NoError)
|
||||
Al.Sourcef(ALSources[i], Al.RolloffFactor, 1.0f);
|
||||
alError = Al.GetError();
|
||||
if (alError != Al.NoError)
|
||||
{
|
||||
throw new Exception("Error setting rolloff factor: " + AL.GetErrorString(alError));
|
||||
throw new Exception("Error setting rolloff factor: " + Al.GetErrorString(alError));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -66,11 +66,11 @@ namespace Barotrauma.Sounds
|
||||
{
|
||||
for (int i = 0; i < ALSources.Length; i++)
|
||||
{
|
||||
AL.DeleteSource(ref ALSources[i]);
|
||||
ALError alError = AL.GetError();
|
||||
if (alError != ALError.NoError)
|
||||
Al.DeleteSource(ALSources[i]);
|
||||
int alError = Al.GetError();
|
||||
if (alError != Al.NoError)
|
||||
{
|
||||
throw new Exception("Failed to delete ALSources[" + i.ToString() + "]: " + AL.GetErrorString(alError));
|
||||
throw new Exception("Failed to delete ALSources[" + i.ToString() + "]: " + Al.GetErrorString(alError));
|
||||
}
|
||||
}
|
||||
ALSources = null;
|
||||
@@ -95,35 +95,35 @@ namespace Barotrauma.Sounds
|
||||
if (position != null)
|
||||
{
|
||||
uint alSource = Sound.Owner.GetSourceFromIndex(Sound.SourcePoolIndex, ALSourceIndex);
|
||||
AL.Source(alSource, ALSourceb.SourceRelative, false);
|
||||
ALError alError = AL.GetError();
|
||||
if (alError != ALError.NoError)
|
||||
Al.Sourcei(alSource, Al.SourceRelative, Al.False);
|
||||
int alError = Al.GetError();
|
||||
if (alError != Al.NoError)
|
||||
{
|
||||
throw new Exception("Failed to enable source's relative flag: " + AL.GetErrorString(alError));
|
||||
throw new Exception("Failed to enable source's relative flag: " + Al.GetErrorString(alError));
|
||||
}
|
||||
|
||||
AL.Source(alSource, ALSource3f.Position, position.Value.X, position.Value.Y, position.Value.Z);
|
||||
alError = AL.GetError();
|
||||
if (alError != ALError.NoError)
|
||||
Al.Source3f(alSource, Al.Position, position.Value.X, position.Value.Y, position.Value.Z);
|
||||
alError = Al.GetError();
|
||||
if (alError != Al.NoError)
|
||||
{
|
||||
throw new Exception("Failed to set source's position: " + AL.GetErrorString(alError));
|
||||
throw new Exception("Failed to set source's position: " + Al.GetErrorString(alError));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
uint alSource = Sound.Owner.GetSourceFromIndex(Sound.SourcePoolIndex, ALSourceIndex);
|
||||
AL.Source(alSource, ALSourceb.SourceRelative, true);
|
||||
ALError alError = AL.GetError();
|
||||
if (alError != ALError.NoError)
|
||||
Al.Sourcei(alSource, Al.SourceRelative, Al.True);
|
||||
int alError = Al.GetError();
|
||||
if (alError != Al.NoError)
|
||||
{
|
||||
throw new Exception("Failed to disable source's relative flag: " + AL.GetErrorString(alError));
|
||||
throw new Exception("Failed to disable source's relative flag: " + Al.GetErrorString(alError));
|
||||
}
|
||||
|
||||
AL.Source(alSource, ALSource3f.Position, 0.0f, 0.0f, 0.0f);
|
||||
alError = AL.GetError();
|
||||
if (alError != ALError.NoError)
|
||||
Al.Source3f(alSource, Al.Position, 0.0f, 0.0f, 0.0f);
|
||||
alError = Al.GetError();
|
||||
if (alError != Al.NoError)
|
||||
{
|
||||
throw new Exception("Failed to reset source's position: " + AL.GetErrorString(alError));
|
||||
throw new Exception("Failed to reset source's position: " + Al.GetErrorString(alError));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -140,12 +140,12 @@ namespace Barotrauma.Sounds
|
||||
if (ALSourceIndex < 0) return;
|
||||
|
||||
uint alSource = Sound.Owner.GetSourceFromIndex(Sound.SourcePoolIndex, ALSourceIndex);
|
||||
AL.Source(alSource, ALSourcef.ReferenceDistance, near);
|
||||
Al.Sourcef(alSource, Al.ReferenceDistance, near);
|
||||
|
||||
ALError alError = AL.GetError();
|
||||
if (alError != ALError.NoError)
|
||||
int alError = Al.GetError();
|
||||
if (alError != Al.NoError)
|
||||
{
|
||||
throw new Exception("Failed to set source's reference distance: " + AL.GetErrorString(alError));
|
||||
throw new Exception("Failed to set source's reference distance: " + Al.GetErrorString(alError));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -161,11 +161,11 @@ namespace Barotrauma.Sounds
|
||||
if (ALSourceIndex < 0) return;
|
||||
|
||||
uint alSource = Sound.Owner.GetSourceFromIndex(Sound.SourcePoolIndex, ALSourceIndex);
|
||||
AL.Source(alSource, ALSourcef.MaxDistance, far);
|
||||
ALError alError = AL.GetError();
|
||||
if (alError != ALError.NoError)
|
||||
Al.Sourcef(alSource, Al.MaxDistance, far);
|
||||
int alError = Al.GetError();
|
||||
if (alError != Al.NoError)
|
||||
{
|
||||
throw new Exception("Failed to set source's max distance: " + AL.GetErrorString(alError));
|
||||
throw new Exception("Failed to set source's max distance: " + Al.GetErrorString(alError));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -185,11 +185,11 @@ namespace Barotrauma.Sounds
|
||||
float effectiveGain = gain;
|
||||
if (category != null) effectiveGain *= Sound.Owner.GetCategoryGainMultiplier(category);
|
||||
|
||||
AL.Source(alSource, ALSourcef.Gain, effectiveGain);
|
||||
ALError alError = AL.GetError();
|
||||
if (alError != ALError.NoError)
|
||||
Al.Sourcef(alSource, Al.Gain, effectiveGain);
|
||||
int alError = Al.GetError();
|
||||
if (alError != Al.NoError)
|
||||
{
|
||||
throw new Exception("Failed to set source's gain: " + AL.GetErrorString(alError));
|
||||
throw new Exception("Failed to set source's gain: " + Al.GetErrorString(alError));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -207,11 +207,11 @@ namespace Barotrauma.Sounds
|
||||
if (!IsStream)
|
||||
{
|
||||
uint alSource = Sound.Owner.GetSourceFromIndex(Sound.SourcePoolIndex, ALSourceIndex);
|
||||
AL.Source(alSource, ALSourceb.Looping, looping);
|
||||
ALError alError = AL.GetError();
|
||||
if (alError != ALError.NoError)
|
||||
Al.Sourcei(alSource, Al.Looping, looping ? Al.True : Al.False);
|
||||
int alError = Al.GetError();
|
||||
if (alError != Al.NoError)
|
||||
{
|
||||
throw new Exception("Failed to set source's looping state: " + AL.GetErrorString(alError));
|
||||
throw new Exception("Failed to set source's looping state: " + Al.GetErrorString(alError));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -242,41 +242,41 @@ namespace Barotrauma.Sounds
|
||||
if (!IsStream)
|
||||
{
|
||||
uint alSource = Sound.Owner.GetSourceFromIndex(Sound.SourcePoolIndex, ALSourceIndex);
|
||||
int playbackPos; AL.GetSource(alSource, ALGetSourcei.SampleOffset, out playbackPos);
|
||||
ALError alError = AL.GetError();
|
||||
if (alError != ALError.NoError)
|
||||
int playbackPos; Al.GetSourcei(alSource, Al.SampleOffset, out playbackPos);
|
||||
int alError = Al.GetError();
|
||||
if (alError != Al.NoError)
|
||||
{
|
||||
throw new Exception("Failed to get source's playback position: " + AL.GetErrorString(alError));
|
||||
throw new Exception("Failed to get source's playback position: " + Al.GetErrorString(alError));
|
||||
}
|
||||
|
||||
AL.SourceStop(alSource);
|
||||
Al.SourceStop(alSource);
|
||||
|
||||
alError = AL.GetError();
|
||||
if (alError != ALError.NoError)
|
||||
alError = Al.GetError();
|
||||
if (alError != Al.NoError)
|
||||
{
|
||||
throw new Exception("Failed to stop source: " + AL.GetErrorString(alError));
|
||||
throw new Exception("Failed to stop source: " + Al.GetErrorString(alError));
|
||||
}
|
||||
|
||||
AL.BindBufferToSource(alSource,(uint)(muffled ? Sound.ALMuffledBuffer : Sound.ALBuffer));
|
||||
Al.Sourcei(alSource, Al.Buffer, muffled ? (int)Sound.ALMuffledBuffer : (int)Sound.ALBuffer);
|
||||
|
||||
alError = AL.GetError();
|
||||
if (alError != ALError.NoError)
|
||||
alError = Al.GetError();
|
||||
if (alError != Al.NoError)
|
||||
{
|
||||
throw new Exception("Failed to bind buffer to source: " + AL.GetErrorString(alError));
|
||||
throw new Exception("Failed to bind buffer to source: " + Al.GetErrorString(alError));
|
||||
}
|
||||
|
||||
AL.SourcePlay(alSource);
|
||||
alError = AL.GetError();
|
||||
if (alError != ALError.NoError)
|
||||
Al.SourcePlay(alSource);
|
||||
alError = Al.GetError();
|
||||
if (alError != Al.NoError)
|
||||
{
|
||||
throw new Exception("Failed to replay source: " + AL.GetErrorString(alError));
|
||||
throw new Exception("Failed to replay source: " + Al.GetErrorString(alError));
|
||||
}
|
||||
|
||||
AL.Source(alSource, ALSourcei.SampleOffset, playbackPos);
|
||||
alError = AL.GetError();
|
||||
if (alError != ALError.NoError)
|
||||
Al.Sourcei(alSource, Al.SampleOffset, playbackPos);
|
||||
alError = Al.GetError();
|
||||
if (alError != Al.NoError)
|
||||
{
|
||||
throw new Exception("Failed to reset playback position: " + AL.GetErrorString(alError));
|
||||
throw new Exception("Failed to reset playback position: " + Al.GetErrorString(alError));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -324,11 +324,13 @@ namespace Barotrauma.Sounds
|
||||
{
|
||||
if (ALSourceIndex < 0) return false;
|
||||
if (IsStream && !reachedEndSample) return true;
|
||||
bool playing = AL.GetSourceState(Sound.Owner.GetSourceFromIndex(Sound.SourcePoolIndex, ALSourceIndex)) == ALSourceState.Playing;
|
||||
ALError alError = AL.GetError();
|
||||
if (alError != ALError.NoError)
|
||||
int state;
|
||||
Al.GetSourcei(Sound.Owner.GetSourceFromIndex(Sound.SourcePoolIndex, ALSourceIndex), 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: " + AL.GetErrorString(alError));
|
||||
throw new Exception("Failed to determine playing state from source: " + Al.GetErrorString(alError));
|
||||
}
|
||||
return playing;
|
||||
}
|
||||
@@ -357,47 +359,47 @@ namespace Barotrauma.Sounds
|
||||
{
|
||||
if (!IsStream)
|
||||
{
|
||||
AL.BindBufferToSource(sound.Owner.GetSourceFromIndex(Sound.SourcePoolIndex, ALSourceIndex), 0);
|
||||
ALError alError = AL.GetError();
|
||||
if (alError != ALError.NoError)
|
||||
Al.Sourcei(sound.Owner.GetSourceFromIndex(Sound.SourcePoolIndex, ALSourceIndex), Al.Buffer, 0);
|
||||
int alError = Al.GetError();
|
||||
if (alError != Al.NoError)
|
||||
{
|
||||
throw new Exception("Failed to reset source buffer: " + AL.GetErrorString(alError));
|
||||
throw new Exception("Failed to reset source buffer: " + Al.GetErrorString(alError));
|
||||
}
|
||||
|
||||
if (!AL.IsBuffer(sound.ALBuffer))
|
||||
if (!Al.IsBuffer(sound.ALBuffer))
|
||||
{
|
||||
throw new Exception(sound.Filename + " has an invalid buffer!");
|
||||
}
|
||||
|
||||
uint alBuffer = sound.Owner.GetCategoryMuffle(category) || muffle ? sound.ALMuffledBuffer : sound.ALBuffer;
|
||||
AL.BindBufferToSource(sound.Owner.GetSourceFromIndex(Sound.SourcePoolIndex, ALSourceIndex), alBuffer);
|
||||
alError = AL.GetError();
|
||||
if (alError != ALError.NoError)
|
||||
Al.Sourcei(sound.Owner.GetSourceFromIndex(Sound.SourcePoolIndex, ALSourceIndex), Al.Buffer, (int)alBuffer);
|
||||
alError = Al.GetError();
|
||||
if (alError != Al.NoError)
|
||||
{
|
||||
throw new Exception("Failed to bind buffer to source (" + ALSourceIndex.ToString() + ":" + sound.Owner.GetSourceFromIndex(Sound.SourcePoolIndex, ALSourceIndex) + "," + sound.ALBuffer.ToString() + "): " + AL.GetErrorString(alError));
|
||||
throw new Exception("Failed to bind buffer to source (" + ALSourceIndex.ToString() + ":" + sound.Owner.GetSourceFromIndex(Sound.SourcePoolIndex, ALSourceIndex) + "," + sound.ALBuffer.ToString() + "): " + Al.GetErrorString(alError));
|
||||
}
|
||||
|
||||
AL.SourcePlay(sound.Owner.GetSourceFromIndex(Sound.SourcePoolIndex, ALSourceIndex));
|
||||
alError = AL.GetError();
|
||||
if (alError != ALError.NoError)
|
||||
Al.SourcePlay(sound.Owner.GetSourceFromIndex(Sound.SourcePoolIndex, ALSourceIndex));
|
||||
alError = Al.GetError();
|
||||
if (alError != Al.NoError)
|
||||
{
|
||||
throw new Exception("Failed to play source: " + AL.GetErrorString(alError));
|
||||
throw new Exception("Failed to play source: " + Al.GetErrorString(alError));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
AL.BindBufferToSource(sound.Owner.GetSourceFromIndex(Sound.SourcePoolIndex, ALSourceIndex), (uint)sound.ALBuffer);
|
||||
ALError alError = AL.GetError();
|
||||
if (alError != ALError.NoError)
|
||||
Al.Sourcei(sound.Owner.GetSourceFromIndex(Sound.SourcePoolIndex, ALSourceIndex), Al.Buffer, (int)sound.ALBuffer);
|
||||
int alError = Al.GetError();
|
||||
if (alError != Al.NoError)
|
||||
{
|
||||
throw new Exception("Failed to reset source buffer: " + AL.GetErrorString(alError));
|
||||
throw new Exception("Failed to reset source buffer: " + Al.GetErrorString(alError));
|
||||
}
|
||||
|
||||
AL.Source(sound.Owner.GetSourceFromIndex(Sound.SourcePoolIndex, ALSourceIndex), ALSourceb.Looping, false);
|
||||
alError = AL.GetError();
|
||||
if (alError != ALError.NoError)
|
||||
Al.Sourcei(sound.Owner.GetSourceFromIndex(Sound.SourcePoolIndex, ALSourceIndex), Al.Looping, Al.False);
|
||||
alError = Al.GetError();
|
||||
if (alError != Al.NoError)
|
||||
{
|
||||
throw new Exception("Failed to set stream looping state: " + AL.GetErrorString(alError));
|
||||
throw new Exception("Failed to set stream looping state: " + Al.GetErrorString(alError));
|
||||
}
|
||||
|
||||
streamShortBuffer = new short[STREAM_BUFFER_SIZE];
|
||||
@@ -406,15 +408,15 @@ namespace Barotrauma.Sounds
|
||||
emptyBuffers = new List<uint>();
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
AL.GenBuffer(out streamBuffers[i]);
|
||||
Al.GenBuffer(out streamBuffers[i]);
|
||||
|
||||
alError = AL.GetError();
|
||||
if (alError != ALError.NoError)
|
||||
alError = Al.GetError();
|
||||
if (alError != Al.NoError)
|
||||
{
|
||||
throw new Exception("Failed to generate stream buffers: " + AL.GetErrorString(alError));
|
||||
throw new Exception("Failed to generate stream buffers: " + Al.GetErrorString(alError));
|
||||
}
|
||||
|
||||
if (!AL.IsBuffer(streamBuffers[i]))
|
||||
if (!Al.IsBuffer(streamBuffers[i]))
|
||||
{
|
||||
throw new Exception("Generated streamBuffer[" + i.ToString() + "] is invalid!");
|
||||
}
|
||||
@@ -445,57 +447,57 @@ namespace Barotrauma.Sounds
|
||||
{
|
||||
if (ALSourceIndex >= 0)
|
||||
{
|
||||
AL.SourceStop(Sound.Owner.GetSourceFromIndex(Sound.SourcePoolIndex, ALSourceIndex));
|
||||
ALError alError = AL.GetError();
|
||||
if (alError != ALError.NoError)
|
||||
Al.SourceStop(Sound.Owner.GetSourceFromIndex(Sound.SourcePoolIndex, ALSourceIndex));
|
||||
int alError = Al.GetError();
|
||||
if (alError != Al.NoError)
|
||||
{
|
||||
throw new Exception("Failed to stop source: " + AL.GetErrorString(alError));
|
||||
throw new Exception("Failed to stop source: " + Al.GetErrorString(alError));
|
||||
}
|
||||
|
||||
if (IsStream)
|
||||
{
|
||||
uint alSource = Sound.Owner.GetSourceFromIndex(Sound.SourcePoolIndex, ALSourceIndex);
|
||||
|
||||
AL.SourceStop(alSource);
|
||||
alError = AL.GetError();
|
||||
if (alError != ALError.NoError)
|
||||
Al.SourceStop(alSource);
|
||||
alError = Al.GetError();
|
||||
if (alError != Al.NoError)
|
||||
{
|
||||
throw new Exception("Failed to stop streamed source: " + AL.GetErrorString(alError));
|
||||
throw new Exception("Failed to stop streamed source: " + Al.GetErrorString(alError));
|
||||
}
|
||||
|
||||
int buffersToUnqueue = 0;
|
||||
int[] unqueuedBuffers = null;
|
||||
uint[] unqueuedBuffers = null;
|
||||
|
||||
buffersToUnqueue = 0;
|
||||
AL.GetSource(alSource, ALGetSourcei.BuffersProcessed, out buffersToUnqueue);
|
||||
alError = AL.GetError();
|
||||
if (alError != ALError.NoError)
|
||||
Al.GetSourcei(alSource, Al.BuffersProcessed, out buffersToUnqueue);
|
||||
alError = Al.GetError();
|
||||
if (alError != Al.NoError)
|
||||
{
|
||||
throw new Exception("Failed to determine processed buffers from streamed source: " + AL.GetErrorString(alError));
|
||||
throw new Exception("Failed to determine processed buffers from streamed source: " + Al.GetErrorString(alError));
|
||||
}
|
||||
|
||||
unqueuedBuffers = new int[buffersToUnqueue];
|
||||
AL.SourceUnqueueBuffers((int)alSource, buffersToUnqueue, unqueuedBuffers);
|
||||
alError = AL.GetError();
|
||||
if (alError != ALError.NoError)
|
||||
unqueuedBuffers = new uint[buffersToUnqueue];
|
||||
Al.SourceUnqueueBuffers(alSource, buffersToUnqueue, unqueuedBuffers);
|
||||
alError = Al.GetError();
|
||||
if (alError != Al.NoError)
|
||||
{
|
||||
throw new Exception("Failed to unqueue buffers from streamed source: " + AL.GetErrorString(alError));
|
||||
throw new Exception("Failed to unqueue buffers from streamed source: " + Al.GetErrorString(alError));
|
||||
}
|
||||
|
||||
AL.BindBufferToSource(alSource, 0);
|
||||
alError = AL.GetError();
|
||||
if (alError != ALError.NoError)
|
||||
|
||||
Al.Sourcei(alSource, Al.Buffer, 0);
|
||||
alError = Al.GetError();
|
||||
if (alError != Al.NoError)
|
||||
{
|
||||
throw new Exception("Failed to reset buffer for streamed source: " + AL.GetErrorString(alError));
|
||||
throw new Exception("Failed to reset buffer for streamed source: " + Al.GetErrorString(alError));
|
||||
}
|
||||
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
AL.DeleteBuffer(ref streamBuffers[i]);
|
||||
alError = AL.GetError();
|
||||
if (alError != ALError.NoError)
|
||||
Al.DeleteBuffer(streamBuffers[i]);
|
||||
alError = Al.GetError();
|
||||
if (alError != Al.NoError)
|
||||
{
|
||||
throw new Exception("Failed to delete streamBuffers[" + i.ToString() + "] ("+streamBuffers[i].ToString()+"): " + AL.GetErrorString(alError));
|
||||
throw new Exception("Failed to delete streamBuffers[" + i.ToString() + "] ("+streamBuffers[i].ToString()+"): " + Al.GetErrorString(alError));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -503,11 +505,11 @@ namespace Barotrauma.Sounds
|
||||
}
|
||||
else
|
||||
{
|
||||
AL.BindBufferToSource(Sound.Owner.GetSourceFromIndex(Sound.SourcePoolIndex, ALSourceIndex), 0);
|
||||
alError = AL.GetError();
|
||||
if (alError != ALError.NoError)
|
||||
Al.Sourcei(Sound.Owner.GetSourceFromIndex(Sound.SourcePoolIndex, ALSourceIndex), Al.Buffer, 0);
|
||||
alError = Al.GetError();
|
||||
if (alError != Al.NoError)
|
||||
{
|
||||
throw new Exception("Failed to unbind buffer to non-streamed source: " + AL.GetErrorString(alError));
|
||||
throw new Exception("Failed to unbind buffer to non-streamed source: " + Al.GetErrorString(alError));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -526,47 +528,49 @@ namespace Barotrauma.Sounds
|
||||
{
|
||||
uint alSource = Sound.Owner.GetSourceFromIndex(Sound.SourcePoolIndex, ALSourceIndex);
|
||||
|
||||
bool playing = AL.GetSourceState(alSource) == ALSourceState.Playing;
|
||||
ALError alError = AL.GetError();
|
||||
if (alError != ALError.NoError)
|
||||
int state;
|
||||
Al.GetSourcei(Sound.Owner.GetSourceFromIndex(Sound.SourcePoolIndex, ALSourceIndex), 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 streamed source: " + AL.GetErrorString(alError));
|
||||
throw new Exception("Failed to determine playing state from streamed source: " + Al.GetErrorString(alError));
|
||||
}
|
||||
|
||||
int buffersToUnqueue = 0;
|
||||
int[] unqueuedBuffers = null;
|
||||
uint[] unqueuedBuffers = null;
|
||||
if (!startedPlaying)
|
||||
{
|
||||
buffersToUnqueue = 0;
|
||||
AL.GetSource(alSource, ALGetSourcei.BuffersProcessed, out buffersToUnqueue);
|
||||
alError = AL.GetError();
|
||||
if (alError != ALError.NoError)
|
||||
Al.GetSourcei(alSource, Al.BuffersProcessed, out buffersToUnqueue);
|
||||
alError = Al.GetError();
|
||||
if (alError != Al.NoError)
|
||||
{
|
||||
throw new Exception("Failed to determine processed buffers from streamed source: " + AL.GetErrorString(alError));
|
||||
throw new Exception("Failed to determine processed buffers from streamed source: " + Al.GetErrorString(alError));
|
||||
}
|
||||
|
||||
unqueuedBuffers = new int[buffersToUnqueue+emptyBuffers.Count];
|
||||
AL.SourceUnqueueBuffers((int)alSource, buffersToUnqueue, unqueuedBuffers);
|
||||
unqueuedBuffers = new uint[buffersToUnqueue+emptyBuffers.Count];
|
||||
Al.SourceUnqueueBuffers(alSource, buffersToUnqueue, unqueuedBuffers);
|
||||
for (int i = 0; i < emptyBuffers.Count; i++)
|
||||
{
|
||||
unqueuedBuffers[buffersToUnqueue + i] = (int)emptyBuffers[i];
|
||||
unqueuedBuffers[buffersToUnqueue + i] = emptyBuffers[i];
|
||||
}
|
||||
buffersToUnqueue += emptyBuffers.Count;
|
||||
emptyBuffers.Clear();
|
||||
alError = AL.GetError();
|
||||
if (alError != ALError.NoError)
|
||||
alError = Al.GetError();
|
||||
if (alError != Al.NoError)
|
||||
{
|
||||
throw new Exception("Failed to unqueue buffers from streamed source: " + AL.GetErrorString(alError));
|
||||
throw new Exception("Failed to unqueue buffers from streamed source: " + Al.GetErrorString(alError));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
startedPlaying = false;
|
||||
buffersToUnqueue = 4;
|
||||
unqueuedBuffers = new int[4];
|
||||
unqueuedBuffers = new uint[4];
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
unqueuedBuffers[i] = (int)streamBuffers[i];
|
||||
unqueuedBuffers[i] = streamBuffers[i];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -612,20 +616,20 @@ namespace Barotrauma.Sounds
|
||||
|
||||
if (readSamples > 0)
|
||||
{
|
||||
AL.BufferData<short>(unqueuedBuffers[i], Sound.ALFormat, buffer, readSamples, Sound.SampleRate);
|
||||
Al.BufferData<short>(unqueuedBuffers[i], Sound.ALFormat, buffer, readSamples, Sound.SampleRate);
|
||||
|
||||
alError = AL.GetError();
|
||||
if (alError != ALError.NoError)
|
||||
alError = Al.GetError();
|
||||
if (alError != Al.NoError)
|
||||
{
|
||||
throw new Exception("Failed to assign data to stream buffer: " +
|
||||
AL.GetErrorString(alError) + ": " + unqueuedBuffers[i].ToString() + "/" + unqueuedBuffers.Length + ", readSamples: " + readSamples);
|
||||
Al.GetErrorString(alError) + ": " + unqueuedBuffers[i].ToString() + "/" + unqueuedBuffers.Length + ", readSamples: " + readSamples);
|
||||
}
|
||||
|
||||
AL.SourceQueueBuffer((int)alSource, unqueuedBuffers[i]);
|
||||
alError = AL.GetError();
|
||||
if (alError != ALError.NoError)
|
||||
Al.SourceQueueBuffer(alSource, unqueuedBuffers[i]);
|
||||
alError = Al.GetError();
|
||||
if (alError != Al.NoError)
|
||||
{
|
||||
throw new Exception("Failed to queue buffer[" + i.ToString() + "] to stream: " + AL.GetErrorString(alError));
|
||||
throw new Exception("Failed to queue buffer[" + i.ToString() + "] to stream: " + Al.GetErrorString(alError));
|
||||
}
|
||||
}
|
||||
else if (readSamples < 0)
|
||||
@@ -637,10 +641,11 @@ namespace Barotrauma.Sounds
|
||||
emptyBuffers.Add((uint)unqueuedBuffers[i]);
|
||||
}
|
||||
}
|
||||
|
||||
if (AL.GetSourceState(alSource) != ALSourceState.Playing)
|
||||
|
||||
Al.GetSourcei(alSource, Al.SourceState, out state);
|
||||
if (state != Al.Playing)
|
||||
{
|
||||
AL.SourcePlay(alSource);
|
||||
Al.SourcePlay(alSource);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
using System.Threading;
|
||||
using System.Collections.Generic;
|
||||
using System.Xml.Linq;
|
||||
using OpenTK.Audio.OpenAL;
|
||||
using OpenAL;
|
||||
using Microsoft.Xna.Framework;
|
||||
using System.Linq;
|
||||
using System.IO;
|
||||
@@ -20,7 +20,7 @@ namespace Barotrauma.Sounds
|
||||
}
|
||||
|
||||
private IntPtr alcDevice;
|
||||
private OpenTK.ContextHandle alcContext;
|
||||
private IntPtr alcContext;
|
||||
|
||||
public enum SourcePoolIndex
|
||||
{
|
||||
@@ -42,11 +42,11 @@ namespace Barotrauma.Sounds
|
||||
{
|
||||
if (Disabled) { return; }
|
||||
listenerPosition = value;
|
||||
AL.Listener(ALListener3f.Position,value.X,value.Y,value.Z);
|
||||
ALError alError = AL.GetError();
|
||||
if (alError != ALError.NoError)
|
||||
Al.Listener3f(Al.Position,value.X,value.Y,value.Z);
|
||||
int alError = Al.GetError();
|
||||
if (alError != Al.NoError)
|
||||
{
|
||||
throw new Exception("Failed to set listener position: " + AL.GetErrorString(alError));
|
||||
throw new Exception("Failed to set listener position: " + Al.GetErrorString(alError));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -59,11 +59,11 @@ namespace Barotrauma.Sounds
|
||||
{
|
||||
if (Disabled) { return; }
|
||||
listenerOrientation[0] = value.X; listenerOrientation[1] = value.Y; listenerOrientation[2] = value.Z;
|
||||
AL.Listener(ALListenerfv.Orientation, ref listenerOrientation);
|
||||
ALError alError = AL.GetError();
|
||||
if (alError != ALError.NoError)
|
||||
Al.Listenerfv(Al.Orientation, listenerOrientation);
|
||||
int alError = Al.GetError();
|
||||
if (alError != Al.NoError)
|
||||
{
|
||||
throw new Exception("Failed to set listener target vector: " + AL.GetErrorString(alError));
|
||||
throw new Exception("Failed to set listener target vector: " + Al.GetErrorString(alError));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -74,11 +74,11 @@ namespace Barotrauma.Sounds
|
||||
{
|
||||
if (Disabled) { return; }
|
||||
listenerOrientation[3] = value.X; listenerOrientation[4] = value.Y; listenerOrientation[5] = value.Z;
|
||||
AL.Listener(ALListenerfv.Orientation, ref listenerOrientation);
|
||||
ALError alError = AL.GetError();
|
||||
if (alError != ALError.NoError)
|
||||
Al.Listenerfv(Al.Orientation, listenerOrientation);
|
||||
int alError = Al.GetError();
|
||||
if (alError != Al.NoError)
|
||||
{
|
||||
throw new Exception("Failed to set listener up vector: " + AL.GetErrorString(alError));
|
||||
throw new Exception("Failed to set listener up vector: " + Al.GetErrorString(alError));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -92,11 +92,11 @@ namespace Barotrauma.Sounds
|
||||
if (Disabled) { return; }
|
||||
if (Math.Abs(ListenerGain - value) < 0.001f) { return; }
|
||||
listenerGain = value;
|
||||
AL.Listener(ALListenerf.Gain, listenerGain);
|
||||
ALError alError = AL.GetError();
|
||||
if (alError != ALError.NoError)
|
||||
Al.Listenerf(Al.Gain, listenerGain);
|
||||
int alError = Al.GetError();
|
||||
if (alError != Al.NoError)
|
||||
{
|
||||
throw new Exception("Failed to set listener gain: " + AL.GetErrorString(alError));
|
||||
throw new Exception("Failed to set listener gain: " + Al.GetErrorString(alError));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -126,8 +126,8 @@ namespace Barotrauma.Sounds
|
||||
return;
|
||||
}
|
||||
|
||||
AlcError alcError = Alc.GetError(alcDevice);
|
||||
if (alcError != AlcError.NoError)
|
||||
int alcError = Alc.GetError(alcDevice);
|
||||
if (alcError != Alc.NoError)
|
||||
{
|
||||
//The audio device probably wasn't ready, this happens quite often
|
||||
//Just wait a while and try again
|
||||
@@ -136,7 +136,7 @@ namespace Barotrauma.Sounds
|
||||
alcDevice = Alc.OpenDevice(null);
|
||||
|
||||
alcError = Alc.GetError(alcDevice);
|
||||
if (alcError != AlcError.NoError)
|
||||
if (alcError != Alc.NoError)
|
||||
{
|
||||
DebugConsole.ThrowError("Error initializing ALC device: " + alcError.ToString() + ". Disabling audio playback...");
|
||||
Disabled = true;
|
||||
@@ -161,14 +161,14 @@ namespace Barotrauma.Sounds
|
||||
}
|
||||
|
||||
alcError = Alc.GetError(alcDevice);
|
||||
if (alcError != AlcError.NoError)
|
||||
if (alcError != Alc.NoError)
|
||||
{
|
||||
DebugConsole.ThrowError("Error after assigning ALC context: " + alcError.ToString() + ". Disabling audio playback...");
|
||||
Disabled = true;
|
||||
return;
|
||||
}
|
||||
|
||||
ALError alError = ALError.NoError;
|
||||
int alError = Al.NoError;
|
||||
|
||||
sourcePools = new SoundSourcePool[2];
|
||||
sourcePools[(int)SourcePoolIndex.Default] = new SoundSourcePool(SOURCE_COUNT);
|
||||
@@ -177,12 +177,12 @@ namespace Barotrauma.Sounds
|
||||
sourcePools[(int)SourcePoolIndex.Voice] = new SoundSourcePool(8);
|
||||
playingChannels[(int)SourcePoolIndex.Voice] = new SoundChannel[8];
|
||||
|
||||
AL.DistanceModel(ALDistanceModel.LinearDistanceClamped);
|
||||
Al.DistanceModel(Al.LinearDistanceClamped);
|
||||
|
||||
alError = AL.GetError();
|
||||
if (alError != ALError.NoError)
|
||||
alError = Al.GetError();
|
||||
if (alError != Al.NoError)
|
||||
{
|
||||
DebugConsole.ThrowError("Error setting distance model: " + AL.GetErrorString(alError) + ". Disabling audio playback...");
|
||||
DebugConsole.ThrowError("Error setting distance model: " + Al.GetErrorString(alError) + ". Disabling audio playback...");
|
||||
Disabled = true;
|
||||
return;
|
||||
}
|
||||
@@ -239,7 +239,7 @@ namespace Barotrauma.Sounds
|
||||
{
|
||||
if (Disabled || srcInd < 0 || srcInd >= sourcePools[(int)poolIndex].ALSources.Length) return 0;
|
||||
|
||||
if (!AL.IsSource(sourcePools[(int)poolIndex].ALSources[srcInd]))
|
||||
if (!Al.IsSource(sourcePools[(int)poolIndex].ALSources[srcInd]))
|
||||
{
|
||||
throw new Exception("alSources[" + srcInd.ToString() + "] is invalid!");
|
||||
}
|
||||
@@ -276,8 +276,8 @@ namespace Barotrauma.Sounds
|
||||
{
|
||||
for (int i = 0; i < sourcePools[0].ALSources.Length; i++)
|
||||
{
|
||||
AL.Source(sourcePools[0].ALSources[i], ALSourcef.MaxGain, i == ind ? 1.0f : 0.0f);
|
||||
AL.Source(sourcePools[0].ALSources[i], ALSourcef.MinGain, 0.0f);
|
||||
Al.Sourcef(sourcePools[0].ALSources[i], Al.MaxGain, i == ind ? 1.0f : 0.0f);
|
||||
Al.Sourcef(sourcePools[0].ALSources[i], Al.MinGain, 0.0f);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -514,7 +514,7 @@ namespace Barotrauma.Sounds
|
||||
sourcePools[(int)SourcePoolIndex.Default]?.Dispose();
|
||||
sourcePools[(int)SourcePoolIndex.Voice]?.Dispose();
|
||||
|
||||
if (!Alc.MakeContextCurrent(OpenTK.ContextHandle.Zero))
|
||||
if (!Alc.MakeContextCurrent(IntPtr.Zero))
|
||||
{
|
||||
throw new Exception("Failed to detach the current ALC context! (error code: " + Alc.GetError(alcDevice).ToString() + ")");
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using OpenTK.Audio.OpenAL;
|
||||
using OpenAL;
|
||||
using Microsoft.Xna.Framework;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
@@ -21,7 +21,7 @@ namespace Barotrauma.Sounds
|
||||
|
||||
public VideoSound(SoundManager owner, string filename, int sampleRate, Video vid) : base(owner, filename, true, false)
|
||||
{
|
||||
ALFormat = ALFormat.Stereo16;
|
||||
ALFormat = Al.FormatStereo16;
|
||||
SampleRate = sampleRate;
|
||||
|
||||
sampleQueue = new Queue<short[]>();
|
||||
@@ -110,4 +110,4 @@ namespace Barotrauma.Sounds
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
using Barotrauma.Networking;
|
||||
using Microsoft.Xna.Framework;
|
||||
using OpenTK.Audio.OpenAL;
|
||||
using OpenAL;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
@@ -58,7 +58,7 @@ namespace Barotrauma.Sounds
|
||||
{
|
||||
VoipConfig.SetupEncoding();
|
||||
|
||||
ALFormat = ALFormat.Mono16;
|
||||
ALFormat = Al.FormatMono16;
|
||||
SampleRate = VoipConfig.FREQUENCY;
|
||||
|
||||
queue = q;
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
<BootstrapperEnabled>true</BootstrapperEnabled>
|
||||
<NuGetPackageImportStamp>
|
||||
</NuGetPackageImportStamp>
|
||||
<AllowedReferenceRelatedFileExtensions>.pdb</AllowedReferenceRelatedFileExtensions>
|
||||
<AllowedReferenceRelatedFileExtensions>.pdb</AllowedReferenceRelatedFileExtensions>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<ApplicationIcon>..\BarotraumaShared\Icon.ico</ApplicationIcon>
|
||||
@@ -39,7 +39,7 @@
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'ReleaseWindows|x64'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>..\bin\ReleaseWindows\</OutputPath>
|
||||
<DefineConstants>TRACE;WINDOWS;CLIENT</DefineConstants>
|
||||
<DefineConstants>TRACE;WINDOWS;CLIENT;X64</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
@@ -49,7 +49,7 @@
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'DebugWindows|x64'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>..\bin\DebugWindows\</OutputPath>
|
||||
<DefineConstants>TRACE;WINDOWS;CLIENT;DEBUG</DefineConstants>
|
||||
<DefineConstants>TRACE;DEBUG;WINDOWS;CLIENT;X64</DefineConstants>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
@@ -60,7 +60,7 @@
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'ReleaseWindows|x86'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>..\bin\x86\ReleaseWindows\</OutputPath>
|
||||
<DefineConstants>TRACE;WINDOWS;CLIENT</DefineConstants>
|
||||
<DefineConstants>TRACE;WINDOWS;CLIENT;X86</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
@@ -70,7 +70,7 @@
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'DebugWindows|x86'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>..\bin\x86\DebugWindows\</OutputPath>
|
||||
<DefineConstants>TRACE;WINDOWS;CLIENT;DEBUG</DefineConstants>
|
||||
<DefineConstants>TRACE;DEBUG;WINDOWS;CLIENT;X86</DefineConstants>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
@@ -95,9 +95,6 @@
|
||||
<Reference Include="NVorbis, Version=0.8.6.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\Libraries\NuGet\NVorbis.0.8.6\lib\net35\NVorbis.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="OpenTK, Version=3.0.1.0, Culture=neutral, PublicKeyToken=bad199fe84eb3df4, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\Libraries\NuGet\OpenTK.3.0.1\lib\net20\OpenTK.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="PresentationCore" />
|
||||
<Reference Include="RestSharp, Version=105.2.3.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\..\Libraries\NuGet\RestSharp.105.2.3\lib\net45\RestSharp.dll</HintPath>
|
||||
@@ -215,16 +212,16 @@
|
||||
<Content Include="Shaders\losshader.fx" />
|
||||
<Content Include="Shaders\postprocess.fx" />
|
||||
<Content Include="Shaders\watershader.fx" />
|
||||
<Content Include="wrap_oal.dll">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="MonoGame.Framework.dll.config">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="OpenTK.dll.config">
|
||||
<Content Include="SharpFont.dll.config">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="SharpFont.dll.config">
|
||||
<Content Include="soft_oal_x64.dll">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="soft_oal_x86.dll">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
@@ -306,7 +303,7 @@
|
||||
<Import Project="ClientCode.projitems" Label="Shared" />
|
||||
<Import Project="..\BarotraumaShared\SharedCode.projitems" Label="Shared" />
|
||||
<Import Project="..\BarotraumaShared\SharedContent.projitems" Label="Shared" />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="..\..\Libraries\NuGet\GameAnalytics.Mono.SDK.2.1.6\build\net45\GameAnalytics.Mono.SDK.targets" Condition="Exists('..\..\Libraries\NuGet\GameAnalytics.Mono.SDK.2.1.6\build\net45\GameAnalytics.Mono.SDK.targets')" />
|
||||
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||
<PropertyGroup>
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
<package id="NLog" version="4.3.8" targetFramework="net45" />
|
||||
<package id="nVLC" version="3.0.0" targetFramework="net45" />
|
||||
<package id="NVorbis" version="0.8.6" targetFramework="net45" />
|
||||
<package id="OpenTK" version="3.0.1" targetFramework="net45" />
|
||||
<package id="RestSharp" version="105.2.3" targetFramework="net45" />
|
||||
<package id="SharpDX" version="4.2.0" targetFramework="net45" />
|
||||
<package id="SharpDX.Direct2D1" version="4.2.0" targetFramework="net45" />
|
||||
|
||||
BIN
Barotrauma/BarotraumaClient/soft_oal_x86.dll
Normal file
BIN
Barotrauma/BarotraumaClient/soft_oal_x86.dll
Normal file
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user