[Qt-interest] QTimer on Windows in Unreliable for Small (16ms - 30ms) Delays
Girish Ramakrishnan
girish at forwardbias.in
Sat Sep 5 06:23:55 CEST 2009
The very late arrival of timer event could very well be some bug in Qt,
so you should report it, if you are convinced that your code is correct.
That said, QTimer uses the system timer which is unreliable and
inaccurate. You should use the Windows Multimedia Timers if you
something accurate. In fact, QTimer uses multimedia timers for interval
< 10ms (maybe it's <= 10ms, not sure). You can either use 8ms timer and
process every alternate one or use the Windows MM Timer Api directly.
Girish
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
>
>
More information about the Qt-interest-old
mailing list