-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #276 from microsoft/pete-dev
Network MIDI 2.0 abstraction scaffolding
- Loading branch information
Showing
22 changed files
with
690 additions
and
178 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
<Include> | ||
<?define SetupVersionName="Developer Preview 5" ?> | ||
<?define SetupVersionNumber="1.0.24044.1942" ?> | ||
<?define SetupVersionNumber="1.0.24044.2146" ?> | ||
</Include> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
src/api/Abstraction/NetworkMidiAbstraction/AbstractionState.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License | ||
// ============================================================================ | ||
// This is part of the Windows MIDI Services App API and should be used | ||
// in your Windows application via an official binary distribution. | ||
// Further information: https://github.com/microsoft/MIDI/ | ||
// ============================================================================ | ||
|
||
#include "pch.h" | ||
|
||
|
||
AbstractionState::AbstractionState() = default; | ||
AbstractionState::~AbstractionState() = default; | ||
|
||
AbstractionState& AbstractionState::Current() | ||
{ | ||
// explanation: http://www.modernescpp.com/index.php/thread-safe-initialization-of-data/ | ||
|
||
static AbstractionState current; | ||
|
||
return current; | ||
} | ||
|
||
|
||
|
||
HRESULT | ||
AbstractionState::ConstructEndpointManager() | ||
{ | ||
RETURN_IF_FAILED(Microsoft::WRL::MakeAndInitialize<CMidi2NetworkMidiEndpointManager>(&m_endpointManager)); | ||
|
||
return S_OK; | ||
} | ||
|
||
|
||
HRESULT | ||
AbstractionState::ConstructConfigurationManager() | ||
{ | ||
RETURN_IF_FAILED(Microsoft::WRL::MakeAndInitialize<CMidi2NetworkMidiConfigurationManager>(&m_configurationManager)); | ||
|
||
return S_OK; | ||
} |
62 changes: 62 additions & 0 deletions
62
src/api/Abstraction/NetworkMidiAbstraction/AbstractionState.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License | ||
// ============================================================================ | ||
// This is part of the Windows MIDI Services App API and should be used | ||
// in your Windows application via an official binary distribution. | ||
// Further information: https://github.com/microsoft/MIDI/ | ||
// ============================================================================ | ||
|
||
|
||
#pragma once | ||
|
||
// singleton | ||
class AbstractionState | ||
{ | ||
|
||
public: | ||
static AbstractionState& Current(); | ||
|
||
// no copying | ||
AbstractionState(_In_ const AbstractionState&) = delete; | ||
AbstractionState& operator=(_In_ const AbstractionState&) = delete; | ||
|
||
|
||
wil::com_ptr<CMidi2NetworkMidiEndpointManager> GetEndpointManager() | ||
{ | ||
return m_endpointManager; | ||
} | ||
|
||
wil::com_ptr<CMidi2NetworkMidiConfigurationManager> GetConfigurationManager() | ||
{ | ||
return m_configurationManager; | ||
} | ||
|
||
std::shared_ptr<MidiNetworkDeviceTable> GetEndpointTable() | ||
{ | ||
return m_endpointTable; | ||
} | ||
|
||
|
||
HRESULT Cleanup() | ||
{ | ||
m_endpointManager.reset(); | ||
m_configurationManager.reset(); | ||
|
||
return S_OK; | ||
} | ||
|
||
|
||
HRESULT ConstructEndpointManager(); | ||
HRESULT ConstructConfigurationManager(); | ||
|
||
|
||
private: | ||
AbstractionState(); | ||
~AbstractionState(); | ||
|
||
|
||
wil::com_ptr<CMidi2NetworkMidiEndpointManager> m_endpointManager; | ||
wil::com_ptr<CMidi2NetworkMidiConfigurationManager> m_configurationManager; | ||
|
||
std::shared_ptr<MidiNetworkDeviceTable> m_endpointTable = std::make_shared<MidiNetworkDeviceTable>(); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
97 changes: 97 additions & 0 deletions
97
src/api/Abstraction/NetworkMidiAbstraction/Midi2.NetworkMidiConfigurationManager.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License | ||
// ============================================================================ | ||
// This is part of the Windows MIDI Services App API and should be used | ||
// in your Windows application via an official binary distribution. | ||
// Further information: https://github.com/microsoft/MIDI/ | ||
// ============================================================================ | ||
|
||
#include "pch.h" | ||
|
||
|
||
_Use_decl_annotations_ | ||
HRESULT | ||
CMidi2NetworkMidiConfigurationManager::Initialize( | ||
GUID AbstractionId, | ||
IUnknown* MidiDeviceManager | ||
) | ||
{ | ||
TraceLoggingWrite( | ||
MidiNetworkMidiAbstractionTelemetryProvider::Provider(), | ||
__FUNCTION__, | ||
TraceLoggingLevel(WINEVENT_LEVEL_INFO), | ||
TraceLoggingPointer(this, "this") | ||
); | ||
|
||
RETURN_HR_IF_NULL(E_INVALIDARG, MidiDeviceManager); | ||
RETURN_IF_FAILED(MidiDeviceManager->QueryInterface(__uuidof(IMidiDeviceManagerInterface), (void**)&m_MidiDeviceManager)); | ||
|
||
m_abstractionId = AbstractionId; | ||
|
||
return S_OK; | ||
} | ||
|
||
_Use_decl_annotations_ | ||
HRESULT | ||
CMidi2NetworkMidiConfigurationManager::UpdateConfiguration( | ||
LPCWSTR ConfigurationJsonSection, | ||
BOOL IsFromConfigurationFile, | ||
BSTR* Response | ||
) | ||
{ | ||
TraceLoggingWrite( | ||
MidiNetworkMidiAbstractionTelemetryProvider::Provider(), | ||
__FUNCTION__, | ||
TraceLoggingLevel(WINEVENT_LEVEL_INFO), | ||
TraceLoggingPointer(this, "this"), | ||
TraceLoggingWideString(ConfigurationJsonSection, "json") | ||
); | ||
|
||
UNREFERENCED_PARAMETER(IsFromConfigurationFile); | ||
|
||
|
||
|
||
// if we're passed a null or empty json, we just quietly exit | ||
if (ConfigurationJsonSection == nullptr) return S_OK; | ||
|
||
json::JsonObject jsonObject; | ||
|
||
// default to failure | ||
auto responseObject = internal::BuildConfigurationResponseObject(false); | ||
|
||
|
||
// TODO: All your json parsing config stuff. Build any device table entries from it, etc. | ||
// See Midi2.LoopbackMidiAbstraction for an example | ||
|
||
// The runtime json sent up from the client in the case of network MIDI may include | ||
// an IP address, port, password, etc. You can assume there can be a UI on the client | ||
// for gathering that information and then sending it up. The API just needs to know | ||
// what is needed. | ||
|
||
|
||
// the response object should include anything the client needs to be able to use | ||
// the endpoint, if the creation was successful. Typically, this is just an SWD | ||
// interface id | ||
internal::JsonStringifyObjectToOutParam(responseObject, &Response); | ||
|
||
return S_OK; | ||
|
||
} | ||
|
||
|
||
HRESULT | ||
CMidi2NetworkMidiConfigurationManager::Cleanup() | ||
{ | ||
TraceLoggingWrite( | ||
MidiNetworkMidiAbstractionTelemetryProvider::Provider(), | ||
__FUNCTION__, | ||
TraceLoggingLevel(WINEVENT_LEVEL_INFO), | ||
TraceLoggingPointer(this, "this") | ||
); | ||
|
||
|
||
|
||
|
||
return S_OK; | ||
} | ||
|
27 changes: 27 additions & 0 deletions
27
src/api/Abstraction/NetworkMidiAbstraction/Midi2.NetworkMidiConfigurationManager.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License | ||
// ============================================================================ | ||
// This is part of the Windows MIDI Services App API and should be used | ||
// in your Windows application via an official binary distribution. | ||
// Further information: https://github.com/microsoft/MIDI/ | ||
// ============================================================================ | ||
|
||
#pragma once | ||
|
||
|
||
class CMidi2NetworkMidiConfigurationManager : | ||
public Microsoft::WRL::RuntimeClass< | ||
Microsoft::WRL::RuntimeClassFlags<Microsoft::WRL::ClassicCom>, | ||
IMidiAbstractionConfigurationManager> | ||
|
||
{ | ||
public: | ||
STDMETHOD(Initialize(_In_ GUID AbstractionId, _In_ IUnknown* MidiDeviceManager)); | ||
STDMETHOD(UpdateConfiguration(_In_ LPCWSTR ConfigurationJsonSection, _In_ BOOL IsFromConfigurationFile, _Out_ BSTR* Response)); | ||
STDMETHOD(Cleanup)(); | ||
|
||
private: | ||
wil::com_ptr_nothrow<IMidiDeviceManagerInterface> m_MidiDeviceManager; | ||
|
||
GUID m_abstractionId; // kept for convenience | ||
}; |
Oops, something went wrong.