If the system has no working Metal devices, disable the visualization. The legacy visualization was also too slow for said systems to handle reasonably anyway, so I guess it's safe to say that they shouldn't have to handle any visualizers at all. At least have working audio playback, of course, since that is the primary function of the application. Too bad that the OpenGL renderers don't work on my scene, it would be nice to have a fallback there. GL 4.1 crashes on an M1, and both GL 4.1 and 3.2 crash with SIGFPE division by zero error on Intel Macs without Metal devices. Meh. Signed-off-by: Christopher Snowhill <kode54@gmail.com>
65 lines
1.3 KiB
Objective-C
65 lines
1.3 KiB
Objective-C
//
|
|
// SpectrumWindowController.m
|
|
// Cog
|
|
//
|
|
// Created by Christopher Snowhill on 5/22/22.
|
|
//
|
|
|
|
#import "SpectrumWindowController.h"
|
|
|
|
#import "SpectrumView.h"
|
|
|
|
@interface SpectrumWindowController ()
|
|
@property SpectrumView *spectrumView;
|
|
@end
|
|
|
|
@implementation SpectrumWindowController
|
|
|
|
- (id)init {
|
|
return [super initWithWindowNibName:@"SpectrumWindow"];
|
|
}
|
|
|
|
- (void)windowDidLoad {
|
|
[super windowDidLoad];
|
|
|
|
[self startRunning];
|
|
}
|
|
|
|
- (void)startRunning {
|
|
if(!self.spectrumView) {
|
|
self.spectrumView = [[SpectrumView alloc] initWithFrame:[[self window] frame]];
|
|
[[self window] setContentView:self.spectrumView];
|
|
if(!self.spectrumView) return;
|
|
|
|
[self.spectrumView enableCameraControl];
|
|
}
|
|
|
|
if(playbackController.playbackStatus == CogStatusPlaying)
|
|
[self.spectrumView startPlayback];
|
|
}
|
|
|
|
- (void)stopRunning {
|
|
[[self window] setContentView:nil];
|
|
self.spectrumView = nil;
|
|
}
|
|
|
|
- (void)windowWillClose:(NSNotification *)notification {
|
|
NSWindow *currentWindow = notification.object;
|
|
if([currentWindow isEqualTo:self.window]) {
|
|
[self stopRunning];
|
|
}
|
|
}
|
|
|
|
- (IBAction)toggleWindow:(id)sender {
|
|
if([[self window] isVisible])
|
|
[[self window] orderOut:self];
|
|
else
|
|
[self showWindow:self];
|
|
}
|
|
|
|
- (IBAction)showWindow:(id)sender {
|
|
[self startRunning];
|
|
return [super showWindow:sender];
|
|
}
|
|
|
|
@end
|