Added subsong support
parent
1def63e087
commit
46607c8d65
|
@ -13,6 +13,7 @@
|
|||
17C8F7B90CBEF380008D969D /* Dumb.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 17C8F69E0CBEE857008D969D /* Dumb.framework */; };
|
||||
17DA363D0CC0600E0003F6B2 /* DumbMetadataReader.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 17DA363B0CC0600E0003F6B2 /* DumbMetadataReader.h */; };
|
||||
17DA363E0CC0600E0003F6B2 /* DumbMetadataReader.m in Sources */ = {isa = PBXBuildFile; fileRef = 17DA363C0CC0600E0003F6B2 /* DumbMetadataReader.m */; };
|
||||
8335FF6717FF6FD9002D8DD2 /* DumbContainer.m in Sources */ = {isa = PBXBuildFile; fileRef = 8335FF6617FF6FD9002D8DD2 /* DumbContainer.m */; };
|
||||
8D5B49B0048680CD000E48DA /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C167DFE841241C02AAC07 /* InfoPlist.strings */; };
|
||||
8D5B49B4048680CD000E48DA /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7ADFEA557BF11CA2CBB /* Cocoa.framework */; };
|
||||
/* End PBXBuildFile section */
|
||||
|
@ -61,6 +62,8 @@
|
|||
17DA363B0CC0600E0003F6B2 /* DumbMetadataReader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DumbMetadataReader.h; sourceTree = "<group>"; };
|
||||
17DA363C0CC0600E0003F6B2 /* DumbMetadataReader.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DumbMetadataReader.m; sourceTree = "<group>"; };
|
||||
32DBCF630370AF2F00C91783 /* Dumb_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Dumb_Prefix.pch; sourceTree = "<group>"; };
|
||||
8335FF6517FF6FD9002D8DD2 /* DumbContainer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DumbContainer.h; sourceTree = "<group>"; };
|
||||
8335FF6617FF6FD9002D8DD2 /* DumbContainer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DumbContainer.m; sourceTree = "<group>"; };
|
||||
8D5B49B6048680CD000E48DA /* Dumb.bundle */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = Dumb.bundle; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
8D5B49B7048680CD000E48DA /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
D2F7E65807B2D6F200F64583 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = /System/Library/Frameworks/CoreData.framework; sourceTree = "<absolute>"; };
|
||||
|
@ -112,6 +115,8 @@
|
|||
08FB77AFFE84173DC02AAC07 /* Classes */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
8335FF6517FF6FD9002D8DD2 /* DumbContainer.h */,
|
||||
8335FF6617FF6FD9002D8DD2 /* DumbContainer.m */,
|
||||
17C8F70C0CBEEC87008D969D /* Plugin.h */,
|
||||
17C8F68E0CBEE846008D969D /* DumbDecoder.h */,
|
||||
17C8F68F0CBEE846008D969D /* DumbDecoder.m */,
|
||||
|
@ -243,6 +248,7 @@
|
|||
isa = PBXSourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
8335FF6717FF6FD9002D8DD2 /* DumbContainer.m in Sources */,
|
||||
17C8F6950CBEE846008D969D /* DumbDecoder.m in Sources */,
|
||||
17DA363E0CC0600E0003F6B2 /* DumbMetadataReader.m in Sources */,
|
||||
);
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
//
|
||||
// DumbContainer.h
|
||||
// Dumb
|
||||
//
|
||||
// Created by Christopher Snowhill on 10/4/13.
|
||||
// Copyright 2013 __NoWork, Inc__. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
#import "Plugin.h"
|
||||
|
||||
@interface DumbContainer : NSObject <CogContainer> {
|
||||
|
||||
}
|
||||
|
||||
@end
|
|
@ -0,0 +1,89 @@
|
|||
//
|
||||
// DumbContainer.m
|
||||
// Dumb
|
||||
//
|
||||
// Created by Christopher Snowhill on 10/4/13.
|
||||
// Copyright 2013 __NoWork, Inc__. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Dumb/dumb.h>
|
||||
|
||||
#import "DumbContainer.h"
|
||||
#import "DumbDecoder.h"
|
||||
|
||||
@implementation DumbContainer
|
||||
|
||||
+ (NSArray *)fileTypes
|
||||
{
|
||||
return [DumbDecoder fileTypes];
|
||||
}
|
||||
|
||||
+ (NSArray *)mimeTypes
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
struct callbackData
|
||||
{
|
||||
NSString * baseUrl;
|
||||
NSMutableArray * tracks;
|
||||
};
|
||||
|
||||
int scanCallback(void *data, int startOrder, long length)
|
||||
{
|
||||
struct callbackData * cbData = ( struct callbackData * ) data;
|
||||
|
||||
[cbData->tracks addObject:[NSURL URLWithString:[cbData->baseUrl stringByAppendingFormat:@"#%i", startOrder]]];
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
+ (NSArray *)urlsForContainerURL:(NSURL *)url
|
||||
{
|
||||
id audioSourceClass = NSClassFromString(@"AudioSource");
|
||||
id<CogSource> source = [audioSourceClass audioSourceForURL:url];
|
||||
|
||||
if (![source open:url])
|
||||
return 0;
|
||||
|
||||
if (![source seekable])
|
||||
return 0;
|
||||
|
||||
DUMBFILE * df = dumbfile_open_ex(source, &dfs);
|
||||
if (!df)
|
||||
{
|
||||
NSLog(@"EX Failed");
|
||||
return NO;
|
||||
}
|
||||
|
||||
NSMutableArray *tracks = [NSMutableArray array];
|
||||
|
||||
int i;
|
||||
int subsongs = dumb_get_psm_subsong_count( df );
|
||||
if ( subsongs ) {
|
||||
dumbfile_close( df );
|
||||
|
||||
for (i = 0; i < subsongs; ++i) {
|
||||
[tracks addObject:[NSURL URLWithString:[[url absoluteString] stringByAppendingFormat:@"#%i", i]]];
|
||||
}
|
||||
} else {
|
||||
dumbfile_seek( df, 0, SEEK_SET );
|
||||
|
||||
DUH *duh;
|
||||
NSString *ext = [[[url path] pathExtension] lowercaseString];
|
||||
duh = dumb_read_any_quick(df, [ext isEqualToString:@"mod"] ? 0 : 1, 0);
|
||||
|
||||
dumbfile_close(df);
|
||||
|
||||
if ( duh ) {
|
||||
struct callbackData data = { [url absoluteString], tracks };
|
||||
|
||||
dumb_it_scan_for_playable_orders( duh_get_it_sigdata( duh ), scanCallback, &data );
|
||||
}
|
||||
}
|
||||
|
||||
return tracks;
|
||||
}
|
||||
|
||||
|
||||
@end
|
|
@ -9,10 +9,7 @@
|
|||
#import <Cocoa/Cocoa.h>
|
||||
|
||||
#import <Dumb/dumb.h>
|
||||
|
||||
#define __FRAMEWORK__
|
||||
#import <Dumb/it.h>
|
||||
#undef __FRAMEWORK__
|
||||
|
||||
#import "Plugin.h"
|
||||
|
||||
|
|
|
@ -104,8 +104,25 @@ DUMBFILE_SYSTEM dfs = {
|
|||
return NO;
|
||||
}
|
||||
|
||||
int subsong = 0;
|
||||
int startOrder = 0;
|
||||
|
||||
NSURL * url = [s url];
|
||||
int track_num;
|
||||
if ([[url fragment] length] == 0)
|
||||
track_num = 0;
|
||||
else
|
||||
track_num = [[url fragment] intValue];
|
||||
|
||||
if ( dumb_get_psm_subsong_count( df ) )
|
||||
subsong = track_num;
|
||||
else
|
||||
startOrder = track_num;
|
||||
|
||||
dumbfile_seek( df, 0, SEEK_SET );
|
||||
|
||||
NSString *ext = [[[[s url] path] pathExtension] lowercaseString];
|
||||
duh = dumb_read_any(df, [ext isEqualToString:@"mod"] ? 0 : 1, 0);
|
||||
duh = dumb_read_any(df, [ext isEqualToString:@"mod"] ? 0 : 1, subsong);
|
||||
if (!duh)
|
||||
{
|
||||
NSLog(@"Failed to create duh");
|
||||
|
@ -114,10 +131,9 @@ DUMBFILE_SYSTEM dfs = {
|
|||
}
|
||||
dumbfile_close(df);
|
||||
|
||||
length = duh_get_length(duh);
|
||||
|
||||
length = dumb_it_build_checkpoints( duh_get_it_sigdata( duh ), startOrder );
|
||||
|
||||
dsr = duh_start_sigrenderer(duh, 0, 2 /* stereo */, 0 /* start from the beginning */);
|
||||
dsr = duh_start_sigrenderer(duh, 0, 2 /* stereo */, startOrder);
|
||||
if (!dsr)
|
||||
{
|
||||
NSLog(@"Failed to create dsr");
|
||||
|
@ -213,7 +229,7 @@ DUMBFILE_SYSTEM dfs = {
|
|||
|
||||
+ (NSArray *)fileTypes
|
||||
{
|
||||
return [NSArray arrayWithObjects:@"it", @"xm", @"s3m", @"mod", @"stm", @"ptm", @"mtm", @"669", @"psm", @"am", @"dsm", @"amf", @"okt", @"okta", nil];
|
||||
return [NSArray arrayWithObjects:@"it", @"itz", @"xm", @"xmz", @"s3m", @"s3z", @"mod", @"mdz", @"stm", @"stz", @"ptm", @"mtm", @"669", @"psm", @"am", @"dsm", @"amf", @"okt", @"okta", nil];
|
||||
}
|
||||
|
||||
+ (NSArray *)mimeTypes
|
||||
|
|
Loading…
Reference in New Issue