[Qt-interest] QTimer on Windows in Unreliable for Small (16ms - 30ms) Delays
Jeffrey Brendecke
jwbrendecke at icanetix.com
Sat Sep 5 05:37:29 CEST 2009
Could disk access be tying up the system?
I don't think the QTimer can be considered reliable. It will try to time out
when it can, but there is no guarantee that it will. The documentation
mentions discarding timeouts.
Maybe you could consider something like the following involving a couple of
threads. Using more than one thread at a time comes with its own set of
problems, so there are many things to consider before trying it out.
* Put the rendering in one thread: This reads the info from the disk and
generates a small queue of frames to be shown. For fluid replay, it would be
necessary to keep this queue from getting empty at all time.
* Use a reliable timer that does not discard ticks. I don't know what this
would be.
* In the main thread, on each time out, pull a rendered frame from the queue
and display it. If the ticks are not getting swallowed due to whatever
external constraints, then it seems the rendering would need to give,
stopping rendering and going on to the next frame if it did not finish in
time. Maybe some sort of interlacing could result in at least the frame
getting covered from top to bottom, though not on every line.
It seems this should work, but the implementation would be very difficult and
involve a good understanding of the control mechanisms necessary in
coordinating the threads.
Then again, there may be something already out there. I have not used Phonon.
I had trouble getting it to compile with its many dependencies when it first
came out and have not tried it since. If you are clear as to why you are not
using Phonon, maybe someone could help you out with it.
----------------------
On Saturday 05 September 2009 05:10:08 Josiah Bryan wrote:
> I realize I may be out of line here and this may not be
> "feasible"....but, I'll ask anyway!
>
> I'm trying to do video playback with Qt. (The end goal is some video
> with text over top - song lyrics for church and the like.) I'm using
> ffmpeg (libavcodec, etc) as the decoder. No problems there - works
> great. The problem comes in getting the frame onto the screen in a
> timely fashion.
>
> I've got the code to compute the optimal delay between frames, based on
> elapsed time, etc. It normally works out to around 33ms for a 30 fps
> video. I set a timer that throws a signal once the time is up for that
> frame. The other end of that signal just draws the frame.
>
> The problem, specifically, is that about once every 20 - 60 frames, the
> timer wacks out and doesn't fire for around 1000 ms - no where *near*
> the requested 30ms or whatever.
>
> I'm just doing:
> QTimer::singleShot(actual_delay, this, SLOT(displayFrame()));
>
> I've tried *everything* I can think of to figure out why its randomly
> taking way longer than requested - raised the priority of the executable
> thru task manager, using a QTimer object instead of
> QTimer::singleShot(), any other misc ideas I can think of. I've been
> googling for *everything* - no answers, nothing seems to help. I've even
> seen metion of something like qt_win_simple_timers or something like
> that - compile errors, didn't help. I tried using windows timer queues -
> I forget the function names - but compile errors there.
>
> Anyway, anyone have any ideas? Or, even alternatives to playing videos
> in QT? (Phonon isn't working for me.)
>
> Thanks,
> -josiah
>
>
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
More information about the Qt-interest-old
mailing list