Browse Source

BLOCKS: Added a method PhysicalTopologySource::isLockedFromOutside()

tags/2021-05-28
Daniel Walz Julian Storer 7 years ago
parent
commit
accb5d573d
2 changed files with 27 additions and 0 deletions
  1. +24
    -0
      modules/juce_blocks_basics/topology/juce_PhysicalTopologySource.cpp
  2. +3
    -0
      modules/juce_blocks_basics/topology/juce_PhysicalTopologySource.h

+ 24
- 0
modules/juce_blocks_basics/topology/juce_PhysicalTopologySource.cpp 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!


+ 3
- 0
modules/juce_blocks_basics/topology/juce_PhysicalTopologySource.h 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. */


Loading…
Cancel
Save