bitfieldaudio / OTTO

Sampler, Sequencer, Multi-engine synth and effects - in a box! [WIP]
https://bitfieldaudio.com
Other
2.63k stars 144 forks source link

Add Conditional Compilation & Linking #175

Closed brianmichel closed 4 years ago

brianmichel commented 4 years ago

Hello! I found out about this project this morning and went to go build it on my macOS machine and encountered a few build errors preventing me from completing compilation.

I did some digging and found that LLVM made filesystem part of the standard c++ lib starting at version 9 and above (https://releases.llvm.org/9.0.0/projects/libcxx/docs/UsingLibcxx.html#using-filesystem) so I looked through some other project and found people solving this problem in a similar way (like here)

I'm certainly no C++ or CMake expert, but this did allow me (in conjunction with the other changes listed) complete the compilation process.

The changes in audio_driver.cpp seem related to macOS not using ALSA, and from what I can tell structs like snd_mixer_t are all set up from within that library, so I forward declared them wrapped in the __APPLE__ flag.

Finally, the changes to log_manager.cpp were in a similar vein, the function that was being called just simply doesn't exist in the pthreads.h for macOS so I took a similar approach.

The code compiles, the tests pass, but running the otto binary crashes with the following stack

stack trace
➜  OTTO git:(bsm/get-macos-compiling-again) build/bin/otto
date       time         ( uptime  ) [ thread name/id ]                   file:line     v|
2020-05-29 11:22:45.480 (   0.000s) [main thread     ]             loguru.hpp:1871     0| arguments: build/bin/otto
2020-05-29 11:22:45.481 (   0.000s) [main thread     ]             loguru.hpp:1874     0| Current dir: /Users/brianmichel/Development/OTTO
2020-05-29 11:22:45.481 (   0.000s) [main thread     ]             loguru.hpp:1876     0| stderr verbosity: 0
2020-05-29 11:22:45.481 (   0.000s) [main thread     ]             loguru.hpp:1877     0| -----------------------------------
2020-05-29 11:22:45.481 (   0.000s) [main thread     ]             loguru.hpp:2031     0| Logging to 'data/log.txt', mode: 'a', verbosity: 9
2020-05-29 11:22:45.481 (   0.000s) [main thread     ]        log_manager.cpp:38       0| LOGGING NOW
2020-05-29 11:22:45.481 (   0.000s) [main thread     ]     preset_manager.cpp:169      0| { void otto::services::DefaultPresetManager::load_preset_files()
2020-05-29 11:22:45.481 (   0.000s) [main thread     ]     preset_manager.cpp:179      0| .   { Loading preset file "data/presets/OTTO.FM/80s EP.json"
2020-05-29 11:22:45.481 (   0.001s) [main thread     ]     preset_manager.cpp:179      0| .   } 0.000 s: Loading preset file "data/presets/OTTO.FM/80s EP.json"
2020-05-29 11:22:45.481 (   0.001s) [main thread     ]     preset_manager.cpp:179      0| .   { Loading preset file "data/presets/OTTO.FM/Braaambr.json"
2020-05-29 11:22:45.481 (   0.001s) [main thread     ]     preset_manager.cpp:179      0| .   } 0.000 s: Loading preset file "data/presets/OTTO.FM/Braaambr.json"
2020-05-29 11:22:45.481 (   0.001s) [main thread     ]     preset_manager.cpp:179      0| .   { Loading preset file "data/presets/Potion/Preset1.json"
2020-05-29 11:22:45.481 (   0.001s) [main thread     ]     preset_manager.cpp:179      0| .   } 0.000 s: Loading preset file "data/presets/Potion/Preset1.json"
2020-05-29 11:22:45.482 (   0.001s) [main thread     ]     preset_manager.cpp:169      0| } 0.001 s: void otto::services::DefaultPresetManager::load_preset_files()

RtApiCore::probeDeviceOpen: the device (0) does not support the requested channel count.

2020-05-29 11:22:45.542 (   0.062s) [main thread     ]         controller.cpp:58       0| Midi input ports:
2020-05-29 11:22:45.542 (   0.062s) [main thread     ]         controller.cpp:136    ERR| Couldn't set up sysex controller. Continuing with dummy. ERR: No input midi port specified. Use --sysex-ctl-in-device=X to select one of the listed ports
libc++abi.dylib: terminating with uncaught exception of type std::__1::system_error: mutex lock failed: Invalid argument
2020-05-29 11:22:45.543 (   0.062s) [main thread     ]      state_manager.cpp:56     ERR| Exception while loading state for UI: [json.exception.type_error.302] type must be string, but is null

Loguru caught a signal: SIGABRT
2020-05-29 11:22:45.543 (   0.062s) [main thread     ]      state_manager.cpp:56     ERR| Exception while loading state for Engines: [json.exception.type_error.304] cannot use at() with null
Stack trace:
8       0x7fff6dfafb8b thread_start + 15
7       0x7fff6dfb4109 _pthread_start + 148
6       0x7fff6b0dd829 std::terminate() + 41
5       0x7fff6b0dd887 std::__terminate(void (*)()) + 8
4       0x7fff6cc0a5b1 _objc_terminate() + 104
3       0x7fff6b0cf8a7 demangling_terminate_handler() + 238
2       0x7fff6b0de458 abort_message + 231
1       0x7fff6de7e808 abort + 120
0          0x100000400 4   ???                                 0x0000000100000400 0x0 + 4294968320
2020-05-29 11:22:45.543 (   0.062s) [          A2898E]                       :0     FATL| Signal: SIGABRT
Exception caught and ignored by Loguru signal handler.
2020-05-29 11:22:45.543 (   0.062s) [main thread     ]       audio_driver.cpp:121      0| Avaliable RtAudio devices:
2020-05-29 11:22:45.544 (   0.064s) [main thread     ]       audio_driver.cpp:125      0| 0: 'Apple Inc.: MacBook Pro Microphone'. 1 in channels, 0 out channels, 0 duplex channels

I wanted to make this PR even with the crashing as perhaps it could solve some issues for other folks, or the devs can advise me here on what they would like. I'm also a patron of this project so I'm pumped to see it on my local machine!

Let me know what you think!

brianmichel commented 4 years ago

It looks like the build might be failing as it's still using Clang 8 for CI jobs. Let me know if you'd like an additional PR to update these jobs to point to Clang 10 @topisani.

topisani commented 4 years ago

yes please, that would be very helpful - you may need to do a manual download of the binaries, its probably not in travis repos yet

brianmichel commented 4 years ago

Closing this as discussed in other PRs. We will be bringing back macOS building support in both CI and the local environment, but this is not the right approach for right now.