From 72bdfbc7a6f0a60358eb3976925ebb6a4d8ad08e Mon Sep 17 00:00:00 2001 From: Romain Vimont Date: Tue, 11 Jun 2019 17:39:50 +0200 Subject: [PATCH] Never return 0 for stream protocol On socket disconnection, on Linux, recv() returns -1 and errno is set. But on Windows, errno is 0. In that case, AVERROR(errno) == 0, leading to the warning: > Invalid return value 0 for stream protocol To avoid the problem, if errno is 0, return AVERROR_EOF. Ref: commit 2876463d394c3bc4dc239a605e65ebab75598353 --- app/src/stream.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/stream.c b/app/src/stream.c index 9a946375..4f38cecf 100644 --- a/app/src/stream.c +++ b/app/src/stream.c @@ -113,7 +113,7 @@ read_packet_with_meta(void *opaque, uint8_t *buf, int buf_size) { ssize_t r = net_recv(stream->socket, buf, buf_size); if (r == -1) { - return AVERROR(errno); + return errno ? AVERROR(errno) : AVERROR_EOF; } if (r == 0) { return AVERROR_EOF; @@ -130,7 +130,7 @@ read_raw_packet(void *opaque, uint8_t *buf, int buf_size) { struct stream *stream = opaque; ssize_t r = net_recv(stream->socket, buf, buf_size); if (r == -1) { - return AVERROR(errno); + return errno ? AVERROR(errno) : AVERROR_EOF; } if (r == 0) { return AVERROR_EOF;