Avoid double calling frameTick on share sources.

Change calculation of individual source frame rates to not be multiplied by the number of attached layers
This commit is contained in:
Zakk 2016-12-27 12:25:42 -05:00
parent d02807708f
commit 827b2e0849
8 changed files with 89 additions and 4 deletions

View file

@ -99,6 +99,7 @@
3451A1E81712C7D000DF6A8B /* libbz2.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 347B7FC516907A1700B5F4B3 /* libbz2.dylib */; };
3451A1E91712C7DE00DF6A8B /* VideoDecodeAcceleration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 347B7FC716907AE700B5F4B3 /* VideoDecodeAcceleration.framework */; };
3451A1EA1712C80400DF6A8B /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 340FE4A115F3417E00E4CE4E /* Cocoa.framework */; };
34559A281E12D4400085883C /* CSCaptureBase+InputFrameTick.m in Sources */ = {isa = PBXBuildFile; fileRef = 34559A271E12D4400085883C /* CSCaptureBase+InputFrameTick.m */; };
34576C7819AFCA1B007BAD90 /* CSPluginLoader.m in Sources */ = {isa = PBXBuildFile; fileRef = 34576C7719AFCA1B007BAD90 /* CSPluginLoader.m */; };
34576C7919AFCA1B007BAD90 /* CSPluginLoader.m in Sources */ = {isa = PBXBuildFile; fileRef = 34576C7719AFCA1B007BAD90 /* CSPluginLoader.m */; };
345F89861976113C00BD4062 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 34A64A36165F208800A68428 /* QuartzCore.framework */; };
@ -717,6 +718,8 @@
3451A1CA17111BD900DF6A8B /* CocoaSplitCmd.1 */ = {isa = PBXFileReference; lastKnownFileType = text.man; path = CocoaSplitCmd.1; sourceTree = "<group>"; };
3451A1D2171187D400DF6A8B /* ControllerProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ControllerProtocol.h; sourceTree = "<group>"; };
3451A1E11712C5F700DF6A8B /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; };
34559A261E12D4400085883C /* CSCaptureBase+InputFrameTick.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "CSCaptureBase+InputFrameTick.h"; sourceTree = "<group>"; };
34559A271E12D4400085883C /* CSCaptureBase+InputFrameTick.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "CSCaptureBase+InputFrameTick.m"; sourceTree = "<group>"; };
34576C7619AFCA1B007BAD90 /* CSPluginLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSPluginLoader.h; sourceTree = "<group>"; };
34576C7719AFCA1B007BAD90 /* CSPluginLoader.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CSPluginLoader.m; sourceTree = "<group>"; };
34576C9819AFE6F7007BAD90 /* CSWindowCapturePlugin.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = CSWindowCapturePlugin.xcodeproj; path = CapturePlugins/CSWindowCapturePlugin/CSWindowCapturePlugin.xcodeproj; sourceTree = "<group>"; };
@ -1221,6 +1224,8 @@
349461581AB420E600F28883 /* CSAnimationRunner */,
349461571AB41DA000F28883 /* CSAnimationRunnerObj.h */,
340DC733197CF6E9003A0BB3 /* CSCaptureBase.m */,
34559A261E12D4400085883C /* CSCaptureBase+InputFrameTick.h */,
34559A271E12D4400085883C /* CSCaptureBase+InputFrameTick.m */,
34938EE61AE4A7E500F3B1CF /* CSCIFilterConfigProxy.h */,
34938EE71AE4A7E500F3B1CF /* CSCIFilterConfigProxy.m */,
346CF44A1A5C10C2008E5BFF /* CSInputLayer.h */,
@ -2456,6 +2461,7 @@
3400A0791BD4533A003E1828 /* CSInputLibraryWindowController.m in Sources */,
345F8B691A16C348009A81E3 /* CAMultiAudioGraph.m in Sources */,
3431FFE119786502000965FE /* InputSource.m in Sources */,
34559A281E12D4400085883C /* CSCaptureBase+InputFrameTick.m in Sources */,
3414C6AE1CBB9EBF00107C69 /* CSIRCompressor.m in Sources */,
34ED8C911B07371C002C0674 /* MIKMIDINoteOnCommand.m in Sources */,
346865471CC353E2002BAB86 /* CSInstantRecorderCompressorViewController.m in Sources */,

