View Full Version : DX Callback (DirectSound)

January 3rd, 2003, 17:19
I'm looking in how to use directx callbacks (directsound). I find it more suitable than using a main loop. And the fact that i can't use one without creating a new thread, which i don't know how to do.

Anyway, I think i know how to create the callback. But i don't know, however, how to declare the callback function. And if it's possible to declare a specified function as callback function?

January 5th, 2003, 02:23
Welcome to the land of Microshaft..

Well I can't answer your question I only use threads sparingly as it is.

However .. there should be examples of call backs somewhere..

Sort of like Ms's discusion of sockets (argh) they didn't tell you how to do it, instead they told you how convenient it was (scratches head). Anyhow if you have to have a call back function I think it is dependant on the block of code you use it with. It has to be thread safe as well. So be wary of ANY GUI function calling.

it will probably be of type
void __fastcall <fnc>() and whatever pararmeters are passed.

Would be nice if one could automagically have the function generated for call backs huh? :)

January 6th, 2003, 00:22
Yeah. Silly microsoft. They always leave out the important.
However, though, i was able to find out and do a little seperate thread loop to recieve the messages. That works nicely :)

Although there is one very funny thing i've found. When passing the address of a function in vb and converting this to a function pointer, this pointer can ONLY be used in exported function which the app must CALL. If not, you get access violation, lol.

January 6th, 2003, 03:40
Doom I am not sure how you are calling the function .. but VB does not like code being called at all by a thread it did not create. So if you have another thread running checking messages it is not allowed to call any vb functions .. VB can not handle threads at all...

January 6th, 2003, 06:21
:cry: Are you saying VB is thread bare? ;)

Sorry I just couldn't resist it.

That would explain why VB lags horribly a lot when I am doing things serial IO and socket IO simultaneously.

January 6th, 2003, 22:35
it is possible to create controls that have multiple threads in them .. but if they are passing data back to VB then it must be in the thread that created the control. Not any it created.

January 7th, 2003, 12:23
Yeah, i noticed that. Vb sux. I made an alternative way, however. By passing an integer by reference, which recieves the messages as they approach, vb can check them in a loop and respond to them. Pretty guinius i think imo.

Oh, and it also checks if there IS a message. If not, then it merly stops. Since I put it in a timer. I'm going to try n' enhance it even more as well, by passing the enabled property so c++ can enable it when a message has arrived ;)