Cog Audio converter: Fix end of track flush and extrapolation
This commit is contained in:
parent
8a91bc1d09
commit
f44e4e793b
1 changed files with 8 additions and 4 deletions
|
@ -400,9 +400,10 @@ static void extrapolate(float *buffer, size_t channels, size_t frameSize, size_t
|
||||||
{
|
{
|
||||||
char writeBuf[CHUNK_SIZE];
|
char writeBuf[CHUNK_SIZE];
|
||||||
|
|
||||||
while ([self shouldContinue] == YES && [self endOfStream] == NO) //Need to watch EOS somehow....
|
while ([self shouldContinue] == YES) //Need to watch EOS somehow....
|
||||||
{
|
{
|
||||||
int amountConverted = [self convert:writeBuf amount:CHUNK_SIZE];
|
int amountConverted = [self convert:writeBuf amount:CHUNK_SIZE];
|
||||||
|
if (!amountConverted) break;
|
||||||
[self writeData:writeBuf amount:amountConverted];
|
[self writeData:writeBuf amount:amountConverted];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -457,17 +458,20 @@ tryagain:
|
||||||
{
|
{
|
||||||
ioNumberPackets = (int)resampler->latency(resampler_data);
|
ioNumberPackets = (int)resampler->latency(resampler_data);
|
||||||
newSize = ioNumberPackets * floatFormat.mBytesPerPacket;
|
newSize = ioNumberPackets * floatFormat.mBytesPerPacket;
|
||||||
|
newSize += inpSize;
|
||||||
if (!inputBuffer || inputBufferSize < newSize)
|
if (!inputBuffer || inputBufferSize < newSize)
|
||||||
inputBuffer = realloc( inputBuffer, inputBufferSize = newSize * 64);
|
inputBuffer = realloc( inputBuffer, inputBufferSize = newSize * 3);
|
||||||
|
|
||||||
extrapolateEnd = ioNumberPackets;
|
extrapolateEnd = ioNumberPackets;
|
||||||
|
|
||||||
// Extrapolate end samples
|
// Extrapolate end samples
|
||||||
if (inpSize)
|
if (inpSize)
|
||||||
|
{
|
||||||
extrapolate( inputBuffer, floatFormat.mChannelsPerFrame, inpSize / floatFormat.mBytesPerPacket, extrapolateEnd, NO);
|
extrapolate( inputBuffer, floatFormat.mChannelsPerFrame, inpSize / floatFormat.mBytesPerPacket, extrapolateEnd, NO);
|
||||||
|
|
||||||
inpSize = newSize;
|
inpOffset = inpSize;
|
||||||
inpOffset = 0;
|
inpSize += extrapolateEnd * floatFormat.mBytesPerPacket;
|
||||||
|
}
|
||||||
latencyPostfill = YES;
|
latencyPostfill = YES;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue