|
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..
Cheers
Vaclav
|
|
|
|
|
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 .
|
|
|
|
|
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.
Thanks for your help, back to coding.
|
|
|
|
|
Hi Developers,
I am using SHA160 algo to generate hash key of a file. I need to store & get it from a table. I am taking hash key in CString variable and try to store it in a TEXT field.
First of all this value is not getting store.
When I execute any query based on that hash key like
CString sTemp;
sTemp.Format(_T( "Select * From MEDIA_MAT Where RemedyID = '%d' And HashKey = '%s' And ID <> %d"), m_strTable, m_lngParentID, strHashValue, *m_lngID );
if( !rsAccessMedia.IsEOF() )
At the last line application get break, It can continue but hash key is not getting stored.
Pls help me out.
Thanks.
Amrit Agrawal
|
|
|
|
|
Hi,
Your CString.Format() has 3 type fields but your passing 4 arguments.
Best Wishes,
-David Delaune
|
|
|
|
|
Format() is a variable parameter function, interface and the Printf() similar: void Format( LPCTSTR lpszFormat, ... ); You can reference MSDN
|
|
|
|
|
Hi,
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.
-David Delaune
|
|
|
|
|
Are you from the United States?
|
|
|
|
|
Are you from the moon?
The best things in life are not things.
|
|
|
|
|
so ?
Watched code never compiles.
|
|
|
|
|
Hi All,
Where can I get the source code of
Begining ATL 3 COM programming
|
|
|
|
|
If there is no URL mentioned in the book then a Google search is probably your best bet. I notice that this book is more than 10 years old so it may well no longer be available.
The best things in life are not things.
|
|
|
|
|
Hi all,
i have an Dialog box here i am having 4 EditBoxes.
all editboxes have some values i want on button click event on this dialog box open a url page that also have 4 editbox(input box).
now page display the values of dialog editbox into the page Input boxes.
please help me how can i do this.
thanks in advance.
|
|
|
|
|
|
Hi all,
i have an problem to convert a CString value in const std::string.
CString result="";
CString str="test";
const std::string s = str;
std::string s1 = fun1(s);
result=s1.c_str();
please help me for this.
thanks in advance.
|
|
|
|
|
How to: Convert Between Various String Types ->[^]
"Every Little Smile can touch Somebody's Heart...
May we find Hundreds of Reasons to Smile Everyday... and
May WE be the Reason for someone else to smile always!" (ICAN)
"Your thoughts are the architects of your destiny."
|
|
|
|
|
|
Are you building for Unicode or MBCS? I think you're building for Unicode, but are using the ANSI version of std string. Try the following:
CString sz = L"Hello";
const std::wstring str = sz;
CStringA sz = "Hello";
const std::string str = sz;
"Real men drive manual transmission" - Rajesh.
|
|
|
|
|
thanks
but now one more error is generated
'fun1' : cannot convert parameter 1 from 'const std::wstring' to 'const std::string &'
and fun1 is like this
std::string fun1 (std::string const& s);
|
|
|
|
|
You need to be consistent in your class selections, use all unicode or all MBCS. If you are using Unicode then you need to use the std::wstring class rather than string .
The best things in life are not things.
|
|
|
|
|
Or use std::tstring[^] and not have to worry about it at all.
Independent ACN representative | -- Check out the possibilities for your future! | -- Financial independance | -- Full time or Part time | -- In more than 20 countries through North America, Europe, Asia and the Pacific |
Within you lies the power for good - Use it!
|
|
|
|
|
PJ Arends wrote: Or use std::tstring[^] and not have to worry about it at all.
A simple typedef, something like
#if defined(UNICODE)
typedef std::wstring STRING
#else
typedef std::string STRING
#endif
would also do it, since both are implementations of basic_string and its functions.
The best things in life are not things.
|
|
|
|
|
|
Hi. It looks like this: there is a worker thread, which just runs and there is a button, which when clicked, should send some data to this worker thread. And now i am thinking, how this can be done. First off, i am a little bit skeptical about pipes and global variables. More real-life example would be something like this:
1. There is a thread.
2. There is a dialog window which accepts files. When file is dropped on this dialog window, thread should be notified that new file has been dropped and receive an open handle to this file and a file name.
I was thinking about user mode APC but actually dont know if using this i can communicate with a thread or change its context, influence its variables, access its variables, modify them and use them - that would be great but the only thing i did so far with APC is terminating a thread.
Another scenario i can thinks of, is having some global structure, update it time to time, signal thread so it will know that our struct has been filled with some new info so the thread can grab it - but yet again, global variables - not so good.
Is there some "clear" and nice way of doing this?
Thanks
011011010110000101100011011010000110100101101110
0110010101110011
|
|
|
|
|
Short answer: You'll use WaitForSingleObject[^] to wait on an event, critical section, or so (depending on your scenario). The event should be triggered (SetEvent[^]) when a file is dropped that needs processing.
csrss wrote:
Is there some "clear" and nice way of doing this?
If you're using MFC, you could use an UI thread[^] (the name is weird - an UI thread need not necessarily be associated with an UI). If you do it, you'll just post a message to the message pump of the thread and the thread will pick it off its queue and process it. This is an easy way, but it is an overkill if the thread is just supposed to do only one type of job (as opposed to doing different things based on the message posted to its queue).
"Real men drive manual transmission" - Rajesh.
|
|
|
|