diff --git a/Controller.h b/Controller.h index 8fe1b9f04..1ce91c45b 100644 --- a/Controller.h +++ b/Controller.h @@ -21,7 +21,7 @@ Semaphore *ioSemaphore; NSMutableArray *amountConverted; - unsigned int amountPlayed; //when amountPlayed > amountConverted[0], amountPlayed -= amountConverted[0], pop(amountConverted[0]) + unsigned int amountPlayed; //when amountPlayed > amountConverted[0], amountPlayed -= amountConverted[0], pop(amountConverted[0]), song changed } - (void)convertedAmount:(int)amount; //called by converter...same thread? diff --git a/Converter.m b/Converter.m index ce5651e8b..52ff2dd2a 100644 --- a/Converter.m +++ b/Converter.m @@ -81,11 +81,16 @@ static OSStatus ACInputProc(AudioConverterRef inAudioConverter, UInt32* ioNumber ioData.mBuffers[0].mNumberChannels = [[soundController output] format].mChannelsPerFrame; ioData.mNumberBuffers = 1; + [[soundController inputLock] lock]; + err = AudioConverterFillComplexBuffer(converter, ACInputProc, &[[soundController input] format], &ioNumberFrames, &ioData, NULL); if (err != noErr) DBLog(@"Converter error: %i", err); - [[soundController inputBuffer] didReadLength:(ioNumberFrames * [[[soundController input] format].mBytesPerFrame]); + [[soundController input] buffer] didReadLength:(ioNumberFrames * [[[soundController input] format].mBytesPerFrame]); + + [[soundController inputLock] unlock]; + [[soundController ioSemaphore] signal]; return ioData.mBuffers[0].mDataByteSize; diff --git a/InputController.m b/InputController.m index dda426d94..c467b780f 100644 --- a/InputController.m +++ b/InputController.m @@ -13,7 +13,7 @@ - (void)play { - [SoundFile open:filename]; + [soundFile open:filename]; } @end