ReadyRead synchronous issue
-
Hi,Guys
I have an problem in implementing a udp socket buffer behavior in QT,
anyone can help me?The details:I want to create a buffer to hold coming data,the "ReadyRead" slot is responsible for recieving.
After i recieve the packet,i want to play the packet which is in audio format.
The playing part is also implemented inside "ReadyRead" function.
The thing is when I play the packet,the "ReadyRead" blocked,did not recieve packet anymore,
which will cause the packet recieving delay.how can make the recieving and playing synchronous?
Thanks.
-
Hi,
you should consider to source out the "playing" (or the reading) into a different thread, so "reading" and "playing" can happen "simultaneously". Well reading will in fact always be some time ahead. Keep in mind how Youtube does and shows it in co-operation with your browser with the gray and red part of the progress bar.
I would call this pattern where one part does not wait on another to finish "asynchronous", though.
-Michael. -
If you do a lengthy operation in the slot the events are waiting in a queue and nothing else is happening with your program. You need to use threads. Either put the UDP communication in a separate thread or the playback in a separate thread.