[FFmpeg-devel] [PATCH] UDP hangs with no input data

Michael Niedermayer michaelni
Wed Nov 12 21:33:54 CET 2008


On Tue, Nov 11, 2008 at 03:20:47PM +0100, Jindrich Makovicka wrote:
> On Tue, Nov 11, 2008 at 14:58, Ronald S. Bultje <rsbultje at gmail.com> wrote:
> > Hi,
> >
> > On Tue, Nov 11, 2008 at 8:47 AM, Jindrich Makovicka <makovick at gmail.com> wrote:
> >> when there are no incoming packets on the specified UDP address/port,
> >> libavformat waits indefinitely, and can be only terminated using
> >> SIGKILL. The attached patches add
> >>
> >> 1) UDP receive timeout, which is 10 seconds by default, and adjustable
> >> in the URL, and
> >
> > Can you do something that unifies tcp.c and udp.c behaviour? tcp.c
> > uses interrupt_cb() (top of tcp_read()) and that callback can
> > implement a timeout or interrupt signal handler (such as a cancel
> > button in a UI) or whatever. udp.c might do something like that as
> > well. there's better approaches, but the two should do the same.
> >
> > If you like the interrupt_cb() idea (in general), this could be moved
> > to an instance vfunc callback instead of a global vfunc and/or it
> > could be given some useful context arguments so we can actually use it
> > in client code as well (object-based, not ust ffmpeg/ffplay) without
> > having to access any global arguments at all (similar to av_log
> > callbacks etc.).
> >
> > If you do it well, you don't have to edit code to add an interrupt
> > handler or change the timeout time value or whatever, but you can just
> > use the instance-specific callback function, implement it one line
> > differently and you have a configurable timeout, inetrrupt handler et
> > al at once.
> 
> Thanks for suggestion. New patch attached.
[...]
> @@ -426,6 +427,11 @@
>           * avoid losing data on OSes that set this too low by default. */
>          tmp = UDP_MAX_PKT_SIZE;
>          setsockopt(udp_fd, SOL_SOCKET, SO_RCVBUF, &tmp, sizeof(tmp));
> +        tv.tv_sec = 0;
> +        tv.tv_usec = 100 * 1000;
> +        if (setsockopt(udp_fd, SOL_SOCKET, SO_RCVTIMEO, &tv, sizeof(tv)) < 0) {

posix says "Note that not all implementations allow this option to be set."
i dont know how relevant this is ...

[...]

> @@ -448,6 +454,8 @@
>              if (ff_neterrno() != FF_NETERROR(EAGAIN) &&
>                  ff_neterrno() != FF_NETERROR(EINTR))
>                  return AVERROR(EIO);
> +            if (url_interrupt_cb())
> +                return AVERROR(EINTR);
>          } else {
>              break;
>          }

that looks ok

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

In fact, the RIAA has been known to suggest that students drop out
of college or go to community college in order to be able to afford
settlements. -- The RIAA
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20081112/da79c005/attachment.pgp>



More information about the ffmpeg-devel mailing list