JACK backend: add a mutex to serialize per-thread port register requests to server
Without this, two threads can both sleep on the same communication channel, and the wake order is non-determinate, so the wrong thread may process the response to the other thread's request.
This commit is contained in:
parent
36f8d48e93
commit
88ee3af3ea
@ -324,6 +324,8 @@ class JACKAudioBackend : public AudioBackend {
|
||||
|
||||
JACKSession* _session;
|
||||
|
||||
Glib::Threads::Mutex port_registration_mutex;
|
||||
|
||||
protected:
|
||||
int _start (bool for_latency_measurement);
|
||||
};
|
||||
|
@ -583,11 +583,16 @@ JACKAudioBackend::monitoring_input (PortHandle port)
|
||||
PortEngine::PortPtr
|
||||
JACKAudioBackend::register_port (const std::string& shortname, ARDOUR::DataType type, ARDOUR::PortFlags flags)
|
||||
{
|
||||
jack_port_t* jack_port;
|
||||
{
|
||||
Glib::Threads::Mutex::Lock lm (port_registration_mutex);
|
||||
GET_PRIVATE_JACK_POINTER_RET (_priv_jack, PortEngine::PortPtr());
|
||||
jack_port_t* jack_port = jack_port_register (_priv_jack, shortname.c_str(),
|
||||
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();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user