mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-10 08:36:32 +01:00
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
2 changed files with 12 additions and 5 deletions
|
|
@ -324,6 +324,8 @@ class JACKAudioBackend : public AudioBackend {
|
||||||
|
|
||||||
JACKSession* _session;
|
JACKSession* _session;
|
||||||
|
|
||||||
|
Glib::Threads::Mutex port_registration_mutex;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
int _start (bool for_latency_measurement);
|
int _start (bool for_latency_measurement);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -583,11 +583,16 @@ JACKAudioBackend::monitoring_input (PortHandle port)
|
||||||
PortEngine::PortPtr
|
PortEngine::PortPtr
|
||||||
JACKAudioBackend::register_port (const std::string& shortname, ARDOUR::DataType type, ARDOUR::PortFlags flags)
|
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_t* jack_port = jack_port_register (_priv_jack, shortname.c_str(),
|
{
|
||||||
ardour_data_type_to_jack_port_type (type),
|
Glib::Threads::Mutex::Lock lm (port_registration_mutex);
|
||||||
ardour_port_flags_to_jack_flags (flags),
|
GET_PRIVATE_JACK_POINTER_RET (_priv_jack, PortEngine::PortPtr());
|
||||||
0);
|
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) {
|
if (!jack_port) {
|
||||||
return PortEngine::PortPtr();
|
return PortEngine::PortPtr();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue