diff --git a/atemOSC/AppDelegate.h b/atemOSC/AppDelegate.h index f72efdb..906f9d7 100644 --- a/atemOSC/AppDelegate.h +++ b/atemOSC/AppDelegate.h @@ -67,7 +67,6 @@ @property (readonly) std::map mHyperdecks; @property (readonly) std::map mHyperdeckMonitors; @property (readonly) std::vector mSwitcherInputAuxList; -@property (readonly) IBMDSwitcherStills* mStills; @property (readonly) IBMDSwitcherInputSuperSource* mSuperSource; @property (readonly) IBMDSwitcherMacroPool* mMacroPool; @property (readonly) IBMDSwitcherMacroControl* mMacroControl; diff --git a/atemOSC/AppDelegate.mm b/atemOSC/AppDelegate.mm index 90b456b..e79b6c8 100644 --- a/atemOSC/AppDelegate.mm +++ b/atemOSC/AppDelegate.mm @@ -42,7 +42,6 @@ @implementation AppDelegate @synthesize switcherTransitionParameters; @synthesize mMediaPool; @synthesize mMediaPlayers; -@synthesize mStills; @synthesize mMacroPool; @synthesize mSuperSource; @synthesize mMacroControl; @@ -63,42 +62,23 @@ @implementation AppDelegate - (void)applicationDidFinishLaunching:(NSNotification *)aNotification { - NSMenu* edit = [[[[NSApplication sharedApplication] mainMenu] itemWithTitle: @"Edit"] submenu]; - if ([[edit itemAtIndex: [edit numberOfItems] - 1] action] == NSSelectorFromString(@"orderFrontCharacterPalette:")) - [edit removeItemAtIndex: [edit numberOfItems] - 1]; - if ([[edit itemAtIndex: [edit numberOfItems] - 1] action] == NSSelectorFromString(@"startDictation:")) - [edit removeItemAtIndex: [edit numberOfItems] - 1]; - if ([[edit itemAtIndex: [edit numberOfItems] - 1] isSeparatorItem]) - [edit removeItemAtIndex: [edit numberOfItems] - 1]; + [self setupMenu]; mSwitcherDiscovery = NULL; mSwitcher = NULL; mMixEffectBlock = NULL; mMediaPool = NULL; mMacroPool = NULL; + mSuperSource = NULL; + mMacroControl = NULL; + mAudioMixer = NULL; + isConnectedToATEM = NO; endpoints = [[NSMutableArray alloc] init]; mOscReceiver = [[OSCReceiver alloc] initWithDelegate:self]; - mSwitcherMonitor = new SwitcherMonitor(self); - mMonitors.push_back(mSwitcherMonitor); - mDownstreamKeyerMonitor = new DownstreamKeyerMonitor(self); - mMonitors.push_back(mDownstreamKeyerMonitor); - mUpstreamKeyerMonitor = new UpstreamKeyerMonitor(self); - mMonitors.push_back(mUpstreamKeyerMonitor); - mUpstreamKeyerLumaParametersMonitor = new UpstreamKeyerLumaParametersMonitor(self); - mMonitors.push_back(mUpstreamKeyerLumaParametersMonitor); - mUpstreamKeyerChromaParametersMonitor = new UpstreamKeyerChromaParametersMonitor(self); - mMonitors.push_back(mUpstreamKeyerChromaParametersMonitor); - mTransitionParametersMonitor = new TransitionParametersMonitor(self); - mMonitors.push_back(mTransitionParametersMonitor); - mMixEffectBlockMonitor = new MixEffectBlockMonitor(self); - mMonitors.push_back(mMixEffectBlockMonitor); - mMacroPoolMonitor = new MacroPoolMonitor(self); - mMonitors.push_back(mMacroPoolMonitor); - mAudioMixerMonitor = new AudioMixerMonitor(self); - mMonitors.push_back(mAudioMixerMonitor); + [self setupMonitors]; [logTextView setTextColor:[NSColor whiteColor]]; @@ -131,6 +111,44 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification [self portChanged:incomingPort out:outgoingPort ip:outIpStr]; } + [self checkForUpdate]; +} + +- (void)setupMenu +{ + NSMenu* edit = [[[[NSApplication sharedApplication] mainMenu] itemWithTitle: @"Edit"] submenu]; + if ([[edit itemAtIndex: [edit numberOfItems] - 1] action] == NSSelectorFromString(@"orderFrontCharacterPalette:")) + [edit removeItemAtIndex: [edit numberOfItems] - 1]; + if ([[edit itemAtIndex: [edit numberOfItems] - 1] action] == NSSelectorFromString(@"startDictation:")) + [edit removeItemAtIndex: [edit numberOfItems] - 1]; + if ([[edit itemAtIndex: [edit numberOfItems] - 1] isSeparatorItem]) + [edit removeItemAtIndex: [edit numberOfItems] - 1]; +} + +- (void)setupMonitors +{ + mSwitcherMonitor = new SwitcherMonitor(self); + mMonitors.push_back(mSwitcherMonitor); + mDownstreamKeyerMonitor = new DownstreamKeyerMonitor(self); + mMonitors.push_back(mDownstreamKeyerMonitor); + mUpstreamKeyerMonitor = new UpstreamKeyerMonitor(self); + mMonitors.push_back(mUpstreamKeyerMonitor); + mUpstreamKeyerLumaParametersMonitor = new UpstreamKeyerLumaParametersMonitor(self); + mMonitors.push_back(mUpstreamKeyerLumaParametersMonitor); + mUpstreamKeyerChromaParametersMonitor = new UpstreamKeyerChromaParametersMonitor(self); + mMonitors.push_back(mUpstreamKeyerChromaParametersMonitor); + mTransitionParametersMonitor = new TransitionParametersMonitor(self); + mMonitors.push_back(mTransitionParametersMonitor); + mMixEffectBlockMonitor = new MixEffectBlockMonitor(self); + mMonitors.push_back(mMixEffectBlockMonitor); + mMacroPoolMonitor = new MacroPoolMonitor(self); + mMonitors.push_back(mMacroPoolMonitor); + mAudioMixerMonitor = new AudioMixerMonitor(self); + mMonitors.push_back(mAudioMixerMonitor); +} + +- (void)checkForUpdate +{ // Check if new version available NSError *error = nil; NSString *url_string = [NSString stringWithFormat: @"https://api.github.com/repos/danielbuechele/atemOSC/releases/latest"]; @@ -287,10 +305,27 @@ - (void)switcherConnected if (SUCCEEDED(mSwitcher->CreateIterator(IID_IBMDSwitcherMixEffectBlockIterator, (void**)&iterator))) { // Use the first Mix Effect Block - if (S_OK != iterator->Next(&mMixEffectBlock)) + if (S_OK == iterator->Next(&mMixEffectBlock)) + { + mMixEffectBlock->AddCallback(mMixEffectBlockMonitor); + mMixEffectBlockMonitor->updateSliderPosition(); + + if (SUCCEEDED(mMixEffectBlock->QueryInterface(IID_IBMDSwitcherTransitionParameters, (void**)&switcherTransitionParameters))) + { + switcherTransitionParameters->AddCallback(mTransitionParametersMonitor); + } + else + { + [self logMessage:@"Could not get IBMDSwitcherTransitionParameters"]; + } + + } + else { [self logMessage:@"Could not get the first IBMDSwitcherMixEffectBlock"]; } + + iterator->Release(); } else { @@ -475,16 +510,6 @@ - (void)switcherConnected { [self logMessage:[NSString stringWithFormat:@"Could not create IBMDSwitcherAudioInputIterator iterator. code: %d", HRESULT_CODE(result)]]; } - - switcherTransitionParameters = NULL; - if (mMixEffectBlock) - { - mMixEffectBlock->QueryInterface(IID_IBMDSwitcherTransitionParameters, (void**)&switcherTransitionParameters); - switcherTransitionParameters->AddCallback(mTransitionParametersMonitor); - mMixEffectBlock->AddCallback(mMixEffectBlockMonitor); - } - - self->mMixEffectBlockMonitor->updateSliderPosition(); // Hyperdeck Setup IBMDSwitcherHyperDeckIterator* hyperDeckIterator = NULL; @@ -512,10 +537,6 @@ - (void)switcherConnected dispatch_async(dispatch_get_main_queue(), ^{ [helpPanel setupWithDelegate: self]; }); - -finish: - if (iterator) - iterator->Release(); } - (void)switcherDisconnected @@ -547,34 +568,38 @@ - (void)switcherDisconnected - (void)cleanUpConnection { - while (mSwitcherInputAuxList.size()) + if (mSwitcher) { - mSwitcherInputAuxList.back()->Release(); - mSwitcherInputAuxList.pop_back(); + mSwitcher->RemoveCallback(mSwitcherMonitor); + mSwitcher->Release(); + mSwitcher = NULL; } - while (mMediaPlayers.size()) + if (mMixEffectBlock) { - mMediaPlayers.back()->Release(); - mMediaPlayers.pop_back(); + mMixEffectBlock->RemoveCallback(mMixEffectBlockMonitor); + mMixEffectBlock->Release(); + mMixEffectBlock = NULL; } - if (mStills) + if (switcherTransitionParameters) { - mStills->Release(); - mStills = NULL; + switcherTransitionParameters->RemoveCallback(mTransitionParametersMonitor); + switcherTransitionParameters->Release(); + switcherTransitionParameters = NULL; } - if (mMediaPool) + for (auto const& it : mInputs) { - mMediaPool->Release(); - mMediaPool = NULL; + it.second->RemoveCallback(mInputMonitors.at(it.first)); + it.second->Release(); } + mInputs.clear(); - while (mSuperSourceBoxes.size()) + while (mSwitcherInputAuxList.size()) { - mSuperSourceBoxes.back()->Release(); - mSuperSourceBoxes.pop_back(); + mSwitcherInputAuxList.back()->Release(); + mSwitcherInputAuxList.pop_back(); } while (keyers.size()) @@ -599,18 +624,16 @@ - (void)cleanUpConnection dsk.pop_back(); } - if (mMixEffectBlock) + while (mMediaPlayers.size()) { - mMixEffectBlock->RemoveCallback(mMixEffectBlockMonitor); - mMixEffectBlock->Release(); - mMixEffectBlock = NULL; + mMediaPlayers.back()->Release(); + mMediaPlayers.pop_back(); } - if (mSwitcher) + if (mMediaPool) { - mSwitcher->RemoveCallback(mSwitcherMonitor); - mSwitcher->Release(); - mSwitcher = NULL; + mMediaPool->Release(); + mMediaPool = NULL; } if (mMacroPool) @@ -620,19 +643,25 @@ - (void)cleanUpConnection mMacroPool = NULL; } - for (auto const& it : mAudioInputs) + while (mSuperSourceBoxes.size()) { - it.second->RemoveCallback(mAudioInputMonitors.at(it.first)); - it.second->Release(); + mSuperSourceBoxes.back()->Release(); + mSuperSourceBoxes.pop_back(); } - mAudioInputs.clear(); - for (auto const& it : mInputs) + if (mAudioMixer) { - it.second->RemoveCallback(mInputMonitors.at(it.first)); + mAudioMixer->RemoveCallback(mAudioMixerMonitor); + mAudioMixer->Release(); + mAudioMixer = NULL; + } + + for (auto const& it : mAudioInputs) + { + it.second->RemoveCallback(mAudioInputMonitors.at(it.first)); it.second->Release(); } - mInputs.clear(); + mAudioInputs.clear(); for (auto const& it : mHyperdecks) { @@ -640,20 +669,6 @@ - (void)cleanUpConnection it.second->Release(); } mHyperdecks.clear(); - - if (mAudioMixer) - { - mAudioMixer->RemoveCallback(mAudioMixerMonitor); - mAudioMixer->Release(); - mAudioMixer = NULL; - } - - if (switcherTransitionParameters) - { - switcherTransitionParameters->RemoveCallback(mTransitionParametersMonitor); - switcherTransitionParameters->Release(); - switcherTransitionParameters = NULL; - } } // We run this recursively so that we can get the diff --git a/atemOSC/English.lproj/MainMenu.xib b/atemOSC/English.lproj/MainMenu.xib index 77160f0..86e62f9 100644 --- a/atemOSC/English.lproj/MainMenu.xib +++ b/atemOSC/English.lproj/MainMenu.xib @@ -377,7 +377,7 @@ - + diff --git a/atemOSC/OSCReceiver.mm b/atemOSC/OSCReceiver.mm index d404ebe..92b5e12 100644 --- a/atemOSC/OSCReceiver.mm +++ b/atemOSC/OSCReceiver.mm @@ -70,6 +70,13 @@ - (instancetype) initWithDelegate:(AppDelegate *) delegate return false; } copy] forKey:@"/atem/audio/input"]; + [validators setObject:[^bool(NSDictionary *d, OSCValue *v) { + if ([appDel mAudioMixer]) + return true; + [appDel logMessage:@"No audio mixer"]; + return false; + } copy] forKey:@"/atem/audio/output"]; + [validators setObject:[^bool(NSDictionary *d, OSCValue *v) { int mplayer = [[d objectForKey:@""] intValue];