Skip to content

Commit

Permalink
Do not initialize metal render delegate unless when using MetalFx
Browse files Browse the repository at this point in the history
  • Loading branch information
TimmyOVO committed May 2, 2024
1 parent e7b9e34 commit 31af06d
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions Limelight/ViewControllers/StreamFrameViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -214,19 +214,21 @@ - (void)viewDidLoad
object: nil];
#endif

_streamView.device = MTLCreateSystemDefaultDevice();
_streamView.backgroundColor = UIColor.blackColor;
if(!_streamView.device) {
NSLog(@"Metal is not supported on this device");
self.view = [[UIView alloc] initWithFrame:self.view.frame];
return;
}

if (@available(iOS 16.0, *)) {
_renderer = [[StreamViewRenderer alloc] initWithMetalKitView:_streamView];
[_renderer mtkView:_streamView drawableSizeWillChange:_streamView.drawableSize];
if ([_settings.metalFxMultiplier unsignedIntValue] > 1) {
_streamView.device = MTLCreateSystemDefaultDevice();
_streamView.backgroundColor = UIColor.blackColor;
if(!_streamView.device) {
NSLog(@"Metal is not supported on this device");
self.view = [[UIView alloc] initWithFrame:self.view.frame];
return;
}

if (@available(iOS 16.0, *)) {
_renderer = [[StreamViewRenderer alloc] initWithMetalKitView:_streamView];
[_renderer mtkView:_streamView drawableSizeWillChange:_streamView.drawableSize];

_streamView.delegate = _renderer;
_streamView.delegate = _renderer;
}
}

// Only enable scroll and zoom in absolute touch mode
Expand Down Expand Up @@ -348,10 +350,15 @@ - (void)updateOverlayText:(NSString*)text {
}
}

- (void)viewDidDisappear:(BOOL)animated {
Log(LOG_I, @"Starting inactivity termination timer");
}
- (void) returnToMainFrame {
// Reset display mode back to default
[self updatePreferredDisplayMode:NO];
[self->_streamView invalidateIntrinsicContentSize];
[self->_streamView releaseDrawables];
self->_streamView = nil;
[_statsUpdateTimer invalidate];
_statsUpdateTimer = nil;

Expand Down

0 comments on commit 31af06d

Please sign in to comment.