And another development arrives.
So I tried adding a try...catch around my call to SoundBuffer.loadFromFile(), and while it is obviously erroring (I put an error message in there) since I caught the error, it actually goes on to load and play the sound fine. I have no freaking idea what's going on at this point.
Here's the most basic code you could want to test it:
module main;
import dsfml.audio;
import dsfml.graphics;
import dsfml.window;
import std.stdio;
void main(string[] args)
{
// new Soundboard().run();
auto window = new RenderWindow(VideoMode(1280, 720), "Virtual Soundboard", Window.Style.Titlebar | Window.Style.Close);
auto buffer = new SoundBuffer();
auto sound = new Sound();
writeln("Buffer and Sound instantiated");
try
{
if(!buffer.loadFromFile("F:\\Soundboard\\Ogg\\AirLeak.ogg"))
return;
writeln("Buffer loaded");
}
catch
{
writeln("Error loading file to buffer");
}
sound.setBuffer(buffer);
sound.play();
while (window.isOpen())
{
Event event;
while(window.pollEvent(event))
{
if(event.type == Event.EventType.Closed)
{
window.close();
}
}
window.clear(Color.Black);
window.display();
}
}
Just put in whatever sound file you want for the buffer and try commenting the try...catch. It'll freeze. But with it in there, it tells you in the console that there was an error loading the buffer (which I believe, if you run it without the try catch, it will tell you is an access violation in that line), but then successfully plays it before starting the main loop.
EDIT: This hack only seems to work for OGG files. Try to do that with a WAV and it will still freeze the program. And when the OGG file continues, it actually gives a core.exception.InvalidMemoryOperationError instead of an access violation. This is extremely weird...
EDIT 2: Even with that hack, it doesn't work every time, and I can't track down why not.
EDIT 3: ACK! It appears that every fifth time I run the program it works, and every now and then it will even load WAVs on that successful run. WHAT THE HECK IS GOING ON?! LOL. This is so perplexing.