Commit c76374c6 authored by Nicolas George's avatar Nicolas George Committed by Ronald S. Bultje
Browse files

Use AVERROR_EXIT with url_interrupt_cb.



Functions interrupted by url_interrupt_cb should not be restarted.
Therefore using AVERROR(EINTR) was wrong, as it did not allow to distinguish
when the underlying system call was interrupted and actually needed to be
restarted.

This fixes roundup issues 2657 and 2659 (ffplay not exiting for streamed
content).
Signed-off-by: default avatarNicolas George <nicolas.george@normalesup.org>
Signed-off-by: default avatarRonald S. Bultje <rsbultje@gmail.com>
parent bafa4dd3
......@@ -528,7 +528,7 @@ reload:
return AVERROR_EOF;
while (av_gettime() - c->last_load_time < c->target_duration*1000000) {
if (url_interrupt_cb())
return AVERROR(EINTR);
return AVERROR_EXIT;
usleep(100*1000);
}
/* Enough time has elapsed since the last reload */
......
......@@ -318,7 +318,7 @@ retry:
return AVERROR_EOF;
while (av_gettime() - s->last_load_time < s->target_duration*1000000) {
if (url_interrupt_cb())
return AVERROR(EINTR);
return AVERROR_EXIT;
usleep(100*1000);
}
goto retry;
......@@ -328,7 +328,7 @@ retry:
ret = url_open(&s->seg_hd, url, URL_RDONLY);
if (ret < 0) {
if (url_interrupt_cb())
return AVERROR(EINTR);
return AVERROR_EXIT;
av_log(NULL, AV_LOG_WARNING, "Unable to open %s\n", url);
s->cur_seq_no++;
goto retry;
......
......@@ -238,7 +238,7 @@ static inline int retry_transfer_wrapper(URLContext *h, unsigned char *buf, int
fast_retries = FFMAX(fast_retries, 2);
len += ret;
if (url_interrupt_cb())
return AVERROR(EINTR);
return AVERROR_EXIT;
}
return len;
}
......
......@@ -237,7 +237,7 @@ void url_get_filename(URLContext *h, char *buf, int buf_size);
/**
* The callback is called in blocking functions to test regulary if
* asynchronous interruption is needed. AVERROR(EINTR) is returned
* asynchronous interruption is needed. AVERROR_EXIT is returned
* in this case by the interrupted function. 'NULL' means no interrupt
* callback is given.
*/
......
......@@ -241,7 +241,7 @@ static int rtp_read(URLContext *h, uint8_t *buf, int size)
#else
for(;;) {
if (url_interrupt_cb())
return AVERROR(EINTR);
return AVERROR_EXIT;
/* build fdset to listen to RTP and RTCP packets */
n = poll(p, 2, 100);
if (n > 0) {
......
......@@ -1565,7 +1565,7 @@ static int udp_read_packet(AVFormatContext *s, RTSPStream **prtsp_st,
for (;;) {
if (url_interrupt_cb())
return AVERROR(EINTR);
return AVERROR_EXIT;
if (wait_end && wait_end - av_gettime() < 0)
return AVERROR(EAGAIN);
max_p = 0;
......
......@@ -73,8 +73,10 @@ static int tcp_open(URLContext *h, const char *uri, int flags)
if (ret < 0) {
struct pollfd p = {fd, POLLOUT, 0};
if (ff_neterrno() == AVERROR(EINTR)) {
if (url_interrupt_cb())
if (url_interrupt_cb()) {
ret = AVERROR_EXIT;
goto fail1;
}
goto redo;
}
if (ff_neterrno() != AVERROR(EINPROGRESS) &&
......@@ -84,7 +86,7 @@ static int tcp_open(URLContext *h, const char *uri, int flags)
/* wait until we are connected or until abort */
for(;;) {
if (url_interrupt_cb()) {
ret = AVERROR(EINTR);
ret = AVERROR_EXIT;
goto fail1;
}
ret = poll(&p, 1, 100);
......
......@@ -452,7 +452,7 @@ static int udp_read(URLContext *h, uint8_t *buf, int size)
for(;;) {
if (url_interrupt_cb())
return AVERROR(EINTR);
return AVERROR_EXIT;
ret = poll(&p, 1, 100);
if (ret < 0) {
if (ff_neterrno() == AVERROR(EINTR))
......
......@@ -2267,7 +2267,7 @@ int av_find_stream_info(AVFormatContext *ic)
read_size = 0;
for(;;) {
if(url_interrupt_cb()){
ret= AVERROR(EINTR);
ret= AVERROR_EXIT;
av_log(ic, AV_LOG_DEBUG, "interrupted\n");
break;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment