Skip to content

Commit

Permalink
[alsa] Refactor version check macros
Browse files Browse the repository at this point in the history
  • Loading branch information
jcelerier committed Oct 29, 2023
1 parent 1f86d7c commit 38e1bd7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
7 changes: 2 additions & 5 deletions include/libremidi/backends/alsa_raw/midi_in.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@

#include <alsa/asoundlib.h>

#if SND_LIB_VERSION >= ((1 << 16) | (2 << 8) | 6)
#define LIBREMIDI_ALSA_SUPPORTS_TREAD 1
#endif
#include <atomic>
#include <thread>

Expand Down Expand Up @@ -69,7 +66,7 @@ class midi_in_impl
return err;
if (int err = snd.rawmidi.params_set_no_active_sensing(midiport_, params, 1); err < 0)
return err;
#if LIBREMIDI_ALSA_SUPPORTS_TREAD
#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);
Expand Down Expand Up @@ -183,7 +180,7 @@ class midi_in_impl
}
}

#if LIBREMIDI_ALSA_SUPPORTS_TREAD
#if LIBREMIDI_ALSA_HAS_RAWMIDI_TREAD
int read_input_buffer_with_timestamps()
{
static const constexpr int nbytes = 1024;
Expand Down
13 changes: 8 additions & 5 deletions include/libremidi/backends/linux/alsa.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@

#include <alsa/asoundlib.h>

#if __has_include(<alsa/rawmidi.h>) && SND_LIB_VERSION >= SND_LIB_VER(1,2,6)
#define LIBREMIDI_ALSA_HAS_RAMWIDI 1
#endif
#if defined(SND_LIB_VERSION)
#if __has_include(<alsa/rawmidi.h>) && SND_LIB_VERSION >= ((1 << 16) | (2 << 8) | 6)
#define LIBREMIDI_ALSA_HAS_RAMWIDI 1
#define LIBREMIDI_ALSA_HAS_RAWMIDI_TREAD 1
#endif

#if __has_include(<alsa/ump.h>) && SND_LIB_VERSION >= SND_LIB_VER(1,2,10)
#define LIBREMIDI_ALSA_HAS_UMP 1
#if __has_include(<alsa/ump.h>) && SND_LIB_VERSION >= ((1 << 16) | (2 << 8) | 10)
#define LIBREMIDI_ALSA_HAS_UMP 1
#endif
#endif

namespace libremidi
Expand Down

0 comments on commit 38e1bd7

Please sign in to comment.