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 Map = "scm12ea.ini";
|
||||||
public string[] Packages = {}; // filename:sha1 pairs.
|
public string[] Packages = {}; // filename:sha1 pairs.
|
||||||
public string[] Mods = { "cnc" }; // mod names
|
public string[] Mods = { "ra" }; // mod names
|
||||||
public int OrderLatency = 3;
|
public int OrderLatency = 3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,8 +44,13 @@ namespace OpenRa
|
|||||||
FileSystem.MountTemporary(new Folder(dir));
|
FileSystem.MountTemporary(new Folder(dir));
|
||||||
|
|
||||||
foreach (var pkg in manifest.Packages)
|
foreach (var pkg in manifest.Packages)
|
||||||
|
if (pkg.StartsWith( "~")) // this package is optional.
|
||||||
|
try { FileSystem.MountTemporary(new Package(pkg.Substring(1))); }
|
||||||
|
catch { }
|
||||||
|
else
|
||||||
FileSystem.MountTemporary(new Package(pkg));
|
FileSystem.MountTemporary(new Package(pkg));
|
||||||
Timer.Time("mount tempory packages: {0}");
|
|
||||||
|
Timer.Time("mount temporary packages: {0}");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void ChangeMap(string mapName)
|
public static void ChangeMap(string mapName)
|
||||||
|
|||||||
@@ -136,7 +136,7 @@ namespace OpenRa
|
|||||||
{
|
{
|
||||||
float volume = 1f;
|
float volume = 1f;
|
||||||
Dictionary<int, bool> sourcePool = new Dictionary<int, bool>();
|
Dictionary<int, bool> sourcePool = new Dictionary<int, bool>();
|
||||||
const int POOL_SIZE = 100;
|
const int POOL_SIZE = 32;
|
||||||
|
|
||||||
public OpenAlSoundEngine()
|
public OpenAlSoundEngine()
|
||||||
{
|
{
|
||||||
@@ -145,17 +145,19 @@ namespace OpenRa
|
|||||||
if (dev == IntPtr.Zero)
|
if (dev == IntPtr.Zero)
|
||||||
throw new InvalidOperationException("Can't create OpenAL device");
|
throw new InvalidOperationException("Can't create OpenAL device");
|
||||||
var ctx = OpenAlInterop.alcCreateContext(dev, IntPtr.Zero);
|
var ctx = OpenAlInterop.alcCreateContext(dev, IntPtr.Zero);
|
||||||
|
if (ctx == IntPtr.Zero)
|
||||||
|
throw new InvalidOperationException("Can't create OpenAL context");
|
||||||
OpenAlInterop.alcMakeContextCurrent(ctx);
|
OpenAlInterop.alcMakeContextCurrent(ctx);
|
||||||
|
|
||||||
int[] sources = new int[POOL_SIZE];
|
for (var i = 0; i < POOL_SIZE; i++)
|
||||||
IntPtr pTemp = Marshal.AllocHGlobal(sizeof(int) * POOL_SIZE);
|
{
|
||||||
OpenAlInterop.alGenSources(POOL_SIZE, pTemp);
|
var source = 0;
|
||||||
Marshal.Copy(pTemp, sources, 0, POOL_SIZE);
|
OpenAlInterop.alGenSources(1, out source);
|
||||||
Marshal.FreeHGlobal(pTemp);
|
if (0 != OpenAlInterop.alGetError())
|
||||||
|
throw new InvalidOperationException("failed generating source {0}".F(i));
|
||||||
foreach (int source in sources)
|
|
||||||
sourcePool.Add(source, false);
|
sourcePool.Add(source, false);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
int GetSourceFromPool()
|
int GetSourceFromPool()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -51,8 +51,14 @@ namespace OpenRa.Support
|
|||||||
[DllImport("OpenAL32.dll")]
|
[DllImport("OpenAL32.dll")]
|
||||||
public static extern void alBufferData(int buffer, int format, byte[] data, int size, int freq);
|
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")]
|
[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")]
|
[DllImport("OpenAL32.dll")]
|
||||||
public static extern void alSourcef(int source, int param, float value);
|
public static extern void alSourcef(int source, int param, float value);
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ Folders:
|
|||||||
./
|
./
|
||||||
|
|
||||||
Packages:
|
Packages:
|
||||||
main.mix
|
~main.mix
|
||||||
redalert.mix
|
redalert.mix
|
||||||
conquer.mix
|
conquer.mix
|
||||||
hires.mix
|
hires.mix
|
||||||
|
|||||||
Reference in New Issue
Block a user