multithreadingdelphisapi

I call sapi in a thread, get an error code : OLE error 80045006


---------------------------
Debugger Exception Notification
---------------------------
Project Project1.exe raised exception class EOleException with message 'OLE error 80045006'.
---------------------------
Break   Continue   Help   
---------------------------

i have called CoInitialize. My code is :

hr := CoInitialize(nil);

SpVoice := TSpVoice.Create(Application);
SpVoice.Connect;
SpVoice.Speak('Test text');

CoUninitialize;

and the error only happened when i select the neospeech voice.


Solution

  • Error 0x80045006 is SPERR_DEVICE_BUSY: Hardware device is in use by another thread or process. MSDN Says: in many older systems, audio output devices can be opened only by a single process. In versions of Windows previous to Windows XP, only a single process can open an audio input device. Therefore, SPERR_DEVICE_BUSY will return if an attempt is made to open a device that is being used by a different process or thread. In Windows XP (and higher), multiple processes can open the same audio device