Can i get a deadlock?
I am playing a little with recording from the soundcard and im wondering if i can write the samples to the disk (using fwrite) from withing the callback function. MSDN states te folowing:
Applications should not call any system-defined functions from inside a callback function, except for EnterCriticalSection, LeaveCriticalSection, midiOutLongMsg, midiOutShortMsg, OutputDebugString, PostMessage, PostThreadMessage, SetEvent, timeGetSystemTime, timeGetTime, timeKillEvent, and timeSetEvent.Calling other wave functions will cause deadlock.
(from http://msdn.microsoft.com/library/de...waveinproc.asp )
I believe this is a little ambiguous. Should i NOT call system functions, or should i NOT call wave functions. What does "system functions" mean anyway? Are that all function from windows??
In this scenario, I'm faily certain they mean all system functions. By system functions, they are referring to windows API functions. You should still be able to make calls into the C runtime library, just make sure you use the multithreaded version of the CRT.
I don't think the documentation is saying that any system function will cause a dead lock. To me, it's saying first that you shouldn't call any system functions from the callback and second thatthe wave functions will cause deadlock. (Maybe the callback needs to be accomplished in some amount of tmie?) I would just follow the documentation in this situatiion. I'd call PostMessage or PostThreadMessage to direct the message to my own thread or main window and handle it from there.