Load the DTS decoder from Perian too.

This commit is contained in:
Damiano Galassi committed 2014-07-29 12:36:44 +02:00
1 parent adc294be53
commit dbf73e87c8
1 file changed
+59 -42
+59 -42
View File
@@ -41,42 +41,55 @@ static NSMutableDictionary *_loadedComponents;
} }
- (void)loadBundledComponents { - (void)loadBundledComponents {
NSURL *url = [[[NSBundle mainBundle] resourceURL] URLByAppendingPathComponent:@"Decoders"]; @synchronized(self) {
NSURL *url = [[[NSBundle mainBundle] resourceURL] URLByAppendingPathComponent:@"Decoders"];
if (![[NSFileManager defaultManager] fileExistsAtPath:[url path] isDirectory:NULL]) { if (![[NSFileManager defaultManager] fileExistsAtPath:[url path] isDirectory:NULL]) {
return; return;
}
if (![self componentLoadedForFormat:kAudioFormatAC3]) {
OSStatus err = [self loadComponent:kAudioDecoderComponentType
format:kAudioFormatAC3
manufacturer:'cd3r'
url:[url URLByAppendingPathComponent:@"A52Codec.component/Contents/MacOS/A52Codec"]
entry:"ACShepA52DecoderEntry"];
if (!err) {
NSLog(@"AC-3 Decoder loaded");
} }
}
if (![self componentLoadedForFormat:'XiVs']) { if (![self componentLoadedForFormat:kAudioFormatAC3]) {
OSStatus err = [self loadComponent:kAudioDecoderComponentType OSStatus err = [self loadComponent:kAudioDecoderComponentType
format:'XiVs' format:kAudioFormatAC3
manufacturer:'Xiph' manufacturer:'cd3r'
url:[url URLByAppendingPathComponent:@"XiphQT.component/Contents/MacOS/XiphQT"] url:[url URLByAppendingPathComponent:@"A52Codec.component/Contents/MacOS/A52Codec"]
entry:"CAOggVorbisDecoderEntry"]; entry:"ACShepA52DecoderEntry"];
if (!err) { if (!err) {
NSLog(@"Vorbis Decoder loaded"); NSLog(@"AC-3 Decoder loaded");
}
} }
}
if (![self componentLoadedForFormat:'XiFL']) { if (![self componentLoadedForFormat:'XiVs']) {
OSStatus err = [self loadComponent:kAudioDecoderComponentType OSStatus err = [self loadComponent:kAudioDecoderComponentType
format:'XiFL' format:'XiVs'
manufacturer:'Xiph' manufacturer:'Xiph'
url:[url URLByAppendingPathComponent:@"XiphQT.component/Contents/MacOS/XiphQT"] url:[url URLByAppendingPathComponent:@"XiphQT.component/Contents/MacOS/XiphQT"]
entry:"CAOggFLACDecoderEntry"]; entry:"CAOggVorbisDecoderEntry"];
if (!err) { if (!err) {
NSLog(@"FLAC Decoder loaded"); NSLog(@"Vorbis Decoder loaded");
}
}
if (![self componentLoadedForFormat:'XiFL']) {
OSStatus err = [self loadComponent:kAudioDecoderComponentType
format:'XiFL'
manufacturer:'Xiph'
url:[url URLByAppendingPathComponent:@"XiphQT.component/Contents/MacOS/XiphQT"]
entry:"CAOggFLACDecoderEntry"];
if (!err) {
NSLog(@"FLAC Decoder loaded");
}
}
if (![self componentLoadedForFormat:'DTS ']) {
OSStatus err = [self loadComponent:kAudioDecoderComponentType
format:'DTS '
manufacturer:'Peri'
url:[url URLByAppendingPathComponent:@"Perian.component/Contents/MacOS/Perian"]
entry:"FFissionVBRDecoderEntry"];
if (!err) {
NSLog(@"DTS Decoder loaded");
}
} }
} }
} }
@@ -84,16 +97,20 @@ static NSMutableDictionary *_loadedComponents;
- (BOOL)componentLoadedForFormat:(OSType)format { - (BOOL)componentLoadedForFormat:(OSType)format {
BOOL loaded = NO; BOOL loaded = NO;
AudioComponentDescription acd = { 0 }; if ([_loadedComponents valueForKey:@(FourCC2Str(format))]) {
acd.componentType = kAudioDecoderComponentType; loaded = YES;;
acd.componentSubType = format; } else {
AudioComponent comp = NULL; AudioComponentDescription acd = { 0 };
acd.componentType = kAudioDecoderComponentType;
acd.componentSubType = format;
AudioComponent comp = NULL;
while((comp = AudioComponentFindNext(comp, &acd))) { while((comp = AudioComponentFindNext(comp, &acd))) {
AudioComponentDescription outDesc = { 0 }; AudioComponentDescription outDesc = { 0 };
AudioComponentGetDescription(comp, &outDesc); AudioComponentGetDescription(comp, &outDesc);
if (outDesc.componentSubType == format) { if (outDesc.componentSubType == format) {
loaded = YES; loaded = YES;
}
} }
} }
@@ -130,7 +147,7 @@ static NSMutableDictionary *_loadedComponents;
cd.componentManufacturer = manufactorer; cd.componentManufacturer = manufactorer;
cd.componentFlags = 0; cd.componentFlags = 0;
cd.componentFlagsMask = 0; cd.componentFlagsMask = 0;
ComponentResult (*ComponentRoutine) (ComponentParameters * cp, Handle componentStorage); ComponentResult (*ComponentRoutine) (ComponentParameters *cp, Handle componentStorage);
void *handle = dlopen([[url path] UTF8String], RTLD_LAZY|RTLD_LOCAL); void *handle = dlopen([[url path] UTF8String], RTLD_LAZY|RTLD_LOCAL);
if (handle) if (handle)
{ {
@@ -169,7 +186,7 @@ static NSMutableDictionary *_loadedComponents;
theDescription.componentManufacturer = manufactorer; theDescription.componentManufacturer = manufactorer;
theDescription.componentFlagsMask = 0; theDescription.componentFlagsMask = 0;
AudioComponentPlugInInterface * (*AudioComponentFactoryFunction)(const AudioComponentDescription *inDesc); AudioComponentPlugInInterface * (*AudioComponentFactoryFunction)(const AudioComponentDescription *inDesc);
void *handle = dlopen([[url path] UTF8String], RTLD_LAZY|RTLD_LOCAL); void *handle = dlopen([[url path] UTF8String], RTLD_LAZY|RTLD_LOCAL);
if (handle) if (handle)
{ {