diff --git a/CHANGELOG.md b/CHANGELOG.md index 6e4e48fc..e3a82b8c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,13 @@ Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Added + +- Added a specific error message when yabridge is not allowed to lock enough + shared memory. If you have not yet set up realtime priviliges and memory + locking limits for your user, then yabridge may not be able to map enough + shared memory for processing audio in plugins with a lot of inputs or outputs. + ### Fixed - Fixed crashes or freezes when a plugin uses the Windows drag-and-drop system diff --git a/src/common/audio-shm.cpp b/src/common/audio-shm.cpp index 7cbf8a9b..d1c5bb17 100644 --- a/src/common/audio-shm.cpp +++ b/src/common/audio-shm.cpp @@ -16,6 +16,8 @@ #include "audio-shm.h" +#include + AudioShmBuffer::AudioShmBuffer(const Config& config) : config(config), shm(boost::interprocess::open_or_create, @@ -61,12 +63,29 @@ void AudioShmBuffer::resize(const Config& new_config) { } void AudioShmBuffer::setup_mapping() { - // Apparently you get a `Resource temporarily unavailable` when calling - // `ftruncate()` with a size of 0 on shared memory - if (config.size > 0) { - shm.truncate(config.size); - buffer = boost::interprocess::mapped_region( - shm, boost::interprocess::read_write, 0, config.size, nullptr, - MAP_LOCKED); + try { + // Apparently you get a `Resource temporarily unavailable` when calling + // `ftruncate()` with a size of 0 on shared memory + if (config.size > 0) { + shm.truncate(config.size); + buffer = boost::interprocess::mapped_region( + shm, boost::interprocess::read_write, 0, config.size, nullptr, + MAP_LOCKED); + } + } catch (const boost::interprocess::interprocess_exception& error) { + if (error.get_native_error() == EAGAIN) { + std::cerr << "ERROR: Could not map shared memory. This means that" + << std::endl; + std::cerr << " your user's memory locking limit has been set" + << std::endl; + std::cerr << " too low. Check your distro's documentation or" + << std::endl; + std::cerr << " wiki for instructions on how to set up" + << std::endl; + std::cerr << " realtime privileges and memlock limits." + << std::endl; + } + + throw; } }