Re: gdk_input_add




Sascha Ziemann <szi@aibon.ping.de> writes:

> Des Herriott <des@ops.netcom.net.uk> writes:
> 
> | > I want to play a video stream with 25 or 50 Hz.
> 
> | It sounds like you may want to use a timer rather than gdk_input_add() -
> 
> The gtk_timeout_add function seems to be intended for this, but I have
> the impression, that the video runs too slow when I use it. When I do:
> 
>   gtk_timeout_add (20, (GtkFunction) update_frame, preview);
> 
> Can I be sure that the calls to update_frame are executed with 50 Hz?
> Or does the time between two calls consists of the timeout time plus
> the time the program spends on other calculations in particular in
> update_frame itself. I think it is a bug, when the time between two
> calls to update_frame is timeout time + time to execute update_frame.

There are two issues here, reliability and accuracy.

GTK+ cannot reliably trigger timeouts exactly at a specified
interval, because the program may be, at that point, handling
a signal, or another timeout.

Accuracy is a a different matter. As you have noticed, GTK+
is currently somewhat sloppy about timeout intervals - it
treats them as minimum intervals, not exact requirements.
A timeout of 20ms that take 5ms to execute, will occur no
more frequently than every 25ms.

To do better would require calling gettimeofday() every
time through the event loop, so to avoid that overhead, I
left it the current way last time I went over the code.
A quick test reveals that on Linux/P133 gettimeofday() takes
3 microseconds per call, so perhaps the overhead of calling
gettimeofday() more frequently would be acceptable.

Regards,
                              Owen



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]