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: Nicolas George <nicolas.george@normalesup.org>
Signed-off-by: Ronald S. Bultje <rsbultje@gmail.com>
This commit is contained in:
Nicolas George 2011-03-13 00:42:27 +01:00 committed by Ronald S. Bultje
parent bafa4dd3e6
commit c76374c6db
9 changed files with 13 additions and 11 deletions

View File

@ -528,7 +528,7 @@ reload:
return AVERROR_EOF; return AVERROR_EOF;
while (av_gettime() - c->last_load_time < c->target_duration*1000000) { while (av_gettime() - c->last_load_time < c->target_duration*1000000) {
if (url_interrupt_cb()) if (url_interrupt_cb())
return AVERROR(EINTR); return AVERROR_EXIT;
usleep(100*1000); usleep(100*1000);
} }
/* Enough time has elapsed since the last reload */ /* Enough time has elapsed since the last reload */

View File

@ -318,7 +318,7 @@ retry:
return AVERROR_EOF; return AVERROR_EOF;
while (av_gettime() - s->last_load_time < s->target_duration*1000000) { while (av_gettime() - s->last_load_time < s->target_duration*1000000) {
if (url_interrupt_cb()) if (url_interrupt_cb())
return AVERROR(EINTR); return AVERROR_EXIT;
usleep(100*1000); usleep(100*1000);
} }
goto retry; goto retry;
@ -328,7 +328,7 @@ retry:
ret = url_open(&s->seg_hd, url, URL_RDONLY); ret = url_open(&s->seg_hd, url, URL_RDONLY);
if (ret < 0) { if (ret < 0) {
if (url_interrupt_cb()) if (url_interrupt_cb())
return AVERROR(EINTR); return AVERROR_EXIT;
av_log(NULL, AV_LOG_WARNING, "Unable to open %s\n", url); av_log(NULL, AV_LOG_WARNING, "Unable to open %s\n", url);
s->cur_seq_no++; s->cur_seq_no++;
goto retry; goto retry;

View File

@ -238,7 +238,7 @@ static inline int retry_transfer_wrapper(URLContext *h, unsigned char *buf, int
fast_retries = FFMAX(fast_retries, 2); fast_retries = FFMAX(fast_retries, 2);
len += ret; len += ret;
if (url_interrupt_cb()) if (url_interrupt_cb())
return AVERROR(EINTR); return AVERROR_EXIT;
} }
return len; return len;
} }

View File

@ -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 * 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 * in this case by the interrupted function. 'NULL' means no interrupt
* callback is given. * callback is given.
*/ */

View File

@ -241,7 +241,7 @@ static int rtp_read(URLContext *h, uint8_t *buf, int size)
#else #else
for(;;) { for(;;) {
if (url_interrupt_cb()) if (url_interrupt_cb())
return AVERROR(EINTR); return AVERROR_EXIT;
/* build fdset to listen to RTP and RTCP packets */ /* build fdset to listen to RTP and RTCP packets */
n = poll(p, 2, 100); n = poll(p, 2, 100);
if (n > 0) { if (n > 0) {

View File

@ -1565,7 +1565,7 @@ static int udp_read_packet(AVFormatContext *s, RTSPStream **prtsp_st,
for (;;) { for (;;) {
if (url_interrupt_cb()) if (url_interrupt_cb())
return AVERROR(EINTR); return AVERROR_EXIT;
if (wait_end && wait_end - av_gettime() < 0) if (wait_end && wait_end - av_gettime() < 0)
return AVERROR(EAGAIN); return AVERROR(EAGAIN);
max_p = 0; max_p = 0;

View File

@ -73,8 +73,10 @@ static int tcp_open(URLContext *h, const char *uri, int flags)
if (ret < 0) { if (ret < 0) {
struct pollfd p = {fd, POLLOUT, 0}; struct pollfd p = {fd, POLLOUT, 0};
if (ff_neterrno() == AVERROR(EINTR)) { if (ff_neterrno() == AVERROR(EINTR)) {
if (url_interrupt_cb()) if (url_interrupt_cb()) {
ret = AVERROR_EXIT;
goto fail1; goto fail1;
}
goto redo; goto redo;
} }
if (ff_neterrno() != AVERROR(EINPROGRESS) && 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 */ /* wait until we are connected or until abort */
for(;;) { for(;;) {
if (url_interrupt_cb()) { if (url_interrupt_cb()) {
ret = AVERROR(EINTR); ret = AVERROR_EXIT;
goto fail1; goto fail1;
} }
ret = poll(&p, 1, 100); ret = poll(&p, 1, 100);

View File

@ -452,7 +452,7 @@ static int udp_read(URLContext *h, uint8_t *buf, int size)
for(;;) { for(;;) {
if (url_interrupt_cb()) if (url_interrupt_cb())
return AVERROR(EINTR); return AVERROR_EXIT;
ret = poll(&p, 1, 100); ret = poll(&p, 1, 100);
if (ret < 0) { if (ret < 0) {
if (ff_neterrno() == AVERROR(EINTR)) if (ff_neterrno() == AVERROR(EINTR))

View File

@ -2267,7 +2267,7 @@ int av_find_stream_info(AVFormatContext *ic)
read_size = 0; read_size = 0;
for(;;) { for(;;) {
if(url_interrupt_cb()){ if(url_interrupt_cb()){
ret= AVERROR(EINTR); ret= AVERROR_EXIT;
av_log(ic, AV_LOG_DEBUG, "interrupted\n"); av_log(ic, AV_LOG_DEBUG, "interrupted\n");
break; break;
} }