From 23d4f90a1cea18551d0e96fe93ff5446a2d51068 Mon Sep 17 00:00:00 2001 From: Chris Moeller Date: Fri, 4 Oct 2013 09:00:18 -0700 Subject: [PATCH] Fixed GME container parser to support CogSource --- Plugins/GME/GameContainer.m | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/Plugins/GME/GameContainer.m b/Plugins/GME/GameContainer.m index 79d2d659e..3d6e7dc32 100755 --- a/Plugins/GME/GameContainer.m +++ b/Plugins/GME/GameContainer.m @@ -27,12 +27,26 @@ //This really should be source... + (NSArray *)urlsForContainerURL:(NSURL *)url { - if (![url isFileURL]) { - return nil; - } + id audioSourceClass = NSClassFromString(@"AudioSource"); + id 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];