[FFmpeg-devel] [PATCH] add timeout to udp_read
Reimar Döffinger
Reimar.Doeffinger
Sun Dec 27 12:31:38 CET 2009
On Sun, Dec 27, 2009 at 12:11:39PM +0100, Stefano Sabatini wrote:
> static VideoState *global_video_state;
> +static int64_t network_timeout_reference_time = 0;
> +static int64_t network_timeout = INT64_MAX;
>
> static int decode_interrupt_cb(void)
> {
> + int64_t network_timeout_delta;
> +
> + if (network_timeout_reference_time &&
> + (network_timeout_delta = (av_gettime() - network_timeout_reference_time) / 1000) > network_timeout) {
Please initialize network_timeout_delta at its declaration, this is
really ugly like this.
I think it would also be a good idea to protect against the clock being
reset by detecting av_gettime() < network_timeout_reference_time and
adjusting network_timeout_reference_time.
> +static int opt_network_timeout(const char *opt, const char *arg)
> +{
> + /* reduced max boundary due to the precision of double at INT64_MAX */
> + network_timeout = parse_number_or_die(opt, arg, OPT_INT64, 0, INT64_MAX - 20000);
You do realize that we are talking about a timeout of 292 million years
here? I think there'll be plenty of other reasons for things to "time
out" before.
Just going with INT32_MAX would still allow a timeout of almost 25 days,
which is probably more than probably networking stack will allow (except
maybe one designed for deep space exploration...).
More information about the ffmpeg-devel
mailing list