Skip to content

Instantly share code, notes, and snippets.

@rfht
Created March 19, 2019 19:53
Show Gist options
  • Save rfht/5f9bf0349bd8c1523049c1fd385e6041 to your computer and use it in GitHub Desktop.
Save rfht/5f9bf0349bd8c1523049c1fd385e6041 to your computer and use it in GitHub Desktop.
diff used to disable OpenAL in MonoGame.Framework to run StardewValley server on instance without audio
diff --git a/MonoGame.Framework/Audio/OpenAL.cs b/MonoGame.Framework/Audio/OpenAL.cs
index 9a8eb4202..4d1c6ef69 100644
--- a/MonoGame.Framework/Audio/OpenAL.cs
+++ b/MonoGame.Framework/Audio/OpenAL.cs
@@ -217,9 +217,9 @@ namespace MonoGame.OpenAL
if (CurrentPlatform.OS == OS.Windows)
ret = FuncLoader.LoadLibrary("soft_oal.dll");
else if (CurrentPlatform.OS == OS.Linux)
- ret = FuncLoader.LoadLibrary("libopenal.so.1");
+ ret = FuncLoader.LoadLibrary("libopenal.so");
else
- ret = FuncLoader.LoadLibrary("libopenal.1.dylib");
+ ret = FuncLoader.LoadLibrary("libopenal.so");
}
#elif ANDROID
ret = FuncLoader.LoadLibrary("libopenal32.so");
diff --git a/MonoGame.Framework/Audio/OpenALSoundController.cs b/MonoGame.Framework/Audio/OpenALSoundController.cs
index 9a95a22bc..63a33be70 100644
--- a/MonoGame.Framework/Audio/OpenALSoundController.cs
+++ b/MonoGame.Framework/Audio/OpenALSoundController.cs
@@ -33,7 +33,7 @@ namespace Microsoft.Xna.Framework.Audio
if (args != null && args.Length > 0)
message = String.Format(message, args);
- throw new InvalidOperationException(message + " (Reason: " + AL.GetErrorString(error) + ")");
+ //throw new InvalidOperationException(message + " (Reason: " + AL.GetErrorString(error) + ")");
}
}
@@ -59,7 +59,7 @@ namespace Microsoft.Xna.Framework.Audio
if (args != null && args.Length > 0)
message = String.Format(message, args);
- throw new InvalidOperationException(message + " (Reason: " + error.ToString() + ")");
+ //throw new InvalidOperationException(message + " (Reason: " + error.ToString() + ")");
}
}
}
@@ -110,7 +110,7 @@ namespace Microsoft.Xna.Framework.Audio
{
if (!OpenSoundController())
{
- throw new NoAudioHardwareException("OpenAL device could not be initialized, see console output for details.");
+ //throw new NoAudioHardwareException("OpenAL device could not be initialized, see console output for details.");
}
if (Alc.IsExtensionPresent(_device, "ALC_EXT_CAPTURE"))
@@ -155,7 +155,7 @@ namespace Microsoft.Xna.Framework.Audio
}
catch (Exception ex)
{
- throw new NoAudioHardwareException("OpenAL device could not be initialized.", ex);
+ //throw new NoAudioHardwareException("OpenAL device could not be initialized.", ex);
}
AlcHelper.CheckError("Could not open OpenAL device");
diff --git a/MonoGame.Framework/Audio/SoundEffect.OpenAL.cs b/MonoGame.Framework/Audio/SoundEffect.OpenAL.cs
index 86a31c1ff..c6f1b02c6 100644
--- a/MonoGame.Framework/Audio/SoundEffect.OpenAL.cs
+++ b/MonoGame.Framework/Audio/SoundEffect.OpenAL.cs
@@ -157,14 +157,14 @@ namespace Microsoft.Xna.Framework.Audio
private void PlatformInitializeXact(MiniFormatTag codec, byte[] buffer, int channels, int sampleRate, int blockAlignment, int loopStart, int loopLength, out TimeSpan duration)
{
- if (codec == MiniFormatTag.Adpcm)
- {
- PlatformInitializeAdpcm(buffer, 0, buffer.Length, sampleRate, (AudioChannels)channels, (blockAlignment + 16) * channels, loopStart, loopLength);
- duration = TimeSpan.FromSeconds(SoundBuffer.Duration);
- return;
- }
-
- throw new NotSupportedException("Unsupported sound format!");
+ //if (codec == MiniFormatTag.Adpcm)
+ //{
+ //PlatformInitializeAdpcm(buffer, 0, buffer.Length, sampleRate, (AudioChannels)channels, (blockAlignment + 16) * channels, loopStart, loopLength);
+ //duration = TimeSpan.FromSeconds(SoundBuffer.Duration);
+ //return;
+ //}
+
+ //throw new NotSupportedException("Unsupported sound format!");
}
#endregion
diff --git a/MonoGame.Framework/Audio/SoundEffect.cs b/MonoGame.Framework/Audio/SoundEffect.cs
index ff0e8ff5e..3d641c20e 100644
--- a/MonoGame.Framework/Audio/SoundEffect.cs
+++ b/MonoGame.Framework/Audio/SoundEffect.cs
@@ -58,7 +58,7 @@ namespace Microsoft.Xna.Framework.Audio
}
// Everything else is platform specific.
- PlatformInitializeFormat(header, buffer, bufferSize, loopStart, loopLength);
+ //PlatformInitializeFormat(header, buffer, bufferSize, loopStart, loopLength);
}
// Only used from XACT WaveBank.
diff --git a/MonoGame.Framework/Audio/SoundEffectInstance.cs b/MonoGame.Framework/Audio/SoundEffectInstance.cs
index 14e3092fd..d6c4a5198 100644
--- a/MonoGame.Framework/Audio/SoundEffectInstance.cs
+++ b/MonoGame.Framework/Audio/SoundEffectInstance.cs
@@ -161,7 +161,7 @@ namespace Microsoft.Xna.Framework.Audio
if (!_isXAct)
PlatformSetVolume(_volume * SoundEffect.MasterVolume);
- PlatformPlay();
+ //PlatformPlay();
}
/// <summary>Resumes playback for a SoundEffectInstance.</summary>
diff --git a/MonoGame.Framework/FrameworkDispatcher.cs b/MonoGame.Framework/FrameworkDispatcher.cs
index 94ba46c4b..71d14fe0c 100644
--- a/MonoGame.Framework/FrameworkDispatcher.cs
+++ b/MonoGame.Framework/FrameworkDispatcher.cs
@@ -39,7 +39,7 @@ namespace Microsoft.Xna.Framework
private static void Initialize()
{
// Initialize sound system
- SoundEffect.InitializeSoundEffect();
+ //SoundEffect.InitializeSoundEffect();
_initialized = true;
}
diff --git a/MonoGame.Framework/SDL/SDL2.cs b/MonoGame.Framework/SDL/SDL2.cs
index 743b4c05e..94cd56177 100644
--- a/MonoGame.Framework/SDL/SDL2.cs
+++ b/MonoGame.Framework/SDL/SDL2.cs
@@ -38,14 +38,14 @@ internal static class Sdl
else if (CurrentPlatform.OS == OS.Linux)
ret = FuncLoader.LoadLibrary("libSDL2-2.0.so.0");
else
- ret = FuncLoader.LoadLibrary("libSDL2-2.0.0.dylib");
+ ret = FuncLoader.LoadLibrary("libSDL2.so");
}
// Welp, all failed, PANIC!!!
- if (ret == IntPtr.Zero)
- throw new Exception("Failed to load SDL library.");
+ //if (ret == IntPtr.Zero)
+ //throw new Exception("Failed to load SDL library.");
- return ret;
+ return FuncLoader.LoadLibrary("/usr/local/lib/libSDL2.so.0.6");
}
public static int Major;
diff --git a/MonoGame.Framework/SDL/SDLGamePlatform.cs b/MonoGame.Framework/SDL/SDLGamePlatform.cs
index 69b3d44d9..5bce92f0d 100644
--- a/MonoGame.Framework/SDL/SDLGamePlatform.cs
+++ b/MonoGame.Framework/SDL/SDLGamePlatform.cs
@@ -63,14 +63,14 @@ namespace Microsoft.Xna.Framework
GamePad.InitDatabase();
Window = _view = new SdlGameWindow(_game);
- try
- {
- _soundControllerInstance = OpenALSoundController.GetInstance;
- }
- catch (DllNotFoundException ex)
- {
- throw (new NoAudioHardwareException("Failed to init OpenALSoundController", ex));
- }
+ //try
+ //{
+ //_soundControllerInstance = OpenALSoundController.GetInstance;
+ //}
+ //catch (DllNotFoundException ex)
+ //{
+ //throw (new NoAudioHardwareException("Failed to init OpenALSoundController", ex));
+ //}
}
public override void BeforeInitialize ()
diff --git a/MonoGame.Framework/Utilities/FuncLoader.Android.cs b/MonoGame.Framework/Utilities/FuncLoader.Android.cs
index 35413272b..ba2e7b5f7 100644
--- a/MonoGame.Framework/Utilities/FuncLoader.Android.cs
+++ b/MonoGame.Framework/Utilities/FuncLoader.Android.cs
@@ -5,10 +5,10 @@ namespace MonoGame.Utilities
{
internal class FuncLoader
{
- [DllImport("dl")]
+ [DllImport("libs.so")]
public static extern IntPtr dlopen(string path, int flags);
- [DllImport("dl")]
+ [DllImport("libc.so")]
public static extern IntPtr dlsym(IntPtr handle, string symbol);
private const int RTLD_LAZY = 0x0001;
diff --git a/MonoGame.Framework/Utilities/FuncLoader.Desktop.cs b/MonoGame.Framework/Utilities/FuncLoader.Desktop.cs
index f3553c1f0..ef3448327 100644
--- a/MonoGame.Framework/Utilities/FuncLoader.Desktop.cs
+++ b/MonoGame.Framework/Utilities/FuncLoader.Desktop.cs
@@ -16,10 +16,10 @@ namespace MonoGame.Utilities
private class Linux
{
- [DllImport("libdl.so.2")]
+ [DllImport("__Internal")]
public static extern IntPtr dlopen(string path, int flags);
- [DllImport("libdl.so.2")]
+ [DllImport("__Internal")]
public static extern IntPtr dlsym(IntPtr handle, string symbol);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment