From bd5476cf31096df860ce978af1f67655768152ef Mon Sep 17 00:00:00 2001 From: Geert Bevin Date: Thu, 11 Apr 2024 20:31:32 -0400 Subject: [PATCH] Updated JUCE MIDI CI module with files from receivemidi --- .../modules/juce_midi_ci/ci/juce_CIDevice.cpp | 9 +++++++ .../juce_midi_ci/ci/juce_CIProfileDelegate.h | 4 ++++ .../juce_midi_ci/ci/juce_CIProfileHost.cpp | 24 +++++++++++++++---- 3 files changed, 32 insertions(+), 5 deletions(-) diff --git a/JuceLibraryCode/modules/juce_midi_ci/ci/juce_CIDevice.cpp b/JuceLibraryCode/modules/juce_midi_ci/ci/juce_CIDevice.cpp index 2c699fd..842e92e 100644 --- a/JuceLibraryCode/modules/juce_midi_ci/ci/juce_CIDevice.cpp +++ b/JuceLibraryCode/modules/juce_midi_ci/ci/juce_CIDevice.cpp @@ -1057,6 +1057,15 @@ class Device::Impl : private SubscriptionManagerDelegate device.profileHost->setProfileEnablement (profileAtAddress, enabled ? jmax (1, numChannels) : 0); } + + virtual std::vector profileDetailsInquired (MUID x, ProfileAtAddress profileAtAddress, std::byte target) override + { + if (auto* d = device.options.getProfileDelegate()) + return d->profileDetailsInquired (x, profileAtAddress, target); + + return std::vector(); + } + private: Impl& device; diff --git a/JuceLibraryCode/modules/juce_midi_ci/ci/juce_CIProfileDelegate.h b/JuceLibraryCode/modules/juce_midi_ci/ci/juce_CIProfileDelegate.h index 23c06a7..d033e84 100644 --- a/JuceLibraryCode/modules/juce_midi_ci/ci/juce_CIProfileDelegate.h +++ b/JuceLibraryCode/modules/juce_midi_ci/ci/juce_CIProfileDelegate.h @@ -56,6 +56,10 @@ struct ProfileDelegate [[maybe_unused]] ProfileAtAddress profileAtAddress, [[maybe_unused]] int numChannels, [[maybe_unused]] bool enabled) = 0; + + virtual std::vector profileDetailsInquired ([[maybe_unused]] MUID x, + [[maybe_unused]] ProfileAtAddress profileAtAddress, + [[maybe_unused]] std::byte target) { return std::vector(); } }; } // namespace juce::midi_ci diff --git a/JuceLibraryCode/modules/juce_midi_ci/ci/juce_CIProfileHost.cpp b/JuceLibraryCode/modules/juce_midi_ci/ci/juce_CIProfileHost.cpp index 1508d55..c6964ac 100644 --- a/JuceLibraryCode/modules/juce_midi_ci/ci/juce_CIProfileHost.cpp +++ b/JuceLibraryCode/modules/juce_midi_ci/ci/juce_CIProfileHost.cpp @@ -111,23 +111,37 @@ class ProfileHost::Visitor : public detail::MessageTypeUtils::MessageVisitor bool messageReceived (const Message::ProfileDetails& body) const { + const auto address = ChannelAddress{}.withGroup (output->getIncomingGroup()) + .withChannel (output->getIncomingHeader().deviceID); + const ProfileAtAddress profileAtAddress { body.profile, address }; + if (body.target == std::byte{}) { - const auto address = ChannelAddress{}.withGroup (output->getIncomingGroup()) - .withChannel (output->getIncomingHeader().deviceID); - const ProfileAtAddress profileAtAddress { body.profile, address }; const auto state = host->getState (profileAtAddress); std::vector extraData; detail::Marshalling::Writer { extraData } (state.active, state.supported); - detail::MessageTypeUtils::send (*output, Message::ProfileDetailsResponse { body.profile, body.target, extraData }); + sendProfileDetailsResponse(body, extraData); } else { - detail::MessageTypeUtils::sendNAK (*output, std::byte { 0x04 }); + const auto extraData = host->delegate.profileDetailsInquired(output->getIncomingHeader().source, profileAtAddress, body.target); + if (extraData.empty()) + { + detail::MessageTypeUtils::sendNAK (*output, std::byte { 0x04 }); + } + else + { + sendProfileDetailsResponse(body, extraData); + } } return true; } + + void sendProfileDetailsResponse (const Message::ProfileDetails& body, const std::vector& extraData) const + { + detail::MessageTypeUtils::send (*output, Message::ProfileDetailsResponse { body.profile, body.target, extraData }); + } template bool profileEnablementReceived (const Body& request) const