Fixed bugs dealing with multi-track files and playlist saving/loading.
Fixed problem where cue sheets would play static.CQTexperiment
parent
4b814bdbf0
commit
bc212f3e96
|
@ -77,6 +77,8 @@
|
||||||
MDQueryEnableUpdates(query);
|
MDQueryEnableUpdates(query);
|
||||||
|
|
||||||
[self processPaths:results];
|
[self processPaths:results];
|
||||||
|
|
||||||
|
[dataSource reloadPathNode:self];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)queryUpdate:(NSNotification *)notification
|
- (void)queryUpdate:(NSNotification *)notification
|
||||||
|
|
|
@ -48,11 +48,16 @@
|
||||||
{
|
{
|
||||||
NSString *basePath = [[[filename stringByStandardizingPath] stringByDeletingLastPathComponent] stringByAppendingString:@"/"];
|
NSString *basePath = [[[filename stringByStandardizingPath] stringByDeletingLastPathComponent] stringByAppendingString:@"/"];
|
||||||
|
|
||||||
if ([entryURL isFileURL] && [[entryURL fragment] isEqualToString:@""]) {
|
if ([entryURL isFileURL]) {
|
||||||
//We want relative paths.
|
//We want relative paths.
|
||||||
NSMutableString *entryPath = [[[[entryURL path] stringByStandardizingPath] mutableCopy] autorelease];
|
NSMutableString *entryPath = [[[[entryURL path] stringByStandardizingPath] mutableCopy] autorelease];
|
||||||
|
|
||||||
[entryPath replaceOccurrencesOfString:basePath withString:@"" options:(NSAnchoredSearch | NSLiteralSearch | NSCaseInsensitiveSearch) range:NSMakeRange(0, [entryPath length])];
|
[entryPath replaceOccurrencesOfString:basePath withString:@"" options:(NSAnchoredSearch | NSLiteralSearch | NSCaseInsensitiveSearch) range:NSMakeRange(0, [entryPath length])];
|
||||||
|
if ([entryURL fragment])
|
||||||
|
{
|
||||||
|
[entryPath appendString:@"#"];
|
||||||
|
[entryPath appendString:[entryURL fragment]];
|
||||||
|
}
|
||||||
|
|
||||||
return entryPath;
|
return entryPath;
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,24 +19,35 @@
|
||||||
- (NSURL *)urlForPath:(NSString *)path relativeTo:(NSString *)baseFilename
|
- (NSURL *)urlForPath:(NSString *)path relativeTo:(NSString *)baseFilename
|
||||||
{
|
{
|
||||||
if ([path hasPrefix:@"/"]) {
|
if ([path hasPrefix:@"/"]) {
|
||||||
return [NSURL fileURLWithPath:path];
|
return [NSURL URLWithString:[@"file://" stringByAppendingString:path]];
|
||||||
}
|
}
|
||||||
|
|
||||||
NSRange foundRange = [path rangeOfString:@"://"];
|
NSRange protocolRange = [path rangeOfString:@"://"];
|
||||||
if (foundRange.location != NSNotFound)
|
if (protocolRange.location != NSNotFound)
|
||||||
{
|
{
|
||||||
return [NSURL URLWithString:path];
|
return [NSURL URLWithString:path];
|
||||||
}
|
}
|
||||||
|
|
||||||
NSString *basePath = [[[baseFilename stringByStandardizingPath] stringByDeletingLastPathComponent] stringByAppendingString:@"/"];
|
|
||||||
NSMutableString *unixPath = [path mutableCopy];
|
|
||||||
|
|
||||||
|
NSMutableString *unixPath = [path mutableCopy];
|
||||||
|
|
||||||
//Only relative paths would have windows backslashes.
|
//Only relative paths would have windows backslashes.
|
||||||
[unixPath replaceOccurrencesOfString:@"\\" withString:@"/" options:0 range:NSMakeRange(0, [unixPath length])];
|
[unixPath replaceOccurrencesOfString:@"\\" withString:@"/" options:0 range:NSMakeRange(0, [unixPath length])];
|
||||||
|
|
||||||
return [NSURL fileURLWithPath:[basePath stringByAppendingString:[unixPath autorelease]]];
|
NSMutableString *urlString = [[NSMutableString alloc] init];
|
||||||
}
|
[urlString setString:@"file://"];
|
||||||
|
|
||||||
|
NSString *basePath = [[[baseFilename stringByStandardizingPath] stringByDeletingLastPathComponent] stringByAppendingString:@"/"];
|
||||||
|
|
||||||
|
[urlString appendString:basePath];
|
||||||
|
[urlString appendString:unixPath];
|
||||||
|
|
||||||
|
[unixPath release];
|
||||||
|
|
||||||
|
NSURL *url = [NSURL URLWithString:urlString];
|
||||||
|
[urlString release];
|
||||||
|
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
|
||||||
- (void)parseFile:(NSString *)filename
|
- (void)parseFile:(NSString *)filename
|
||||||
{
|
{
|
||||||
|
|
|
@ -17,9 +17,12 @@
|
||||||
id<CogSource> source;
|
id<CogSource> source;
|
||||||
id<CogDecoder> decoder;
|
id<CogDecoder> decoder;
|
||||||
|
|
||||||
int bytesPerSecond;
|
int bytesPerFrame; //Number of bytes per frame, ie channels * (bitsPerSample/8)
|
||||||
int bytePosition;
|
int bytesPerSecond; //Number of bytes per second, ie bytesPerFrame * sampleRate
|
||||||
double trackEnd;
|
|
||||||
|
int bytePosition; //Current position in bytes.
|
||||||
|
|
||||||
|
double trackEnd; //Seconds until end of track.
|
||||||
|
|
||||||
CueSheet *cuesheet;
|
CueSheet *cuesheet;
|
||||||
CueSheetTrack *track;
|
CueSheetTrack *track;
|
||||||
|
|
|
@ -81,7 +81,8 @@
|
||||||
int channels = [[properties objectForKey:@"channels"] intValue];
|
int channels = [[properties objectForKey:@"channels"] intValue];
|
||||||
float sampleRate = [[properties objectForKey:@"sampleRate"] floatValue];
|
float sampleRate = [[properties objectForKey:@"sampleRate"] floatValue];
|
||||||
|
|
||||||
bytesPerSecond = (int)((bitsPerSample/8) * channels * sampleRate);
|
bytesPerFrame = (bitsPerSample/8) * channels;
|
||||||
|
bytesPerSecond = (int)(bytesPerFrame * sampleRate);
|
||||||
|
|
||||||
[decoder seekToTime: [track time] * 1000.0];
|
[decoder seekToTime: [track time] * 1000.0];
|
||||||
|
|
||||||
|
@ -170,12 +171,9 @@
|
||||||
time += trackStartMs;
|
time += trackStartMs;
|
||||||
|
|
||||||
bytePosition = (time/1000.0) * bytesPerSecond;
|
bytePosition = (time/1000.0) * bytesPerSecond;
|
||||||
|
|
||||||
int bitsPerSample = [[[decoder properties] objectForKey:@"bitsPerSample"] intValue];
|
|
||||||
int channels = [[[decoder properties] objectForKey:@"channels"] intValue];
|
|
||||||
|
|
||||||
NSLog(@"Before: %li", bytePosition);
|
NSLog(@"Before: %li", bytePosition);
|
||||||
bytePosition -= bytePosition % (bitsPerSample/8 * channels);
|
bytePosition -= bytePosition % bytesPerFrame;
|
||||||
NSLog(@"After: %li", bytePosition);
|
NSLog(@"After: %li", bytePosition);
|
||||||
|
|
||||||
return [decoder seekToTime:time];
|
return [decoder seekToTime:time];
|
||||||
|
@ -184,6 +182,7 @@
|
||||||
- (int)fillBuffer:(void *)buf ofSize:(UInt32)size
|
- (int)fillBuffer:(void *)buf ofSize:(UInt32)size
|
||||||
{
|
{
|
||||||
long trackByteEnd = trackEnd * bytesPerSecond;
|
long trackByteEnd = trackEnd * bytesPerSecond;
|
||||||
|
trackByteEnd -= trackByteEnd % (bytesPerFrame);
|
||||||
|
|
||||||
if (bytePosition + size > trackByteEnd) {
|
if (bytePosition + size > trackByteEnd) {
|
||||||
size = trackByteEnd - bytePosition;
|
size = trackByteEnd - bytePosition;
|
||||||
|
|
|
@ -24,22 +24,34 @@
|
||||||
+ (NSURL *)urlForPath:(NSString *)path relativeTo:(NSString *)baseFilename
|
+ (NSURL *)urlForPath:(NSString *)path relativeTo:(NSString *)baseFilename
|
||||||
{
|
{
|
||||||
if ([path hasPrefix:@"/"]) {
|
if ([path hasPrefix:@"/"]) {
|
||||||
return [NSURL fileURLWithPath:path];
|
return [NSURL URLWithString:[@"file://" stringByAppendingString:path]];
|
||||||
}
|
}
|
||||||
|
|
||||||
NSRange foundRange = [path rangeOfString:@"://"];
|
NSRange protocolRange = [path rangeOfString:@"://"];
|
||||||
if (foundRange.location != NSNotFound)
|
if (protocolRange.location != NSNotFound)
|
||||||
{
|
{
|
||||||
return [NSURL URLWithString:path];
|
return [NSURL URLWithString:path];
|
||||||
}
|
}
|
||||||
|
|
||||||
NSString *basePath = [[[baseFilename stringByStandardizingPath] stringByDeletingLastPathComponent] stringByAppendingString:@"/"];
|
|
||||||
NSMutableString *unixPath = [path mutableCopy];
|
NSMutableString *unixPath = [path mutableCopy];
|
||||||
|
|
||||||
//Only relative paths would have windows backslashes.
|
//Only relative paths would have windows backslashes.
|
||||||
[unixPath replaceOccurrencesOfString:@"\\" withString:@"/" options:0 range:NSMakeRange(0, [unixPath length])];
|
[unixPath replaceOccurrencesOfString:@"\\" withString:@"/" options:0 range:NSMakeRange(0, [unixPath length])];
|
||||||
|
|
||||||
|
NSMutableString *urlString = [[NSMutableString alloc] init];
|
||||||
|
[urlString setString:@"file://"];
|
||||||
|
|
||||||
|
NSString *basePath = [[[baseFilename stringByStandardizingPath] stringByDeletingLastPathComponent] stringByAppendingString:@"/"];
|
||||||
|
|
||||||
|
[urlString appendString:basePath];
|
||||||
|
[urlString appendString:unixPath];
|
||||||
|
|
||||||
|
[unixPath release];
|
||||||
|
|
||||||
return [NSURL fileURLWithPath:[basePath stringByAppendingString:[unixPath autorelease]]];
|
NSURL *url = [NSURL URLWithString:urlString];
|
||||||
|
[urlString release];
|
||||||
|
|
||||||
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (NSArray *)urlsForContainerURL:(NSURL *)url
|
+ (NSArray *)urlsForContainerURL:(NSURL *)url
|
||||||
|
|
|
@ -24,22 +24,34 @@
|
||||||
+ (NSURL *)urlForPath:(NSString *)path relativeTo:(NSString *)baseFilename
|
+ (NSURL *)urlForPath:(NSString *)path relativeTo:(NSString *)baseFilename
|
||||||
{
|
{
|
||||||
if ([path hasPrefix:@"/"]) {
|
if ([path hasPrefix:@"/"]) {
|
||||||
return [NSURL fileURLWithPath:path];
|
return [NSURL URLWithString:[@"file://" stringByAppendingString:path]];
|
||||||
}
|
}
|
||||||
|
|
||||||
NSRange foundRange = [path rangeOfString:@"://"];
|
NSRange protocolRange = [path rangeOfString:@"://"];
|
||||||
if (foundRange.location != NSNotFound)
|
if (protocolRange.location != NSNotFound)
|
||||||
{
|
{
|
||||||
return [NSURL URLWithString:path];
|
return [NSURL URLWithString:path];
|
||||||
}
|
}
|
||||||
|
|
||||||
NSString *basePath = [[[baseFilename stringByStandardizingPath] stringByDeletingLastPathComponent] stringByAppendingString:@"/"];
|
|
||||||
NSMutableString *unixPath = [path mutableCopy];
|
NSMutableString *unixPath = [path mutableCopy];
|
||||||
|
|
||||||
//Only relative paths would have windows backslashes.
|
//Only relative paths would have windows backslashes.
|
||||||
[unixPath replaceOccurrencesOfString:@"\\" withString:@"/" options:0 range:NSMakeRange(0, [unixPath length])];
|
[unixPath replaceOccurrencesOfString:@"\\" withString:@"/" options:0 range:NSMakeRange(0, [unixPath length])];
|
||||||
|
|
||||||
|
NSMutableString *urlString = [[NSMutableString alloc] init];
|
||||||
|
[urlString setString:@"file://"];
|
||||||
|
|
||||||
|
NSString *basePath = [[[baseFilename stringByStandardizingPath] stringByDeletingLastPathComponent] stringByAppendingString:@"/"];
|
||||||
|
|
||||||
|
[urlString appendString:basePath];
|
||||||
|
[urlString appendString:unixPath];
|
||||||
|
|
||||||
|
[unixPath release];
|
||||||
|
|
||||||
return [NSURL fileURLWithPath:[basePath stringByAppendingString:[unixPath autorelease]]];
|
NSURL *url = [NSURL URLWithString:urlString];
|
||||||
|
[urlString release];
|
||||||
|
|
||||||
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (NSArray *)urlsForContainerURL:(NSURL *)url
|
+ (NSArray *)urlsForContainerURL:(NSURL *)url
|
||||||
|
|
Loading…
Reference in New Issue