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
This commit is contained in:
parent
8604f16b30
commit
72bdfbc7a6
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user