[FFmpeg-devel] rtsp.c udp_read_packet() fails to return when stream ends, simple fix
Ronald S. Bultje
rsbultje
Thu Mar 25 20:12:18 CET 2010
Hi,
On Thu, Mar 25, 2010 at 1:44 PM, Sam Gerstein <sgerstein at bluefinlab.com> wrote:
> It wasn't apparent to me what is the correct way of passing
> configuration down to this code, so here it is with a constant
> defined. ?Pointers on configuration would be welcome, as would be any
> comments on style, etc. -
[..]
> +#define SELECT_TIMEOUT_MS 100
> +#define READ_PACKET_TIMEOUT_S 10
[..]
> + int fd, fd_max, n, i, ret, tcp_fd, timeout_cnt, max_timeouts;
> struct timeval tv;
>
> + timeout_cnt = 0;
> + max_timeouts = READ_PACKET_TIMEOUT_S * 1000 / SELECT_TIMEOUT_MS;
int timeout_cnt = 0 can go in the variable declaration. max_timeouts
can be a define since it's constant (so #define at top).
> + } else if (n == 0) {
> + /* select() timed out */
> + if (++timeout_cnt >= max_timeouts) {
> + return AVERROR(ETIME);
> + }
> + } else {
> + if (errno != EINTR) {
> + /* select() encountered an error*/
> + return AVERROR(errno);
> + }
} else if (n == 0 && ++timeout_cnt >= MAX_TIMEOUTS) {
return AVERROR(ETIME);
} else if (errno != EINTR)
return errno;
4 lines instead of 10. :-).
Ronald
More information about the ffmpeg-devel
mailing list