1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00
JUCE/modules/juce_midi_ci/detail/juce_CIPropertyHostUtils.h
reuk 60757de2f2
CIDevice: Improve robustness of subscription API
The old API only allowed cancelling property "get" inquiries and
subscription updates. However, there are use-cases for cancelling other
requests too. e.g. switching between views in a JUCE app might mean that
it's no longer necessary to subscribe to a particular property.

Cancelling subscriptions ends up being quite involved. Different
handling is needed depending on whether the subscription is cancelled
before or after the responder replies to the initial request.
In addition, the responder may ask the initiator to retry a subscription
begin request.
2024-01-18 10:37:17 +00:00

55 lines
2.1 KiB
C++

/*
==============================================================================
This file is part of the JUCE library.
Copyright (c) 2022 - Raw Material Software Limited
JUCE is an open source library subject to commercial or open-source
licensing.
By using JUCE, you agree to the terms of both the JUCE 7 End-User License
Agreement and JUCE Privacy Policy.
End User License Agreement: www.juce.com/juce-7-licence
Privacy Policy: www.juce.com/juce-privacy-policy
Or: You may also use this code under the terms of the GPL v3 (see
www.gnu.org/licenses).
JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
DISCLAIMED.
==============================================================================
*/
namespace juce::midi_ci::detail
{
struct PropertyHostUtils
{
PropertyHostUtils() = delete;
static void send (BufferOutput& output,
uint8_t group,
std::byte subID2,
MUID targetMuid,
std::byte requestID,
Span<const std::byte> header,
Span<const std::byte> body,
int chunkSize)
{
MemoryInputStream stream (body.data(), body.size(), false);
const detail::PropertyDataMessageChunker chunker { output.getOutputBuffer(),
std::min (chunkSize, 1 << 16),
subID2,
requestID,
header,
output.getMuid(),
targetMuid,
stream };
std::for_each (chunker.begin(), chunker.end(), [&] (auto) { output.send (group); });
}
};
} // namespace juce::midi_ci::detail