Error handler: Better handle errors and increase silence generator to 10 seconds at a time

CQTexperiment
Christopher Snowhill 2021-12-22 16:22:05 -08:00
parent 7da3324e32
commit 9566a36815
2 changed files with 6 additions and 3 deletions

View File

@ -51,10 +51,10 @@
id<CogSource> source = [AudioSource audioSourceForURL:url];
DLog(@"Opening: %@", url);
if (![source open:url])
if (!source || ![source open:url])
{
DLog(@"Couldn't open source...");
url = [NSURL URLWithString:@"silence://1"];
url = [NSURL URLWithString:@"silence://10"];
source = [AudioSource audioSourceForURL:url];
if (![source open:url])
return NO;

View File

@ -23,7 +23,10 @@ enum { channels = 2 };
NSString * path = [[[s url] relativeString] substringFromIndex:10];
length = [path intValue] * sample_rate;
int seconds = [path intValue];
if (!seconds) seconds = 10;
length = seconds * sample_rate;
remain = length;
[self willChangeValueForKey:@"properties"];