[Qt-interest] QTimer on Windows in Unreliable for Small (16ms - 30ms) Delays
Pau Garcia i Quiles
pgquiles at elpauer.org
Sat Sep 5 11:58:18 CEST 2009
Hello,
We have seen issues with QTimer on Windows, too, when you ask for a
tiny interval or the system is under high load. The reason for this
broken behavior is QTimer essentially counts events on Windows. A
better approach would be to call GetTickCount or
QueryPerformanceCounter. On Unix, QTimer uses clock_gettime, which
works fine.
For now we are using ACE timers (
http://www.cs.wustl.edu/~schmidt/ACE.html ) instead of QTimers where
we see problems.
That being, said, your problem is probably not due to QTimer but due
to the latency of the Phonon backend (DirectX under Windows).
Different backends behave different: some have a longer latency than
others. Some will support a feature, others won't. This very issue,
failing to playing very short media files, we have found to happen
with DirectX (Windows), Xine (Linux), GStreamer (Linux) and VLC
(Linux). VLC behaved a bit better than the others did but still failed
in some cases.
On Sat, Sep 5, 2009 at 5:10 AM, Josiah
Bryan<jbryan at productiveconcepts.com> 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
>
--
Pau Garcia i Quiles
http://www.elpauer.org
(Due to my workload, I may need 10 days to answer)
More information about the Qt-interest-old
mailing list