Fix for some playback issues (low frequency files).
parent
57ce59b549
commit
79934e0607
|
@ -16,6 +16,7 @@
|
|||
AudioConverterRef converter;
|
||||
|
||||
void *outputBuffer;
|
||||
int outputBufferSize;
|
||||
|
||||
//Temporary for callback use
|
||||
void *inputBuffer;
|
||||
|
@ -30,10 +31,12 @@
|
|||
}
|
||||
|
||||
- (void *)outputBuffer;
|
||||
- (int)outputBufferSize;
|
||||
|
||||
- (void)setupWithInputFormat:(AudioStreamBasicDescription)inputFormat outputFormat:(AudioStreamBasicDescription)outputFormat;
|
||||
- (void)cleanUp;
|
||||
|
||||
//Returns the amount actually read from input
|
||||
- (int)convert:(void *)input amount:(int)inputSize;
|
||||
|
||||
@end
|
||||
|
|
|
@ -37,6 +37,7 @@ static OSStatus ACInputProc(AudioConverterRef inAudioConverter, UInt32* ioNumber
|
|||
|
||||
if (converter->inputBufferSize > 0) {
|
||||
int amountConverted = *ioNumberDataPackets * converter->inputFormat.mBytesPerPacket;
|
||||
NSLog(@"Asking: %i", amountConverted);
|
||||
if (amountConverted > converter->inputBufferSize) {
|
||||
amountConverted = converter->inputBufferSize;
|
||||
}
|
||||
|
@ -50,6 +51,7 @@ static OSStatus ACInputProc(AudioConverterRef inAudioConverter, UInt32* ioNumber
|
|||
|
||||
converter->inputBufferSize -= amountConverted;
|
||||
converter->inputBuffer = ((char *)converter->inputBuffer) + amountConverted;
|
||||
NSLog(@"Converted: %i", amountConverted);
|
||||
}
|
||||
else {
|
||||
ioData->mBuffers[0].mData = NULL;
|
||||
|
@ -70,6 +72,7 @@ static OSStatus ACInputProc(AudioConverterRef inAudioConverter, UInt32* ioNumber
|
|||
UInt32 ioNumberFrames;
|
||||
|
||||
if (inputSize <= 0) {
|
||||
outputBufferSize = inputSize;
|
||||
return inputSize;
|
||||
}
|
||||
|
||||
|
@ -84,14 +87,20 @@ static OSStatus ACInputProc(AudioConverterRef inAudioConverter, UInt32* ioNumber
|
|||
ioData.mNumberBuffers = 1;
|
||||
inputBuffer = input;
|
||||
inputBufferSize = inputSize;
|
||||
|
||||
NSLog(@"Converting: %i", inputSize);
|
||||
|
||||
err = AudioConverterFillComplexBuffer(converter, ACInputProc, self, &ioNumberFrames, &ioData, NULL);
|
||||
if (err != noErr || needsReset) //It returns insz at EOS at times...so run it again to make sure all data is converted
|
||||
{
|
||||
NSLog(@"Error:%i %i", err, noErr);
|
||||
AudioConverterReset(converter);
|
||||
}
|
||||
|
||||
NSLog(@"Pass: %i", inputSize - inputBufferSize);
|
||||
|
||||
return ioData.mBuffers[0].mDataByteSize;
|
||||
outputBufferSize = ioData.mBuffers[0].mDataByteSize;
|
||||
|
||||
return inputSize - inputBufferSize;
|
||||
}
|
||||
|
||||
- (void)setupWithInputFormat:(AudioStreamBasicDescription)inf outputFormat:(AudioStreamBasicDescription)outf
|
||||
|
@ -148,6 +157,11 @@ static OSStatus ACInputProc(AudioConverterRef inAudioConverter, UInt32* ioNumber
|
|||
return outputBuffer;
|
||||
}
|
||||
|
||||
- (int)outputBufferSize
|
||||
{
|
||||
return outputBufferSize;
|
||||
}
|
||||
|
||||
- (void)cleanUp
|
||||
{
|
||||
if (outputBuffer) {
|
||||
|
|
|
@ -80,9 +80,9 @@
|
|||
|
||||
- (void)process
|
||||
{
|
||||
int amountRead, amountConverted;
|
||||
int amountRead = 0, amountConverted = 0, amountInBuffer = 0;
|
||||
void *inputBuffer = malloc(CHUNK_SIZE);
|
||||
|
||||
|
||||
NSLog(@"Playing file: %i", self);
|
||||
|
||||
while ([self shouldContinue] == YES && [self endOfStream] == NO)
|
||||
|
@ -93,17 +93,27 @@
|
|||
[decoder seekToTime:seekTime];
|
||||
shouldSeek = NO;
|
||||
}
|
||||
|
||||
if (amountInBuffer < CHUNK_SIZE) {
|
||||
amountRead = [decoder fillBuffer:((char *)inputBuffer) + amountInBuffer ofSize:CHUNK_SIZE - amountInBuffer];
|
||||
amountInBuffer += amountRead;
|
||||
}
|
||||
|
||||
amountRead = [decoder fillBuffer:inputBuffer ofSize:CHUNK_SIZE];
|
||||
amountConverted = [converter convert:inputBuffer amount:amountRead]; //Convert fills in converter buffer, til the next call
|
||||
if (amountConverted <= 0)
|
||||
amountConverted = [converter convert:inputBuffer amount:amountInBuffer]; //Convert fills in converter buffer, til the next call
|
||||
if (amountInBuffer - amountConverted > 0) {
|
||||
memmove(inputBuffer,((char *)inputBuffer) + amountConverted, amountInBuffer - amountConverted);
|
||||
}
|
||||
amountInBuffer -= amountConverted;
|
||||
|
||||
if ([converter outputBufferSize] <= 0)
|
||||
{
|
||||
NSLog(@"END OF FILE?!");
|
||||
endOfStream = YES;
|
||||
[controller endOfInputReached];
|
||||
break; //eof
|
||||
}
|
||||
|
||||
[self writeData:[converter outputBuffer] amount:amountConverted];
|
||||
|
||||
[self writeData:[converter outputBuffer] amount:[converter outputBufferSize]];
|
||||
}
|
||||
|
||||
[decoder close];
|
||||
|
|
|
@ -48,23 +48,6 @@
|
|||
8EC122600B993BD500C5B3AD /* Converter.m in Sources */ = {isa = PBXBuildFile; fileRef = 8EC1225E0B993BD500C5B3AD /* Converter.m */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXBuildStyle section */
|
||||
281899720BEC711E003176EE /* Development */ = {
|
||||
isa = PBXBuildStyle;
|
||||
buildSettings = {
|
||||
COPY_PHASE_STRIP = NO;
|
||||
};
|
||||
name = Development;
|
||||
};
|
||||
281899730BEC711E003176EE /* Deployment */ = {
|
||||
isa = PBXBuildStyle;
|
||||
buildSettings = {
|
||||
COPY_PHASE_STRIP = YES;
|
||||
};
|
||||
name = Deployment;
|
||||
};
|
||||
/* End PBXBuildStyle section */
|
||||
|
||||
/* Begin PBXCopyFilesBuildPhase section */
|
||||
17D21D2B0B8BE6A200D1EBDE /* CopyFiles */ = {
|
||||
isa = PBXCopyFilesBuildPhase;
|
||||
|
@ -354,12 +337,6 @@
|
|||
0867D690FE84028FC02AAC07 /* Project object */ = {
|
||||
isa = PBXProject;
|
||||
buildConfigurationList = 1DEB91B108733DA50010E9CD /* Build configuration list for PBXProject "CogAudio" */;
|
||||
buildSettings = {
|
||||
};
|
||||
buildStyles = (
|
||||
281899720BEC711E003176EE /* Development */,
|
||||
281899730BEC711E003176EE /* Deployment */,
|
||||
);
|
||||
hasScannedForEncodings = 1;
|
||||
mainGroup = 0867D691FE84028FC02AAC07 /* CogAudio */;
|
||||
productRefGroup = 034768DFFF38A50411DB9C8B /* Products */;
|
||||
|
|
|
@ -45,7 +45,7 @@ AudioStreamBasicDescription propertiesToASBD(NSDictionary *properties)
|
|||
asbd.mBytesPerFrame = (asbd.mBitsPerChannel/8)*asbd.mChannelsPerFrame;
|
||||
|
||||
asbd.mFramesPerPacket = 1;
|
||||
asbd.mBytesPerPacket = asbd.mBytesPerFrame;
|
||||
asbd.mBytesPerPacket = asbd.mBytesPerFrame * asbd.mFramesPerPacket;
|
||||
asbd.mReserved = 0;
|
||||
|
||||
if ([[properties objectForKey:@"endian"] isEqualToString:@"big"] || ([[properties objectForKey:@"endian"] isEqualToString:@"host"] && hostIsBigEndian() ))
|
||||
|
|
|
@ -116,23 +116,6 @@
|
|||
8EFFCD6F0AA093AF00C458A5 /* PathNode.m in Sources */ = {isa = PBXBuildFile; fileRef = 8EFFCD530AA093AF00C458A5 /* PathNode.m */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
||||
/* Begin PBXBuildStyle section */
|
||||
28FE105D0BF57082000F8216 /* Development */ = {
|
||||
isa = PBXBuildStyle;
|
||||
buildSettings = {
|
||||
COPY_PHASE_STRIP = NO;
|
||||
};
|
||||
name = Development;
|
||||
};
|
||||
28FE105E0BF57082000F8216 /* Deployment */ = {
|
||||
isa = PBXBuildStyle;
|
||||
buildSettings = {
|
||||
COPY_PHASE_STRIP = YES;
|
||||
};
|
||||
name = Deployment;
|
||||
};
|
||||
/* End PBXBuildStyle section */
|
||||
|
||||
/* Begin PBXCopyFilesBuildPhase section */
|
||||
177FD1000B90CB570011C3B5 /* CopyFiles */ = {
|
||||
isa = PBXCopyFilesBuildPhase;
|
||||
|
@ -733,12 +716,6 @@
|
|||
29B97313FDCFA39411CA2CEA /* Project object */ = {
|
||||
isa = PBXProject;
|
||||
buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "Cog" */;
|
||||
buildSettings = {
|
||||
};
|
||||
buildStyles = (
|
||||
28FE105D0BF57082000F8216 /* Development */,
|
||||
28FE105E0BF57082000F8216 /* Deployment */,
|
||||
);
|
||||
hasScannedForEncodings = 1;
|
||||
mainGroup = 29B97314FDCFA39411CA2CEA /* Cog */;
|
||||
projectDirPath = "";
|
||||
|
|
|
@ -44,12 +44,14 @@ namespace TagLib {
|
|||
|
||||
virtual String title() const
|
||||
{
|
||||
if(file->ID3v2Tag() && !file->ID3v2Tag()->title().isEmpty())
|
||||
if(file->ID3v2Tag() && !file->ID3v2Tag()->title().isEmpty()) {
|
||||
printf("Id3v2\n");
|
||||
return file->ID3v2Tag()->title();
|
||||
|
||||
if(file->ID3v1Tag())
|
||||
}
|
||||
if(file->ID3v1Tag()) {
|
||||
printf("Id3v1\n");
|
||||
return file->ID3v1Tag()->title();
|
||||
|
||||
}
|
||||
return String::null;
|
||||
}
|
||||
|
||||
|
|
|
@ -110,7 +110,6 @@
|
|||
{
|
||||
NSLog(@"Loading playlist: %@", filename);
|
||||
|
||||
|
||||
NSError *error = nil;
|
||||
NSString *contents = [NSString stringWithContentsOfFile:filename encoding:NSUTF8StringEncoding error:&error];
|
||||
if (error || !contents) {
|
||||
|
|
Loading…
Reference in New Issue