From 2c3721ef531a69e774c61c1df16b22414835f93e Mon Sep 17 00:00:00 2001 From: SteffeyDev Date: Thu, 26 Oct 2017 21:58:28 -0400 Subject: [PATCH] Resolves #50 - Aux Fix --- atemOSC/AppDelegate.mm | 25 +++++++++++++++++++++++++ atemOSC/OSCReceiver.mm | 7 +++++-- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/atemOSC/AppDelegate.mm b/atemOSC/AppDelegate.mm index 67f5a15..5bbe7a6 100644 --- a/atemOSC/AppDelegate.mm +++ b/atemOSC/AppDelegate.mm @@ -191,6 +191,7 @@ - (void)switcherConnected IBMDSwitcherMixEffectBlockIterator* iterator = NULL; IBMDSwitcherMediaPlayerIterator* mediaPlayerIterator = NULL; IBMDSwitcherSuperSourceBoxIterator* superSourceIterator = NULL; + IBMDSwitcherInputIterator* inputIterator = NULL; isConnectedToATEM = YES; if ([[NSProcessInfo processInfo] respondsToSelector:@selector(beginActivityWithOptions:reason:)]) @@ -230,6 +231,30 @@ - (void)switcherConnected [self logMessage:@"Could not get the first IBMDSwitcherMixEffectBlock"]; return; } + // Create an InputMonitor for each input so we can catch any changes to input names + result = mSwitcher->CreateIterator(IID_IBMDSwitcherInputIterator, (void**)&inputIterator); + if (SUCCEEDED(result)) + { + IBMDSwitcherInput* input = NULL; + + // For every input, install a callback to monitor property changes on the input + while (S_OK == inputIterator->Next(&input)) + { + IBMDSwitcherInputAux* auxObj; + result = input->QueryInterface(IID_IBMDSwitcherInputAux, (void**)&auxObj); + if (SUCCEEDED(result)) + { + BMDSwitcherInputId auxId; + result = auxObj->GetInputSource(&auxId); + if (SUCCEEDED(result)) + { + mSwitcherInputAuxList.push_back(auxObj); + } + } + } + inputIterator->Release(); + inputIterator = NULL; + } //Upstream Keyer diff --git a/atemOSC/OSCReceiver.mm b/atemOSC/OSCReceiver.mm index f12a3e3..1f8bbac 100644 --- a/atemOSC/OSCReceiver.mm +++ b/atemOSC/OSCReceiver.mm @@ -237,7 +237,7 @@ - (void) receivedOSCMessage:(OSCMessage *)m else if ([[address objectAtIndex:2] isEqualToString:@"aux"]) { int auxToChange = [[address objectAtIndex:3] intValue]; - int source = [[m value] intValue]; + int source = [[m value] floatValue]; [self handleAuxSource:auxToChange channel:source]; } @@ -294,7 +294,10 @@ - (void) changeTransitionSelection:(int)t select:(bool) select - (void) handleAuxSource:(int)auxToChange channel:(int)channel { BMDSwitcherInputId inputId = channel; - [appDel mSwitcherInputAuxList][auxToChange-1]->SetInputSource(inputId); + if (auxToChange-1 < [appDel mSwitcherInputAuxList].size()) + [appDel mSwitcherInputAuxList][auxToChange-1]->SetInputSource(inputId); + else + [appDel logMessage:[NSString stringWithFormat:@"Aux number %d not available on your switcher", channel]]; } - (void) handleMacros:(OSCMessage *)m address:(NSArray*)address