problem in triggering events
-
Hi all, i've developed a dialog based application, which has to respond for certain events (ex:when the sound filled in a buffer has stopped playing.. etc). To achieve this i've used the function, MsgWaitForMultipleObjects( 1, &g_hNotificationEvent,FALSE, INFINITE, QS_ALLEVENTS ); where, g_hNotificationEvent --> handle to the event to be triggered. the problem what i'm facing is,where to place this function? if i put this within OnInitDialog the application stops executing further.The problem will be solved if this function is placed within WinMain() ,but where i do i find WinMain in a dialog based MFC application? It'll be really great if someone can help me out in this. Thanks and regards, rajeev
-
Hi all, i've developed a dialog based application, which has to respond for certain events (ex:when the sound filled in a buffer has stopped playing.. etc). To achieve this i've used the function, MsgWaitForMultipleObjects( 1, &g_hNotificationEvent,FALSE, INFINITE, QS_ALLEVENTS ); where, g_hNotificationEvent --> handle to the event to be triggered. the problem what i'm facing is,where to place this function? if i put this within OnInitDialog the application stops executing further.The problem will be solved if this function is placed within WinMain() ,but where i do i find WinMain in a dialog based MFC application? It'll be really great if someone can help me out in this. Thanks and regards, rajeev
Start a separate thread to check for that, otherwise your GUI will freeze until you receive the event. Once the event is received in your thread, send a user defined message to your dialog to specify that the event is finished.
-
Hi all, i've developed a dialog based application, which has to respond for certain events (ex:when the sound filled in a buffer has stopped playing.. etc). To achieve this i've used the function, MsgWaitForMultipleObjects( 1, &g_hNotificationEvent,FALSE, INFINITE, QS_ALLEVENTS ); where, g_hNotificationEvent --> handle to the event to be triggered. the problem what i'm facing is,where to place this function? if i put this within OnInitDialog the application stops executing further.The problem will be solved if this function is placed within WinMain() ,but where i do i find WinMain in a dialog based MFC application? It'll be really great if someone can help me out in this. Thanks and regards, rajeev
Umm.. The whole thing about having an event signaled is the use of multiple threads. Since you seem to have only one thread I don't understand why you consider this solution. Why don't you post a user defined message from where you are signalling the event and write a message handler for that message instead? -- Roger
It's suppose to be hard, otherwise anybody could do it!
-
Umm.. The whole thing about having an event signaled is the use of multiple threads. Since you seem to have only one thread I don't understand why you consider this solution. Why don't you post a user defined message from where you are signalling the event and write a message handler for that message instead? -- Roger
It's suppose to be hard, otherwise anybody could do it!
Let me explain the application more clearly. i've a demodulator hardware which keeps pumping out some sound data which is being feed to a sound card. I've used "DirectX" to achieve this. when the sound fed to the card has finished playing ,the application has to be notified so that it can fill the buffer with new data and play it again.This process has to repeat continuously. Please let me know whether using MsgWaitForMultipleObjects(...)is a good idea ? rajeev -- modified at 6:54 Thursday 27th April, 2006
-
Let me explain the application more clearly. i've a demodulator hardware which keeps pumping out some sound data which is being feed to a sound card. I've used "DirectX" to achieve this. when the sound fed to the card has finished playing ,the application has to be notified so that it can fill the buffer with new data and play it again.This process has to repeat continuously. Please let me know whether using MsgWaitForMultipleObjects(...)is a good idea ? rajeev -- modified at 6:54 Thursday 27th April, 2006
rajeev82 wrote:
MsgWaitForMultipleObjects(...)is a good idea ?
It depends on how you know when your demodulator has finished feeding the sound card... If it signals an event, then I suggest you create a worker thread simply waits for the event with WaitFormUltipleObjects(), presumably there's no need to process messages. If a message gets posted you write a message handler and restart the feeding process from there. To be able to help you futher we need to know how you can tell when the demodulator has finished feeding the sound card. -- Roger
It's suppose to be hard, otherwise anybody could do it!
-
Let me explain the application more clearly. i've a demodulator hardware which keeps pumping out some sound data which is being feed to a sound card. I've used "DirectX" to achieve this. when the sound fed to the card has finished playing ,the application has to be notified so that it can fill the buffer with new data and play it again.This process has to repeat continuously. Please let me know whether using MsgWaitForMultipleObjects(...)is a good idea ? rajeev -- modified at 6:54 Thursday 27th April, 2006
The demodulator doesnt feed the data to the sound card directly.Itz my program which collects the data from the demodulator and feeds it to the sound card so that it can be heard.the sound which comes out from the demodulator is in chunks of 4096 points. In directx there is a interface called IDirectSoundNotify which will notify my application when one chunk of 4096 has been played ,so that the next 4096 points can be loaded ,played and so on. as long my application runs the demodulator will work and it'll pump out something(atleast noise).so please tell me how to call a function according to the notification i receive. rajeev
-
The demodulator doesnt feed the data to the sound card directly.Itz my program which collects the data from the demodulator and feeds it to the sound card so that it can be heard.the sound which comes out from the demodulator is in chunks of 4096 points. In directx there is a interface called IDirectSoundNotify which will notify my application when one chunk of 4096 has been played ,so that the next 4096 points can be loaded ,played and so on. as long my application runs the demodulator will work and it'll pump out something(atleast noise).so please tell me how to call a function according to the notification i receive. rajeev
Well, given that I've understood your problem correctly I suggest the following: 1. Set up interface sinks and create objects necessary. 2. Create a worker thread that gathers the data from the demodulator and put the data in a queue which is read from... 3. a second worker thread that feeds the sound card and waits for an event which gets signalled when your app is notified using WFMO(). 4. Marshal needed interfaces to your threads before you unleash them. (Create them suspended.) This will keep the GUI responsive since the main thread is not blocked. You should also get the notification in the main thread. Read JoeNewcomer's article[^] about multithreading if you are unfamiliar with the subject. Hope this helps -- Roger
It's suppose to be hard, otherwise anybody could do it!