X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=osx_write.c;h=4d0bfbdf4f4f9aa300364aa3d53dcee40bb8ba14;hp=4656b9d2f22ef16bf23decc41d26371b6e0bc024;hb=d42af6d28fa44d085b048cb064e20c79189b88b2;hpb=14fb4f851fef5772ecdd1bd5b55aec1ec29ae68b diff --git a/osx_write.c b/osx_write.c index 4656b9d2..4d0bfbdf 100644 --- a/osx_write.c +++ b/osx_write.c @@ -37,39 +37,35 @@ #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; }; -typedef struct osx_buffer osx_buffer; /* FIXME */ struct private_osx_write_data { long size; AudioUnit output; char play; - osx_buffer *from; /* Current buffers */ - osx_buffer *to; + struct osx_buffer *from; /* Current buffers */ + struct osx_buffer *to; unsigned samplerate; 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) { - osx_buffer *ptr; - osx_buffer *ptr2; + struct osx_buffer *ptr; + struct osx_buffer *ptr2; ptr = powd->to->next; powd->to->next = NULL; while (ptr) { @@ -80,14 +76,16 @@ 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; - osx_buffer ** ptrptr; ptrptr = &powd->to; - for (i = 0; i < NUMBER_BUFFERS; i++) { - *ptrptr = malloc(sizeof(osx_buffer)); + for (i = 0; i < conf->numbuffers_arg; i++) { + *ptrptr = malloc(sizeof(struct osx_buffer)); (*ptrptr)->size = 0; (*ptrptr)->remaining = 0; (*ptrptr)->buffer = NULL; @@ -96,7 +94,7 @@ static void init_buffers(struct private_osx_write_data *powd) *ptrptr = powd->from = powd->to; } -static void fill_buffer(osx_buffer *b, short *source, long size) +static void fill_buffer(struct osx_buffer *b, short *source, long size) { float *dest; @@ -227,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,