Fixed bug that caused problems when doing sample rate conversion.
This commit is contained in:
parent
ea921ae3ca
commit
bbba06e4b2
2 changed files with 12 additions and 29 deletions
|
@ -36,14 +36,20 @@ static OSStatus ACInputProc(AudioConverterRef inAudioConverter, UInt32* ioNumber
|
|||
OSStatus err = noErr;
|
||||
|
||||
if (converter->inputBufferSize > 0) {
|
||||
int amountConverted = *ioNumberDataPackets * converter->inputFormat.mBytesPerPacket;
|
||||
if (amountConverted > converter->inputBufferSize) {
|
||||
amountConverted = converter->inputBufferSize;
|
||||
}
|
||||
|
||||
ioData->mBuffers[0].mData = converter->inputBuffer;
|
||||
ioData->mBuffers[0].mDataByteSize = converter->inputBufferSize;
|
||||
ioData->mBuffers[0].mDataByteSize = amountConverted;
|
||||
ioData->mBuffers[0].mNumberChannels = (converter->inputFormat.mChannelsPerFrame);
|
||||
ioData->mNumberBuffers = 1;
|
||||
|
||||
*ioNumberDataPackets = amountConverted / converter->inputFormat.mBytesPerPacket;
|
||||
|
||||
*ioNumberDataPackets = converter->inputBufferSize / converter->inputFormat.mBytesPerFrame;
|
||||
|
||||
converter->inputBufferSize = 0;
|
||||
converter->inputBufferSize -= amountConverted;
|
||||
converter->inputBuffer = ((char *)converter->inputBuffer) + amountConverted;
|
||||
}
|
||||
else {
|
||||
ioData->mBuffers[0].mData = NULL;
|
||||
|
@ -71,7 +77,7 @@ static OSStatus ACInputProc(AudioConverterRef inAudioConverter, UInt32* ioNumber
|
|||
|
||||
needsReset = NO;
|
||||
|
||||
ioNumberFrames = outputSize/outputFormat.mBytesPerFrame;
|
||||
ioNumberFrames = inputSize/inputFormat.mBytesPerFrame;
|
||||
ioData.mBuffers[0].mData = outputBuffer;
|
||||
ioData.mBuffers[0].mDataByteSize = outputSize;
|
||||
ioData.mBuffers[0].mNumberChannels = outputFormat.mChannelsPerFrame;
|
||||
|
@ -120,7 +126,7 @@ static OSStatus ACInputProc(AudioConverterRef inAudioConverter, UInt32* ioNumber
|
|||
kAudioConverterPropertyCalculateOutputBufferSize,
|
||||
&dataSize,
|
||||
(void*)&outputSize);
|
||||
|
||||
NSLog(@"Output size: %i %i", outputSize, CHUNK_SIZE);
|
||||
if (outputBuffer)
|
||||
{
|
||||
NSLog(@"FREEING");
|
||||
|
|
|
@ -116,23 +116,6 @@
|
|||
8EFFCD6F0AA093AF00C458A5 /* PathNode.m in Sources */ = {isa = PBXBuildFile; fileRef = 8EFFCD530AA093AF00C458A5 /* PathNode.m */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXBuildStyle section */
|
||||
28FFB7160BC863C10047EC24 /* Development */ = {
|
||||
isa = PBXBuildStyle;
|
||||
buildSettings = {
|
||||
COPY_PHASE_STRIP = NO;
|
||||
};
|
||||
name = Development;
|
||||
};
|
||||
28FFB7170BC863C10047EC24 /* Deployment */ = {
|
||||
isa = PBXBuildStyle;
|
||||
buildSettings = {
|
||||
COPY_PHASE_STRIP = YES;
|
||||
};
|
||||
name = Deployment;
|
||||
};
|
||||
/* End PBXBuildStyle section */
|
||||
|
||||
/* Begin PBXCopyFilesBuildPhase section */
|
||||
177FD1000B90CB570011C3B5 /* CopyFiles */ = {
|
||||
isa = PBXCopyFilesBuildPhase;
|
||||
|
@ -734,12 +717,6 @@
|
|||
29B97313FDCFA39411CA2CEA /* Project object */ = {
|
||||
isa = PBXProject;
|
||||
buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "Cog" */;
|
||||
buildSettings = {
|
||||
};
|
||||
buildStyles = (
|
||||
28FFB7160BC863C10047EC24 /* Development */,
|
||||
28FFB7170BC863C10047EC24 /* Deployment */,
|
||||
);
|
||||
hasScannedForEncodings = 1;
|
||||
mainGroup = 29B97314FDCFA39411CA2CEA /* Cog */;
|
||||
projectDirPath = "";
|
||||
|
|
Loading…
Reference in a new issue