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;
|
OSStatus err = noErr;
|
||||||
|
|
||||||
if (converter->inputBufferSize > 0) {
|
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].mData = converter->inputBuffer;
|
||||||
ioData->mBuffers[0].mDataByteSize = converter->inputBufferSize;
|
ioData->mBuffers[0].mDataByteSize = amountConverted;
|
||||||
ioData->mBuffers[0].mNumberChannels = (converter->inputFormat.mChannelsPerFrame);
|
ioData->mBuffers[0].mNumberChannels = (converter->inputFormat.mChannelsPerFrame);
|
||||||
ioData->mNumberBuffers = 1;
|
ioData->mNumberBuffers = 1;
|
||||||
|
|
||||||
|
*ioNumberDataPackets = amountConverted / converter->inputFormat.mBytesPerPacket;
|
||||||
|
|
||||||
*ioNumberDataPackets = converter->inputBufferSize / converter->inputFormat.mBytesPerFrame;
|
converter->inputBufferSize -= amountConverted;
|
||||||
|
converter->inputBuffer = ((char *)converter->inputBuffer) + amountConverted;
|
||||||
converter->inputBufferSize = 0;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ioData->mBuffers[0].mData = NULL;
|
ioData->mBuffers[0].mData = NULL;
|
||||||
|
@ -71,7 +77,7 @@ static OSStatus ACInputProc(AudioConverterRef inAudioConverter, UInt32* ioNumber
|
||||||
|
|
||||||
needsReset = NO;
|
needsReset = NO;
|
||||||
|
|
||||||
ioNumberFrames = outputSize/outputFormat.mBytesPerFrame;
|
ioNumberFrames = inputSize/inputFormat.mBytesPerFrame;
|
||||||
ioData.mBuffers[0].mData = outputBuffer;
|
ioData.mBuffers[0].mData = outputBuffer;
|
||||||
ioData.mBuffers[0].mDataByteSize = outputSize;
|
ioData.mBuffers[0].mDataByteSize = outputSize;
|
||||||
ioData.mBuffers[0].mNumberChannels = outputFormat.mChannelsPerFrame;
|
ioData.mBuffers[0].mNumberChannels = outputFormat.mChannelsPerFrame;
|
||||||
|
@ -120,7 +126,7 @@ static OSStatus ACInputProc(AudioConverterRef inAudioConverter, UInt32* ioNumber
|
||||||
kAudioConverterPropertyCalculateOutputBufferSize,
|
kAudioConverterPropertyCalculateOutputBufferSize,
|
||||||
&dataSize,
|
&dataSize,
|
||||||
(void*)&outputSize);
|
(void*)&outputSize);
|
||||||
|
NSLog(@"Output size: %i %i", outputSize, CHUNK_SIZE);
|
||||||
if (outputBuffer)
|
if (outputBuffer)
|
||||||
{
|
{
|
||||||
NSLog(@"FREEING");
|
NSLog(@"FREEING");
|
||||||
|
|
|
@ -116,23 +116,6 @@
|
||||||
8EFFCD6F0AA093AF00C458A5 /* PathNode.m in Sources */ = {isa = PBXBuildFile; fileRef = 8EFFCD530AA093AF00C458A5 /* PathNode.m */; };
|
8EFFCD6F0AA093AF00C458A5 /* PathNode.m in Sources */ = {isa = PBXBuildFile; fileRef = 8EFFCD530AA093AF00C458A5 /* PathNode.m */; };
|
||||||
/* End PBXBuildFile section */
|
/* 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 */
|
/* Begin PBXCopyFilesBuildPhase section */
|
||||||
177FD1000B90CB570011C3B5 /* CopyFiles */ = {
|
177FD1000B90CB570011C3B5 /* CopyFiles */ = {
|
||||||
isa = PBXCopyFilesBuildPhase;
|
isa = PBXCopyFilesBuildPhase;
|
||||||
|
@ -734,12 +717,6 @@
|
||||||
29B97313FDCFA39411CA2CEA /* Project object */ = {
|
29B97313FDCFA39411CA2CEA /* Project object */ = {
|
||||||
isa = PBXProject;
|
isa = PBXProject;
|
||||||
buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "Cog" */;
|
buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "Cog" */;
|
||||||
buildSettings = {
|
|
||||||
};
|
|
||||||
buildStyles = (
|
|
||||||
28FFB7160BC863C10047EC24 /* Development */,
|
|
||||||
28FFB7170BC863C10047EC24 /* Deployment */,
|
|
||||||
);
|
|
||||||
hasScannedForEncodings = 1;
|
hasScannedForEncodings = 1;
|
||||||
mainGroup = 29B97314FDCFA39411CA2CEA /* Cog */;
|
mainGroup = 29B97314FDCFA39411CA2CEA /* Cog */;
|
||||||
projectDirPath = "";
|
projectDirPath = "";
|
||||||
|
|
Loading…
Reference in a new issue