On 01.05.2013 01:31, Fred van Stappen wrote:
This about audio and fpc and fpGUI and LCL and Linux. (working good with
Windows)
Have some trouble with threads synchronize() procedure.
The main thread.execute is a loop to read-write audio data.
Inside the loop i use synchronize(myProc) to synchronize some graphic
component ( like taskbar.position, position.text,...). With LCL the
graphic synchro is good and the quality of sound is ok and not altered
with synchronize(myProc). With fpGui the synchro is good but not the
quality of sound.
Some audio chunk are omitted when using synchronize(myProc).

I was thinking that the reason was the Graphic-refresh  but it is not.
If i do a synchronize(dummyproc) i have the same bad result.
Without synchronize(dummyproc), the sound is perfect.
Here some code :


With Synchronize you need to keep in mind that the execution of the calling thread will be blocked until the given method was executed in the context of the main thread. So if the main thread doesn't call CheckSynchronize often enough your thread will hang longer (Note: CheckSynchronize is internally called by the event loop of the widgetset). Like Silvio said if you use FPC 2.7.1 you should use the new Queue method instead of Synchronize, because this won't block the calling thread. Alternatively you could try to use Application.QueueAsyncCall (only available for LCL applications).


I have a test example for Linux 64 bit.

There are 3 binaries from same code : fpGUI, GTK2, Qt.

On the fpGUI demo, there are 3 checkboxs more,
- With syhchro Grahic
- With synchro Dummy
- Without syhchro

On my slow computer, the sound is altered while using synchro, even if the proc 
is dummy !
Why, what do synchronize() if the procedure is dummy ?

Do you use fpGUI directly or fpGUI through the LCL?
In both cases it could be the case that the event loop is doing a CheckSynchronize to seldomly. Maybe you should better ask this on the lazarus mailing list, so that the Lazarus devs could adjust this if it is a problem in the fpGUI glue code for the LCL.

Regards,
Sven
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to