PDA

View Full Version : Painting output of phono/video widget to QImage from worked thread in QT



vivek.m
14th July 2010, 13:39
In my QT application, I am using phonon's video widget to play video. This video widget is added to main scene using proxy widget.

I have observed that when the video is playing, repaint messages are sent regularly to scene around 40 times in a second. Also, each call to refresh the video widget takes around 20 ms. Now if I have 5 such video widgets, then all these video widgets will send repaint commands to main view and 20*5 = 100 ms will be lost in just repainting them.

This is causing unacceptable delay in our application when the user is interacting very quickly e.g. mouse messages in quick succession while video is playing. In 100 ms, you will on average lose around 10 mouse messages which is a lot.

My idea is to repaint these video frames on a separate background image in a separate thread and only copy the exposed-rect part from background image to screen during paint event which will bring down the 20 ms repaint time to micro-seconds. You can consider it equivalent to video widget doing all its painting on QImage.

For this, I created a separate thread and tried repainting the video widget onto a QImage. But my code fails inside drawWidget routine in qwidget.cpp while sending a spontaneous repaint event to widget (Line 5339, qwidget.cpp) with the error that sending events to object from thread other than owner thread is not allowed.

Any workaround or alternate approaches to my problem?

wysota
14th July 2010, 16:34
I don't think Phonon can paint on anything but a widget and the widget itself is controlled by another process so I'd assume you can access the wideo from the widget as well as it probably doesn't go through Qt's backbuffer. And I'm sure you know you can't paint to widgets in worker threads so using phonon there is probably out of a question.