Skip to content

Commit

Permalink
Aux refactor, #194 sending aux feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
SteffeyDev committed Mar 6, 2021
1 parent a1e817b commit de6b4fe
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 14 deletions.
15 changes: 15 additions & 0 deletions atemOSC/FeedbackMonitors.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,21 @@ class InputMonitor : public GenericMonitor<IBMDSwitcherInputCallback>, public Se
BMDSwitcherInputId inputId_;
};

class InputAuxMonitor : public GenericMonitor<IBMDSwitcherInputAuxCallback>, public SendStatusInterface
{
public:
InputAuxMonitor(Switcher *switcher, BMDSwitcherInputId inputId) : GenericMonitor(switcher), inputId_(inputId) { }
HRESULT Notify(BMDSwitcherInputAuxEventType eventType);
float sendStatus() const;

protected:
virtual ~InputAuxMonitor() { }

private:
void updateInputSource() const;
BMDSwitcherInputId inputId_;
};

class DownstreamKeyerMonitor : public GenericMonitor<IBMDSwitcherDownstreamKeyCallback>, public SendStatusInterface
{
public:
Expand Down
31 changes: 31 additions & 0 deletions atemOSC/FeedbackMonitors.mm
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,37 @@
return 0.1;
}

HRESULT InputAuxMonitor::Notify(BMDSwitcherInputAuxEventType eventType)
{
switch (eventType)
{
case bmdSwitcherInputAuxEventTypeInputSourceChanged:
updateInputSource();
break;
default:
// ignore other property changes not used for this app
break;
}
return S_OK;
}

void InputAuxMonitor::updateInputSource() const
{
if (switcher.mAuxInputs.count(inputId_) > 0)
{
BMDSwitcherInputId source;
switcher.mAuxInputs[inputId_]->GetInputSource(&source);
sendFeedbackMessage(switcher, [NSString stringWithFormat:@"/aux/%lld", inputId_], [OSCValue createWithLongLong:source]);
}
}

float InputAuxMonitor::sendStatus() const
{
updateInputSource();

return 0.02;
}

// Send OSC messages out when DSK Tie is changed on switcher
void DownstreamKeyerMonitor::updateDSKTie() const
{
Expand Down
8 changes: 5 additions & 3 deletions atemOSC/OSCAddressView.mm
Original file line number Diff line number Diff line change
Expand Up @@ -236,11 +236,13 @@ - (void)loadFromSwitcher:(Switcher *)switcher
}

[self addHeader:@"Aux Outputs" toString:helpString];
for (int i = 0; i<[switcher mSwitcherInputAuxList].size();i++)
for (auto const& it : [switcher mAuxInputs])
{
[self
addEntry:[NSString stringWithFormat:@"Set Aux %d to Source",i+1]
forAddress:[NSString stringWithFormat:@"/aux/%d\t<valid_program_source>",i+1]
addEntry:[NSString stringWithFormat:@"Set Aux %lld to Source",it.first]
forAddress:[NSString stringWithFormat:@"/aux/%lld\t<valid_program_source>",it.first]
toString:helpString];
}

if ([switcher mMediaPlayers].size() > 0)
{
Expand Down
10 changes: 5 additions & 5 deletions atemOSC/OSCReceiver.mm
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ - (instancetype) initWithDelegate:(AppDelegate *) delegate
} copy] forKey:@"/supersource"];

