]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/beosaudio.cpp
remove silly video check, theres nothing video specific in there
[ffmpeg] / libavformat / beosaudio.cpp
index 0aad8b6fb763765fdbd2f769e1e9c949768a4947..6c16f0048c42023808da048158d8ec5fafab0861 100644 (file)
@@ -2,19 +2,21 @@
  * BeOS audio play interface
  * Copyright (c) 2000, 2001 Fabrice Bellard.
  *
- * This library is free software; you can redistribute it and/or
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
+ * version 2.1 of the License, or (at your option) any later version.
  *
- * This library is distributed in the hope that it will be useful,
+ * FFmpeg is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
 #include <signal.h>
@@ -33,6 +35,7 @@ extern "C" {
 
 #ifdef HAVE_BSOUNDRECORDER
 #include <SoundRecorder.h>
+using namespace BPrivate::Media::Experimental;
 #endif
 
 /* enable performance checks */
@@ -42,7 +45,6 @@ extern "C" {
 //#define LATENCY_CHECK
 
 #define AUDIO_BLOCK_SIZE 4096
-//#define AUDIO_BLOCK_SIZE 2048
 #define AUDIO_BLOCK_COUNT 8
 
 #define AUDIO_BUFFER_SIZE (AUDIO_BLOCK_SIZE*AUDIO_BLOCK_COUNT)
@@ -60,7 +62,6 @@ typedef struct {
     int input_index;
     sem_id output_sem;
     int output_index;
-    int queued;
     BSoundPlayer *player;
 #ifdef HAVE_BSOUNDRECORDER
     BSoundRecorder *recorder;
@@ -193,20 +194,18 @@ static int audio_open(AudioData *s, int is_output, const char *audio_device)
 
 #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");
-//    s->input_sem = create_sem(AUDIO_BLOCK_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;
-    s->queued = 0;
     create_bapp_if_needed();
     s->frame_size = AUDIO_BLOCK_SIZE;
     /* bump up the priority (avoid realtime though) */
@@ -227,7 +226,7 @@ static int audio_open(AudioData *s, int is_output, const char *audio_device)
                 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;
@@ -253,7 +252,7 @@ static int audio_open(AudioData *s, int is_output, const char *audio_device)
             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);
@@ -290,16 +289,16 @@ static int audio_write_header(AVFormatContext *s1)
     int ret;
 
     st = s1->streams[0];
-    s->sample_rate = st->codec.sample_rate;
-    s->channels = st->codec.channels;
+    s->sample_rate = st->codec->sample_rate;
+    s->channels = st->codec->channels;
     ret = audio_open(s, 1, NULL);
     if (ret < 0)
-        return -EIO;
+        return AVERROR(EIO);
     return 0;
 }
 
 static int audio_write_packet(AVFormatContext *s1, int stream_index,
-                              uint8_t *buf, int size, int force_pts)
+                              const uint8_t *buf, int size, int64_t force_pts)
 {
     AudioData *s = (AudioData *)s1->priv_data;
     int len, ret;
@@ -316,7 +315,7 @@ lat1 = s->player->Latency();
         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;
@@ -357,21 +356,21 @@ static int audio_read_header(AVFormatContext *s1, AVFormatParameters *ap)
 
     st = av_new_stream(s1, 0);
     if (!st) {
-        return -ENOMEM;
+        return AVERROR(ENOMEM);
     }
     s->sample_rate = ap->sample_rate;
     s->channels = ap->channels;
 
-    ret = audio_open(s, 0, ap->device);
+    ret = audio_open(s, 0, s1->filename);
     if (ret < 0) {
         av_free(st);
-        return -EIO;
+        return AVERROR(EIO);
     }
     /* take real parameters */
-    st->codec.codec_type = CODEC_TYPE_AUDIO;
-    st->codec.codec_id = s->codec_id;
-    st->codec.sample_rate = s->sample_rate;
-    st->codec.channels = s->channels;
+    st->codec->codec_type = CODEC_TYPE_AUDIO;
+    st->codec->codec_id = s->codec_id;
+    st->codec->sample_rate = s->sample_rate;
+    st->codec->channels = s->channels;
     return 0;
     av_set_pts_info(s1, 48, 1, 1000000);  /* 48 bits pts in us */
 }
@@ -385,7 +384,7 @@ static int audio_read_packet(AVFormatContext *s1, AVPacket *pkt)
     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) {
@@ -394,7 +393,7 @@ static int audio_read_packet(AVFormatContext *s1, AVPacket *pkt)
         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);
@@ -422,7 +421,7 @@ static int audio_read_close(AVFormatContext *s1)
     return 0;
 }
 
-static AVInputFormat audio_in_format = {
+static AVInputFormat audio_demuxer = {
     "audio_device",
     "audio grab and output",
     sizeof(AudioData),
@@ -434,7 +433,7 @@ static AVInputFormat audio_in_format = {
     AVFMT_NOFILE,
 };
 
-AVOutputFormat audio_out_format = {
+AVOutputFormat audio_muxer = {
     "audio_device",
     "audio grab and output",
     "",
@@ -457,8 +456,8 @@ extern "C" {
 int audio_init(void)
 {
     main_thid = find_thread(NULL);
-    av_register_input_format(&audio_in_format);
-    av_register_output_format(&audio_out_format);
+    av_register_input_format(&audio_demuxer);
+    av_register_output_format(&audio_muxer);
     return 0;
 }