From cc36bbf942aa43c94f5449f0310bb73a69d68627 Mon Sep 17 00:00:00 2001 From: Gabe Gonzalez II Date: Mon, 1 Jan 2024 22:29:43 -0600 Subject: [PATCH] Fix more missed warnings when building in linux Mostly more of the same of the previous commit. Also removes a few missed checks for LIBREMIDI_HAS_SPAN since C++20 is the minimum now. Signed-off-by: Gabe Gonzalez II --- CMakeLists.txt | 35 ++++++++-------- .../libremidi/backends/alsa_raw/config.hpp | 2 +- .../libremidi/backends/alsa_raw/midi_in.hpp | 37 ++++++++--------- .../libremidi/backends/alsa_raw/midi_out.hpp | 6 +-- .../libremidi/backends/alsa_seq/helpers.hpp | 2 +- include/libremidi/backends/jack/helpers.hpp | 10 ++--- include/libremidi/backends/jack/midi_in.hpp | 2 +- include/libremidi/backends/jack/midi_out.hpp | 16 ++++---- include/libremidi/backends/jack/observer.hpp | 4 +- include/libremidi/backends/winmm/midi_in.hpp | 4 +- include/libremidi/client.hpp | 2 +- include/libremidi/cmidi2.hpp | 1 + include/libremidi/detail/midi_out.hpp | 15 ++++--- include/libremidi/libremidi.hpp | 36 ++++++++--------- include/libremidi/midi_out.cpp | 40 +++++++++---------- include/libremidi/reader.hpp | 4 +- 16 files changed, 109 insertions(+), 107 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 93886a3b..b94347e6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,6 +32,7 @@ option(LIBREMIDI_FIND_BOOST "Actively look for Boost" OFF) option(LIBREMIDI_EXAMPLES "Enable examples" OFF) option(LIBREMIDI_TESTS "Enable tests" OFF) option(LIBREMIDI_CI "To be enabled only in CI, some tests cannot run there" OFF) +option(LIBREMIDI_NO_WARNINGS "Disables warnings from library compilation" OFF) ### C++ features ### if(NOT CMAKE_CXX_STANDARD) @@ -178,22 +179,24 @@ else() set(_private PRIVATE) endif() -if(MSVC) - set(WARNING_FLAGS - /W4 - ) -elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU") - set(WARNING_FLAGS - -Werror # Turns all warnings into errors - -Wall # Enable most warning messages. - -Wextra # Print extra (possibly unwanted) warnings. - #-Wpedantic # Issue warnings needed for strict compliance to the standard. - ) -else() - message(WARNING "CMake flags for compiler aren't set for compiler ${CMAKE_CXX_COMPILER_ID}") -endif() - -target_compile_options(libremidi PUBLIC ${WARNING_FLAGS}) +if(NOT LIBREMIDI_NO_WARNINGS) + if(MSVC) + set(WARNING_FLAGS + /W4 + ) + elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU") + set(WARNING_FLAGS + -Werror # Turns all warnings into errors + -Wall # Enable most warning messages. + -Wextra # Print extra (possibly unwanted) warnings. + #-Wpedantic # Issue warnings needed for strict compliance to the standard. + ) + else() + message(WARNING "CMake flags for compiler aren't set for compiler ${CMAKE_CXX_COMPILER_ID}") + endif() + + target_compile_options(libremidi PRIVATE ${WARNING_FLAGS}) +endif () add_library(libremidi::libremidi ALIAS libremidi) diff --git a/include/libremidi/backends/alsa_raw/config.hpp b/include/libremidi/backends/alsa_raw/config.hpp index 4d4c4d1e..f30975e8 100644 --- a/include/libremidi/backends/alsa_raw/config.hpp +++ b/include/libremidi/backends/alsa_raw/config.hpp @@ -45,7 +45,7 @@ struct LIBREMIDI_EXPORT chunking_parameters */ std::function wait = chunking_parameters::default_wait; - static bool default_wait(std::chrono::microseconds time_to_wait, int written_bytes) + static bool default_wait(std::chrono::microseconds time_to_wait, int /*written_bytes*/) { std::this_thread::sleep_for(time_to_wait); return true; diff --git a/include/libremidi/backends/alsa_raw/midi_in.hpp b/include/libremidi/backends/alsa_raw/midi_in.hpp index ddb544ee..2032d92d 100644 --- a/include/libremidi/backends/alsa_raw/midi_in.hpp +++ b/include/libremidi/backends/alsa_raw/midi_in.hpp @@ -7,7 +7,6 @@ #include -#include #include namespace libremidi::alsa_raw @@ -53,7 +52,7 @@ class midi_in_impl [[nodiscard]] int do_init_port(const char* portname) { constexpr int mode = SND_RAWMIDI_NONBLOCK; - if (int err = snd.rawmidi.open(&midiport_, nullptr, portname, mode); err < 0) + if (const int err = snd.rawmidi.open(&midiport_, nullptr, portname, mode); err < 0) { error(this->configuration, "midi_in_alsa_raw::open_port: cannot open device."); return err; @@ -62,33 +61,33 @@ class midi_in_impl snd_rawmidi_params_t* params{}; snd_rawmidi_params_alloca(¶ms); - if (int err = snd.rawmidi.params_current(midiport_, params); err < 0) + if (const int err = snd.rawmidi.params_current(midiport_, params); err < 0) return err; - if (int err = snd.rawmidi.params_set_no_active_sensing(midiport_, params, 1); err < 0) + if (const int err = snd.rawmidi.params_set_no_active_sensing(midiport_, params, 1); err < 0) return err; #if LIBREMIDI_ALSA_HAS_RAWMIDI_TREAD if (configuration.timestamps == timestamp_mode::NoTimestamp) { - if (int err = snd.rawmidi.params_set_read_mode(midiport_, params, SND_RAWMIDI_READ_STANDARD); + if (const int err = snd.rawmidi.params_set_read_mode(midiport_, params, SND_RAWMIDI_READ_STANDARD); err < 0) return err; - if (int err = snd.rawmidi.params_set_clock_type(midiport_, params, SND_RAWMIDI_CLOCK_NONE); + if (const int err = snd.rawmidi.params_set_clock_type(midiport_, params, SND_RAWMIDI_CLOCK_NONE); err < 0) return err; } else { - if (int err = snd.rawmidi.params_set_read_mode(midiport_, params, SND_RAWMIDI_READ_TSTAMP); + if (const int err = snd.rawmidi.params_set_read_mode(midiport_, params, SND_RAWMIDI_READ_TSTAMP); err < 0) return err; - if (int err + if (const int err = snd.rawmidi.params_set_clock_type(midiport_, params, SND_RAWMIDI_CLOCK_MONOTONIC); err < 0) return err; } #endif - if (int err = snd.rawmidi.params(midiport_, params); err < 0) + if (const int err = snd.rawmidi.params(midiport_, params); err < 0) return err; return init_pollfd(); @@ -101,7 +100,7 @@ class midi_in_impl [[nodiscard]] int init_pollfd() { - int num_fds = snd.rawmidi.poll_descriptors_count(this->midiport_); + const int num_fds = snd.rawmidi.poll_descriptors_count(this->midiport_); this->fds_.clear(); this->fds_.resize(num_fds); @@ -119,7 +118,7 @@ class midi_in_impl else { unsigned short res{}; - int err + const int err = snd.rawmidi.poll_descriptors_revents(this->midiport_, fds.data(), fds.size(), &res); if (err < 0) return err; @@ -160,7 +159,7 @@ class midi_in_impl case timestamp_mode::NoTimestamp: break; case timestamp_mode::Relative: { - auto t = int64_t(ts.tv_sec) * nanos + int64_t(ts.tv_nsec); + const auto t = static_cast(ts.tv_sec) * nanos + static_cast(ts.tv_nsec); if (firstMessage == true) { firstMessage = false; @@ -177,13 +176,15 @@ class midi_in_impl case timestamp_mode::SystemMonotonic: res = int64_t(ts.tv_sec) * nanos + int64_t(ts.tv_nsec); break; + default: + break; } } #if LIBREMIDI_ALSA_HAS_RAWMIDI_TREAD int read_input_buffer_with_timestamps() { - static const constexpr int nbytes = 1024; + static constexpr int nbytes = 1024; unsigned char bytes[nbytes]; struct timespec ts; @@ -236,10 +237,10 @@ class midi_in_alsa_raw_threaded : public midi_in_impl } } - ~midi_in_alsa_raw_threaded() + ~midi_in_alsa_raw_threaded() override { // Close a connection if it exists. - this->close_port(); + this->midi_in_alsa_raw_threaded::close_port(); } private: @@ -292,9 +293,9 @@ class midi_in_alsa_raw_threaded : public midi_in_impl return true; } - bool open_port(const input_port& port, std::string_view name) override + bool open_port(const input_port& port, std::string_view /*name*/) override { - if (int err = midi_in_impl::init_port(port); err < 0) + if (const int err = midi_in_impl::init_port(port); err < 0) return false; if (!start_thread()) return false; @@ -347,7 +348,7 @@ class midi_in_alsa_raw_manual : public midi_in_impl } } - bool open_port(const input_port& p, std::string_view name) override + bool open_port(const input_port& p, std::string_view /*name*/) override { if (midi_in_impl::init_port(p) < 0) return false; diff --git a/include/libremidi/backends/alsa_raw/midi_out.hpp b/include/libremidi/backends/alsa_raw/midi_out.hpp index 657863f2..de73b040 100644 --- a/include/libremidi/backends/alsa_raw/midi_out.hpp +++ b/include/libremidi/backends/alsa_raw/midi_out.hpp @@ -133,7 +133,7 @@ class midi_out_impl final const std::size_t chunk_size = std::min(get_chunk_size(), size); // Send the first buffer - int len = chunk_size; + std::size_t len = chunk_size; if (!write(data, len)) return; @@ -156,10 +156,10 @@ class midi_out_impl final return; // Write more data - int len = end - data; + len = end - data; // Maybe until the end of the sysex - if (auto sysex_end = (unsigned char*)memchr(data, 0xf7, len)) + if (const auto sysex_end = static_cast(memchr(data, 0xf7, len))) len = sysex_end - data + 1; if (len > chunk_size) diff --git a/include/libremidi/backends/alsa_seq/helpers.hpp b/include/libremidi/backends/alsa_seq/helpers.hpp index 63776882..f726b55d 100644 --- a/include/libremidi/backends/alsa_seq/helpers.hpp +++ b/include/libremidi/backends/alsa_seq/helpers.hpp @@ -222,7 +222,7 @@ struct alsa_data } [[nodiscard]] int create_port( - auto& self, std::string_view portName, unsigned int caps, unsigned int type, + auto& /*self*/, std::string_view portName, unsigned int caps, unsigned int type, std::optional queue) { if (this->vport < 0) diff --git a/include/libremidi/backends/jack/helpers.hpp b/include/libremidi/backends/jack/helpers.hpp index 4cefe456..8c878f21 100644 --- a/include/libremidi/backends/jack/helpers.hpp +++ b/include/libremidi/backends/jack/helpers.hpp @@ -4,7 +4,7 @@ #include #elif __has_include() #include -#elif __has_include() +#elif __has_include( ) #include #include #include @@ -39,7 +39,7 @@ struct jack_client } else { - auto short_name = jack_port_short_name(port); + const auto short_name = jack_port_short_name(port); if (short_name && strlen(short_name) > 0) return short_name; return jack_port_name(port); @@ -51,7 +51,7 @@ struct jack_client -> std::conditional_t { return {{ - .client = std::uintptr_t(client), + .client = reinterpret_cast(client), .port = 0, .manufacturer = "", .device_name = "", @@ -61,7 +61,7 @@ struct jack_client } template - static auto get_ports(jack_client_t* client, const char* pattern, JackPortFlags flags) noexcept + static auto get_ports(jack_client_t* client, const char* pattern, const JackPortFlags flags) noexcept -> std::vector> { std::vector> ret; @@ -214,7 +214,7 @@ struct jack_helpers : jack_client if (portName.empty()) portName = flags & JackPortIsInput ? "i" : "o"; - if (self.configuration.client_name.size() + portName.size() + 1 + 1 >= jack_port_name_size()) + if (self.configuration.client_name.size() + portName.size() + 2u >= static_cast(jack_port_name_size())) { self.template error( self.configuration, "JACK: port name length limit exceeded"); diff --git a/include/libremidi/backends/jack/midi_in.hpp b/include/libremidi/backends/jack/midi_in.hpp index 24f09b23..23f229f7 100644 --- a/include/libremidi/backends/jack/midi_in.hpp +++ b/include/libremidi/backends/jack/midi_in.hpp @@ -72,7 +72,7 @@ class midi_in_jack final } void set_timestamp( - jack_nframes_t frame, jack_nframes_t start_frames, jack_time_t abs_usec, + jack_nframes_t frame, jack_nframes_t start_frames, jack_time_t /*abs_usec*/, libremidi::message& msg) noexcept { switch (configuration.timestamps) diff --git a/include/libremidi/backends/jack/midi_out.hpp b/include/libremidi/backends/jack/midi_out.hpp index 4f9abad9..267531a6 100644 --- a/include/libremidi/backends/jack/midi_out.hpp +++ b/include/libremidi/backends/jack/midi_out.hpp @@ -37,28 +37,28 @@ struct jack_queue jack_ringbuffer_free(ringbuffer); } - void write(const unsigned char* data, int32_t sz) noexcept + void write(const unsigned char* data, int32_t sz) const noexcept { - if (sz + size_sz > ringbuffer_space) + if (static_cast(sz + size_sz) > ringbuffer_space) return; - while (jack_ringbuffer_write_space(ringbuffer) < size_sz + sz) + while (jack_ringbuffer_write_space(ringbuffer) < sz + size_sz) sched_yield(); - jack_ringbuffer_write(ringbuffer, (char*)&sz, size_sz); - jack_ringbuffer_write(ringbuffer, (const char*)data, sz); + jack_ringbuffer_write(ringbuffer, reinterpret_cast(&sz), size_sz); + jack_ringbuffer_write(ringbuffer, reinterpret_cast(data), sz); } - void read(void* jack_events) noexcept + void read(void* jack_events) const noexcept { int32_t sz; - while (jack_ringbuffer_peek(ringbuffer, (char*)&sz, size_sz) == size_sz + while (jack_ringbuffer_peek(ringbuffer, reinterpret_cast(&sz), size_sz) == size_sz && jack_ringbuffer_read_space(ringbuffer) >= size_sz + sz) { jack_ringbuffer_read_advance(ringbuffer, size_sz); if (auto midi = jack_midi_event_reserve(jack_events, 0, sz)) - jack_ringbuffer_read(ringbuffer, (char*)midi, sz); + jack_ringbuffer_read(ringbuffer, reinterpret_cast(midi), sz); else jack_ringbuffer_read_advance(ringbuffer, sz); } diff --git a/include/libremidi/backends/jack/observer.hpp b/include/libremidi/backends/jack/observer.hpp index a2c3b73f..0b82b545 100644 --- a/include/libremidi/backends/jack/observer.hpp +++ b/include/libremidi/backends/jack/observer.hpp @@ -185,8 +185,8 @@ class observer_jack final jack_set_port_rename_callback( this->client, - +[](jack_port_id_t p, const char* old_name, const char* new_name, void* arg) { - auto& self = *(observer_jack*)arg; + +[](jack_port_id_t p, const char* /*old_name*/, const char* /*new_name*/, void* arg) { + const auto& self = *static_cast(arg); auto port = jack_port_by_id(self.client, p); if (!port) diff --git a/include/libremidi/backends/winmm/midi_in.hpp b/include/libremidi/backends/winmm/midi_in.hpp index 64a4b11c..9dee2948 100644 --- a/include/libremidi/backends/winmm/midi_in.hpp +++ b/include/libremidi/backends/winmm/midi_in.hpp @@ -64,7 +64,7 @@ class midi_in_winmm final bool do_open(unsigned int portNumber) { MMRESULT result = midiInOpen( - &this->inHandle, portNumber, reinterpret_cast(&midiInputCallback), reinterpret_cast(this), + &this->inHandle, portNumber, std::bit_cast(&midiInputCallback), std::bit_cast(this), CALLBACK_FUNCTION); if (result != MMSYSERR_NOERROR) { @@ -78,7 +78,7 @@ class midi_in_winmm final this->sysexBuffer.resize(bufferCount); for (std::size_t i = 0; i < bufferCount; ++i) { - this->sysexBuffer[i] = reinterpret_cast(new char[sizeof(MIDIHDR)]); + this->sysexBuffer[i] = new MIDIHDR; this->sysexBuffer[i]->lpData = new char[configuration.sysex_buffer_size]; this->sysexBuffer[i]->dwBufferLength = static_cast(configuration.sysex_buffer_size); this->sysexBuffer[i]->dwUser = i; // We use the dwUser parameter as buffer indicator diff --git a/include/libremidi/client.hpp b/include/libremidi/client.hpp index f5a5a639..b807173b 100644 --- a/include/libremidi/client.hpp +++ b/include/libremidi/client.hpp @@ -17,7 +17,7 @@ struct client_configuration //! Set a callback function to be invoked for incoming MIDI messages. //! Mandatory! std::function on_message - = []([[maybe_unused]] const libremidi::input_port& port, libremidi::message&&) {}; + = [](const libremidi::input_port& /*port*/, libremidi::message&&) {}; //! Observation callbacks for when ports are added or removed input_port_callback input_added; diff --git a/include/libremidi/cmidi2.hpp b/include/libremidi/cmidi2.hpp index 2e1c4560..d9d9cfc7 100644 --- a/include/libremidi/cmidi2.hpp +++ b/include/libremidi/cmidi2.hpp @@ -1,6 +1,7 @@ #ifndef CMIDI2_H_INCLUDED #define CMIDI2_H_INCLUDED +#pragma GCC system_header // Todo: remove before commit #include #include diff --git a/include/libremidi/detail/midi_out.hpp b/include/libremidi/detail/midi_out.hpp index 9a415973..6833ac97 100644 --- a/include/libremidi/detail/midi_out.hpp +++ b/include/libremidi/detail/midi_out.hpp @@ -18,19 +18,18 @@ class midi_out_api : public midi_api midi_out_api& operator=(const midi_out_api&) = delete; midi_out_api& operator=(midi_out_api&&) = delete; - [[nodiscard]] virtual bool open_port(const output_port& pt, std::string_view local_port_name) - = 0; + [[nodiscard]] virtual bool open_port(const output_port& pt, std::string_view local_port_name) = 0; - virtual int64_t current_time() const noexcept { return 0; } + [[nodiscard]] virtual int64_t current_time() const noexcept { return 0; } virtual void send_message(const unsigned char* message, size_t size) = 0; - virtual void schedule_message([[maybe_unused]] int64_t ts, const unsigned char* message, size_t size) + virtual void schedule_message(int64_t /*ts*/, const unsigned char* message, size_t size) { return send_message(message, size); } virtual void send_ump(const uint32_t* message, size_t size) = 0; - virtual void schedule_ump([[maybe_unused]] int64_t ts, const uint32_t* ump, size_t size) + virtual void schedule_ump(int64_t /*ts*/, const uint32_t* ump, size_t size) { return send_ump(ump, size); } @@ -45,10 +44,10 @@ class out_api : public midi_out_api public: using midi_out_api::midi_out_api; - void send_ump(const uint32_t* message, [[maybe_unused]] size_t size) + void send_ump(const uint32_t* message, size_t /*size*/) { uint8_t midi[65536]; - int n = cmidi2_convert_single_ump_to_midi1(midi, sizeof(midi), (uint32_t*)message); + int n = cmidi2_convert_single_ump_to_midi1(midi, sizeof(midi), const_cast(message)); if (n > 0) send_message(midi, n); } @@ -89,6 +88,6 @@ class out_api : public midi_out_api template std::unique_ptr make(libremidi::output_configuration&& conf, Arg&& arg) { - return std::make_unique(std::move(conf), std::move(arg)); + return std::make_unique(std::move(conf), std::forward(arg)); } } diff --git a/include/libremidi/libremidi.hpp b/include/libremidi/libremidi.hpp index f9c29444..aeb47708 100644 --- a/include/libremidi/libremidi.hpp +++ b/include/libremidi/libremidi.hpp @@ -172,13 +172,13 @@ class LIBREMIDI_EXPORT midi_out ~midi_out(); //! Returns the MIDI API specifier for the current instance of midi_out. - [[nodiscard]] libremidi::API get_current_api() noexcept; + [[nodiscard]] libremidi::API get_current_api() const noexcept; //! Open a MIDI output connection. - void open_port(const output_port& pt, std::string_view local_port_name = "libremidi input"); + void open_port(const output_port& pt, std::string_view local_port_name = "libremidi input") const; //! Close an open MIDI connection (if one exists). - void close_port(); + void close_port() const; //! Returns true if a port has been opened successfully with open_port or open_virtual_port [[nodiscard]] bool is_port_open() const noexcept; @@ -192,23 +192,23 @@ class LIBREMIDI_EXPORT midi_out //! //! \param portName An optional name for the application port that is //! used to connect to portId can be specified. - void open_virtual_port(std::string_view portName = "libremidi virtual port"); + void open_virtual_port(std::string_view portName = "libremidi virtual port") const; - void set_port_name(std::string_view portName); + void set_port_name(std::string_view portName) const; //! Immediately send a single message out an open MIDI output port. /*! An exception is thrown if an error occurs during output or an output connection was not previously established. */ - void send_message(const libremidi::message& message); + void send_message(const libremidi::message& message) const; //! Immediately send a single message to an open MIDI output port. - void send_message(const unsigned char* message, size_t size); - void send_message(std::span); - void send_message(unsigned char b0); - void send_message(unsigned char b0, unsigned char b1); - void send_message(unsigned char b0, unsigned char b1, unsigned char b2); + void send_message(const unsigned char* message, size_t size) const; + void send_message(std::span) const; + void send_message(unsigned char b0) const; + void send_message(unsigned char b0, unsigned char b1) const; + void send_message(unsigned char b0, unsigned char b1, unsigned char b2) const; //! Current time in the timestamp referential int64_t current_time(); @@ -218,13 +218,13 @@ class LIBREMIDI_EXPORT midi_out void schedule_message(int64_t timestamp, const unsigned char* message, size_t size); //! Immediately send a single UMP packet to an open MIDI output port. - void send_ump(const uint32_t* message, size_t size); - void send_ump(const libremidi::ump&); - void send_ump(std::span); - void send_ump(uint32_t b0); - void send_ump(uint32_t b0, uint32_t b1); - void send_ump(uint32_t b0, uint32_t b1, uint32_t b2); - void send_ump(uint32_t b0, uint32_t b1, uint32_t b2, uint32_t b3); + void send_ump(const uint32_t* message, size_t size) const; + void send_ump(const libremidi::ump&) const; + void send_ump(std::span) const; + void send_ump(uint32_t b0) const; + void send_ump(uint32_t b0, uint32_t b1) const; + void send_ump(uint32_t b0, uint32_t b1, uint32_t b2) const; + void send_ump(uint32_t b0, uint32_t b1, uint32_t b2, uint32_t b3) const; //! Try to schedule an UMP packet later in time if the underlying API supports it //! (currently not implemented anywhere) diff --git a/include/libremidi/midi_out.cpp b/include/libremidi/midi_out.cpp index e822dd06..edf6fa9f 100644 --- a/include/libremidi/midi_out.cpp +++ b/include/libremidi/midi_out.cpp @@ -70,19 +70,19 @@ LIBREMIDI_INLINE midi_out& midi_out::operator=(midi_out&& other) noexcept } LIBREMIDI_INLINE -void midi_out::set_port_name(std::string_view portName) +void midi_out::set_port_name(std::string_view portName) const { impl_->set_port_name(portName); } LIBREMIDI_INLINE -libremidi::API midi_out::get_current_api() noexcept +libremidi::API midi_out::get_current_api() const noexcept { return impl_->get_current_api(); } LIBREMIDI_INLINE -void midi_out::open_port(const output_port& port, std::string_view portName) +void midi_out::open_port(const output_port& port, std::string_view portName) const { if (impl_->is_port_open()) return; @@ -95,7 +95,7 @@ void midi_out::open_port(const output_port& port, std::string_view portName) } LIBREMIDI_INLINE -void midi_out::open_virtual_port(std::string_view portName) +void midi_out::open_virtual_port(std::string_view portName) const { if (impl_->is_port_open()) return; @@ -107,7 +107,7 @@ void midi_out::open_virtual_port(std::string_view portName) } LIBREMIDI_INLINE -void midi_out::close_port() +void midi_out::close_port() const { impl_->close_port(); impl_->connected_ = false; @@ -127,87 +127,87 @@ bool midi_out::is_port_connected() const noexcept } LIBREMIDI_INLINE -void midi_out::send_message(const libremidi::message& message) +void midi_out::send_message(const libremidi::message& message) const { send_message(message.bytes.data(), message.bytes.size()); } LIBREMIDI_INLINE -void midi_out::send_message(std::span message) +void midi_out::send_message(std::span message) const { send_message(message.data(), message.size()); } LIBREMIDI_INLINE -void midi_out::send_message(unsigned char b0) +void midi_out::send_message(unsigned char b0) const { send_message(&b0, 1); } LIBREMIDI_INLINE -void midi_out::send_message(unsigned char b0, unsigned char b1) +void midi_out::send_message(unsigned char b0, unsigned char b1) const { send_message(std::to_array({b0, b1})); } LIBREMIDI_INLINE -void midi_out::send_message(unsigned char b0, unsigned char b1, unsigned char b2) +void midi_out::send_message(unsigned char b0, unsigned char b1, unsigned char b2) const { send_message(std::to_array({b0, b1, b2})); } LIBREMIDI_INLINE -void midi_out::send_message(const unsigned char* message, size_t size) +void midi_out::send_message(const unsigned char* message, size_t size) const { #if defined(LIBREMIDI_ASSERTIONS) assert(size > 0); #endif - (static_cast(impl_.get()))->send_message(message, size); + impl_->send_message(message, size); } LIBREMIDI_INLINE - void midi_out::send_ump(const uint32_t* message, size_t size) + void midi_out::send_ump(const uint32_t* message, size_t size) const { #if defined(LIBREMIDI_ASSERTIONS) assert(size > 0); assert(size <= 4); #endif - (static_cast(impl_.get()))->send_ump(message, size); + impl_->send_ump(message, size); } LIBREMIDI_INLINE - void midi_out::send_ump(const libremidi::ump& message) + void midi_out::send_ump(const libremidi::ump& message) const { send_ump(message.bytes, message.size()); } LIBREMIDI_INLINE - void midi_out::send_ump(std::span message) + void midi_out::send_ump(std::span message) const { send_ump(message.data(), message.size()); } LIBREMIDI_INLINE - void midi_out::send_ump(uint32_t b0) + void midi_out::send_ump(uint32_t b0) const { send_ump(&b0, 1); } LIBREMIDI_INLINE - void midi_out::send_ump(uint32_t b0, uint32_t b1) + void midi_out::send_ump(uint32_t b0, uint32_t b1) const { send_ump(std::to_array({b0, b1})); } LIBREMIDI_INLINE - void midi_out::send_ump(uint32_t b0, uint32_t b1, uint32_t b2) + void midi_out::send_ump(uint32_t b0, uint32_t b1, uint32_t b2) const { send_ump(std::to_array({b0, b1, b2})); } LIBREMIDI_INLINE - void midi_out::send_ump(uint32_t b0, uint32_t b1, uint32_t b2, uint32_t b3) + void midi_out::send_ump(uint32_t b0, uint32_t b1, uint32_t b2, uint32_t b3) const { send_ump(std::to_array({b0, b1, b2, b3})); } diff --git a/include/libremidi/reader.hpp b/include/libremidi/reader.hpp index c80c888b..1d99b469 100644 --- a/include/libremidi/reader.hpp +++ b/include/libremidi/reader.hpp @@ -55,11 +55,9 @@ class LIBREMIDI_EXPORT reader parse_result parse(const uint8_t* data, std::size_t size) noexcept; parse_result parse(const std::vector& buffer) noexcept; -#if defined(LIBREMIDI_HAS_SPAN) parse_result parse(std::span buffer) noexcept; -#endif - double get_end_time() const noexcept; + [[nodiscard]] double get_end_time() const noexcept; float ticksPerBeat{}; // precision (number of ticks distinguishable per second) float startingTempo{};