Mercurial > libavformat.hg
comparison aviobuf.c @ 5253:a2289b41a9f2 libavformat
Make get_buffer and get_partial_buffer return url_ferror or AVERROR_EOF as
appropriate if it couldn't read any data at all.
This should make handling of EOF and error simpler or make it work right without
extra code in a few place (e.g. raw demuxer).
author | reimar |
---|---|
date | Fri, 02 Oct 2009 06:36:39 +0000 |
parents | 37da30baa62d |
children | ff81ddf5de81 |
comparison
equal
deleted
inserted
replaced
5252:ae691877fdea | 5253:a2289b41a9f2 |
---|---|
413 buf += len; | 413 buf += len; |
414 s->buf_ptr += len; | 414 s->buf_ptr += len; |
415 size -= len; | 415 size -= len; |
416 } | 416 } |
417 } | 417 } |
418 if (size1 == size) { | |
419 if (url_ferror(s)) return url_ferror(s); | |
420 if (url_feof(s)) return AVERROR_EOF; | |
421 } | |
418 return size1 - size; | 422 return size1 - size; |
419 } | 423 } |
420 | 424 |
421 int get_partial_buffer(ByteIOContext *s, unsigned char *buf, int size) | 425 int get_partial_buffer(ByteIOContext *s, unsigned char *buf, int size) |
422 { | 426 { |
432 } | 436 } |
433 if (len > size) | 437 if (len > size) |
434 len = size; | 438 len = size; |
435 memcpy(buf, s->buf_ptr, len); | 439 memcpy(buf, s->buf_ptr, len); |
436 s->buf_ptr += len; | 440 s->buf_ptr += len; |
441 if (!len) { | |
442 if (url_ferror(s)) return url_ferror(s); | |
443 if (url_feof(s)) return AVERROR_EOF; | |
444 } | |
437 return len; | 445 return len; |
438 } | 446 } |
439 | 447 |
440 unsigned int get_le16(ByteIOContext *s) | 448 unsigned int get_le16(ByteIOContext *s) |
441 { | 449 { |