]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
osx_write: make number of buffers configurable
authorAndre Noll <maan@congo.fml.local>
Thu, 24 Aug 2006 18:58:33 +0000 (20:58 +0200)
committerAndre Noll <maan@congo.fml.local>
Thu, 24 Aug 2006 18:58:33 +0000 (20:58 +0200)
Two buffers seems to be too less for mp3.

osx_write.c
osx_write.ggo

index 87d700cc24fc926f0f3f9e5ede87ec35cc5475d7..b3049c5aadf375abd365e49dafc8a26ff123bd91 100644 (file)
@@ -55,16 +55,6 @@ struct private_osx_write_data {
        unsigned channels;
 };
 
-
-/*
- * Tried with 3 buffers, but then any little window move is sufficient to
- * stop the sound (OK, on a G3 400 with a Public Beta. Perhaps now we can
- * go down to 2 buffers). With 16 buffers we have 1.5 seconds music
- * buffered (or, if you're pessimistic, 1.5 seconds latency). Note 0
- * buffers don't work much further than the Bus error.
- */
-#define NUMBER_BUFFERS 2
-
 static void destroy_buffers(struct private_osx_write_data *powd)
 {
        struct osx_buffer *ptr;
@@ -79,13 +69,15 @@ static void destroy_buffers(struct private_osx_write_data *powd)
        }
 }
 
-static void init_buffers(struct private_osx_write_data *powd)
+static void init_buffers(struct writer_node *wn)
 {
+       struct private_osx_write_data *powd = wn->private_data;
+       struct osx_write_args_info *conf = wn->conf;
+       struct osx_buffer **ptrptr;
        int i;
 
-       struct osx_buffer **ptrptr;
        ptrptr = &powd->to;
-       for (i = 0; i < NUMBER_BUFFERS; i++) {
+       for (i = 0; i < conf->numbuffers_arg; i++) {
                *ptrptr = malloc(sizeof(struct osx_buffer));
                (*ptrptr)->size = 0;
                (*ptrptr)->remaining = 0;
@@ -226,7 +218,7 @@ static int osx_write_open(struct writer_node *wn)
                        kAudioUnitScope_Input, 0, &format,
                        sizeof(AudioStreamBasicDescription)))
                goto e2;
-       init_buffers(powd);
+       init_buffers(wn);
        ret = -E_ADD_CALLBACK;
        if (AudioUnitSetProperty(powd->output, kAudioUnitProperty_SetRenderCallback,
                        kAudioUnitScope_Input, 0, &inputCallback,
index 7f319fb2805af1c58e60d3c3ea76e7c2a18985ff..bfee7e6a958fea2b1f05f25837952f1a93aeba73 100644 (file)
@@ -19,3 +19,13 @@ raw audio)"
        int typestr="num"
        default="44100"
        optional
+
+option "numbuffers" n
+#~~~~~~~~~~~~~~~~~~~~~
+
+"number of audio buffers to allocate (increase if
+you get buffer underruns)"
+
+       int typestr="num"
+       default="3"
+       optional