Skip to content

Commit

Permalink
Merge branch 'main' into pete-dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Psychlist1972 committed Feb 24, 2024
2 parents 69150b1 + 33f9b1f commit 556d93d
Show file tree
Hide file tree
Showing 30 changed files with 424 additions and 442 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions samples/electron-js/electron-api-basics/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ CMidi2BluetoothMidiConfigurationManager::UpdateConfiguration(

return E_FAIL;
}

_Use_decl_annotations_

HRESULT
CMidi2BluetoothMidiConfigurationManager::Cleanup()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,8 @@ CMidi2KSMidiConfigurationManager::UpdateConfiguration(LPCWSTR configurationJson,
}



_Use_decl_annotations_
HRESULT
CMidi2KSMidiConfigurationManager::Cleanup()
{
return S_OK;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,9 @@ GetMidiSrvBindingHandle(handle_t* BindingHandle

RETURN_IF_WIN32_ERROR(RpcStringBindingCompose(
nullptr,
(RPC_WSTR)MIDISRV_LRPC_PROTOCOL,
(RPC_WSTR) MIDISRV_LRPC_PROTOCOL,
nullptr,
(RPC_WSTR)MIDISRV_ENDPOINT,
(RPC_WSTR) MIDISRV_ENDPOINT,
nullptr,
&stringBinding));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ CMidi2MidiSrvConfigurationManager::Initialize(GUID abstractionGuid, IUnknown* de

}

_Use_decl_annotations_
HRESULT
CMidi2MidiSrvConfigurationManager::Cleanup()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,10 @@ CMidi2VirtualPatchBayEndpointManager::Initialize(
return S_OK;
}




_Use_decl_annotations_
HRESULT
CMidi2VirtualPatchBayEndpointManager::CreateEndpoint(
)
{



return S_OK;
}

Expand All @@ -75,7 +68,6 @@ CMidi2VirtualPatchBayEndpointManager::Cleanup()
TraceLoggingPointer(this, "this")
);


return S_OK;
}

243 changes: 121 additions & 122 deletions src/api/Client/Midi2Client/MidiMessage64.cpp
Original file line number Diff line number Diff line change
@@ -1,122 +1,121 @@
// 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"
#include "MidiMessage64.h"
#include "MidiMessage64.g.cpp"


namespace winrt::Windows::Devices::Midi2::implementation
{
_Use_decl_annotations_
collections::IVector<uint32_t> MidiMessage64::GetAllWords() const noexcept
{
auto vec = winrt::single_threaded_vector<uint32_t>();

vec.Append(m_ump.word0);
vec.Append(m_ump.word1);

return vec;
}

_Use_decl_annotations_
uint8_t MidiMessage64::AppendAllMessageWordsToVector(collections::IVector<uint32_t> targetVector) const noexcept
{
targetVector.Append(m_ump.word0);
targetVector.Append(m_ump.word1);

return 2;
}

_Use_decl_annotations_
uint8_t MidiMessage64::AddAllMessageBytesToBuffer(uint32_t const byteOffset, foundation::IMemoryBuffer const& buffer) const noexcept
{
const uint8_t numWordsInPacket = 2;
const uint8_t numBytesInPacket = numWordsInPacket * sizeof(uint32_t);

try
{
auto ref = buffer.CreateReference();
auto interop = ref.as<IMemoryBufferByteAccess>();

uint8_t* value{};
uint32_t valueSize{};

// get a pointer to the buffer
if (SUCCEEDED(interop->GetBuffer(&value, &valueSize)))
{
if (byteOffset + numBytesInPacket > valueSize)
{
// no room
return 0;
}
else
{
uint32_t* bufferWordPointer = reinterpret_cast<uint32_t*>(value + byteOffset);

// copy the number of valid bytes in our internal UMP structure
memcpy(bufferWordPointer, &m_ump, numBytesInPacket);

return numBytesInPacket;
}
}
else
{
return 0;
}

}
catch (...)
{
return 0;
}
}


_Use_decl_annotations_
MidiMessage64::MidiMessage64(
internal::MidiTimestamp const timestamp,
uint32_t const word0,
uint32_t const word1)
{
m_timestamp = timestamp;

m_ump.word0 = word0;
m_ump.word1 = word1;
}

// internal constructor for reading from the service callback
_Use_decl_annotations_
void MidiMessage64::InternalInitializeFromPointer(
internal::MidiTimestamp const timestamp,
PVOID data)
{
if (data == nullptr) return;

m_timestamp = timestamp;

// need to have some safeties around this
memcpy((void*)&m_ump, data, sizeof(internal::PackedUmp64));
}


winrt::hstring MidiMessage64::ToString()
{
std::stringstream stream;

stream << "64-bit MIDI message:"
<< " 0x" << std::hex << std::setw(8) << std::setfill('0') << Word0()
<< " 0x" << std::hex << std::setw(8) << std::setfill('0') << Word1();

return winrt::to_hstring(stream.str());
}



}