[validators setObject:[^bool(Switcher *s, NSDictionary *d, OSCValue *v) {
int auxToChange = [[d objectForKey:@"<key>"] intValue];
if (auxToChange > 0 && auxToChange-1 < [s mSwitcherInputAuxList].size())
int auxToChange = [[d objectForKey:@"<number>"] intValue];
if ([s mAuxInputs].count(auxToChange) > 0)
return true;
[weakAppDel logMessage:[NSString stringWithFormat:@"Aux number %d not available on your switcher", auxToChange]];
return false;
Expand Down Expand Up @@ -663,10 +663,10 @@ - (instancetype) initWithDelegate:(AppDelegate *) delegate
[[s outPort] sendThisMessage:newMsg];
}];

[self addEndpoint:@"/aux/<key>" valueType:OSCValInt handler:^void(Switcher *s, NSDictionary *d, OSCValue *v) {
int auxToChange = [[d objectForKey:@"<key>"] intValue];
[self addEndpoint:@"/aux/<number>" valueType:OSCValInt handler:^void(Switcher *s, NSDictionary *d, OSCValue *v) {
int auxToChange = [[d objectForKey:@"<number>"] intValue];
BMDSwitcherInputId inputId = [v intValue];
[s mSwitcherInputAuxList][auxToChange-1]->SetInputSource(inputId);
[s mAuxInputs][auxToChange]->SetInputSource(inputId);
}];

[self addEndpoint:@"/audio/input/<number>/gain" valueType:OSCValFloat handler:^void(Switcher *s, NSDictionary *d, OSCValue *v) {
Expand Down
3 changes: 2 additions & 1 deletion atemOSC/Switcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ NS_ASSUME_NONNULL_BEGIN
@interface Switcher : NSObject<NSCoding>
{
std::map<BMDSwitcherInputId, InputMonitor*> mInputMonitors;
std::map<BMDSwitcherInputId, InputAuxMonitor*> mAuxInputMonitors;
SwitcherMonitor* mSwitcherMonitor;
std::map<BMDSwitcherHyperDeckId, HyperDeckMonitor*> mHyperdeckMonitors;
DownstreamKeyerMonitor* mDownstreamKeyerMonitor;
Expand Down Expand Up @@ -61,8 +62,8 @@ NS_ASSUME_NONNULL_BEGIN
@property (readonly) std::map<int, std::vector<IBMDSwitcherKey*> > keyers;
@property (readonly) std::vector<IBMDSwitcherSuperSourceBox*> mSuperSourceBoxes;
@property (readonly) std::map<BMDSwitcherInputId, IBMDSwitcherInput*> mInputs;
@property (readonly) std::map<BMDSwitcherInputId, IBMDSwitcherInputAux*> mAuxInputs;
@property (readonly) std::map<BMDSwitcherHyperDeckId, IBMDSwitcherHyperDeck*> mHyperdecks;
@property (readonly) std::vector<IBMDSwitcherInputAux*> mSwitcherInputAuxList;
@property (readonly) IBMDSwitcherInputSuperSource* mSuperSource;
@property (readonly) IBMDSwitcherMacroPool* mMacroPool;
@property (readonly) IBMDSwitcherMacroControl* mMacroControl;
Expand Down
17 changes: 12 additions & 5 deletions atemOSC/Switcher.mm
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ @implementation Switcher
@synthesize mMacroControl;
@synthesize mSuperSourceBoxes;
@synthesize mInputs;
@synthesize mSwitcherInputAuxList;
@synthesize mAuxInputs;

@synthesize mAudioInputs;
@synthesize mAudioMixer;
Expand Down Expand Up @@ -341,7 +341,12 @@ - (void)switcherConnected
result = auxObj->GetInputSource(&auxId);
if (SUCCEEDED(result))
{
mSwitcherInputAuxList.push_back(auxObj);
unsigned long index = mAuxInputs.size()+1;
mAuxInputs.insert(std::make_pair(index, auxObj));
InputAuxMonitor *monitor = new InputAuxMonitor(self, index);
auxObj->AddCallback(monitor);
mMonitors.push_back(monitor);
mAuxInputMonitors.insert(std::make_pair(index, monitor));
}
}

Expand Down Expand Up @@ -688,11 +693,13 @@ - (void)cleanUpConnection
mInputs.clear();
mInputMonitors.clear();

while (mSwitcherInputAuxList.size())
for (auto const& it : mAuxInputs)
{
mSwitcherInputAuxList.back()->Release();
mSwitcherInputAuxList.pop_back();
it.second->RemoveCallback(mAuxInputMonitors.at(it.first));
it.second->Release();
}
mAuxInputs.clear();
mAuxInputMonitors.clear();


while (dsk.size())
Expand Down

0 comments on commit de6b4fe

Please sign in to comment.