working on win32 uwp! and libremidi update

This commit is contained in:
Sebastian @ HfG
2024-10-28 19:24:18 +01:00
parent 06cb6d8319
commit 1e3755148c
106 changed files with 8474 additions and 2198 deletions
@@ -1,7 +1,9 @@
#pragma once
#include <libremidi/detail/memory.hpp>
#include <libremidi/detail/midi_api.hpp>
#include <libremidi/error_handler.hpp>
#include <libremidi/input_configuration.hpp>
#include <libremidi/backends/coremidi/error_domain.hpp>
#include <CoreMIDI/CoreMIDI.h>
#include <CoreServices/CoreServices.h>
@@ -28,7 +30,8 @@ namespace
static inline std::string get_string_property(MIDIObjectRef object, CFStringRef property) noexcept
{
CFStringRef res;
MIDIObjectGetStringProperty(object, property, &res);
if (MIDIObjectGetStringProperty(object, property, &res) || !res)
return {};
char name[256];
CFStringGetCString(res, name, sizeof(name), kCFStringEncodingUTF8);
@@ -215,15 +218,15 @@ locate_object(auto& self, const port_information& info, MIDIObjectType requested
auto ret = MIDIObjectFindByUniqueID(uid, &object, &type);
if (ret != noErr)
{
self.template error<invalid_parameter_error>(
self.configuration, "coremidi::locate_object: cannot find port: " + info.port_name);
self.libremidi_handle_error(
self.configuration, "cannot find port: " + info.port_name);
return 0;
}
if (type != requested_type || object == 0)
{
self.template error<invalid_parameter_error>(
self.configuration, "coremidi::locate_object: invalid object: " + info.port_name + " : "
self.libremidi_handle_error(
self.configuration, "invalid object: " + info.port_name + " : "
+ std::to_string(object));
return 0;
}
@@ -255,6 +258,13 @@ struct coremidi_data
}
}
void close_client(auto& self)
{
self.client_open_ = std::errc::not_connected;
if (!self.configuration.context)
MIDIClientDispose(self.client);
}
static uint64_t time_in_nanos(MIDITimeStamp tp) noexcept
{
if (tp == 0)
@@ -319,6 +329,23 @@ struct coremidi_data
}
}
}
stdx::error close_port()
{
if (this->endpoint)
{
MIDIEndpointDispose(this->endpoint);
this->endpoint = 0;
}
if (this->port)
{
MIDIPortDispose(this->port);
this->port = 0;
}
return stdx::error{};
}
};
}