diff beosaudio.cpp @ 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 0899bfe4105c
children 62792a60f740
line wrap: on
line diff
--- 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);