diff --git a/libs/backends/jack/jack_audiobackend.h b/libs/backends/jack/jack_audiobackend.h index 4bda9a5e3f..f01c5e0e7e 100644 --- a/libs/backends/jack/jack_audiobackend.h +++ b/libs/backends/jack/jack_audiobackend.h @@ -324,6 +324,8 @@ class JACKAudioBackend : public AudioBackend { JACKSession* _session; + Glib::Threads::Mutex port_registration_mutex; + protected: int _start (bool for_latency_measurement); }; diff --git a/libs/backends/jack/jack_portengine.cc b/libs/backends/jack/jack_portengine.cc index f31d41fb55..7a5531b6ec 100644 --- a/libs/backends/jack/jack_portengine.cc +++ b/libs/backends/jack/jack_portengine.cc @@ -583,11 +583,16 @@ JACKAudioBackend::monitoring_input (PortHandle port) PortEngine::PortPtr JACKAudioBackend::register_port (const std::string& shortname, ARDOUR::DataType type, ARDOUR::PortFlags flags) { - GET_PRIVATE_JACK_POINTER_RET (_priv_jack, PortEngine::PortPtr()); - jack_port_t* jack_port = jack_port_register (_priv_jack, shortname.c_str(), - ardour_data_type_to_jack_port_type (type), - ardour_port_flags_to_jack_flags (flags), - 0); + jack_port_t* jack_port; + { + Glib::Threads::Mutex::Lock lm (port_registration_mutex); + GET_PRIVATE_JACK_POINTER_RET (_priv_jack, PortEngine::PortPtr()); + jack_port = jack_port_register (_priv_jack, shortname.c_str(), + ardour_data_type_to_jack_port_type (type), + ardour_port_flags_to_jack_flags (flags), + 0); + } + if (!jack_port) { return PortEngine::PortPtr(); }