allow optional mixes again; fix openal so it can *tell* when it fails to allocate sources, rather than just copying 400 bytes of ununitialized garbage into our managed space
This commit is contained in:
@@ -31,7 +31,7 @@ namespace OpenRa.FileFormats
|
||||
{
|
||||
public string Map = "scm12ea.ini";
|
||||
public string[] Packages = {}; // filename:sha1 pairs.
|
||||
public string[] Mods = { "cnc" }; // mod names
|
||||
public string[] Mods = { "ra" }; // mod names
|
||||
public int OrderLatency = 3;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,8 +44,13 @@ namespace OpenRa
|
||||
FileSystem.MountTemporary(new Folder(dir));
|
||||
|
||||
foreach (var pkg in manifest.Packages)
|
||||
FileSystem.MountTemporary(new Package(pkg));
|
||||
Timer.Time("mount tempory packages: {0}");
|
||||
if (pkg.StartsWith( "~")) // this package is optional.
|
||||
try { FileSystem.MountTemporary(new Package(pkg.Substring(1))); }
|
||||
catch { }
|
||||
else
|
||||
FileSystem.MountTemporary(new Package(pkg));
|
||||
|
||||
Timer.Time("mount temporary packages: {0}");
|
||||
}
|
||||
|
||||
public static void ChangeMap(string mapName)
|
||||
|
||||
@@ -136,7 +136,7 @@ namespace OpenRa
|
||||
{
|
||||
float volume = 1f;
|
||||
Dictionary<int, bool> sourcePool = new Dictionary<int, bool>();
|
||||
const int POOL_SIZE = 100;
|
||||
const int POOL_SIZE = 32;
|
||||
|
||||
public OpenAlSoundEngine()
|
||||
{
|
||||
@@ -145,16 +145,18 @@ namespace OpenRa
|
||||
if (dev == IntPtr.Zero)
|
||||
throw new InvalidOperationException("Can't create OpenAL device");
|
||||
var ctx = OpenAlInterop.alcCreateContext(dev, IntPtr.Zero);
|
||||
if (ctx == IntPtr.Zero)
|
||||
throw new InvalidOperationException("Can't create OpenAL context");
|
||||
OpenAlInterop.alcMakeContextCurrent(ctx);
|
||||
|
||||
int[] sources = new int[POOL_SIZE];
|
||||
IntPtr pTemp = Marshal.AllocHGlobal(sizeof(int) * POOL_SIZE);
|
||||
OpenAlInterop.alGenSources(POOL_SIZE, pTemp);
|
||||
Marshal.Copy(pTemp, sources, 0, POOL_SIZE);
|
||||
Marshal.FreeHGlobal(pTemp);
|
||||
|
||||
foreach (int source in sources)
|
||||
for (var i = 0; i < POOL_SIZE; i++)
|
||||
{
|
||||
var source = 0;
|
||||
OpenAlInterop.alGenSources(1, out source);
|
||||
if (0 != OpenAlInterop.alGetError())
|
||||
throw new InvalidOperationException("failed generating source {0}".F(i));
|
||||
sourcePool.Add(source, false);
|
||||
}
|
||||
}
|
||||
|
||||
int GetSourceFromPool()
|
||||
|
||||
@@ -51,8 +51,14 @@ namespace OpenRa.Support
|
||||
[DllImport("OpenAL32.dll")]
|
||||
public static extern void alBufferData(int buffer, int format, byte[] data, int size, int freq);
|
||||
|
||||
//[DllImport("OpenAL32.dll")]
|
||||
//public static extern void alGenSources(int n, IntPtr sources);
|
||||
|
||||
[DllImport("OpenAL32.dll")]
|
||||
public static extern void alGenSources(int n, IntPtr sources);
|
||||
public static extern void alGenSources(int one, out int source);
|
||||
|
||||
[DllImport("OpenAL32.dll")]
|
||||
public static extern int alGetError();
|
||||
|
||||
[DllImport("OpenAL32.dll")]
|
||||
public static extern void alSourcef(int source, int param, float value);
|
||||
|
||||
@@ -4,7 +4,7 @@ Folders:
|
||||
./
|
||||
|
||||
Packages:
|
||||
main.mix
|
||||
~main.mix
|
||||
redalert.mix
|
||||
conquer.mix
|
||||
hires.mix
|
||||
|
||||
Reference in New Issue
Block a user