X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=osx_writer.c;h=b0d672c963443b7225ef2053871c3fb614b9df67;hp=c4a97e4b5ae9c0f2575f8239bb79c43dab45a8f7;hb=4c80bf4a2082c4922094f7e8ce75193edb6be80f;hpb=ee055536fd64fa1c382d0c8f81c242ef2e8a79db diff --git a/osx_writer.c b/osx_writer.c index c4a97e4b..b0d672c9 100644 --- a/osx_writer.c +++ b/osx_writer.c @@ -32,7 +32,6 @@ #include #include #include -#include struct osx_buffer { float *buffer; long size; @@ -47,10 +46,10 @@ struct private_osx_writer_data { short *ptr; AudioUnit output; char play; - sem_t *semaphore; osx_buffer *from; /* Current buffers */ osx_buffer *to; unsigned samplerate; + unsigned channels; }; @@ -91,7 +90,6 @@ static void init_buffers(struct private_osx_writer_data *powd) (*ptrptr)->buffer = NULL; ptrptr = &(*ptrptr)->next; /* This buffer is ready for filling (of course, it is empty!) */ - sem_post(powd->semaphore); } *ptrptr = powd->from = powd->to; } @@ -145,6 +143,7 @@ static OSStatus osx_callback(void * inClientData, dest = outOutputData->mBuffers[i].mData; while (m > 0) { if ((n = powd->from->remaining) <= 0) { + PARA_INFO_LOG("%s", "buffer underrun\n"); /* no more bytes in the current read buffer! */ while ((n = powd->from->remaining) <= 0) /* wait for the results */ @@ -162,11 +161,8 @@ static OSStatus osx_callback(void * inClientData, /* remember all done work */ m -= n; powd->from->ptr += n; - if ((powd->from->remaining -= n) <= 0) { - /* tell that there's a buffer to fill */ - sem_post(powd->semaphore); + if ((powd->from->remaining -= n) <= 0) powd->from = powd->from->next; - } } } return 0; @@ -180,8 +176,7 @@ static int osx_writer_open(struct writer_node *wn) Component comp; AURenderCallbackStruct inputCallback = {osx_callback, powd}; AudioStreamBasicDescription format; - char s[10]; - int m, ret; + int ret; struct writer_node_group *wng = wn->wng; struct osx_write_args_info *conf = wn->conf; @@ -223,12 +218,12 @@ static int osx_writer_open(struct writer_node *wn) format.mFormatFlags = kLinearPCMFormatFlagIsFloat | kLinearPCMFormatFlagIsPacked | kLinearPCMFormatFlagIsBigEndian; - /* - * We produce 2-channel audio. Now if we have a mega-super-hyper card for our - * audio, it is its problem to convert it to 8-, 16-, 32- or 1024-channel data. - */ + if (!conf->channels_given && wng->channels) + powd->channels = *wng->channels; + else + powd->channels = conf->channels_arg; + format.mChannelsPerFrame = powd->channels; format.mFramesPerPacket = 1; - format.mChannelsPerFrame = 2; format.mBytesPerPacket = format.mChannelsPerFrame * sizeof(float); format.mBytesPerFrame = format.mFramesPerPacket * format.mBytesPerPacket; /* one of the most constant constants of the whole computer history */ @@ -238,16 +233,6 @@ static int osx_writer_open(struct writer_node *wn) kAudioUnitScope_Input, 0, &format, sizeof(AudioStreamBasicDescription))) goto e2; - /* init the semaphore */ - strcpy(s, "/mpg123-0000"); - do { - for (m = 10;; m--) - if( (s[m]++) <= '9') - break; - else - s[m] = '0'; - } while ((powd->semaphore = sem_open(s, O_CREAT | O_EXCL, 0644, 0)) - == (sem_t *)SEM_FAILED); init_buffers(powd); ret = -E_ADD_CALLBACK; if (AudioUnitSetProperty(powd->output, kAudioUnitProperty_SetRenderCallback, @@ -289,7 +274,6 @@ static void osx_writer_close(struct writer_node *wn) AudioUnitUninitialize(powd->output); CloseComponent(powd->output); destroy_buffers(powd); - sem_close(powd->semaphore); free(powd); }