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