Fixed GME container parser to support CogSource

CQTexperiment
Chris Moeller 2013-10-04 09:00:18 -07:00
parent 44da1bda00
commit 23d4f90a1c
1 changed files with 18 additions and 4 deletions

View File

@ -27,12 +27,26 @@
//This really should be source...
+ (NSArray *)urlsForContainerURL:(NSURL *)url
{
if (![url isFileURL]) {
return nil;
}
id audioSourceClass = NSClassFromString(@"AudioSource");
id<CogSource> source = [audioSourceClass audioSourceForURL:url];
if (![source open:url])
return 0;
if (![source seekable])
return 0;
[source seek:0 whence:SEEK_END];
long size = [source tell];
[source seek:0 whence:SEEK_SET];
void * data = malloc(size);
[source read:data amount:size];
Music_Emu *emu;
gme_err_t error = gme_open_file([[url path] UTF8String], &emu, 44100);
gme_err_t error = gme_open_data(data, size, &emu, 44100);
free(data);
if (NULL != error) {
NSLog(@"GME: Error loading file: %@ %s", [url path], error);
return [NSArray arrayWithObject:url];