]> git.tue.mpg.de Git - paraslash.git/commitdiff
osx_write: kill superfluous semaphore code
authorAndre Noll <maan@congo.fml.local>
Sun, 20 Aug 2006 15:12:35 +0000 (17:12 +0200)
committerAndre Noll <maan@congo.fml.local>
Sun, 20 Aug 2006 15:12:35 +0000 (17:12 +0200)
osx_writer.c

index 54a1acd1e98e3c3ce597982cf7f05d56842e698b..b0d672c963443b7225ef2053871c3fb614b9df67 100644 (file)
@@ -32,7 +32,6 @@
 #include <CoreAudio/CoreAudio.h>
 #include <AudioUnit/AudioUnit.h>
 #include <AudioToolbox/DefaultAudioOutput.h>
-#include <semaphore.h>
 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);
 }