Merge commit '55a215ba63d9fa79cd7ee265ee2e777ee86b200c'
authorMichael Niedermayer <michaelni@gmx.at>
Wed, 12 Mar 2014 01:33:27 +0000 (02:33 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Wed, 12 Mar 2014 01:34:02 +0000 (02:34 +0100)
* commit '55a215ba63d9fa79cd7ee265ee2e777ee86b200c':
  http: Return meaningful error codes

Merged-by: Michael Niedermayer <michaelni@gmx.at>
1  2 
libavformat/http.c

@@@ -974,29 -737,22 +974,29 @@@ static int64_t http_seek(URLContext *h
  
      if (whence == AVSEEK_SIZE)
          return s->filesize;
 +    else if ((whence == SEEK_CUR && off == 0) || (whence == SEEK_SET && off == s->off))
 +        return s->off;
      else if ((s->filesize == -1 && whence == SEEK_END) || h->is_streamed)
-         return -1;
+         return AVERROR(ENOSYS);
  
 -    /* we save the old context in case the seek fails */
 -    old_buf_size = s->buf_end - s->buf_ptr;
 -    memcpy(old_buf, s->buf_ptr, old_buf_size);
 -    s->hd = NULL;
      if (whence == SEEK_CUR)
          off += s->off;
      else if (whence == SEEK_END)
          off += s->filesize;
 +    else if (whence != SEEK_SET)
 +        return AVERROR(EINVAL);
 +    if (off < 0)
 +        return AVERROR(EINVAL);
      s->off = off;
  
 +    /* we save the old context in case the seek fails */
 +    old_buf_size = s->buf_end - s->buf_ptr;
 +    memcpy(old_buf, s->buf_ptr, old_buf_size);
 +    s->hd = NULL;
 +
      /* if it fails, continue on old connection */
      av_dict_copy(&options, s->chained_options, 0);
-     if (http_open_cnx(h, &options) < 0) {
+     if ((ret = http_open_cnx(h, &options)) < 0) {
          av_dict_free(&options);
          memcpy(s->buffer, old_buf, old_buf_size);
          s->buf_ptr = s->buffer;