X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=osx_write.c;h=4d0bfbdf4f4f9aa300364aa3d53dcee40bb8ba14;hp=87d700cc24fc926f0f3f9e5ede87ec35cc5475d7;hb=d7fd31be838a33e3a55717f80be850b7db55746d;hpb=b4cd8ef176f2e33f57b2172cef33daabd7d5fd6b diff --git a/osx_write.c b/osx_write.c index 87d700cc..4d0bfbdf 100644 --- a/osx_write.c +++ b/osx_write.c @@ -37,11 +37,18 @@ #include #include #include + +/** describes one input buffer for the osx writer */ struct osx_buffer { + /** pointer to the beginning of the buffer */ float *buffer; + /** the size of this buffer */ long size; - float *ptr; /* Where in the buffer are we? */ + /* current position in the buffer */ + float *ptr; + /** number of floats not yet consuned */ long remaining; + /** pointer to the next audio buffer */ struct osx_buffer *next; }; @@ -55,16 +62,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 +76,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 +225,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,