[Visualizer] Disable processing when vis is hidden
When visualizer windows are created, but not actually visible, stop the update timer, to save processing, especially if the vis is enabled in one or the other main/mini windows. Signed-off-by: Christopher Snowhill <kode54@gmail.com>swiftingly
parent
c208f60da4
commit
dc103ac546
|
@ -64,10 +64,10 @@ extern NSString *CogPlaybackDidStopNotficiation;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void)updateVisListening {
|
- (void)updateVisListening {
|
||||||
if(self.isListening && (paused || stopped)) {
|
if(self.isListening && (!self.window.isVisible || paused || stopped)) {
|
||||||
[self stopTimer];
|
[self stopTimer];
|
||||||
self.isListening = NO;
|
self.isListening = NO;
|
||||||
} else if(!self.isListening && (!stopped && !paused)) {
|
} else if(!self.isListening && (self.window.isVisible && !stopped && !paused)) {
|
||||||
[self startTimer];
|
[self startTimer];
|
||||||
self.isListening = YES;
|
self.isListening = YES;
|
||||||
}
|
}
|
||||||
|
@ -79,6 +79,8 @@ extern NSString *CogPlaybackDidStopNotficiation;
|
||||||
context:(void *)context {
|
context:(void *)context {
|
||||||
if(context == kSpectrumViewContext) {
|
if(context == kSpectrumViewContext) {
|
||||||
[self updateControls];
|
[self updateControls];
|
||||||
|
} else if([keyPath isEqualToString:@"self.window.visible"]) {
|
||||||
|
[self updateVisListening];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -181,6 +183,8 @@ extern NSString *CogPlaybackDidStopNotficiation;
|
||||||
[[NSUserDefaultsController sharedUserDefaultsController] addObserver:self forKeyPath:@"values.spectrumBarColor" options:0 context:kSpectrumViewContext];
|
[[NSUserDefaultsController sharedUserDefaultsController] addObserver:self forKeyPath:@"values.spectrumBarColor" options:0 context:kSpectrumViewContext];
|
||||||
[[NSUserDefaultsController sharedUserDefaultsController] addObserver:self forKeyPath:@"values.spectrumDotColor" options:0 context:kSpectrumViewContext];
|
[[NSUserDefaultsController sharedUserDefaultsController] addObserver:self forKeyPath:@"values.spectrumDotColor" options:0 context:kSpectrumViewContext];
|
||||||
|
|
||||||
|
[self addObserver:self forKeyPath:@"self.window.visible" options:0 context:nil];
|
||||||
|
|
||||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||||
selector:@selector(playbackDidBegin:)
|
selector:@selector(playbackDidBegin:)
|
||||||
name:CogPlaybackDidBeginNotficiation
|
name:CogPlaybackDidBeginNotficiation
|
||||||
|
@ -215,6 +219,8 @@ extern NSString *CogPlaybackDidStopNotficiation;
|
||||||
[[NSUserDefaultsController sharedUserDefaultsController] removeObserver:self forKeyPath:@"values.spectrumBarColor"];
|
[[NSUserDefaultsController sharedUserDefaultsController] removeObserver:self forKeyPath:@"values.spectrumBarColor"];
|
||||||
[[NSUserDefaultsController sharedUserDefaultsController] removeObserver:self forKeyPath:@"values.spectrumDotColor"];
|
[[NSUserDefaultsController sharedUserDefaultsController] removeObserver:self forKeyPath:@"values.spectrumDotColor"];
|
||||||
|
|
||||||
|
[self removeObserver:self forKeyPath:@"self.window.visible" context:nil];
|
||||||
|
|
||||||
[[NSNotificationCenter defaultCenter] removeObserver:self
|
[[NSNotificationCenter defaultCenter] removeObserver:self
|
||||||
name:CogPlaybackDidBeginNotficiation
|
name:CogPlaybackDidBeginNotficiation
|
||||||
object:nil];
|
object:nil];
|
||||||
|
|
Loading…
Reference in New Issue