Désolé pour mon anglais , je suis francais .
I see on the forum that many people have a crash when they use Callback in the EXE COMPILED FILE. (and not in IDE)
See that :
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.
That’s the reason why the application crash. ( i see the example when u want to get the title of a net stream).
Solution : Use the function PostMessage and make subclassing.
- Anonymous asked 13 years ago
I actually do believe that the same rules apply. At least in theory a callback always works the same way no matter how you implement it. As duch has already pointed out, it’s “illegal” to make API calls inside a callback, probably because of the way they’re executed. While PostMessage is safe as it only sends a message to a queue and doesn’t lock execution. The reason why it works inside the IDE is probably because the execution is done in other threads than the program itself.
Working with that theory I simply fired a timer inside the callback and let it do the calls to extract Artist and Title from the stream. However fmod apparently clears the memory location as soon as it’s been sent to the callback because if there’s a heavy load, the return value is nothing. The timer simply cannot guarantee retreival of the data before it’s wiped. Using postmessage is therefore much better but adds ?stupid? extra work in VB, as is the case with the timer too.
I’m not at all familiar with how fmod works, really, nor do I have any reason to believe I can solve this as the rules of VB are written in stone and meant to be worked around rather than broken down.
But, however, it would be simpler if either:
* The memory was not wiped – this way it could be polled at any time and the callback would simply just tell me that it has been updated.
* Instead of an address, the actual string stored there was sent. This way, no added calls would be needed in the callback to extract the data.
It all works very slick in C++ but this is VB and I would rather see simplified tools for retreiving the data in both languages than tearing my hair reading up on exceptions and twirks in VB. Just because it’s easy to do advanced things in C it doesn’t mean it is in VB. Oftentimes it’s more difficult to do the really advanced things in VB as opposed to C++ where the really easy things mostly looks like a hairball of code.
True, but rather than pointing to the location where it was stored it’d be easier if the string came along with the calling of the callback – as a string value. A bit crude though and I wouldn’t really recommend it in a C environment as the “tools” to do it otherwise is there.
On the memory thing, I mean the storage space for title and artist. I assume it’s not reused for something else. When fmod has new information to put there, it could simply use metadatacallback to alert the program that new info is to be fetched and keep the info there. As it is now, as soon as the callback is finished there’s very little time before that space is cleared. Trying to get the strings a few seconds after the callback will result in a blank or just garbage.
Please login first to submit.