Mercurial > libavformat.hg
comparison aviobuf.c @ 1787:eb16c64144ee libavformat
This fixes error handling for BeOS, removing the need for some ifdefs.
AVERROR_ defines are moved to avcodec.h as they are needed in there as well. Feel free to move that to avutil/common.h.
Bumped up avcodec/format version numbers as though it's binary compatible we will want to rebuild apps as error values changed.
Please from now on use return AVERROR(EFOO) instead of the ugly return -EFOO in your code.
This also removes the need for berrno.h.
author | mmu_man |
---|---|
date | Tue, 13 Feb 2007 18:26:14 +0000 |
parents | fa70e732d2db |
children | 3328f652d741 |
comparison
equal
deleted
inserted
replaced
1786:8cc34fe98a3b | 1787:eb16c64144ee |
---|---|
115 { | 115 { |
116 offset_t offset1; | 116 offset_t offset1; |
117 offset_t pos= s->pos - (s->write_flag ? 0 : (s->buf_end - s->buffer)); | 117 offset_t pos= s->pos - (s->write_flag ? 0 : (s->buf_end - s->buffer)); |
118 | 118 |
119 if (whence != SEEK_CUR && whence != SEEK_SET) | 119 if (whence != SEEK_CUR && whence != SEEK_SET) |
120 return -EINVAL; | 120 return AVERROR(EINVAL); |
121 | 121 |
122 if (whence == SEEK_CUR) { | 122 if (whence == SEEK_CUR) { |
123 offset1 = pos + (s->buf_ptr - s->buffer); | 123 offset1 = pos + (s->buf_ptr - s->buffer); |
124 if (offset == 0) | 124 if (offset == 0) |
125 return offset1; | 125 return offset1; |
134 offset1 >= 0 && offset1 < (s->buf_end - s->buffer) + (1<<16)){ | 134 offset1 >= 0 && offset1 < (s->buf_end - s->buffer) + (1<<16)){ |
135 while(s->pos < offset && !s->eof_reached) | 135 while(s->pos < offset && !s->eof_reached) |
136 fill_buffer(s); | 136 fill_buffer(s); |
137 s->buf_ptr = s->buf_end + offset - s->pos; | 137 s->buf_ptr = s->buf_end + offset - s->pos; |
138 } else { | 138 } else { |
139 offset_t res = -EPIPE; | 139 offset_t res = AVERROR(EPIPE); |
140 | 140 |
141 #if defined(CONFIG_MUXERS) || defined(CONFIG_NETWORK) | 141 #if defined(CONFIG_MUXERS) || defined(CONFIG_NETWORK) |
142 if (s->write_flag) { | 142 if (s->write_flag) { |
143 flush_buffer(s); | 143 flush_buffer(s); |
144 s->must_flush = 1; | 144 s->must_flush = 1; |
169 offset_t url_fsize(ByteIOContext *s) | 169 offset_t url_fsize(ByteIOContext *s) |
170 { | 170 { |
171 offset_t size; | 171 offset_t size; |
172 | 172 |
173 if (!s->seek) | 173 if (!s->seek) |
174 return -EPIPE; | 174 return AVERROR(EPIPE); |
175 size = s->seek(s->opaque, 0, AVSEEK_SIZE); | 175 size = s->seek(s->opaque, 0, AVSEEK_SIZE); |
176 if(size<0){ | 176 if(size<0){ |
177 if ((size = s->seek(s->opaque, -1, SEEK_END)) < 0) | 177 if ((size = s->seek(s->opaque, -1, SEEK_END)) < 0) |
178 return size; | 178 return size; |
179 size++; | 179 size++; |
509 } else { | 509 } else { |
510 buffer_size = IO_BUFFER_SIZE; | 510 buffer_size = IO_BUFFER_SIZE; |
511 } | 511 } |
512 buffer = av_malloc(buffer_size); | 512 buffer = av_malloc(buffer_size); |
513 if (!buffer) | 513 if (!buffer) |
514 return -ENOMEM; | 514 return AVERROR(ENOMEM); |
515 | 515 |
516 if (init_put_byte(s, buffer, buffer_size, | 516 if (init_put_byte(s, buffer, buffer_size, |
517 (h->flags & URL_WRONLY || h->flags & URL_RDWR), h, | 517 (h->flags & URL_WRONLY || h->flags & URL_RDWR), h, |
518 url_read_packet, url_write_packet, url_seek_packet) < 0) { | 518 url_read_packet, url_write_packet, url_seek_packet) < 0) { |
519 av_free(buffer); | 519 av_free(buffer); |
528 int url_setbufsize(ByteIOContext *s, int buf_size) | 528 int url_setbufsize(ByteIOContext *s, int buf_size) |
529 { | 529 { |
530 uint8_t *buffer; | 530 uint8_t *buffer; |
531 buffer = av_malloc(buf_size); | 531 buffer = av_malloc(buf_size); |
532 if (!buffer) | 532 if (!buffer) |
533 return -ENOMEM; | 533 return AVERROR(ENOMEM); |
534 | 534 |
535 av_free(s->buffer); | 535 av_free(s->buffer); |
536 s->buffer = buffer; | 536 s->buffer = buffer; |
537 s->buffer_size = buf_size; | 537 s->buffer_size = buf_size; |
538 s->buf_ptr = buffer; | 538 s->buf_ptr = buffer; |