My engine will init allegro inside the DLL on startup and will shut it down before it terminates. When al_install_audio is called, it will hang 100 percent of the time. Why? I worked around the issue by making sure audio init/shutdown is done from the calling process (the EXE). Just wondering what is the problem as all the other init routines work without any apparent issues.
I initialise allegro sound from within a dll as well but it works for me.
I initialise allegro sound from within a dll as well but it works for me.
Interesting. I've had this problem since I've first started using Allegro with Delphi. It's been on my list of things to investigate so I figure I would see if I can get to the bottom of it. I will keep digging.
Are you using global init or do you call an install function?
This is stupid but try initializing audio before installing the keyboard and mouse.
This is stupid but try initializing audio before installing the keyboard and mouse.
no, a good idea actually but sadly the same result
Can you debug this? Step into al_install_audio, and see where it hangs.
Can you debug this? Step into al_install_audio, and see where it hangs.
Wish I could. Rem I'm using Delphi (Object Pascal). I can step up to the function call is all.
How did you build / link to allegro?
What libraries did you use and where did you get them?
You have to convert .h headers to Delphi (object pascal), and just ref as external routines.
void my_cfunction(void);
procedure my_cfunction; cdecl; external 'allegro5.dll';
compile this and you can directly call my_cfunction in Pascal.
The binaries from https://github.com/liballeg/allegro5/releases, 32bit monolithic version
Does allegro.log get created?
You can enable it in release mode by doing...
al_set_config_value(al_get_system_config(), "trace", "level", "debug")
ok, good call. Log attached. Thx.
stops at this line:
audio-dsound I dsound.cpp:271 _dsound_open [ 2.27177] Starting DirectSound...
Ok, useful info there. Thx for that.
In Delphi, it has the concept of a unit and can have an init/final section:
There is where I usually init and shut down the engine when the DLL loads into the calling process. What I will do to see if it makes a diff is call from DLL_PROCESS_ATTACH/DLL_PROCESS_DETACH.
Bump for news of progress
nope, still hangs and there are other issues with the dllmain approach. I discovered that delphi unit init/final methods is safer, the RTL will call in the proper order and they only run once so Engine_Init/Shutdown only runs once. Will keep digging. Thanks for your help bro.
Hmm... what is the difference between calling DirectSoundCreate8(NULL, &device, NULL) inside DLL vs outside I wonder?
Edit 1:
I found this - http://forums.codeguru.com/showthread.php?407844-DirectSoundCreate8-wont-initialize-in-DLL
He suggests calling from main EXE which is the only way I got it to work.
Right, I don't Engine::Init in dllmain but in EagleSystem::Initialize which the user calls from main. At least that's what I see being described here.