src/audio/coreaudio/SDL_coreaudio.c
changeset 6352 a9bcd26e7105
parent 6281 e46d6f4b469e
child 6413 701a0c0d70d0
equal deleted inserted replaced
6351:8f5535d05e34 6352:a9bcd26e7105
   278         remaining = abuf->mDataByteSize;
   278         remaining = abuf->mDataByteSize;
   279         ptr = abuf->mData;
   279         ptr = abuf->mData;
   280         while (remaining > 0) {
   280         while (remaining > 0) {
   281             if (this->hidden->bufferOffset >= this->hidden->bufferSize) {
   281             if (this->hidden->bufferOffset >= this->hidden->bufferSize) {
   282                 /* Generate the data */
   282                 /* Generate the data */
   283                 SDL_memset(this->hidden->buffer, this->spec.silence,
       
   284                            this->hidden->bufferSize);
       
   285                 SDL_mutexP(this->mixer_lock);
   283                 SDL_mutexP(this->mixer_lock);
   286                 (*this->spec.callback)(this->spec.userdata,
   284                 (*this->spec.callback)(this->spec.userdata,
   287                             this->hidden->buffer, this->hidden->bufferSize);
   285                             this->hidden->buffer, this->hidden->bufferSize);
   288                 SDL_mutexV(this->mixer_lock);
   286                 SDL_mutexV(this->mixer_lock);
   289                 this->hidden->bufferOffset = 0;
   287                 this->hidden->bufferOffset = 0;
   334 
   332 
   335             /* stop processing the audio unit */
   333             /* stop processing the audio unit */
   336             result = AudioOutputUnitStop(this->hidden->audioUnit);
   334             result = AudioOutputUnitStop(this->hidden->audioUnit);
   337 
   335 
   338             /* Remove the input callback */
   336             /* Remove the input callback */
   339             SDL_memset(&callback, '\0', sizeof(AURenderCallbackStruct));
   337             SDL_memset(&callback, 0, sizeof(AURenderCallbackStruct));
   340             result = AudioUnitSetProperty(this->hidden->audioUnit,
   338             result = AudioUnitSetProperty(this->hidden->audioUnit,
   341                                           kAudioUnitProperty_SetRenderCallback,
   339                                           kAudioUnitProperty_SetRenderCallback,
   342                                           scope, bus, &callback,
   340                                           scope, bus, &callback,
   343                                           sizeof(callback));
   341                                           sizeof(callback));
   344 
   342 
   429                                   kAudioUnitProperty_StreamFormat,
   427                                   kAudioUnitProperty_StreamFormat,
   430                                   scope, bus, strdesc, sizeof(*strdesc));
   428                                   scope, bus, strdesc, sizeof(*strdesc));
   431     CHECK_RESULT("AudioUnitSetProperty (kAudioUnitProperty_StreamFormat)");
   429     CHECK_RESULT("AudioUnitSetProperty (kAudioUnitProperty_StreamFormat)");
   432 
   430 
   433     /* Set the audio callback */
   431     /* Set the audio callback */
   434     SDL_memset(&callback, '\0', sizeof(AURenderCallbackStruct));
   432     SDL_memset(&callback, 0, sizeof(AURenderCallbackStruct));
   435     callback.inputProc = ((iscapture) ? inputCallback : outputCallback);
   433     callback.inputProc = ((iscapture) ? inputCallback : outputCallback);
   436     callback.inputProcRefCon = this;
   434     callback.inputProcRefCon = this;
   437     result = AudioUnitSetProperty(this->hidden->audioUnit,
   435     result = AudioUnitSetProperty(this->hidden->audioUnit,
   438                                   kAudioUnitProperty_SetRenderCallback,
   436                                   kAudioUnitProperty_SetRenderCallback,
   439                                   scope, bus, &callback, sizeof(callback));
   437                                   scope, bus, &callback, sizeof(callback));