// 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"
#include "MidiMessage64.h"
#include "MidiMessage64.g.cpp"


namespace winrt::Windows::Devices::Midi2::implementation
{
collections::IVectorView<uint32_t> MidiMessage64::GetAllWords() const noexcept
{
auto vec = winrt::single_threaded_vector<uint32_t>();

vec.Append(m_ump.word0);
vec.Append(m_ump.word1);

return vec;
}

_Use_decl_annotations_
uint8_t MidiMessage64::AppendAllMessageWordsToVector(collections::IVector<uint32_t> targetVector) const noexcept
{
targetVector.Append(m_ump.word0);
targetVector.Append(m_ump.word1);

return 2;
}

_Use_decl_annotations_
uint8_t MidiMessage64::AddAllMessageBytesToBuffer(uint32_t const byteOffset, foundation::IMemoryBuffer const& buffer) const noexcept
{
const uint8_t numWordsInPacket = 2;
const uint8_t numBytesInPacket = numWordsInPacket * sizeof(uint32_t);

try
{
auto ref = buffer.CreateReference();
auto interop = ref.as<IMemoryBufferByteAccess>();

uint8_t* value{};
uint32_t valueSize{};

// get a pointer to the buffer
if (SUCCEEDED(interop->GetBuffer(&value, &valueSize)))
{
if (byteOffset + numBytesInPacket > valueSize)
{
// no room
return 0;
}
else
{
uint32_t* bufferWordPointer = reinterpret_cast<uint32_t*>(value + byteOffset);

// copy the number of valid bytes in our internal UMP structure
memcpy(bufferWordPointer, &m_ump, numBytesInPacket);

return numBytesInPacket;
}
}
else
{
return 0;
}

}
catch (...)
{
return 0;
}
}


_Use_decl_annotations_
MidiMessage64::MidiMessage64(
internal::MidiTimestamp const timestamp,
uint32_t const word0,
uint32_t const word1)
{
m_timestamp = timestamp;

m_ump.word0 = word0;
m_ump.word1 = word1;
}

// internal constructor for reading from the service callback
_Use_decl_annotations_
void MidiMessage64::InternalInitializeFromPointer(
internal::MidiTimestamp const timestamp,
PVOID data)
{
if (data == nullptr) return;

m_timestamp = timestamp;

// need to have some safeties around this
memcpy((void*)&m_ump, data, sizeof(internal::PackedUmp64));
}


winrt::hstring MidiMessage64::ToString()
{
std::stringstream stream;

stream << "64-bit MIDI message:"
<< " 0x" << std::hex << std::setw(8) << std::setfill('0') << Word0()
<< " 0x" << std::hex << std::setw(8) << std::setfill('0') << Word1();

return winrt::to_hstring(stream.str());
}



}

2 changes: 1 addition & 1 deletion src/api/Client/Midi2Client/MidiService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ namespace winrt::Windows::Devices::Midi2::implementation

// parse it into json objects

if (sessionListJson != nullptr && sessionListJson.Length() > 0)
if (sessionListJson.m_str != nullptr && sessionListJson.Length() > 0)
{
winrt::hstring hstr(sessionListJson, sessionListJson.Length());

Expand Down
Loading

0 comments on commit 556d93d

Please sign in to comment.