Since I needed a way to stop / disable COM port DTR signal I have ventured into unknown territory of multithreading . I am making progress.
Now I need to use same approach to start / stop audio recording.
I am using waveInOpen function with CALLBACK_FUNTION.
Upon receiving the WIM_DATA the callback function will run the worker thread.
However,waveInOpen has an option to use CALLBACK_THREAD and I am unable to find any examples on how it can be used.
Since using callback can be challenging, it is for me, I like the callback function giving me feedback aka – WIM_OPEN.
How can I get that response from CALLBACK_THREAD / worker thread?
I am coding in VC++ / MFC, please do not waste your and mine time suggesting alternative development tools.
Any constructive help will be as always appreciated..
Use can use CreateThread to first create a thread.
The last parameter of CreateThread will give you the identifier of the thread that you pass in the dwCallback parameter of waveInOpen.
In the thread function, you can have a GetMessage loop to retrieve the messages being sent to the thread which are MM_WIM_OPEN, MM_WIM_CLOSE, and MM_WIM_DATA.
«_Superman_» I love work. It gives me something to do between weekends.
Are you saying I need to use user interface thread because I need to intercept the wave messages? Makes sense.
But I think I am making things unnecessary complex,I think I can get away with just using the CALLBACK function.
I can start the recording in the dialog without creating worker thread. I can get an event from "Stop" button ( that is what I am after) while the audio file is updating, however, my waveInStop does not work, not yet.
Thank you for that little golden nugget of Tai Chi wisdom. I'm going back through all of my old code to add some extra arguments to all of the functions accepting variable argument lists. Because the I-Ching uses a set of 64 hexagrams I'll make sure to pass a minimum of six arguments to each function.