Add decoder open error indicator

When decoder is redirected to the internal silence decoder, show an icon
on the playlist indicating a playback error.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
CQTexperiment
Christopher Snowhill 2022-02-10 02:15:48 -08:00
parent 8f1143818b
commit 5ff1f95481
10 changed files with 48 additions and 0 deletions

View File

@ -768,6 +768,11 @@ NSDictionary *makeRGInfo(PlaylistEntry *pe) {
[[NSNotificationCenter defaultCenter] postNotificationName:CogPlaybackDidBeginNotficiation object:pe];
}
- (void)audioPlayer:(AudioPlayer *)player setError:(NSNumber *)status toTrack:(id)userInfo {
PlaylistEntry *pe = (PlaylistEntry *)userInfo;
[pe setError:[status boolValue]];
}
- (void)removeHDCD:(id)sender {
MainWindow *mainWindow = (MainWindow *)appController.mainWindow;
[mainWindow showHDCDLogo:NO];

View File

@ -127,4 +127,5 @@
- (void)audioPlayer:(AudioPlayer *)player sustainHDCD:(id)userInfo;
- (void)audioPlayer:(AudioPlayer *)player restartPlaybackAtCurrentPosition:(id)userInfo;
- (void)audioPlayer:(AudioPlayer *)player pushInfo:(NSDictionary *)info toTrack:(id)userInfo;
- (void)audioPlayer:(AudioPlayer *)player setError:(NSNumber *)status toTrack:(id)userInfo;
@end

View File

@ -492,6 +492,10 @@
[self sendDelegateMethod:@selector(audioPlayer:sustainHDCD:) withObject:[bufferChain userInfo] waitUntilDone:NO];
}
- (void)setError:(BOOL)status {
[self sendDelegateMethod:@selector(audioPlayer:setError:toTrack:) withObject:[NSNumber numberWithBool:status] withObject:[bufferChain userInfo] waitUntilDone:NO];
}
- (void)setPlaybackStatus:(int)status {
[self setPlaybackStatus:status waitUntilDone:NO];
}

View File

@ -79,4 +79,6 @@
- (void)pushInfo:(NSDictionary *)info;
- (void)setError:(BOOL)status;
@end

View File

@ -268,4 +268,8 @@
[controller pushInfo:info];
}
- (void)setError:(BOOL)status {
[controller setError:status];
}
@end

View File

@ -139,6 +139,16 @@
BOOL shouldClose = YES;
BOOL seekError = NO;
BOOL isError = NO;
if([decoder respondsToSelector:@selector(isSilence)]) {
if([decoder isSilence]) {
isError = YES;
}
}
[controller setError:isError];
while([self shouldContinue] == YES && [self endOfStream] == NO) {
if(shouldSeek == YES) {
BufferChain *bufferChain = [[controller controller] bufferChain];
@ -159,6 +169,10 @@
shouldSeek = NO;
DLog(@"Seeked! Resetting Buffer");
initialBufferFilled = NO;
if(seekError) {
[controller setError:YES];
}
}
if(amountInBuffer < CHUNK_SIZE) {

View File

@ -53,6 +53,8 @@
// These are in NSObject, so as long as you are a subclass of that, you are ok.
- (void)addObserver:(NSObject *)observer forKeyPath:(NSString *)keyPath options:(NSKeyValueObservingOptions)options context:(void *)context;
- (void)removeObserver:(NSObject *)observer forKeyPath:(NSString *)keyPath;
- (BOOL)isSilence;
@end
@protocol CogMetadataReader <NSObject>

View File

@ -122,4 +122,10 @@
return n;
}
- (BOOL)isSilence {
if([decoder respondsToSelector:@selector(isSilence)])
return [decoder isSilence];
return NO;
}
@end

View File

@ -295,4 +295,10 @@
return n;
}
- (BOOL)isSilence {
if([decoder respondsToSelector:@selector(isSilence)])
return [decoder isSilence];
return NO;
}
@end

View File

@ -85,6 +85,10 @@ enum { channels = 2 };
return source;
}
- (BOOL)isSilence {
return YES;
}
+ (NSArray *)fileTypes {
return @[];
}