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);
|
||||
|
||||
[self processPaths:results];
|
||||
|
||||
[dataSource reloadPathNode:self];
|
||||
}
|
||||
|
||||
- (void)queryUpdate:(NSNotification *)notification
|
||||
|
|
|
@ -48,11 +48,16 @@
|
|||
{
|
||||
NSString *basePath = [[[filename stringByStandardizingPath] stringByDeletingLastPathComponent] stringByAppendingString:@"/"];
|
||||
|
||||
if ([entryURL isFileURL] && [[entryURL fragment] isEqualToString:@""]) {
|
||||
if ([entryURL isFileURL]) {
|
||||
//We want relative paths.
|
||||
NSMutableString *entryPath = [[[[entryURL path] stringByStandardizingPath] mutableCopy] autorelease];
|
||||
|
||||
[entryPath replaceOccurrencesOfString:basePath withString:@"" options:(NSAnchoredSearch | NSLiteralSearch | NSCaseInsensitiveSearch) range:NSMakeRange(0, [entryPath length])];
|
||||
if ([entryURL fragment])
|
||||
{
|
||||
[entryPath appendString:@"#"];
|
||||
[entryPath appendString:[entryURL fragment]];
|
||||
}
|
||||
|
||||
return entryPath;
|
||||
}
|
||||
|
|
|
@ -19,24 +19,35 @@
|
|||
- (NSURL *)urlForPath:(NSString *)path relativeTo:(NSString *)baseFilename
|
||||
{
|
||||
if ([path hasPrefix:@"/"]) {
|
||||
return [NSURL fileURLWithPath:path];
|
||||
return [NSURL URLWithString:[@"file://" stringByAppendingString:path]];
|
||||
}
|
||||
|
||||
NSRange foundRange = [path rangeOfString:@"://"];
|
||||
if (foundRange.location != NSNotFound)
|
||||
NSRange protocolRange = [path rangeOfString:@"://"];
|
||||
if (protocolRange.location != NSNotFound)
|
||||
{
|
||||
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.
|
||||
[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
|
||||
{
|
||||
|
|
|
@ -17,9 +17,12 @@
|
|||
id<CogSource> source;
|
||||
id<CogDecoder> decoder;
|
||||
|
||||
int bytesPerSecond;
|
||||
int bytePosition;
|
||||
double trackEnd;
|
||||
int bytesPerFrame; //Number of bytes per frame, ie channels * (bitsPerSample/8)
|
||||
int bytesPerSecond; //Number of bytes per second, ie bytesPerFrame * sampleRate
|
||||
|
||||
int bytePosition; //Current position in bytes.
|
||||
|
||||
double trackEnd; //Seconds until end of track.
|
||||
|
||||
CueSheet *cuesheet;
|
||||
CueSheetTrack *track;
|
||||
|
|
|
@ -81,7 +81,8 @@
|
|||
int channels = [[properties objectForKey:@"channels"] intValue];
|
||||
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];
|
||||
|
||||
|
@ -170,12 +171,9 @@
|
|||
time += trackStartMs;
|
||||
|
||||
bytePosition = (time/1000.0) * bytesPerSecond;
|
||||
|
||||
int bitsPerSample = [[[decoder properties] objectForKey:@"bitsPerSample"] intValue];
|
||||
int channels = [[[decoder properties] objectForKey:@"channels"] intValue];
|
||||
|
||||
|
||||
NSLog(@"Before: %li", bytePosition);
|
||||
bytePosition -= bytePosition % (bitsPerSample/8 * channels);
|
||||
bytePosition -= bytePosition % bytesPerFrame;
|
||||
NSLog(@"After: %li", bytePosition);
|
||||
|
||||
return [decoder seekToTime:time];
|
||||
|
@ -184,6 +182,7 @@
|
|||
- (int)fillBuffer:(void *)buf ofSize:(UInt32)size
|
||||
{
|
||||
long trackByteEnd = trackEnd * bytesPerSecond;
|
||||
trackByteEnd -= trackByteEnd % (bytesPerFrame);
|
||||
|
||||
if (bytePosition + size > trackByteEnd) {
|
||||
size = trackByteEnd - bytePosition;
|
||||
|
|
|
@ -24,22 +24,34 @@
|
|||
+ (NSURL *)urlForPath:(NSString *)path relativeTo:(NSString *)baseFilename
|
||||
{
|
||||
if ([path hasPrefix:@"/"]) {
|
||||
return [NSURL fileURLWithPath:path];
|
||||
return [NSURL URLWithString:[@"file://" stringByAppendingString:path]];
|
||||
}
|
||||
|
||||
NSRange foundRange = [path rangeOfString:@"://"];
|
||||
if (foundRange.location != NSNotFound)
|
||||
NSRange protocolRange = [path rangeOfString:@"://"];
|
||||
if (protocolRange.location != NSNotFound)
|
||||
{
|
||||
return [NSURL URLWithString:path];
|
||||
}
|
||||
|
||||
NSString *basePath = [[[baseFilename stringByStandardizingPath] stringByDeletingLastPathComponent] stringByAppendingString:@"/"];
|
||||
|
||||
NSMutableString *unixPath = [path mutableCopy];
|
||||
|
||||
//Only relative paths would have windows backslashes.
|
||||
[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
|
||||
|
|
|
@ -24,22 +24,34 @@
|
|||
+ (NSURL *)urlForPath:(NSString *)path relativeTo:(NSString *)baseFilename
|
||||
{
|
||||
if ([path hasPrefix:@"/"]) {
|
||||
return [NSURL fileURLWithPath:path];
|
||||
return [NSURL URLWithString:[@"file://" stringByAppendingString:path]];
|
||||
}
|
||||
|
||||
NSRange foundRange = [path rangeOfString:@"://"];
|
||||
if (foundRange.location != NSNotFound)
|
||||
NSRange protocolRange = [path rangeOfString:@"://"];
|
||||
if (protocolRange.location != NSNotFound)
|
||||
{
|
||||
return [NSURL URLWithString:path];
|
||||
}
|
||||
|
||||
NSString *basePath = [[[baseFilename stringByStandardizingPath] stringByDeletingLastPathComponent] stringByAppendingString:@"/"];
|
||||
|
||||
NSMutableString *unixPath = [path mutableCopy];
|
||||
|
||||
//Only relative paths would have windows backslashes.
|
||||
[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
|
||||
|
|
Loading…
Reference in New Issue