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
+12 -8
View File
@@ -1,5 +1,6 @@
#pragma once
#include <libremidi/cmidi2.hpp>
#include <libremidi/error.hpp>
#include <cinttypes>
#include <cstdint>
@@ -17,7 +18,7 @@ enum class segmentation_error
* Utility function to segment an ump stream into individual messages.
* Used to send a stream to APIs that work message-by-message.
*/
inline void
inline stdx::error
segment_ump_stream(const uint32_t* ump_stream, int64_t count, auto write_func, auto realloc_func)
{
while (count > 0)
@@ -35,24 +36,27 @@ segment_ump_stream(const uint32_t* ump_stream, int64_t count, auto write_func, a
const auto ump_bytes = cmidi2_ump_get_num_bytes(ump_stream[0]);
// FIXME std::expected, propagate the error back to caller?
switch (write_func(ump_stream, ump_bytes))
switch (int err = static_cast<int>(write_func(ump_stream, ump_bytes)))
{
case segmentation_error::no_error:
case 0:
break;
case segmentation_error::need_space:
case -ENOMEM:
case ENOMEM:
// Try again if we didn't have enough space in the OS queue
realloc_func();
if (write_func(ump_stream, ump_bytes) != segmentation_error::no_error)
return;
if (auto err = write_func(ump_stream, ump_bytes); err != std::errc{})
return std::make_error_code(err);
break;
case segmentation_error::other:
return;
default:
return from_errc(err);
}
const auto ump_uints = ump_bytes / 4;
ump_stream += ump_uints;
count -= ump_uints;
}
return stdx::error{};
}
}