Mercurial > libavformat.hg
changeset 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 | 8cc34fe98a3b |
children | 6dd0da50623a |
files | audio.c avformat.h avio.c avio.h aviobuf.c beosaudio.cpp ffm.c file.c framehook.c gifdec.c grab.c grab_bktr.c http.c img2.c mpeg.c mpegts.c rtpproto.c smacker.c sol.c tcp.c udp.c utils.c v4l2.c wv.c x11grab.c |
diffstat | 25 files changed, 64 insertions(+), 81 deletions(-) [+] |
line wrap: on
line diff
--- a/audio.c Tue Feb 13 08:21:47 2007 +0000 +++ b/audio.c Tue Feb 13 18:26:14 2007 +0000 @@ -224,7 +224,7 @@ st = av_new_stream(s1, 0); if (!st) { - return -ENOMEM; + return AVERROR(ENOMEM); } s->sample_rate = ap->sample_rate; s->channels = ap->channels;
--- a/avformat.h Tue Feb 13 08:21:47 2007 +0000 +++ b/avformat.h Tue Feb 13 18:26:14 2007 +0000 @@ -25,8 +25,8 @@ extern "C" { #endif -#define LIBAVFORMAT_VERSION_INT ((51<<16)+(9<<8)+0) -#define LIBAVFORMAT_VERSION 51.9.0 +#define LIBAVFORMAT_VERSION_INT ((51<<16)+(10<<8)+0) +#define LIBAVFORMAT_VERSION 51.10.0 #define LIBAVFORMAT_BUILD LIBAVFORMAT_VERSION_INT #define LIBAVFORMAT_IDENT "Lavf" AV_STRINGIFY(LIBAVFORMAT_VERSION) @@ -433,14 +433,6 @@ /* no av_open for output, so applications will need this: */ AVFormatContext *av_alloc_format_context(void); -#define AVERROR_UNKNOWN (-1) /* unknown error */ -#define AVERROR_IO (-2) /* i/o error */ -#define AVERROR_NUMEXPECTED (-3) /* number syntax expected in filename */ -#define AVERROR_INVALIDDATA (-4) /* invalid data found */ -#define AVERROR_NOMEM (-5) /* not enough memory */ -#define AVERROR_NOFMT (-6) /* unknown format */ -#define AVERROR_NOTSUPP (-7) /* operation not supported */ - int av_find_stream_info(AVFormatContext *ic); int av_read_packet(AVFormatContext *s, AVPacket *pkt); int av_read_frame(AVFormatContext *s, AVPacket *pkt);
--- a/avio.c Tue Feb 13 08:21:47 2007 +0000 +++ b/avio.c Tue Feb 13 18:26:14 2007 +0000 @@ -67,12 +67,12 @@ goto found; up = up->next; } - err = -ENOENT; + err = AVERROR(ENOENT); goto fail; found: uc = av_malloc(sizeof(URLContext) + strlen(filename) + 1); if (!uc) { - err = -ENOMEM; + err = AVERROR(ENOMEM); goto fail; } #if LIBAVFORMAT_VERSION_INT >= (52<<16) @@ -124,7 +124,7 @@ offset_t ret; if (!h->prot->url_seek) - return -EPIPE; + return AVERROR(EPIPE); ret = h->prot->url_seek(h, pos, whence); return ret; } @@ -188,8 +188,8 @@ /** * The callback is called in blocking functions to test regulary if - * asynchronous interruption is needed. -EINTR is returned in this - * case by the interrupted function. 'NULL' means no interrupt + * asynchronous interruption is needed. AVERROR(EINTR) is returned + * in this case by the interrupted function. 'NULL' means no interrupt * callback is given. */ void url_set_interrupt_cb(URLInterruptCB *interrupt_cb)
--- a/avio.h Tue Feb 13 08:21:47 2007 +0000 +++ b/avio.h Tue Feb 13 18:26:14 2007 +0000 @@ -65,8 +65,8 @@ 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. -EINTR is returned in this - case by the interrupted function. 'NULL' means no interrupt + asynchronous interruption is needed. AVERROR(EINTR) is returned + in this case by the interrupted function. 'NULL' means no interrupt callback is given. */ void url_set_interrupt_cb(URLInterruptCB *interrupt_cb);
--- a/aviobuf.c Tue Feb 13 08:21:47 2007 +0000 +++ b/aviobuf.c Tue Feb 13 18:26:14 2007 +0000 @@ -117,7 +117,7 @@ offset_t pos= s->pos - (s->write_flag ? 0 : (s->buf_end - s->buffer)); if (whence != SEEK_CUR && whence != SEEK_SET) - return -EINVAL; + return AVERROR(EINVAL); if (whence == SEEK_CUR) { offset1 = pos + (s->buf_ptr - s->buffer); @@ -136,7 +136,7 @@ fill_buffer(s); s->buf_ptr = s->buf_end + offset - s->pos; } else { - offset_t res = -EPIPE; + offset_t res = AVERROR(EPIPE); #if defined(CONFIG_MUXERS) || defined(CONFIG_NETWORK) if (s->write_flag) { @@ -171,7 +171,7 @@ offset_t size; if (!s->seek) - return -EPIPE; + return AVERROR(EPIPE); size = s->seek(s->opaque, 0, AVSEEK_SIZE); if(size<0){ if ((size = s->seek(s->opaque, -1, SEEK_END)) < 0) @@ -511,7 +511,7 @@ } buffer = av_malloc(buffer_size); if (!buffer) - return -ENOMEM; + return AVERROR(ENOMEM); if (init_put_byte(s, buffer, buffer_size, (h->flags & URL_WRONLY || h->flags & URL_RDWR), h, @@ -530,7 +530,7 @@ uint8_t *buffer; buffer = av_malloc(buf_size); if (!buffer) - return -ENOMEM; + return AVERROR(ENOMEM); av_free(s->buffer); s->buffer = buffer;
--- a/beosaudio.cpp Tue Feb 13 08:21:47 2007 +0000 +++ b/beosaudio.cpp Tue Feb 13 18:26:14 2007 +0000 @@ -194,15 +194,15 @@ #ifndef HAVE_BSOUNDRECORDER if (!is_output) - return -EIO; /* not for now */ + return AVERROR(EIO); /* not for now */ #endif s->input_sem = create_sem(AUDIO_BUFFER_SIZE, "ffmpeg_ringbuffer_input"); if (s->input_sem < B_OK) - return -EIO; + return AVERROR(EIO); s->output_sem = create_sem(0, "ffmpeg_ringbuffer_output"); if (s->output_sem < B_OK) { delete_sem(s->input_sem); - return -EIO; + return AVERROR(EIO); } s->input_index = 0; s->output_index = 0; @@ -226,7 +226,7 @@ delete_sem(s->input_sem); if (s->output_sem) delete_sem(s->output_sem); - return -EIO; + return AVERROR(EIO); } s->codec_id = (iformat.byte_order == B_MEDIA_LITTLE_ENDIAN)?CODEC_ID_PCM_S16LE:CODEC_ID_PCM_S16BE; s->channels = iformat.channel_count; @@ -252,7 +252,7 @@ delete_sem(s->input_sem); if (s->output_sem) delete_sem(s->output_sem); - return -EIO; + return AVERROR(EIO); } s->player->SetCookie(s); s->player->SetVolume(1.0); @@ -293,7 +293,7 @@ s->channels = st->codec->channels; ret = audio_open(s, 1, NULL); if (ret < 0) - return -EIO; + return AVERROR(EIO); return 0; } @@ -315,7 +315,7 @@ int amount; len = MIN(size, AUDIO_BLOCK_SIZE); if (acquire_sem_etc(s->input_sem, len, B_CAN_INTERRUPT, 0LL) < B_OK) - return -EIO; + return AVERROR(EIO); amount = MIN(len, (AUDIO_BUFFER_SIZE - s->input_index)); memcpy(&s->buffer[s->input_index], buf, amount); s->input_index += amount; @@ -356,7 +356,7 @@ st = av_new_stream(s1, 0); if (!st) { - return -ENOMEM; + return AVERROR(ENOMEM); } s->sample_rate = ap->sample_rate; s->channels = ap->channels; @@ -364,7 +364,7 @@ ret = audio_open(s, 0, ap->device); if (ret < 0) { av_free(st); - return -EIO; + return AVERROR(EIO); } /* take real parameters */ st->codec->codec_type = CODEC_TYPE_AUDIO; @@ -384,7 +384,7 @@ status_t err; if (av_new_packet(pkt, s->frame_size) < 0) - return -EIO; + return AVERROR(EIO); buf = (unsigned char *)pkt->data; size = pkt->size; while (size > 0) { @@ -393,7 +393,7 @@ while ((err=acquire_sem_etc(s->output_sem, len, B_CAN_INTERRUPT, 0LL)) == B_INTERRUPTED); if (err < B_OK) { av_free_packet(pkt); - return -EIO; + return AVERROR(EIO); } amount = MIN(len, (AUDIO_BUFFER_SIZE - s->output_index)); memcpy(buf, &s->buffer[s->output_index], amount);
--- a/ffm.c Tue Feb 13 08:21:47 2007 +0000 +++ b/ffm.c Tue Feb 13 18:26:14 2007 +0000 @@ -579,7 +579,7 @@ switch(ffm->read_state) { case READ_HEADER: if (!ffm_is_avail_data(s, FRAME_HEADER_SIZE)) { - return -EAGAIN; + return AVERROR(EAGAIN); } #if 0 printf("pos=%08"PRIx64" spos=%"PRIx64", write_index=%"PRIx64" size=%"PRIx64"\n", @@ -587,7 +587,7 @@ #endif if (ffm_read_data(s, ffm->header, FRAME_HEADER_SIZE, 1) != FRAME_HEADER_SIZE) - return -EAGAIN; + return AVERROR(EAGAIN); #if 0 { int i; @@ -601,7 +601,7 @@ case READ_DATA: size = (ffm->header[2] << 16) | (ffm->header[3] << 8) | ffm->header[4]; if (!ffm_is_avail_data(s, size)) { - return -EAGAIN; + return AVERROR(EAGAIN); } duration = (ffm->header[5] << 16) | (ffm->header[6] << 8) | ffm->header[7]; @@ -616,7 +616,7 @@ if (ffm_read_data(s, pkt->data, size, 0) != size) { /* bad case: desynchronized packet. we cancel all the packet loading */ av_free_packet(pkt); - return -EAGAIN; + return AVERROR(EAGAIN); } if (ffm->first_frame_in_packet) {
--- a/file.c Tue Feb 13 08:21:47 2007 +0000 +++ b/file.c Tue Feb 13 18:26:14 2007 +0000 @@ -45,7 +45,7 @@ #endif fd = open(filename, access, 0666); if (fd < 0) - return -ENOENT; + return AVERROR(ENOENT); h->priv_data = (void *)(size_t)fd; return 0; }
--- a/framehook.c Tue Feb 13 08:21:47 2007 +0000 +++ b/framehook.c Tue Feb 13 18:26:14 2007 +0000 @@ -57,7 +57,7 @@ fhe = av_mallocz(sizeof(*fhe)); if (!fhe) { - return -ENOMEM; + return AVERROR(ENOMEM); } fhe->Configure = dlsym(loaded, "Configure"); @@ -66,18 +66,18 @@ if (!fhe->Process) { av_log(NULL, AV_LOG_ERROR, "Failed to find Process entrypoint in %s\n", argv[0]); - return -1; + return AVERROR(ENOENT); } if (!fhe->Configure && argc > 1) { av_log(NULL, AV_LOG_ERROR, "Failed to find Configure entrypoint in %s\n", argv[0]); - return -1; + return AVERROR(ENOENT); } if (argc > 1 || fhe->Configure) { if (fhe->Configure(&fhe->ctx, argc, argv)) { av_log(NULL, AV_LOG_ERROR, "Failed to Configure %s\n", argv[0]); - return -1; + return AVERROR(EINVAL); } }
--- a/gifdec.c Tue Feb 13 08:21:47 2007 +0000 +++ b/gifdec.c Tue Feb 13 18:26:14 2007 +0000 @@ -305,13 +305,13 @@ /* verify that all the image is inside the screen dimensions */ if (left + width > s->screen_width || top + height > s->screen_height) - return -EINVAL; + return AVERROR(EINVAL); /* build the palette */ if (s->pix_fmt == PIX_FMT_RGB24) { line = av_malloc(width); if (!line) - return -ENOMEM; + return AVERROR(ENOMEM); } else { n = (1 << bits_per_pixel); spal = palette; @@ -537,7 +537,7 @@ s->image_linesize = s->screen_width * 3; s->image_buf = av_malloc(s->screen_height * s->image_linesize); if (!s->image_buf) - return -ENOMEM; + return AVERROR(ENOMEM); s->pix_fmt = PIX_FMT_RGB24; /* now we are ready: build format streams */ st = av_new_stream(s1, 0);
--- a/grab.c Tue Feb 13 08:21:47 2007 +0000 +++ b/grab.c Tue Feb 13 18:26:14 2007 +0000 @@ -92,7 +92,7 @@ st = av_new_stream(s1, 0); if (!st) - return -ENOMEM; + return AVERROR(ENOMEM); av_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in us */ s->width = width;
--- a/grab_bktr.c Tue Feb 13 08:21:47 2007 +0000 +++ b/grab_bktr.c Tue Feb 13 18:26:14 2007 +0000 @@ -225,7 +225,7 @@ VideoData *s = s1->priv_data; if (av_new_packet(pkt, video_buf_size) < 0) - return -EIO; + return AVERROR(EIO); bktr_getframe(s->per_frame); @@ -259,7 +259,7 @@ st = av_new_stream(s1, 0); if (!st) - return -ENOMEM; + return AVERROR(ENOMEM); av_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in use */ s->width = width; @@ -287,7 +287,7 @@ if (bktr_init(video_device, width, height, format, &(s->video_fd), &(s->tuner_fd), -1, 0.0) < 0) - return -EIO; + return AVERROR(EIO); nsignals = 0; last_frame_time = 0;
--- a/http.c Tue Feb 13 08:21:47 2007 +0000 +++ b/http.c Tue Feb 13 18:26:14 2007 +0000 @@ -120,7 +120,7 @@ s = av_malloc(sizeof(HTTPContext)); if (!s) { - return -ENOMEM; + return AVERROR(ENOMEM); } h->priv_data = s; s->filesize = -1;
--- a/img2.c Tue Feb 13 08:21:47 2007 +0000 +++ b/img2.c Tue Feb 13 18:26:14 2007 +0000 @@ -177,7 +177,7 @@ st = av_new_stream(s1, 0); if (!st) { - return -ENOMEM; + return AVERROR(ENOMEM); } pstrcpy(s->path, sizeof(s->path), s1->filename);
--- a/mpeg.c Tue Feb 13 08:21:47 2007 +0000 +++ b/mpeg.c Tue Feb 13 18:26:14 2007 +0000 @@ -513,7 +513,7 @@ for(i=0;i<ctx->nb_streams;i++) { av_free(ctx->streams[i]->priv_data); } - return -ENOMEM; + return AVERROR(ENOMEM); } static inline void put_timestamp(ByteIOContext *pb, int id, int64_t timestamp)
--- a/mpegts.c Tue Feb 13 08:21:47 2007 +0000 +++ b/mpegts.c Tue Feb 13 18:26:14 2007 +0000 @@ -1357,7 +1357,7 @@ uint8_t pcr_buf[12]; if (av_new_packet(pkt, TS_PACKET_SIZE) < 0) - return -ENOMEM; + return AVERROR(ENOMEM); pkt->pos= url_ftell(&s->pb); ret = read_packet(&s->pb, pkt->data, ts->raw_packet_size); if (ret < 0) {
--- a/rtpproto.c Tue Feb 13 08:21:47 2007 +0000 +++ b/rtpproto.c Tue Feb 13 18:26:14 2007 +0000 @@ -113,7 +113,7 @@ s = av_mallocz(sizeof(RTPContext)); if (!s) - return -ENOMEM; + return AVERROR(ENOMEM); h->priv_data = s; url_split(NULL, 0, NULL, 0, hostname, sizeof(hostname), &port,
--- a/smacker.c Tue Feb 13 08:21:47 2007 +0000 +++ b/smacker.c Tue Feb 13 18:26:14 2007 +0000 @@ -226,7 +226,7 @@ int pos; if (url_feof(&s->pb) || smk->cur_frame >= smk->frames) - return -EIO; + return AVERROR(EIO); /* if we demuxed all streams, pass another frame */ if(smk->curstream < 0) {
--- a/sol.c Tue Feb 13 08:21:47 2007 +0000 +++ b/sol.c Tue Feb 13 18:26:14 2007 +0000 @@ -133,7 +133,7 @@ int ret; if (url_feof(&s->pb)) - return -EIO; + return AVERROR(EIO); ret= av_get_packet(&s->pb, pkt, MAX_SIZE); pkt->stream_index = 0;
--- a/tcp.c Tue Feb 13 08:21:47 2007 +0000 +++ b/tcp.c Tue Feb 13 18:26:14 2007 +0000 @@ -62,7 +62,7 @@ s = av_malloc(sizeof(TCPContext)); if (!s) - return -ENOMEM; + return AVERROR(ENOMEM); h->priv_data = s; if (port <= 0 || port >= 65536) @@ -90,7 +90,7 @@ /* wait until we are connected or until abort */ for(;;) { if (url_interrupt_cb()) { - ret = -EINTR; + ret = AVERROR(EINTR); goto fail1; } fd_max = fd; @@ -130,7 +130,7 @@ for (;;) { if (url_interrupt_cb()) - return -EINTR; + return AVERROR(EINTR); fd_max = s->fd; FD_ZERO(&rfds); FD_SET(s->fd, &rfds); @@ -141,11 +141,7 @@ len = recv(s->fd, buf, size, 0); if (len < 0) { if (errno != EINTR && errno != EAGAIN) -#ifdef __BEOS__ - return errno; -#else - return -errno; -#endif + return AVERROR(errno); } else return len; } else if (ret < 0) { return -1; @@ -163,7 +159,7 @@ size1 = size; while (size > 0) { if (url_interrupt_cb()) - return -EINTR; + return AVERROR(EINTR); fd_max = s->fd; FD_ZERO(&wfds); FD_SET(s->fd, &wfds); @@ -173,13 +169,8 @@ if (ret > 0 && FD_ISSET(s->fd, &wfds)) { len = send(s->fd, buf, size, 0); if (len < 0) { - if (errno != EINTR && errno != EAGAIN) { -#ifdef __BEOS__ - return errno; -#else - return -errno; -#endif - } + if (errno != EINTR && errno != EAGAIN) + return AVERROR(errno); continue; } size -= len;
--- a/udp.c Tue Feb 13 08:21:47 2007 +0000 +++ b/udp.c Tue Feb 13 18:26:14 2007 +0000 @@ -295,7 +295,7 @@ s = av_malloc(sizeof(UDPContext)); if (!s) - return -ENOMEM; + return AVERROR(ENOMEM); h->priv_data = s; s->ttl = 16;
--- a/utils.c Tue Feb 13 08:21:47 2007 +0000 +++ b/utils.c Tue Feb 13 18:26:14 2007 +0000 @@ -478,7 +478,7 @@ /* read probe data */ pd->buf= av_realloc(pd->buf, probe_size); pd->buf_size = get_buffer(pb, pd->buf, probe_size); - if (url_fseek(pb, 0, SEEK_SET) == (offset_t)-EPIPE) { + if (url_fseek(pb, 0, SEEK_SET) == (offset_t)AVERROR(EPIPE)) { url_fclose(pb); if (url_fopen(pb, filename, URL_RDONLY) < 0) { file_opened = 0; @@ -805,7 +805,7 @@ /* read next packet */ ret = av_read_packet(s, &s->cur_pkt); if (ret < 0) { - if (ret == -EAGAIN) + if (ret == AVERROR(EAGAIN)) return ret; /* return the last frames, if any */ for(i = 0; i < s->nb_streams; i++) { @@ -916,7 +916,7 @@ AVPacketList **plast_pktl= &s->packet_buffer; int ret= av_read_frame_internal(s, pkt); if(ret<0){ - if(pktl && ret != -EAGAIN){ + if(pktl && ret != AVERROR(EAGAIN)){ eof=1; continue; }else
--- a/v4l2.c Tue Feb 13 08:21:47 2007 +0000 +++ b/v4l2.c Tue Feb 13 18:26:14 2007 +0000 @@ -415,7 +415,7 @@ st = av_new_stream(s1, 0); if (!st) { - return -ENOMEM; + return AVERROR(ENOMEM); } av_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in us */
--- a/wv.c Tue Feb 13 08:21:47 2007 +0000 +++ b/wv.c Tue Feb 13 18:26:14 2007 +0000 @@ -170,7 +170,7 @@ int ret; if (url_feof(&s->pb)) - return -EIO; + return AVERROR(EIO); if(wc->block_parsed){ if(wv_read_block_header(s, &s->pb) < 0) return -1;
--- a/x11grab.c Tue Feb 13 08:21:47 2007 +0000 +++ b/x11grab.c Tue Feb 13 18:26:14 2007 +0000 @@ -130,7 +130,7 @@ st = av_new_stream(s1, 0); if (!st) { - return -ENOMEM; + return AVERROR(ENOMEM); } av_set_pts_info(st, 64, 1, 1000000); /* 64 bits pts in us */ @@ -151,7 +151,7 @@ IPC_CREAT|0777); if (x11grab->shminfo.shmid == -1) { av_log(s1, AV_LOG_ERROR, "Fatal: Can't get shared memory!\n"); - return -ENOMEM; + return AVERROR(ENOMEM); } x11grab->shminfo.shmaddr = image->data = shmat(x11grab->shminfo.shmid, 0, 0); x11grab->shminfo.readOnly = False;