1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-11 23:54:18 +00:00

BLOCKS: Added a method PhysicalTopologySource::isLockedFromOutside()

This commit is contained in:
Daniel Walz 2018-09-12 14:50:21 +01:00 committed by Julian Storer
parent ce5757821d
commit accb5d573d
2 changed files with 27 additions and 0 deletions

View file

@ -228,6 +228,8 @@ struct PhysicalTopologySource::Internal
if (dev->lockAgainstOtherProcesses (pair.inputName, pair.outputName))
{
lockedFromOutside = false;
dev->midiInput.reset (juce::MidiInput::openDevice (pair.inputIndex, dev.get()));
dev->midiOutput.reset (juce::MidiOutput::openDevice (pair.outputIndex));
@ -237,11 +239,20 @@ struct PhysicalTopologySource::Internal
return dev.release();
}
}
else
{
lockedFromOutside = true;
}
}
return nullptr;
}
bool isLockedFromOutside() const override
{
return lockedFromOutside;
}
static bool isBlocksMidiDeviceName (const juce::String& name)
{
return name.indexOf (" BLOCK") > 0 || name.indexOf (" Block") > 0;
@ -303,6 +314,9 @@ struct PhysicalTopologySource::Internal
return result;
}
private:
bool lockedFromOutside = true;
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MIDIDeviceDetector)
};
@ -2598,6 +2612,8 @@ PhysicalTopologySource::~PhysicalTopologySource()
void PhysicalTopologySource::setActive (bool shouldBeActive)
{
JUCE_ASSERT_MESSAGE_MANAGER_IS_LOCKED
if (isActive() == shouldBeActive)
return;
@ -2622,6 +2638,14 @@ bool PhysicalTopologySource::isActive() const
return detector != nullptr;
}
bool PhysicalTopologySource::isLockedFromOutside() const
{
if (detector != nullptr && detector->detector != nullptr)
return detector->detector->deviceDetector.isLockedFromOutside();
return false;
}
BlockTopology PhysicalTopologySource::getCurrentTopology() const
{
JUCE_ASSERT_MESSAGE_MANAGER_IS_LOCKED // This method must only be called from the message thread!

View file

@ -51,6 +51,8 @@ public:
/** Returns true, if the TopologySource is currently trying to connect the block devices */
bool isActive() const override;
/** This method will tell, if an other PhysicalTopologySource has locked the Midi connection */
bool isLockedFromOutside() const;
//==========================================================================
/** For custom transport systems, this represents a connected device */
@ -71,6 +73,7 @@ public:
virtual juce::StringArray scanForDevices() = 0;
virtual DeviceConnection* openDevice (int index) = 0;
virtual bool isLockedFromOutside() const { return false; }
};
/** Constructor for custom transport systems. */