Add configurable framesPerSecond preference for CADisplayLink
Allow users to configure the target frame rate via preferences instead of hardcoding 30fps. Defaults to 30fps when not specified. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -14,7 +14,8 @@
|
||||
nativeWidth:(size_t)nativeWidth
|
||||
nativeHeight:(size_t)nativeHeight
|
||||
renderServerSurface:(IOSurfaceRef)renderServerSurface
|
||||
captureModeBlock:(CaptureMode(^)(void))captureModeBlock;
|
||||
captureModeBlock:(CaptureMode(^)(void))captureModeBlock
|
||||
preferredFramesPerSecond:(int)preferredFramesPerSecond;
|
||||
- (void)startFrameLoop;
|
||||
- (void)stopFrameLoop;
|
||||
@end
|
||||
|
||||
@@ -22,6 +22,9 @@
|
||||
IOSurfaceRef _renderServerSurface; // Separate surface for CARenderServer (avoids framebuffer locking)
|
||||
CaptureMode(^_captureModeBlock)(void);
|
||||
|
||||
// Frame rate
|
||||
int _preferredFramesPerSecond;
|
||||
|
||||
// Diagnostics
|
||||
uint64_t _timerFires;
|
||||
uint64_t _framesRendered;
|
||||
@@ -40,7 +43,8 @@
|
||||
nativeWidth:(size_t)nativeWidth
|
||||
nativeHeight:(size_t)nativeHeight
|
||||
renderServerSurface:(IOSurfaceRef)renderServerSurface
|
||||
captureModeBlock:(CaptureMode(^)(void))captureModeBlock {
|
||||
captureModeBlock:(CaptureMode(^)(void))captureModeBlock
|
||||
preferredFramesPerSecond:(int)preferredFramesPerSecond {
|
||||
if ((self = [super init])) {
|
||||
_q = [[NSOperationQueue alloc] init];
|
||||
_q.maxConcurrentOperationCount = 1; // Serialize to prevent frame queue buildup
|
||||
@@ -59,6 +63,7 @@
|
||||
|
||||
_renderServerSurface = renderServerSurface;
|
||||
_captureModeBlock = [captureModeBlock copy];
|
||||
_preferredFramesPerSecond = preferredFramesPerSecond;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
@@ -155,7 +160,7 @@
|
||||
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
_displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(_updateFrame)];
|
||||
_displayLink.preferredFramesPerSecond = 30;
|
||||
_displayLink.preferredFramesPerSecond = _preferredFramesPerSecond;
|
||||
[_displayLink addToRunLoop:[NSRunLoop mainRunLoop] forMode:NSRunLoopCommonModes];
|
||||
});
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
@implementation ScreenDumpVNC {
|
||||
int _prefsHeight;
|
||||
int _prefsWidth;
|
||||
int _prefsFramesPerSecond;
|
||||
bool _enabled;
|
||||
NSString *_password;
|
||||
rfbScreenInfoPtr _rfbScreenInfo;
|
||||
@@ -90,6 +91,9 @@
|
||||
NSNumber *enabled = [defaults objectForKey:@"enabled"];
|
||||
_enabled = enabled ? [enabled boolValue] : NO;
|
||||
_password = [defaults objectForKey:@"password"];
|
||||
|
||||
NSNumber *framesPerSecond = [defaults objectForKey:@"framesPerSecond"];
|
||||
_prefsFramesPerSecond = framesPerSecond ? [framesPerSecond intValue] : 30;
|
||||
}
|
||||
|
||||
-(void)setupVNCAuthentication {
|
||||
@@ -319,7 +323,8 @@
|
||||
captureModeBlock:^CaptureMode(void) {
|
||||
ScreenDumpVNC *strongSelf = weakSelf;
|
||||
return strongSelf ? strongSelf->_captureMode : CaptureModeCARenderServer;
|
||||
}];
|
||||
}
|
||||
preferredFramesPerSecond:_prefsFramesPerSecond];
|
||||
}
|
||||
|
||||
-(rfbBool)handleVNCAuthorization:(rfbClientPtr)client data:(const char *)data size:(int)size {
|
||||
|
||||
@@ -16,8 +16,6 @@
|
||||
<dict>
|
||||
<key>cell</key>
|
||||
<string>PSGroupCell</string>
|
||||
<key>label</key>
|
||||
<string>General</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>PostNotification</key>
|
||||
@@ -49,9 +47,7 @@
|
||||
<key>cell</key>
|
||||
<string>PSGroupCell</string>
|
||||
<key>label</key>
|
||||
<string>Custom Resolution</string>
|
||||
<key>footerText</key>
|
||||
<string>High Resolution Can Be Slow</string>
|
||||
<string>Performance</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>PostNotification</key>
|
||||
@@ -81,6 +77,22 @@
|
||||
<key>isNumeric</key>
|
||||
<true/>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>PostNotification</key>
|
||||
<string>com.mousen.screendump/restart</string>
|
||||
<key>cell</key>
|
||||
<string>PSEditTextCell</string>
|
||||
<key>defaults</key>
|
||||
<string>com.mousen.screendump</string>
|
||||
<key>key</key>
|
||||
<string>framesPerSecond</string>
|
||||
<key>label</key>
|
||||
<string>Max FPS</string>
|
||||
<key>default</key>
|
||||
<integer>30</integer>
|
||||
<key>isNumeric</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
|
||||
Reference in New Issue
Block a user