From: Andre Noll Date: Sun, 20 Aug 2006 15:12:35 +0000 (+0200) Subject: osx_write: kill superfluous semaphore code X-Git-Tag: v0.2.14~45 X-Git-Url: http://git.tue.mpg.de/?a=commitdiff_plain;h=4c80bf4a2082c4922094f7e8ce75193edb6be80f;p=paraslash.git osx_write: kill superfluous semaphore code --- diff --git a/osx_writer.c b/osx_writer.c index 54a1acd1..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,7 +46,6 @@ struct private_osx_writer_data { short *ptr; AudioUnit output; char play; - sem_t *semaphore; osx_buffer *from; /* Current buffers */ osx_buffer *to; unsigned samplerate; @@ -92,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; } @@ -146,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 */ @@ -163,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; @@ -181,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; @@ -239,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, @@ -290,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); }