From 8f3474ecfdb00d41281f265510b315b2b9161e1e Mon Sep 17 00:00:00 2001 From: Peter Veenstra Date: Sun, 10 Nov 2019 14:50:11 +0000 Subject: [PATCH] Make it possible to compile without CoreMIDI and CoreAudio on Mac OS X using a non-Apple compiler. Give some feedback to user in this case. (modified version of patch by krcroft with input from jmarsh, Dominus and Qbix) Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@4281 --- configure.ac | 28 +++++++++++++++++++++++++++- include/midi.h | 9 ++++++++- src/gui/midi.cpp | 8 +++++++- 3 files changed, 42 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index af394c65..d65acfbc 100644 --- a/configure.ac +++ b/configure.ac @@ -189,6 +189,33 @@ CXXFLAGS="$CXXFLAGS -mno-ms-bitfields" ],[AC_MSG_RESULT([no])]) CFLAGS="$BACKUP_CFLAGS" +dnl When on macOS, enable support for Apple's Core MIDI and/or Core Audio if our compiler can #include their headers +case "$host" in + *-*-darwin*) + AC_MSG_CHECKING(if compiler supports Apple's Core MIDI headers) + AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ + #include + int blah() { return 0; } + ]])], [AC_MSG_RESULT(yes);LIBS="$LIBS -framework CoreMIDI";AC_DEFINE([C_SUPPORTS_COREMIDI], [], + [Compiler supports Core MIDI headers])], + AC_MSG_RESULT(no);AC_MSG_WARN([Compiler can't compile Apple headers. CoreMIDI functionality disabled. Please use the Apple compiler!])) + + AC_MSG_CHECKING(if compiler supports Apple's Core Audio headers) + AC_COMPILE_IFELSE([AC_LANG_SOURCE([[ + #include + #include + int blah() { return 0; } + ]])], [AC_MSG_RESULT(yes);LIBS="$LIBS -framework AudioUnit -framework AudioToolbox";AC_DEFINE([C_SUPPORTS_COREAUDIO], [], + [Compiler supports Core Audio headers])], + AC_MSG_RESULT(no);AC_MSG_WARN([Compiler can't compile Apple headers. CoreAudio functionality disabled. Please use the Apple compiler!])) + ;; + + *) + AC_MSG_CHECKING(if compiler supports Apple's MIDI headers) + AC_MSG_RESULT([no, not on Apple]) + ;; +esac + dnl enable disable alsa and pass it's cflags to CXXFLAGS AC_ARG_ENABLE(alsa-midi, AC_HELP_STRING([--enable-alsa-midi],[compile with alsa midi support (default yes)]), @@ -564,7 +591,6 @@ case "$host" in dnl to do more to distinguish them. dnl For now I am lazy and do not add proper detection code. AC_DEFINE(MACOSX, 1, [Compiling on Mac OS X]) - LIBS="$LIBS -framework CoreMIDI -framework AudioUnit -framework AudioToolbox" AC_DEFINE(C_DIRECTSERIAL, 1, [ Define to 1 if you want serial passthrough support (Win32, Posix and OS/2).]) ;; *-*-linux*) diff --git a/include/midi.h b/include/midi.h index ea9afdad..773b6e6c 100644 --- a/include/midi.h +++ b/include/midi.h @@ -20,6 +20,10 @@ #ifndef DOSBOX_MIDI_H #define DOSBOX_MIDI_H +#ifndef DOSBOX_DOSBOX_H +#include "dosbox.h" +#endif + #ifndef DOSBOX_PROGRAMS_H #include "programs.h" #endif @@ -27,7 +31,10 @@ class MidiHandler { public: MidiHandler(); - virtual bool Open(const char * /*conf*/) { return true; }; + virtual bool Open(const char * /*conf*/) { + LOG_MSG("No working midi device found/selected! Please check your settings and/or compilation environment."); + return true; + }; virtual void Close(void) {}; virtual void PlayMsg(Bit8u * /*msg*/) {}; virtual void PlaySysex(Bit8u * /*sysex*/,Bitu /*len*/) {}; diff --git a/src/gui/midi.cpp b/src/gui/midi.cpp index b5361051..28b65f46 100644 --- a/src/gui/midi.cpp +++ b/src/gui/midi.cpp @@ -68,12 +68,18 @@ MidiHandler::MidiHandler(){ MidiHandler Midi_none; -/* Include different midi drivers, lowest ones get checked first for default */ +/* Include different midi drivers, lowest ones get checked first for default. + Each header provides an independent midi interface. */ #if defined(MACOSX) +#if defined(C_SUPPORTS_COREMIDI) #include "midi_coremidi.h" +#endif + +#if defined(C_SUPPORTS_COREAUDIO) #include "midi_coreaudio.h" +#endif #elif defined (WIN32)