Reputation: 622
I am trying to initialize Direct Sound the following way:
// Somewhere in my header...
#define DIRECT_SOUND_CREATE(name) HRESULT WINAPI name(LPCGUID pcGuidDevice, LPDIRECTSOUND *ppDS, LPUNKNOWN pUnkOuter)
typedef DIRECT_SOUND_CREATE(direct_sound_create);
// Initialization code...
HMODULE DSoundLib = LoadLibraryA("dsound.dll");
if(DSoundLib)
{
direct_sound_create *DirectSoundCreate = (direct_sound_create*)
GetProcAddress(DSoundLib, "DirectSoundCreate");
LPDIRECTSOUND DirectSound;
if(DirectSoundCreate && SUCCEEDED(DirectSoundCreate(0, &DirectSound,0)))
{
The issue is that I am getting this error(?)
onecore\com\combase\objact\objact.cxx(812)\combase.dll!75521B90: (caller: 7552093B) ReturnHr(1) tid(2444) 800401F0 CoInitialize has not been called.
Could anyone tell what this is/is related to? Do I need to call CoInitialize when using DirectSound or can I bypass COM stuff?
Here are my linker options:
set CommonLinkerFlags= -incremental:no -nodefaultlib -stack:0x100000,0x100000 ^
kernel32.lib ^
user32.lib ^
gdi32.lib ^
winmm.lib
Upvotes: 0
Views: 695
Reputation: 37587
There is no way to use Direct Sound without COM because it is COM-based. The very first call you make DirectSoundCreate
, creates an instance of object implementing IDirectSound
COM interface. Documentation mentions that explicit COM initialization is not required in some situations. But it is a good idea to manually perform it anyway to be on the safe side. CoInitialize
is mandatory when dealing with COM stuff. Typically this should be on of the first things to do at application initialization, before creating windows / renders. And don't forget to call CoUninitialize
when you done working with COM.
Upvotes: 1