BIN
CocoaSplit/.DS_Store vendored

Binary file not shown.

View file

@ -0,0 +1,21 @@
//
// CSCaptureBase+InputFrameTick.h
// CocoaSplit
//
// Created by Zakk on 12/27/16.
// Copyright © 2016 Zakk. All rights reserved.
//
#import "CSCaptureBase.h"
@class InputSource;
@interface CSCaptureBase (InputFrameTick)
-(void)frameTickFromInput:(InputSource *)input;
@property (weak) InputSource *tickInput;
@end
@protocol CSCaptureBaseInputFrameTickProtocol
-(void)frameTickFromInput:(InputSource *)input;
@end

View file

@ -0,0 +1,25 @@
//
// CSCaptureBase+InputFrameTick.m
// CocoaSplit
//
// Created by Zakk on 12/27/16.
// Copyright © 2016 Zakk. All rights reserved.
//
#import "CSCaptureBase+InputFrameTick.h"
@implementation CSCaptureBase (InputFrameTick)
@dynamic tickInput;
-(void)frameTickFromInput:(InputSource *)input
{
if (self.tickInput && (input == self.tickInput))
{
[self frameTick];
}
}
@end

View file

@ -21,6 +21,7 @@
frame_render_behavior _saved_render_behavior;
CFAbsoluteTime _fps_start_time;
int _fps_frame_cnt;
}
@ -30,7 +31,7 @@
@property (assign) CGFloat detectedInputWidth;
@property (assign) CGFloat detectedInputHeight;
@property (assign) double layerUpdateFPS;
@property (weak) InputSource *tickInput;
@end
@ -181,6 +182,12 @@
}
}
-(void)frameTickFromInput:(InputSource *)input
{
[self frameTick];
}
-(void)frameTick
{
return;
@ -276,6 +283,10 @@
CALayer *newLayer = [self createNewLayer];
@synchronized(self)
{
if (!self.tickInput)
{
self.tickInput = inputsrc;
}
[_allLayers setObject:newLayer forKey:inputsrc];
}
[CATransaction commit];
@ -287,7 +298,22 @@
{
@synchronized(self)
{
if (self.tickInput == inputsrc)
{
self.tickInput = nil;
}
[_allLayers removeObjectForKey:inputsrc];
if (!self.tickInput)
{
for (id key in _allLayers)
{
if (key)
{
self.tickInput = key;
}
}
}
if (_allLayers.count == 0)
{
[self willDelete];
@ -295,6 +321,7 @@
}
}
-(void)updateLayersWithFramedataBlock:(void(^)(CALayer *))updateBlock
{
@ -315,6 +342,10 @@
layersCopy = _allLayers.copy;
}
[CATransaction begin];
if (frameData)
{
_fps_frame_cnt++;
}
for (id key in layersCopy)
{
InputSource *layerSrc = (InputSource *)key;
@ -329,7 +360,6 @@
updateBlock(clayer);
if (frameData)
{
_fps_frame_cnt++;
[layerSrc layerUpdated];
}
}

View file

@ -10,6 +10,7 @@
#import <QuartzCore/CoreImage.h>
#import "Capture.h"
#import "CSCaptureSourceProtocol.h"
#import "CSCaptureBase+InputFrameTick.h"
#import "CSPluginLoader.h"
#import "SourceCache.h"
#import "InputPopupControllerViewController.h"
@ -97,7 +98,7 @@ typedef enum resize_style_t {
@property (assign) float scrollXSpeed;
@property (assign) float scrollYSpeed;
@property (strong) NSObject<CSCaptureSourceProtocol> *videoInput;
@property (strong) NSObject<CSCaptureSourceProtocol,CSCaptureBaseInputFrameTickProtocol> *videoInput;
@property (assign) float rotationAngle;
@property (assign) float rotationAngleY;
@property (assign) float rotationAngleX;

View file

@ -1794,7 +1794,9 @@ static NSArray *_sourceTypes = nil;
self.layer.sourceLayer = _currentLayer;
}
[self.videoInput frameTick];
[self.videoInput frameTickFromInput:self];
[self.layer frameTick];
if (self.needsAdjustment)
{