What's new

DX Callback (DirectSound)

Doomulation

?????????????????????????
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?
 

Cyberman

Moderator
Moderator
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? :)
 
OP
Doomulation

Doomulation

?????????????????????????
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.
 

tooie

New member
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...
 

Cyberman

Moderator
Moderator
: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.
 

tooie

New member
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.
 
OP
Doomulation

Doomulation

?????????????????????????
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 ;)
 

Top