DLL thread in the pit daddy's synchronize?

Source: Internet
Author: User

1, origin

Developed a voice-to-Talk Windows program, using the Delphi language, and the Delphix tdxsound control.

The Dxsound provides a Tsoundcapturestream class that allows you to record sound cards for a specified frequency, number of digits, and channel. In its Onfilledbuffer event processing, the audio data is sent to the specified device for streaming intercom.

First write a Test exe program, run OK. It then needs to encapsulate its functionality as a DLL function for other applications to invoke when it is developed, encapsulating it and finding that the microphone's sound is not being sent out. WTF?

2, analysis

Debug found that the callback event code in Onfilledbuffer has not been executed since the call DLL started the talkback function. This does not exist in the EXE program. Remember that Udpserver control has a similar problem, if not set to its Threadedevent property is true, then its Onudpread event in the DLL is basically not receiving any information.

But are there similar property settings in Dxsound? View the source code of the Dxsounds unit and discover that Tsoundcapturestream has a fnotifythread attribute (another thread!). ), when the Start method is called to begin capturing the sound card, a tsoundcapturestreamnotify notification thread is created, and the notification thread calls the Synchronize (Update) method to send the sound card information to the main thread.

Query data found that if the project file is a DLL instead of EXE, application default does not create a window handle, so synchronize send a message to application will not respond at all.

See also: https://www.cnblogs.com/enli/archive/2010/09/28/1837728.html

3, solve

The solution is also to use the method provided above, in the DLL's L project file to add the following statement, problem resolution.

application.initialize; if 0  Then begin     Application.createhandle; End ; Application.Run;

DLL thread in the pit daddy's synchronize?

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.