working on win32 uwp! and libremidi update
This commit is contained in:
@@ -22,55 +22,52 @@ public:
|
||||
: configuration{std::move(conf), std::move(apiconf)}
|
||||
{
|
||||
winrt_init();
|
||||
this->client_open_ = stdx::error{};
|
||||
}
|
||||
|
||||
~midi_out_winuwp() override { close_port(); }
|
||||
|
||||
bool open_virtual_port(std::string_view) override
|
||||
~midi_out_winuwp() override
|
||||
{
|
||||
warning(configuration, "midi_out_winuwp: open_virtual_port unsupported");
|
||||
return false;
|
||||
}
|
||||
void set_client_name(std::string_view) override
|
||||
{
|
||||
warning(configuration, "midi_out_winuwp: set_client_name unsupported");
|
||||
}
|
||||
void set_port_name(std::string_view) override
|
||||
{
|
||||
warning(configuration, "midi_out_winuwp: set_port_name unsupported");
|
||||
close_port();
|
||||
this->client_open_ = std::errc::not_connected;
|
||||
}
|
||||
|
||||
libremidi::API get_current_api() const noexcept override { return libremidi::API::WINDOWS_UWP; }
|
||||
|
||||
bool open_port(const output_port& port, std::string_view) override
|
||||
stdx::error open_port(const output_port& port, std::string_view) override
|
||||
{
|
||||
const auto id = winrt::to_hstring(port.port_name);
|
||||
if (id.empty())
|
||||
return false;
|
||||
return std::errc::invalid_argument;
|
||||
|
||||
port_ = get(MidiOutPort::FromIdAsync(id));
|
||||
return bool(port_);
|
||||
if (!bool(port_))
|
||||
return std::errc::io_error;
|
||||
|
||||
return stdx::error{};
|
||||
}
|
||||
|
||||
void close_port() override
|
||||
stdx::error close_port() override
|
||||
{
|
||||
if (port_)
|
||||
{
|
||||
port_.Close();
|
||||
port_ = {};
|
||||
}
|
||||
return stdx::error{};
|
||||
}
|
||||
|
||||
void send_message(const unsigned char* message, size_t size) override
|
||||
stdx::error send_message(const unsigned char* message, size_t size) override
|
||||
{
|
||||
if (!port_)
|
||||
return;
|
||||
return std::errc::not_connected;
|
||||
|
||||
InMemoryRandomAccessStream str;
|
||||
DataWriter rb(str);
|
||||
rb.WriteBytes(
|
||||
winrt::array_view<const uint8_t>{(const uint8_t*)message, (const uint8_t*)message + size});
|
||||
port_.SendBuffer(rb.DetachBuffer());
|
||||
|
||||
return stdx::error{};
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user