diff --git a/CSFFMpegCapturePlugin/CSFFMpegCapturePlugin/CSFFMpegCapture.m b/CSFFMpegCapturePlugin/CSFFMpegCapturePlugin/CSFFMpegCapture.m index 4835d355..de2a8821 100644 --- a/CSFFMpegCapturePlugin/CSFFMpegCapturePlugin/CSFFMpegCapture.m +++ b/CSFFMpegCapturePlugin/CSFFMpegCapturePlugin/CSFFMpegCapture.m @@ -471,7 +471,6 @@ -(void)registerPCMOutput:(CMItemCount)frameCount audioFormat:(const AudioStreamBasicDescription *)audioFormat { - if (self.pcmPlayer) { //looks like we already have one? diff --git a/CSNDICapturePlugin/CSNDICapturePlugin/CSNDICapture.m b/CSNDICapturePlugin/CSNDICapturePlugin/CSNDICapture.m index 01ea2e12..9848f05b 100644 --- a/CSNDICapturePlugin/CSNDICapturePlugin/CSNDICapture.m +++ b/CSNDICapturePlugin/CSNDICapturePlugin/CSNDICapture.m @@ -158,9 +158,11 @@ return; } - - _pcmPlayer = [self createPCMInput:self.captureName withFormat:audioFormat]; - _pcmPlayer.name = self.captureName; + //dispatch_async(dispatch_get_main_queue(), ^{ + _pcmPlayer = [self createPCMInput:self.captureName withFormat:audioFormat]; + _pcmPlayer.name = self.captureName; + + // }); } @@ -181,8 +183,6 @@ -(void)NDIAudioOutput:(CAMultiAudioPCM *)pcmData fromReceiver:(CSNDIReceiver *)fromReceiver { - - if (!_pcmPlayer && self.isLive) { AudioStreamBasicDescription useFormat = pcmData.pcmFormat; @@ -311,5 +311,16 @@ return [bundle imageForResource:@"ndi_logo"]; } +-(void)willDelete +{ + NSLog(@"WILL DELEGTE"); + + [self deregisterPCMOutput]; +} + +-(void)dealloc +{ + NSLog(@"DEALLOC NDI"); +} @end diff --git a/CSNDICapturePlugin/CSNDICapturePlugin/CSNDIReceiver.h b/CSNDICapturePlugin/CSNDICapturePlugin/CSNDIReceiver.h index 01e27178..4366d078 100644 --- a/CSNDICapturePlugin/CSNDICapturePlugin/CSNDIReceiver.h +++ b/CSNDICapturePlugin/CSNDICapturePlugin/CSNDIReceiver.h @@ -19,8 +19,8 @@ CSNDISource *_ndi_source; CVPixelBufferPoolRef _cvpool; NSSize _currentSize; - dispatch_queue_t _video_output_queue; - dispatch_queue_t _audio_output_queue; + __weak dispatch_queue_t _video_output_queue; + __weak dispatch_queue_t _audio_output_queue; bool _stop_audio; bool _stop_video; bool _audio_running; diff --git a/CSNDICapturePlugin/CSNDICapturePlugin/CSNDIReceiver.m b/CSNDICapturePlugin/CSNDICapturePlugin/CSNDIReceiver.m index 5e528826..032684bc 100644 --- a/CSNDICapturePlugin/CSNDICapturePlugin/CSNDIReceiver.m +++ b/CSNDICapturePlugin/CSNDICapturePlugin/CSNDIReceiver.m @@ -243,7 +243,9 @@ { memcpy(dBuf, audio_frame.p_data, 4*audio_frame.no_samples*audio_frame.no_channels); } - [_audioDelegate NDIAudioOutput:retPCM fromReceiver:self]; + dispatch_async(_audio_output_queue, ^{ + [_audioDelegate NDIAudioOutput:retPCM fromReceiver:self]; + }); } dispatch->NDIlib_recv_free_audio(_receiver_instance, &audio_frame); diff --git a/CocoaSplit/CSCaptureBase.m b/CocoaSplit/CSCaptureBase.m index 32c3c229..054e560b 100644 --- a/CocoaSplit/CSCaptureBase.m +++ b/CocoaSplit/CSCaptureBase.m @@ -423,7 +423,6 @@ useEngine = layerSrc.sourceLayout.recorder.audioEngine; } } - if (!useEngine) { useEngine = [CaptureController sharedCaptureController].multiAudioEngine; diff --git a/CocoaSplit/Compressor/CompressorBase.m b/CocoaSplit/Compressor/CompressorBase.m index 15cace8f..b2cf4bcd 100644 --- a/CocoaSplit/Compressor/CompressorBase.m +++ b/CocoaSplit/Compressor/CompressorBase.m @@ -3,7 +3,6 @@ // CocoaSplit // // Created by Zakk on 7/4/14. -// Copyright (c) 2014 Zakk. All rights reserved. // #import "CompressorBase.h" diff --git a/CocoaSplit/InputSource.m b/CocoaSplit/InputSource.m index 2cdc2986..b0635627 100644 --- a/CocoaSplit/InputSource.m +++ b/CocoaSplit/InputSource.m @@ -2502,6 +2502,9 @@ static NSArray *_sourceTypes = nil; self.name = _editedName; } + + + -(void) setSelectedVideoType:(NSString *)selectedVideoType { NSMutableDictionary *pluginMap = [[CSPluginLoader sharedPluginLoader] sourcePlugins]; diff --git a/CocoaSplit/Interface/CSSourceListViewController.m b/CocoaSplit/Interface/CSSourceListViewController.m index e0f426ee..95ceb161 100644 --- a/CocoaSplit/Interface/CSSourceListViewController.m +++ b/CocoaSplit/Interface/CSSourceListViewController.m @@ -50,19 +50,73 @@ -(void)outlineViewDoubleClick:(NSOutlineView *)sender { - NSTreeNode *node = [sender itemAtRow:sender.clickedRow]; - if (node) + NSObject*src = [sender itemAtRow:sender.clickedRow]; + if (src) { - NSObject*src = node.representedObject; [self openInputConfigWindows:@[src]]; } } +-(id)outlineView:(NSOutlineView *)outlineView child:(NSInteger)index ofItem:(id)item +{ + + if (!item) + { + SourceLayout *layout = self.sourceLayoutController.content; + + return [layout.topLevelSourceList objectAtIndex:index]; + } + + + NSObject *useItem = item; + if (useItem.isVideo) + { + InputSource *vItem = (InputSource *)useItem; + return [vItem.attachedInputs objectAtIndex:index]; + } + + return nil; +} + +-(BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable:(id)item +{ + + if (!item) + { + return YES; + } + + + NSObject *useItem = item; + if (!useItem.isVideo) + { + return NO; + } + InputSource *vSrc = item; + return vSrc.attachedInputs.count > 0; +} + +-(NSInteger) outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item +{ + if (!item) + { + SourceLayout *layout = self.sourceLayoutController.content; + return layout.topLevelSourceList.count; + } + + NSObject *useItem = item; + if (useItem.isVideo) + { + InputSource *vItem = item; + return vItem.attachedInputs.count; + } + + return 0; +} -(void)outlineView:(NSOutlineView *)outlineView didAddRowView:(NSTableRowView *)rowView forRow:(NSInteger)row { - NSTreeNode *node = [outlineView itemAtRow:row]; - NSObject *src = node.representedObject; + NSObject *src = [outlineView itemAtRow:row]; if (!src.isVideo || !((InputSource *)src).parentInput) { dispatch_async(dispatch_get_main_queue(), ^{ @@ -72,15 +126,23 @@ } +-(NSView *)outlineView:(NSOutlineView *)outlineView viewForTableColumn:(NSTableColumn *)tableColumn item:(id)item +{ + + NSTableCellView *ret = [outlineView makeViewWithIdentifier:@"defaultView" owner:self]; + ret.objectValue = item; + return ret; +} + + -(BOOL)outlineView:(NSOutlineView *)outlineView writeItems:(NSArray *)items toPasteboard:(NSPasteboard *)pasteboard { NSPasteboardItem *pItem = [[NSPasteboardItem alloc] init]; NSMutableArray *sourceIDS = [NSMutableArray array]; - for (NSTreeNode *node in items) + for (NSObject*iSrc in items) { - NSObject *iSrc = node.representedObject; NSString *iUUID = iSrc.uuid; [sourceIDS addObject:iUUID]; @@ -93,12 +155,7 @@ -(NSDragOperation)outlineView:(NSOutlineView *)outlineView validateDrop:(id)info proposedItem:(id)item proposedChildIndex:(NSInteger)index { - NSTreeNode *nodeItem = (NSTreeNode *)item; - InputSource *nodeInput = nil; - if (nodeItem) - { - nodeInput = nodeItem.representedObject; - } + InputSource *nodeInput = item; @@ -306,8 +363,7 @@ NSArray *draggedUUIDS = [pb propertyListForType:@"cocoasplit.input.item"]; - NSTreeNode *parentNode = (NSTreeNode *)item; - InputSource *parentSource = nil; + InputSource *parentSource = item; NSMutableDictionary *currentDepths = [NSMutableDictionary dictionary]; @@ -317,32 +373,26 @@ } - NSIndexPath *droppedIdxPath = nil; - if (parentNode) - { - parentSource = parentNode.representedObject; - droppedIdxPath = [[parentNode indexPath] indexPathByAddingIndex:index]; - } else { - droppedIdxPath = [NSIndexPath indexPathWithIndex:index]; - } + - NSTreeNode *idxNode = nil; + NSObject *iSrc = nil; float newDepth = 1; if (index == -1) { newDepth = -FLT_MAX; } else { - idxNode = [self.sourceTreeController.arrangedObjects descendantNodeAtIndexPath:droppedIdxPath]; - + if (index < [outlineView numberOfChildrenOfItem:item]) + { + iSrc = [outlineView child:index ofItem:item]; + } } - if (idxNode) + if (iSrc) { - NSObject *iSrc = idxNode.representedObject; if (iSrc.isVideo) { InputSource *dSrc = (InputSource *)iSrc; @@ -382,6 +432,7 @@ [parentSource attachInput:iSrc]; [[undoManager prepareWithInvocationTarget:self] detachSourcesByUUID:@[iSrc.uuid]]; } + iSrc.depth = newDepth++; } @@ -533,10 +584,29 @@ _activeConfigWindows = [NSMutableDictionary dictionary]; _activeConfigControllers = [NSMutableDictionary dictionary]; + + + } + + +} + +-(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context +{ + + if ([keyPath isEqualToString:@"content.topLevelSourceList"]) + { + dispatch_async(dispatch_get_main_queue(), ^{ + [self.sourceOutlineView reloadData]; + }); } } - (void)viewDidLoad { [super viewDidLoad]; + if (self.sourceLayoutController) + { + [self.sourceLayoutController addObserver:self forKeyPath:@"content.topLevelSourceList" options:NSKeyValueObservingOptionNew context:NULL]; + } // Do view setup here. } @@ -607,11 +677,26 @@ +-(NSArray *)getSelectedItems +{ + NSIndexSet *selectedRows = [self.sourceOutlineView selectedRowIndexes]; + NSMutableArray *selectedItems = [NSMutableArray array]; + + [selectedRows enumerateIndexesUsingBlock:^(NSUInteger idx, BOOL * _Nonnull stop) { + id item = [self.sourceOutlineView itemAtRow:idx]; + if (item) + { + [selectedItems addObject:item]; + } + }]; + + return selectedItems; +} -(IBAction)sourceDeleteClicked:(NSButton *)sender { - NSArray *selectedSources = self.sourceTreeController.selectedObjects; + NSArray *selectedSources = [self getSelectedItems]; NSUndoManager *undoManager = self.view.window.undoManager; @@ -640,6 +725,8 @@ [undoMap addObject:undoEntry]; } + self.selectedObjects = @[]; + NSData *undoData = [NSKeyedArchiver archivedDataWithRootObject:undoMap]; [[undoManager prepareWithInvocationTarget:self] undoDeleteSources:undoData]; } @@ -647,7 +734,7 @@ -(IBAction)sourceConfigClicked:(NSButton *)sender { - NSArray *selectedSources = self.sourceTreeController.selectedObjects; + NSArray *selectedSources = [self getSelectedItems]; [self openInputConfigWindows:selectedSources]; } @@ -661,20 +748,23 @@ -(void)highlightSources:(NSArray *)sources { - [self.sourceTreeController setSelectionIndexPaths:@[]]; + NSMutableIndexSet *selectedRows = [[NSMutableIndexSet alloc] init]; + for (NSObject *src in sources) { - NSIndexPath *srcPath = [self.sourceTreeController indexPathOfObject:src]; - if (srcPath) - { - [self.sourceTreeController addSelectionIndexPaths:@[srcPath]]; - } + NSInteger idx = [self.sourceOutlineView rowForItem:src]; + + [selectedRows addIndex:idx]; } + + [self.sourceOutlineView selectRowIndexes:selectedRows byExtendingSelection:NO]; } -(void)outlineViewSelectionDidChange:(NSNotification *)notification { - self.selectedObjects = self.sourceTreeController.selectedObjects; + + self.selectedObjects = [self getSelectedItems]; + } -(void)menuEndedTracking:(NSNotification *)notification @@ -941,5 +1031,12 @@ } } +-(void)dealloc +{ + if (self.sourceLayoutController) + { + [self.sourceLayoutController removeObserver:self forKeyPath:@"content.topLevelSourceList"]; + } +} @end diff --git a/CocoaSplit/Interface/CSSourceListViewController.xib b/CocoaSplit/Interface/CSSourceListViewController.xib index 4781e582..eff47f35 100644 --- a/CocoaSplit/Interface/CSSourceListViewController.xib +++ b/CocoaSplit/Interface/CSSourceListViewController.xib @@ -45,7 +45,7 @@ - + @@ -106,8 +106,6 @@ - - @@ -192,11 +190,7 @@ CA - - - - - + diff --git a/CocoaSplit/SourceLayout.m b/CocoaSplit/SourceLayout.m index 8462ec2d..43e43833 100644 --- a/CocoaSplit/SourceLayout.m +++ b/CocoaSplit/SourceLayout.m @@ -497,7 +497,7 @@ JS_EXPORT void JSSynchronousGarbageCollectForDebugging(JSContextRef ctx); NSMutableArray *tmpArray = [NSMutableArray array]; NSMutableArray *noLayer = [NSMutableArray array]; - float currentDepth = 0.0f; + float currentDepth = 100.0f; [self willChangeValueForKey:@"topLevelSourceList"];