Jump to content
  • Advertisement
Sign in to follow this  
Chett2001

Multi-threading? [Solved]

This topic is 4063 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey, im wondering how tricky it is to do multithreading? Basically the problem im having it i have developed a 3d application with a user interface and im doing the following using microsoft text to speech:
if(playAudio==true)
		{
				
				if(bPageOnePlayed==true)
				{
				int lTts;
			    lTts =iTts;
				lTts++;
				ISpVoice * pVoice = NULL;
				char* ansistr = "error, no text found";
				ansistr = myPage.pageArray[lTts];
				int a = lstrlenA(ansistr);
				BSTR unicodestr = SysAllocStringLen(NULL, a);
				
				::MultiByteToWideChar(CP_ACP, 0, ansistr, a, unicodestr, a);
				::SysFreeString(unicodestr);
				CoInitialize(NULL);
				HRESULT hr = CoCreateInstance(CLSID_SpVoice, NULL, CLSCTX_ALL, IID_ISpVoice, (void **)&pVoice);
				
    if( SUCCEEDED( hr ) )
			{
				hr = pVoice->Speak(unicodestr, 0, NULL); 
				pVoice->Release();
				pVoice = NULL;
			}
The problem? when the text to speech is engaged nothing happens, this small function seems to hold the CPU's attention till the text has finished, the same is true of a mock up test i did for playing a wav file:
if( ::GetAsyncKeyState('Q') & 0x8000f )
				{
					if(iSound<1)
					{
		    PlaySound("drac1.wav", NULL, SND_FILENAME);
				iSound++;
					}
				}
			}
So does this sort of thing require multithreading? if so does anyone has some simple examples of how to implement it (im still very much a noobie). The over all goal is to be able to interact with the user interface whilst the sound is playing, efficiency isnt a big issue i simply need to get this prototype working as best it can :D Im using C++ with native directX if it helps. [Edited by - Chett2001 on June 2, 2007 5:17:49 PM]

Share this post


Link to post
Share on other sites
Advertisement
1. Use the Async flag for the Speak command. That means it will not halt the CPU while speaking.

2. Use WaitForSingleObject() to wait for the speaking to finish if you want your thread to wait.

Share this post


Link to post
Share on other sites
Wow thanks i cant believe i missed the tag for 1, anyone got a solution for the wav file issue?

edit:Cool i found a similar tag for playSound, thanks for your help HeadKaze, appreciated.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!