Message ID | 20200115165434.14282-1-anthony.2lannoy@gmail.com |
---|---|
State | Superseded |
Headers | show |
Series | [FFmpeg-devel] lavf/libsrt: nonblock enabling correction | expand |
Context | Check | Description |
---|---|---|
andriy/ffmpeg-patchwork | success | Make fate finished |
On Wed, 15 Jan 2020, Anthony Delannoy wrote: > As written in https://github.com/Haivision/srt/blob/v1.4.1/docs/API.md, > the nonblock mode is activated if SRTO_SNDSYN and SRTO_RCVSYN, for > sending and receiving respectively, are set to 0. > --- > libavformat/libsrt.c | 10 +++++----- > 1 file changed, 5 insertions(+), 5 deletions(-) > > diff --git a/libavformat/libsrt.c b/libavformat/libsrt.c > index 16975b6d94..60b1dd8e9c 100644 > --- a/libavformat/libsrt.c > +++ b/libavformat/libsrt.c > @@ -152,12 +152,12 @@ static int libsrt_neterrno(URLContext *h) > return AVERROR_UNKNOWN; > } > > -static int libsrt_socket_nonblock(int socket, int enable) > +static int libsrt_socket_nonblock(int socket, int disable) So if you want to enable nonblocking mode you'd have to call libsrt_socket_nonblock(socket, 0). That is just ugly. I suggest you either - rename the function to libsrt_socket_block() or - keep the function declaration as is and do the negation inside the function and add a comment that it is intentional. Regards, Marton > { > - int ret = srt_setsockopt(socket, 0, SRTO_SNDSYN, &enable, sizeof(enable)); > + int ret = srt_setsockopt(socket, 0, SRTO_SNDSYN, &disable, sizeof(disable)); > if (ret < 0) > return ret; > - return srt_setsockopt(socket, 0, SRTO_RCVSYN, &enable, sizeof(enable)); > + return srt_setsockopt(socket, 0, SRTO_RCVSYN, &disable, sizeof(disable)); > } > > static int libsrt_network_wait_fd(URLContext *h, int eid, int fd, int write) > @@ -235,7 +235,7 @@ static int libsrt_listen(int eid, int fd, const struct sockaddr *addr, socklen_t > ret = srt_accept(fd, NULL, NULL); > if (ret < 0) > return libsrt_neterrno(h); > - if (libsrt_socket_nonblock(ret, 1) < 0) > + if (libsrt_socket_nonblock(ret, 0) < 0) > av_log(h, AV_LOG_DEBUG, "libsrt_socket_nonblock failed\n"); > > return ret; > @@ -245,7 +245,7 @@ static int libsrt_listen_connect(int eid, int fd, const struct sockaddr *addr, s > { > int ret; > > - if (libsrt_socket_nonblock(fd, 1) < 0) > + if (libsrt_socket_nonblock(fd, 0) < 0) > av_log(h, AV_LOG_DEBUG, "ff_socket_nonblock failed\n"); > > while ((ret = srt_connect(fd, addr, addrlen))) { > -- > 2.24.1 > > _______________________________________________ > ffmpeg-devel mailing list > ffmpeg-devel@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-devel > > To unsubscribe, visit link above, or email > ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
As requested I negate the value inside the function instead of using directly the input. Regards, Anthony Delannoy
diff --git a/libavformat/libsrt.c b/libavformat/libsrt.c index 16975b6d94..60b1dd8e9c 100644 --- a/libavformat/libsrt.c +++ b/libavformat/libsrt.c @@ -152,12 +152,12 @@ static int libsrt_neterrno(URLContext *h) return AVERROR_UNKNOWN; } -static int libsrt_socket_nonblock(int socket, int enable) +static int libsrt_socket_nonblock(int socket, int disable) { - int ret = srt_setsockopt(socket, 0, SRTO_SNDSYN, &enable, sizeof(enable)); + int ret = srt_setsockopt(socket, 0, SRTO_SNDSYN, &disable, sizeof(disable)); if (ret < 0) return ret; - return srt_setsockopt(socket, 0, SRTO_RCVSYN, &enable, sizeof(enable)); + return srt_setsockopt(socket, 0, SRTO_RCVSYN, &disable, sizeof(disable)); } static int libsrt_network_wait_fd(URLContext *h, int eid, int fd, int write) @@ -235,7 +235,7 @@ static int libsrt_listen(int eid, int fd, const struct sockaddr *addr, socklen_t ret = srt_accept(fd, NULL, NULL); if (ret < 0) return libsrt_neterrno(h); - if (libsrt_socket_nonblock(ret, 1) < 0) + if (libsrt_socket_nonblock(ret, 0) < 0) av_log(h, AV_LOG_DEBUG, "libsrt_socket_nonblock failed\n"); return ret; @@ -245,7 +245,7 @@ static int libsrt_listen_connect(int eid, int fd, const struct sockaddr *addr, s { int ret; - if (libsrt_socket_nonblock(fd, 1) < 0) + if (libsrt_socket_nonblock(fd, 0) < 0) av_log(h, AV_LOG_DEBUG, "ff_socket_nonblock failed\n"); while ((ret = srt_connect(fd, addr, addrlen))) {